snarkvm_circuit_program/data/record/entry/
mod.rs1mod equal;
17mod find;
18mod num_randomizers;
19mod to_bits;
20mod to_fields;
21
22use crate::{Access, Ciphertext, Plaintext, Visibility};
23use snarkvm_circuit_network::Aleo;
24use snarkvm_circuit_types::{Boolean, Field, environment::prelude::*};
25
26#[derive(Clone)]
28pub enum Entry<A: Aleo, Private: Visibility<A>> {
29 Constant(Plaintext<A>),
31 Public(Plaintext<A>),
33 Private(Private),
35}
36
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
50impl<A: Aleo> Inject for Entry<A, Ciphertext<A>> {
51 type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
52
53 fn new(mode: Mode, plaintext: Self::Primitive) -> Self {
55 match plaintext {
56 Self::Primitive::Constant(plaintext) => Self::Constant(Plaintext::new(mode, plaintext)),
57 Self::Primitive::Public(plaintext) => Self::Public(Plaintext::new(mode, plaintext)),
58 Self::Primitive::Private(ciphertext) => Self::Private(Ciphertext::new(mode, ciphertext)),
59 }
60 }
61}
62
63impl<A: Aleo> Eject for Entry<A, Plaintext<A>> {
64 type Primitive = console::Entry<A::Network, console::Plaintext<A::Network>>;
65
66 fn eject_mode(&self) -> Mode {
68 match self {
69 Entry::Constant(_) => Mode::Constant,
70 Entry::Public(_) => Mode::Public,
71 Entry::Private(_) => Mode::Private,
72 }
73 }
74
75 fn eject_value(&self) -> Self::Primitive {
77 match self {
78 Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
79 Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
80 Entry::Private(plaintext) => Self::Primitive::Private(plaintext.eject_value()),
81 }
82 }
83}
84
85impl<A: Aleo> Eject for Entry<A, Ciphertext<A>> {
86 type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
87
88 fn eject_mode(&self) -> Mode {
90 match self {
91 Entry::Constant(_) => Mode::Constant,
92 Entry::Public(_) => Mode::Public,
93 Entry::Private(_) => Mode::Private,
94 }
95 }
96
97 fn eject_value(&self) -> Self::Primitive {
99 match self {
100 Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
101 Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
102 Entry::Private(ciphertext) => Self::Primitive::Private(ciphertext.eject_value()),
103 }
104 }
105}