mod equal;
mod find;
mod num_randomizers;
mod to_bits;
use crate::{Ciphertext, Identifier, Plaintext, Visibility};
use snarkvm_circuit_network::Aleo;
use snarkvm_circuit_types::{environment::prelude::*, Boolean};
#[derive(Clone)]
pub enum Entry<A: Aleo, Private: Visibility<A>> {
Constant(Plaintext<A>),
Public(Plaintext<A>),
Private(Private),
}
#[cfg(console)]
impl<A: Aleo> Inject for Entry<A, Plaintext<A>> {
type Primitive = console::Entry<A::Network, console::Plaintext<A::Network>>;
fn new(mode: Mode, plaintext: Self::Primitive) -> Self {
match plaintext {
Self::Primitive::Constant(plaintext) => Self::Constant(Plaintext::new(mode, plaintext)),
Self::Primitive::Public(plaintext) => Self::Public(Plaintext::new(mode, plaintext)),
Self::Primitive::Private(plaintext) => Self::Private(Plaintext::new(mode, plaintext)),
}
}
}
#[cfg(console)]
impl<A: Aleo> Inject for Entry<A, Ciphertext<A>> {
type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
fn new(mode: Mode, plaintext: Self::Primitive) -> Self {
match plaintext {
Self::Primitive::Constant(plaintext) => Self::Constant(Plaintext::new(mode, plaintext)),
Self::Primitive::Public(plaintext) => Self::Public(Plaintext::new(mode, plaintext)),
Self::Primitive::Private(ciphertext) => Self::Private(Ciphertext::new(mode, ciphertext)),
}
}
}
#[cfg(console)]
impl<A: Aleo> Eject for Entry<A, Plaintext<A>> {
type Primitive = console::Entry<A::Network, console::Plaintext<A::Network>>;
fn eject_mode(&self) -> Mode {
match self {
Entry::Constant(_) => Mode::Constant,
Entry::Public(_) => Mode::Public,
Entry::Private(_) => Mode::Private,
}
}
fn eject_value(&self) -> Self::Primitive {
match self {
Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
Entry::Private(plaintext) => Self::Primitive::Private(plaintext.eject_value()),
}
}
}
#[cfg(console)]
impl<A: Aleo> Eject for Entry<A, Ciphertext<A>> {
type Primitive = console::Entry<A::Network, console::Ciphertext<A::Network>>;
fn eject_mode(&self) -> Mode {
match self {
Entry::Constant(_) => Mode::Constant,
Entry::Public(_) => Mode::Public,
Entry::Private(_) => Mode::Private,
}
}
fn eject_value(&self) -> Self::Primitive {
match self {
Entry::Constant(plaintext) => Self::Primitive::Constant(plaintext.eject_value()),
Entry::Public(plaintext) => Self::Primitive::Public(plaintext.eject_value()),
Entry::Private(ciphertext) => Self::Primitive::Private(ciphertext.eject_value()),
}
}
}