RelinKeyGenerator

Struct RelinKeyGenerator 

Source
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(&parameters, &mut rng);
let crp = CommonRandomPoly::new_vec(&parameters, &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>

Source

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.

  1. Private input: BFV secret key share
  2. Public input: common random polynomial vector
Source

pub fn round_1<R: RngCore + CryptoRng>( &self, rng: &mut R, ) -> Result<RelinKeyShare<R1>>

Generate share for round 1

Source

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 A
where A: Aggregate<S>,

Source§

fn from_shares<T>(iter: T) -> Result<A, Error>
where T: IntoIterator<Item = Result<S, Error>>,

Aggregate shares in an MPC protocol.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V