pub struct RelinKeyGenerator<'a, 'b> { /* private fields */ }Expand description
A builder for creating relinearization key generation shares per party.
Each party uses the RelinKeyGenerator to generate their shares and
participate in the “Protocol 2: RelinKeyGen” protocol detailed in
Multiparty BFV (p6). The shares need to be aggregated between
rounds:
use std::sync::Arc;
use fhe::bfv::{BfvParametersBuilder, RelinearizationKey, SecretKey};
use fhe::mbfv::{Aggregate, CommonRandomPoly, RelinKeyGenerator, RelinKeyShare, round::*};
let parameters = BfvParametersBuilder::new()
.set_degree(4096)
.set_moduli(&[0xffffee001, 0xffffc4001, 0x1ffffe0001])
.set_plaintext_modulus(1 << 10)
.build_arc()?;
// Party perspective
let mut rng = rand::rng();
let sk_share = SecretKey::random(¶meters, &mut rng);
let crp = CommonRandomPoly::new_vec(¶meters, &mut rng)?;
let rlk_generator = RelinKeyGenerator::new(&sk_share, &crp, &mut rng)?;
let rlk_r1_share = rlk_generator.round_1(&mut rng)?;
// Aggregator perspective
let r1_shares = vec![rlk_r1_share]; // all party shares go here
let rlk_r1_aggregated = RelinKeyShare::<R1Aggregated>::from_shares(r1_shares)?;
// Party perspective
let rlk_r2_share = rlk_generator.round_2(&Arc::new(rlk_r1_aggregated), &mut rng)?;
// Aggregator perspective
let r2_shares = vec![rlk_r2_share]; // all party shares go here
let rlk = RelinearizationKey::from_shares(r2_shares)?;Implementations§
Source§impl<'a, 'b> RelinKeyGenerator<'a, 'b>
impl<'a, 'b> RelinKeyGenerator<'a, 'b>
Sourcepub fn new<R: RngCore + CryptoRng>(
sk_share: &'a SecretKey,
crp: &'b [CommonRandomPoly],
rng: &mut R,
) -> Result<Self>
pub fn new<R: RngCore + CryptoRng>( sk_share: &'a SecretKey, crp: &'b [CommonRandomPoly], rng: &mut R, ) -> Result<Self>
Create a new relin key generator for a given party.
- Private input: BFV secret key share
- Public input: common random polynomial vector
Sourcepub fn round_1<R: RngCore + CryptoRng>(
&self,
rng: &mut R,
) -> Result<RelinKeyShare<R1>>
pub fn round_1<R: RngCore + CryptoRng>( &self, rng: &mut R, ) -> Result<RelinKeyShare<R1>>
Generate share for round 1
Sourcepub fn round_2<R: RngCore + CryptoRng>(
&self,
r1: &Arc<RelinKeyShare<R1Aggregated>>,
rng: &mut R,
) -> Result<RelinKeyShare<R2>>
pub fn round_2<R: RngCore + CryptoRng>( &self, r1: &Arc<RelinKeyShare<R1Aggregated>>, rng: &mut R, ) -> Result<RelinKeyShare<R2>>
Generate share for round 2
Auto Trait Implementations§
impl<'a, 'b> Freeze for RelinKeyGenerator<'a, 'b>
impl<'a, 'b> RefUnwindSafe for RelinKeyGenerator<'a, 'b>
impl<'a, 'b> Send for RelinKeyGenerator<'a, 'b>
impl<'a, 'b> Sync for RelinKeyGenerator<'a, 'b>
impl<'a, 'b> Unpin for RelinKeyGenerator<'a, 'b>
impl<'a, 'b> UnwindSafe for RelinKeyGenerator<'a, 'b>
Blanket Implementations§
Source§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more