/ console / program / src / request / input_id / mod.rs
mod.rs
 1  // Copyright (c) 2019-2025 Alpha-Delta Network Inc.
 2  // This file is part of the alphavm library.
 3  
 4  // Licensed under the Apache License, Version 2.0 (the "License");
 5  // you may not use this file except in compliance with the License.
 6  // You may obtain a copy of the License at:
 7  
 8  // http://www.apache.org/licenses/LICENSE-2.0
 9  
10  // Unless required by applicable law or agreed to in writing, software
11  // distributed under the License is distributed on an "AS IS" BASIS,
12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  // See the License for the specific language governing permissions and
14  // limitations under the License.
15  
16  mod bytes;
17  mod serialize;
18  mod string;
19  
20  use alphavm_console_network::Network;
21  use alphavm_console_types::prelude::*;
22  
23  #[derive(Copy, Clone, PartialEq, Eq, Hash)]
24  pub enum InputID<N: Network> {
25      /// The hash of the constant input.
26      Constant(Field<N>),
27      /// The hash of the public input.
28      Public(Field<N>),
29      /// The ciphertext hash of the private input.
30      Private(Field<N>),
31      /// The commitment, gamma, record view key, serial number, and tag of the record input.
32      Record(Field<N>, Group<N>, Field<N>, Field<N>, Field<N>),
33      /// The hash of the external record's (function_id, record, tvk, input index).
34      ExternalRecord(Field<N>),
35  }
36  
37  impl<N: Network> InputID<N> {
38      /// Returns the (primary) input ID.
39      pub const fn id(&self) -> &Field<N> {
40          match self {
41              InputID::Constant(id) => id,
42              InputID::Public(id) => id,
43              InputID::Private(id) => id,
44              InputID::Record(id, ..) => id,
45              InputID::ExternalRecord(id) => id,
46          }
47      }
48  }