pub struct Plaintext { /* private fields */ }
Expand description

A BFV12 Plaintext (an encoded message)

Implementations

Instantiate a new Plaintext

  • poly: the polynomial set to the input vector
  • t: the plaintext modulus
use bfv12::Plaintext;
let pt = Plaintext::new(vec![0, 1, 2, 3], 4);

Instantiate a new random Plaintext uniformly over [0, t) with length degree

  • degree: the degree (length) of the newly generated plaintext
  • t: 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);

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])

Encrypt a plaintext with a given public key

  • pub_key: the public key used to encrypt plaintext
  • std_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

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.