snarkvm_console_program/request/input_id/
mod.rs

1// Copyright (c) 2019-2025 Provable Inc.
2// This file is part of the snarkVM 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
16mod bytes;
17mod serialize;
18mod string;
19
20use snarkvm_console_network::Network;
21use snarkvm_console_types::prelude::*;
22
23#[derive(Copy, Clone, PartialEq, Eq, Hash)]
24pub 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, serial number, and tag of the record input.
32    Record(Field<N>, Group<N>, Field<N>, Field<N>),
33    /// The hash of the external record input.
34    ExternalRecord(Field<N>),
35}
36
37impl<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}