snarkvm_circuit_program/data/record/entry/
mod.rs1mod equal;
17mod find;
18mod num_randomizers;
19mod to_bits;
20
21use crate::{Access, Ciphertext, Plaintext, Visibility};
22use snarkvm_circuit_network::Aleo;
23use snarkvm_circuit_types::{Boolean, environment::prelude::*};
24
25#[derive(Clone)]
27pub enum Entry<A: Aleo, Private: Visibility<A>> {
28 Constant(Plaintext<A>),
30 Public(Plaintext<A>),
32 Private(Private),
34}
35
36#[cfg(feature = "console")]
37impl<A: Aleo> Inject for Entry<A, Plaintext<A>> {
38 type Primitive = console::Entry<A::Network, console::Plaintext<A::Network>>;
39
40 fn new(mode: Mode, plaintext: Self::Primitive) -> Self {
42 match plaintext {
43 Self::Primitive::Constant(plaintext) => Self::Constant(Plaintext::new(mode, plaintext)),
44 Self::Primitive::Public(plaintext) => Self::Public(Plaintext::new(mode, plaintext)),
45 Self::Primitive::Private(plaintext) => Self::Private(Plaintext::new(mode, plaintext)),
46 }
47 }
48}
49
50#[cfg(feature = "console")]
51impl<A: Aleo> Inject for Entry<A, Ciphertext<A>> {
52 type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
53
54 fn new(mode: Mode, plaintext: Self::Primitive) -> Self {
56 match plaintext {
57 Self::Primitive::Constant(plaintext) => Self::Constant(Plaintext::new(mode, plaintext)),
58 Self::Primitive::Public(plaintext) => Self::Public(Plaintext::new(mode, plaintext)),
59 Self::Primitive::Private(ciphertext) => Self::Private(Ciphertext::new(mode, ciphertext)),
60 }
61 }
62}
63
64#[cfg(feature = "console")]
65impl<A: Aleo> Eject for Entry<A, Plaintext<A>> {
66 type Primitive = console::Entry<A::Network, console::Plaintext<A::Network>>;
67
68 fn eject_mode(&self) -> Mode {
70 match self {
71 Entry::Constant(_) => Mode::Constant,
72 Entry::Public(_) => Mode::Public,
73 Entry::Private(_) => Mode::Private,
74 }
75 }
76
77 fn eject_value(&self) -> Self::Primitive {
79 match self {
80 Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
81 Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
82 Entry::Private(plaintext) => Self::Primitive::Private(plaintext.eject_value()),
83 }
84 }
85}
86
87#[cfg(feature = "console")]
88impl<A: Aleo> Eject for Entry<A, Ciphertext<A>> {
89 type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
90
91 fn eject_mode(&self) -> Mode {
93 match self {
94 Entry::Constant(_) => Mode::Constant,
95 Entry::Public(_) => Mode::Public,
96 Entry::Private(_) => Mode::Private,
97 }
98 }
99
100 fn eject_value(&self) -> Self::Primitive {
102 match self {
103 Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
104 Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
105 Entry::Private(ciphertext) => Self::Primitive::Private(ciphertext.eject_value()),
106 }
107 }
108}