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
36impl<A: Aleo> Inject for Entry<A, Plaintext<A>> {
37 type Primitive = console::Entry<A::Network, console::Plaintext<A::Network>>;
38
39 fn new(mode: Mode, plaintext: Self::Primitive) -> Self {
41 match plaintext {
42 Self::Primitive::Constant(plaintext) => Self::Constant(Plaintext::new(mode, plaintext)),
43 Self::Primitive::Public(plaintext) => Self::Public(Plaintext::new(mode, plaintext)),
44 Self::Primitive::Private(plaintext) => Self::Private(Plaintext::new(mode, plaintext)),
45 }
46 }
47}
48
49impl<A: Aleo> Inject for Entry<A, Ciphertext<A>> {
50 type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
51
52 fn new(mode: Mode, plaintext: Self::Primitive) -> Self {
54 match plaintext {
55 Self::Primitive::Constant(plaintext) => Self::Constant(Plaintext::new(mode, plaintext)),
56 Self::Primitive::Public(plaintext) => Self::Public(Plaintext::new(mode, plaintext)),
57 Self::Primitive::Private(ciphertext) => Self::Private(Ciphertext::new(mode, ciphertext)),
58 }
59 }
60}
61
62impl<A: Aleo> Eject for Entry<A, Plaintext<A>> {
63 type Primitive = console::Entry<A::Network, console::Plaintext<A::Network>>;
64
65 fn eject_mode(&self) -> Mode {
67 match self {
68 Entry::Constant(_) => Mode::Constant,
69 Entry::Public(_) => Mode::Public,
70 Entry::Private(_) => Mode::Private,
71 }
72 }
73
74 fn eject_value(&self) -> Self::Primitive {
76 match self {
77 Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
78 Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
79 Entry::Private(plaintext) => Self::Primitive::Private(plaintext.eject_value()),
80 }
81 }
82}
83
84impl<A: Aleo> Eject for Entry<A, Ciphertext<A>> {
85 type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
86
87 fn eject_mode(&self) -> Mode {
89 match self {
90 Entry::Constant(_) => Mode::Constant,
91 Entry::Public(_) => Mode::Public,
92 Entry::Private(_) => Mode::Private,
93 }
94 }
95
96 fn eject_value(&self) -> Self::Primitive {
98 match self {
99 Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
100 Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
101 Entry::Private(ciphertext) => Self::Primitive::Private(ciphertext.eject_value()),
102 }
103 }
104}