pub struct Plaintext { /* private fields */ }
Expand description
A BFV12 Plaintext (an encoded message)
Implementations
sourceimpl Plaintext
impl Plaintext
sourcepub fn new(val: Vec<i64>, t: i64) -> Plaintext
pub fn new(val: Vec<i64>, t: i64) -> Plaintext
Instantiate a new Plaintext
poly
: the polynomial set to the input vectort
: the plaintext modulus
use bfv12::Plaintext;
let pt = Plaintext::new(vec![0, 1, 2, 3], 4);
sourcepub fn rand<T: RngCore + CryptoRng>(
degree: usize,
t: i64,
rng: &mut T
) -> Plaintext
pub fn rand<T: RngCore + CryptoRng>(
degree: usize,
t: i64,
rng: &mut T
) -> Plaintext
Instantiate a new random Plaintext uniformly over [0, t) with length degree
degree
: the degree (length) of the newly generated plaintextt
: the plaintext modulus
rng
: the RNG used to generate randomness. Any Rng that imlements RngCore + CryptoRng can be used.
use bfv12::Plaintext;
let rand_pt = Plaintext::rand(10, 4, &mut rng);
sourcepub fn poly(&self) -> Poly
pub fn poly(&self) -> Poly
Return the polynomial that represents the encoded messeage
use bfv12::Plaintext;
let pt = Plaintext::new(vec![0, 1, 2, 3], 4);
let pt_poly = pt.poly();
assert_eq!(pt_poly.val(), vec![0, 1, 2, 3])
sourcepub fn encrypt<T: RngCore + CryptoRng>(
&self,
pub_key: &PublicKey,
std_dev: f64,
rng: &mut T
) -> Ciphertext
pub fn encrypt<T: RngCore + CryptoRng>(
&self,
pub_key: &PublicKey,
std_dev: f64,
rng: &mut T
) -> Ciphertext
Encrypt a plaintext with a given public key
pub_key
: the public key used to encrypt plaintextstd_dev
: the standard deviation used for generating the error in the encryption
rng
: the RNG used to generate randomness. Any Rng that imlements RngCore + CryptoRng can be used.
use bfv12::{Plaintext, SecretKey};
let pt = Plaintext::new(vec![0, 1, 2, 3], t);
let secret_key = SecretKey::generate(degree, &mut rng);
let public_key = secret_key.public_key_gen(q, std_dev, &mut rng);
let ct = pt.encrypt(&public_key, std_dev, &mut rng);
Trait Implementations
impl StructuralPartialEq for Plaintext
Auto Trait Implementations
impl RefUnwindSafe for Plaintext
impl Send for Plaintext
impl Sync for Plaintext
impl Unpin for Plaintext
impl UnwindSafe for Plaintext
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more