use super::*;
impl<N: Network> ToBits for Entry<N, Plaintext<N>> {
fn write_bits_le(&self, vec: &mut Vec<bool>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[false, false]),
Self::Public(..) => vec.extend_from_slice(&[false, true]),
Self::Private(..) => vec.extend_from_slice(&[true, false]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_le(vec),
Self::Public(plaintext) => plaintext.write_bits_le(vec),
Self::Private(plaintext) => plaintext.write_bits_le(vec),
};
}
fn write_bits_be(&self, vec: &mut Vec<bool>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[false, false]),
Self::Public(..) => vec.extend_from_slice(&[false, true]),
Self::Private(..) => vec.extend_from_slice(&[true, false]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_be(vec),
Self::Public(plaintext) => plaintext.write_bits_be(vec),
Self::Private(plaintext) => plaintext.write_bits_be(vec),
};
}
}
impl<N: Network> ToBits for Entry<N, Ciphertext<N>> {
fn write_bits_le(&self, vec: &mut Vec<bool>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[false, false]),
Self::Public(..) => vec.extend_from_slice(&[false, true]),
Self::Private(..) => vec.extend_from_slice(&[true, false]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_le(vec),
Self::Public(plaintext) => plaintext.write_bits_le(vec),
Self::Private(plaintext) => plaintext.write_bits_le(vec),
};
}
fn write_bits_be(&self, vec: &mut Vec<bool>) {
match self {
Self::Constant(..) => vec.extend_from_slice(&[false, false]),
Self::Public(..) => vec.extend_from_slice(&[false, true]),
Self::Private(..) => vec.extend_from_slice(&[true, false]),
};
match self {
Self::Constant(plaintext) => plaintext.write_bits_be(vec),
Self::Public(plaintext) => plaintext.write_bits_be(vec),
Self::Private(plaintext) => plaintext.write_bits_be(vec),
};
}
}