use super::*;
impl<A: Aleo> ToBits for Entry<A, Plaintext<A>> {
type Boolean = Boolean<A>;
fn to_bits_le(&self) -> Vec<Boolean<A>> {
let mut bits_le = match self {
Self::Constant(..) => vec![Boolean::constant(false), Boolean::constant(false)],
Self::Public(..) => vec![Boolean::constant(false), Boolean::constant(true)],
Self::Private(..) => vec![Boolean::constant(true), Boolean::constant(false)],
};
match self {
Self::Constant(plaintext) => bits_le.extend(plaintext.to_bits_le()),
Self::Public(plaintext) => bits_le.extend(plaintext.to_bits_le()),
Self::Private(plaintext) => bits_le.extend(plaintext.to_bits_le()),
}
bits_le
}
fn to_bits_be(&self) -> Vec<Boolean<A>> {
let mut bits_be = match self {
Self::Constant(..) => vec![Boolean::constant(false), Boolean::constant(false)],
Self::Public(..) => vec![Boolean::constant(false), Boolean::constant(true)],
Self::Private(..) => vec![Boolean::constant(true), Boolean::constant(false)],
};
match self {
Self::Constant(plaintext) => bits_be.extend(plaintext.to_bits_be()),
Self::Public(plaintext) => bits_be.extend(plaintext.to_bits_be()),
Self::Private(plaintext) => bits_be.extend(plaintext.to_bits_be()),
}
bits_be
}
}
impl<A: Aleo> ToBits for Entry<A, Ciphertext<A>> {
type Boolean = Boolean<A>;
fn to_bits_le(&self) -> Vec<Boolean<A>> {
let mut bits_le = match self {
Self::Constant(..) => vec![Boolean::constant(false), Boolean::constant(false)],
Self::Public(..) => vec![Boolean::constant(false), Boolean::constant(true)],
Self::Private(..) => vec![Boolean::constant(true), Boolean::constant(false)],
};
match self {
Self::Constant(plaintext) => bits_le.extend(plaintext.to_bits_le()),
Self::Public(plaintext) => bits_le.extend(plaintext.to_bits_le()),
Self::Private(plaintext) => bits_le.extend(plaintext.to_bits_le()),
}
bits_le
}
fn to_bits_be(&self) -> Vec<Boolean<A>> {
let mut bits_be = match self {
Self::Constant(..) => vec![Boolean::constant(false), Boolean::constant(false)],
Self::Public(..) => vec![Boolean::constant(false), Boolean::constant(true)],
Self::Private(..) => vec![Boolean::constant(true), Boolean::constant(false)],
};
match self {
Self::Constant(plaintext) => bits_be.extend(plaintext.to_bits_be()),
Self::Public(plaintext) => bits_be.extend(plaintext.to_bits_be()),
Self::Private(plaintext) => bits_be.extend(plaintext.to_bits_be()),
}
bits_be
}
}