diff --git a/co-circom/co-groth16/src/mpc.rs b/co-circom/co-groth16/src/mpc.rs index fa5b2d48..84d75041 100644 --- a/co-circom/co-groth16/src/mpc.rs +++ b/co-circom/co-groth16/src/mpc.rs @@ -17,7 +17,7 @@ pub trait CircomGroth16Prover: Send { type PointShareG2: Send; type PartyID: Send + Sync + Copy; - fn rand(&mut self) -> Self::ArithmeticShare; + async fn rand(&mut self) -> IoResult; fn get_party_id(&self) -> Self::PartyID; diff --git a/co-circom/co-groth16/src/mpc/plain.rs b/co-circom/co-groth16/src/mpc/plain.rs index f7f86e0a..ab6249d5 100644 --- a/co-circom/co-groth16/src/mpc/plain.rs +++ b/co-circom/co-groth16/src/mpc/plain.rs @@ -6,6 +6,8 @@ use rand::thread_rng; use super::CircomGroth16Prover; +type IoResult = std::io::Result; + pub struct PlainGroth16Driver; impl CircomGroth16Prover

for PlainGroth16Driver { @@ -17,9 +19,9 @@ impl CircomGroth16Prover

for PlainGroth16Driver { type PartyID = usize; - fn rand(&mut self) -> Self::ArithmeticShare { + async fn rand(&mut self) -> IoResult { let mut rng = thread_rng(); - Self::ArithmeticShare::rand(&mut rng) + Ok(Self::ArithmeticShare::rand(&mut rng)) } fn get_party_id(&self) -> Self::PartyID { diff --git a/co-circom/co-groth16/src/mpc/rep3.rs b/co-circom/co-groth16/src/mpc/rep3.rs index dce148a3..fe483991 100644 --- a/co-circom/co-groth16/src/mpc/rep3.rs +++ b/co-circom/co-groth16/src/mpc/rep3.rs @@ -1,10 +1,10 @@ use ark_ec::pairing::Pairing; use itertools::izip; use mpc_core::protocols::rep3::{ - self, arithmetic, + arithmetic, id::PartyID, network::{IoContext, Rep3Network}, - Rep3PointShare, Rep3PrimeFieldShare, + pointshare, Rep3PointShare, Rep3PrimeFieldShare, }; use super::{CircomGroth16Prover, IoResult}; @@ -26,8 +26,8 @@ impl CircomGroth16Prover

for Rep3Groth16Driver type PartyID = PartyID; - fn rand(&mut self) -> Self::ArithmeticShare { - Self::ArithmeticShare::rand(&mut self.io_context) + async fn rand(&mut self) -> IoResult { + Ok(Self::ArithmeticShare::rand(&mut self.io_context)) } fn get_party_id(&self) -> Self::PartyID { @@ -44,7 +44,7 @@ impl CircomGroth16Prover

for Rep3Groth16Driver public_inputs: &[P::ScalarField], private_witness: &[Self::ArithmeticShare], ) -> Self::ArithmeticShare { - let mut acc = Rep3PrimeFieldShare::default(); + let mut acc = Self::ArithmeticShare::default(); for (coeff, index) in lhs { if index < &public_inputs.len() { let val = public_inputs[*index]; @@ -70,7 +70,7 @@ impl CircomGroth16Prover

for Rep3Groth16Driver fn sub_assign_vec(a: &mut [Self::ArithmeticShare], b: &[Self::ArithmeticShare]) { for (a, b) in izip!(a, b) { - rep3::arithmetic::sub_assign(a, *b); + arithmetic::sub_assign(a, *b); } } @@ -79,7 +79,7 @@ impl CircomGroth16Prover

for Rep3Groth16Driver a: Self::ArithmeticShare, b: Self::ArithmeticShare, ) -> IoResult { - rep3::arithmetic::mul(a, b, &mut self.io_context).await + arithmetic::mul(a, b, &mut self.io_context).await } async fn mul_vec( @@ -87,7 +87,7 @@ impl CircomGroth16Prover

for Rep3Groth16Driver lhs: &[Self::ArithmeticShare], rhs: &[Self::ArithmeticShare], ) -> IoResult> { - rep3::arithmetic::mul_vec(lhs, rhs, &mut self.io_context).await + arithmetic::mul_vec(lhs, rhs, &mut self.io_context).await } fn fft_in_place>( @@ -118,7 +118,7 @@ impl CircomGroth16Prover

for Rep3Groth16Driver ) { let mut pow = c; for share in coeffs.iter_mut() { - rep3::arithmetic::mul_assign_public(share, pow); + arithmetic::mul_assign_public(share, pow); pow *= g; } } @@ -127,31 +127,31 @@ impl CircomGroth16Prover

for Rep3Groth16Driver points: &[P::G1Affine], scalars: &[Self::ArithmeticShare], ) -> Self::PointShareG1 { - rep3::pointshare::msm_public_points(points, scalars) + pointshare::msm_public_points(points, scalars) } fn msm_public_points_g2( points: &[P::G2Affine], scalars: &[Self::ArithmeticShare], ) -> Self::PointShareG2 { - rep3::pointshare::msm_public_points(points, scalars) + pointshare::msm_public_points(points, scalars) } fn scalar_mul_public_point_g1(a: &P::G1, b: Self::ArithmeticShare) -> Self::PointShareG1 { - rep3::pointshare::scalar_mul_public_point(a, b) + pointshare::scalar_mul_public_point(a, b) } /// Add a shared point B in place to the shared point A: \[A\] += \[B\] fn add_assign_points_g1(a: &mut Self::PointShareG1, b: &Self::PointShareG1) { - rep3::pointshare::add_assign(a, b) + pointshare::add_assign(a, b) } fn add_assign_points_public_g1(id: Self::PartyID, a: &mut Self::PointShareG1, b: &P::G1) { - rep3::pointshare::add_assign_public(a, b, id) + pointshare::add_assign_public(a, b, id) } async fn open_point_g1(&mut self, a: &Self::PointShareG1) -> IoResult { - rep3::pointshare::open_point(a, &mut self.io_context).await + pointshare::open_point(a, &mut self.io_context).await } async fn scalar_mul_g1( @@ -159,23 +159,23 @@ impl CircomGroth16Prover

for Rep3Groth16Driver a: &Self::PointShareG1, b: Self::ArithmeticShare, ) -> IoResult { - rep3::pointshare::scalar_mul(a, b, &mut self.io_context).await + pointshare::scalar_mul(a, b, &mut self.io_context).await } fn sub_assign_points_g1(a: &mut Self::PointShareG1, b: &Self::PointShareG1) { - rep3::pointshare::sub_assign(a, b); + pointshare::sub_assign(a, b); } fn scalar_mul_public_point_g2(a: &P::G2, b: Self::ArithmeticShare) -> Self::PointShareG2 { - rep3::pointshare::scalar_mul_public_point(a, b) + pointshare::scalar_mul_public_point(a, b) } fn add_assign_points_g2(a: &mut Self::PointShareG2, b: &Self::PointShareG2) { - rep3::pointshare::add_assign(a, b) + pointshare::add_assign(a, b) } fn add_assign_points_public_g2(id: Self::PartyID, a: &mut Self::PointShareG2, b: &P::G2) { - rep3::pointshare::add_assign_public(a, b, id) + pointshare::add_assign_public(a, b, id) } async fn open_two_points( diff --git a/co-circom/co-groth16/src/mpc/shamir.rs b/co-circom/co-groth16/src/mpc/shamir.rs index 2ec37d74..9e793842 100644 --- a/co-circom/co-groth16/src/mpc/shamir.rs +++ b/co-circom/co-groth16/src/mpc/shamir.rs @@ -1,6 +1,200 @@ +use super::{CircomGroth16Prover, IoResult}; +use ark_ec::pairing::Pairing; use ark_ff::PrimeField; -use mpc_core::protocols::shamir::{network::ShamirNetwork, ShamirProtocol}; +use itertools::izip; +use mpc_core::protocols::shamir::{ + arithmetic, network::ShamirNetwork, pointshare, ShamirPointShare, ShamirPrimeFieldShare, + ShamirProtocol, +}; pub struct ShamirGroth16Driver { protocol: ShamirProtocol, } + +impl ShamirGroth16Driver { + pub fn new(protocol: ShamirProtocol) -> Self { + Self { protocol } + } +} + +impl CircomGroth16Prover

+ for ShamirGroth16Driver +{ + type ArithmeticShare = ShamirPrimeFieldShare; + type PointShareG1 = ShamirPointShare; + type PointShareG2 = ShamirPointShare; + + type PartyID = usize; + + async fn rand(&mut self) -> IoResult { + self.protocol.rand().await + } + + fn get_party_id(&self) -> Self::PartyID { + self.protocol.network.get_id() + } + + fn fork(&mut self) -> Self { + todo!() + } + + fn evaluate_constraint( + _party_id: Self::PartyID, + lhs: &[(

::ScalarField, usize)], + public_inputs: &[

::ScalarField], + private_witness: &[Self::ArithmeticShare], + ) -> Self::ArithmeticShare { + let mut acc = Self::ArithmeticShare::default(); + for (coeff, index) in lhs { + if index < &public_inputs.len() { + let val = public_inputs[*index]; + let mul_result = val * coeff; + arithmetic::add_assign_public(&mut acc, mul_result); + } else { + let current_witness = private_witness[*index - public_inputs.len()]; + arithmetic::add_assign(&mut acc, arithmetic::mul_public(current_witness, *coeff)); + } + } + acc + } + + fn promote_to_trivial_shares( + id: Self::PartyID, + public_values: &[

::ScalarField], + ) -> Vec { + todo!() + } + + fn sub_assign_vec(a: &mut [Self::ArithmeticShare], b: &[Self::ArithmeticShare]) { + for (a, b) in izip!(a, b) { + arithmetic::sub_assign(a, *b); + } + } + + async fn mul( + &mut self, + a: Self::ArithmeticShare, + b: Self::ArithmeticShare, + ) -> IoResult { + arithmetic::mul(a, b, &mut self.protocol).await + } + + async fn mul_vec( + &mut self, + a: &[Self::ArithmeticShare], + b: &[Self::ArithmeticShare], + ) -> IoResult> { + arithmetic::mul_vec(a, b, &mut self.protocol).await + } + + fn fft_in_place::ScalarField>>( + data: &mut Vec, + domain: &D, + ) { + domain.fft_in_place(data) + } + + fn ifft_in_place::ScalarField>>( + data: &mut Vec, + domain: &D, + ) { + domain.ifft_in_place(data) + } + + fn ifft::ScalarField>>( + data: &[Self::ArithmeticShare], + domain: &D, + ) -> Vec { + domain.ifft(&data) + } + + fn distribute_powers_and_mul_by_const( + coeffs: &mut [Self::ArithmeticShare], + g:

::ScalarField, + c:

::ScalarField, + ) { + let mut pow = c; + for share in coeffs.iter_mut() { + arithmetic::mul_assign_public(share, pow); + pow *= g; + } + } + + fn msm_public_points_g1( + points: &[

::G1Affine], + scalars: &[Self::ArithmeticShare], + ) -> Self::PointShareG1 { + pointshare::msm_public_points(points, scalars) + } + + fn msm_public_points_g2( + points: &[

::G2Affine], + scalars: &[Self::ArithmeticShare], + ) -> Self::PointShareG2 { + pointshare::msm_public_points(points, scalars) + } + + fn scalar_mul_public_point_g1( + a: &

::G1, + b: Self::ArithmeticShare, + ) -> Self::PointShareG1 { + pointshare::scalar_mul_public_point(b, a) + } + + fn add_assign_points_g1(a: &mut Self::PointShareG1, b: &Self::PointShareG1) { + pointshare::add_assign(a, b) + } + + fn add_assign_points_public_g1( + _id: Self::PartyID, + a: &mut Self::PointShareG1, + b: &

::G1, + ) { + pointshare::add_assign_public(a, b) + } + + async fn open_point_g1(&mut self, a: &Self::PointShareG1) -> IoResult<

::G1> { + pointshare::open_point(a, &mut self.protocol).await + } + + async fn scalar_mul_g1( + &mut self, + a: &Self::PointShareG1, + b: Self::ArithmeticShare, + ) -> IoResult { + pointshare::scalar_mul(a, b, &mut self.protocol).await + } + + fn sub_assign_points_g1(a: &mut Self::PointShareG1, b: &Self::PointShareG1) { + pointshare::sub_assign(a, b); + } + + fn scalar_mul_public_point_g2( + a: &

::G2, + b: Self::ArithmeticShare, + ) -> Self::PointShareG2 { + pointshare::scalar_mul_public_point(b, a) + } + + fn add_assign_points_g2(a: &mut Self::PointShareG2, b: &Self::PointShareG2) { + pointshare::add_assign(a, b) + } + + fn add_assign_points_public_g2( + _id: Self::PartyID, + a: &mut Self::PointShareG2, + b: &

::G2, + ) { + pointshare::add_assign_public(a, b) + } + + async fn open_two_points( + &mut self, + a: Self::PointShareG1, + b: Self::PointShareG2, + ) -> std::io::Result<(

::G1,

::G2)> { + let a_res = pointshare::open_point(&a, &mut self.protocol).await?; + let b_res = pointshare::open_point(&b, &mut self.protocol).await?; + Ok((a_res, b_res)) + } +} diff --git a/mpc-core/src/protocols/shamir.rs b/mpc-core/src/protocols/shamir.rs index 170a1303..2fd1334f 100644 --- a/mpc-core/src/protocols/shamir.rs +++ b/mpc-core/src/protocols/shamir.rs @@ -172,7 +172,7 @@ pub struct ShamirProtocol { pub(crate) open_lagrange_2t: Vec, mul_lagrange_2t: Vec, rng_buffer: ShamirRng, - network: N, + pub network: N, field: PhantomData, } @@ -223,7 +223,7 @@ impl ShamirProtocol { .await } - pub(crate) async fn rand(&mut self) -> IoResult> { + pub async fn rand(&mut self) -> IoResult> { let (r, _) = self.rng_buffer.get_pair(&mut self.network).await?; Ok(ShamirPrimeFieldShare::new(r)) } diff --git a/mpc-core/src/protocols/shamir/arithmetic.rs b/mpc-core/src/protocols/shamir/arithmetic.rs index 25f05330..2337f191 100644 --- a/mpc-core/src/protocols/shamir/arithmetic.rs +++ b/mpc-core/src/protocols/shamir/arithmetic.rs @@ -7,18 +7,37 @@ pub(super) mod types; type ShamirShare = types::ShamirPrimeFieldShare; +/// Performs addition between two shares. pub fn add(a: ShamirShare, b: ShamirShare) -> ShamirShare { a + b } +/// Performs addition between two shares where the result is stored in `a`. +pub fn add_assign(a: &mut ShamirShare, b: ShamirShare) { + *a += b; +} + +/// Performs subtraction between two shares. pub fn sub(a: ShamirShare, b: ShamirShare) -> ShamirShare { a - b } +/// Performs subtraction between two shares where the result is stored in `a`. +pub fn sub_assign(a: &mut ShamirShare, b: ShamirShare) { + *a -= b; +} + +/// Performs addition between a share and a public value. pub fn add_public(shared: ShamirShare, public: F) -> ShamirShare { shared + public } +/// Performs addition between a share and a public value where the result is stored in `shared`. +pub fn add_assign_public(shared: &mut ShamirShare, public: F) { + *shared += public; +} + +/// Performs multiplication between two shares. pub async fn mul( a: ShamirShare, b: ShamirShare, @@ -28,7 +47,8 @@ pub async fn mul( shamir.degree_reduce(mul).await } -pub async fn mul_many( +/// Performs element-wise multiplication of two slices of shares. +pub async fn mul_vec( a: &[ShamirShare], b: &[ShamirShare], shamir: &mut ShamirProtocol, @@ -41,10 +61,17 @@ pub async fn mul_many( shamir.degree_reduce_vec(mul).await } -pub fn mul_with_public(shared: ShamirShare, public: F) -> ShamirShare { +/// Performs multiplication between a share and a public value. +pub fn mul_public(shared: ShamirShare, public: F) -> ShamirShare { shared * public } +/// Performs multiplication between a share and a public value where the result is stored in `shared`. +pub fn mul_assign_public(shared: &mut ShamirShare, public: F) { + *shared *= public; +} + +/// Computes the inverse of a shared field element pub async fn inv( a: ShamirShare, shamir: &mut ShamirProtocol, @@ -61,6 +88,7 @@ pub async fn inv( Ok(r * y_inv) } +/// Computes the inverse of a vector of shared field elements pub async fn inv_many( a: &[ShamirShare], shamir: &mut ShamirProtocol, @@ -81,10 +109,12 @@ pub async fn inv_many( //Ok(res) } +/// Performs negation of a share pub fn neg(a: ShamirShare) -> ShamirShare { -a } +/// Opens a shared value and returns the corresponding field element. pub async fn open( a: ShamirShare, shamir: &mut ShamirProtocol, @@ -97,6 +127,7 @@ pub async fn open( Ok(res) } +/// Opens a vector of shared values and returns the corresponding field elements. pub async fn open_many( a: &[ShamirShare], shamir: &mut ShamirProtocol, diff --git a/mpc-core/src/protocols/shamir/arithmetic/ops.rs b/mpc-core/src/protocols/shamir/arithmetic/ops.rs index 92b04db3..6c0252d3 100644 --- a/mpc-core/src/protocols/shamir/arithmetic/ops.rs +++ b/mpc-core/src/protocols/shamir/arithmetic/ops.rs @@ -10,6 +10,12 @@ impl std::ops::Add for ShamirPrimeFieldShare { } } +impl std::ops::AddAssign for ShamirPrimeFieldShare { + fn add_assign(&mut self, rhs: Self) { + self.a += rhs.a; + } +} + impl std::ops::Add<&ShamirPrimeFieldShare> for ShamirPrimeFieldShare { type Output = Self; @@ -42,6 +48,12 @@ impl std::ops::Add for ShamirPrimeFieldShare { } } +impl std::ops::AddAssign for ShamirPrimeFieldShare { + fn add_assign(&mut self, rhs: F) { + self.a += rhs; + } +} + impl std::ops::Sub for ShamirPrimeFieldShare { type Output = Self; @@ -50,6 +62,12 @@ impl std::ops::Sub for ShamirPrimeFieldShare { } } +impl std::ops::SubAssign for ShamirPrimeFieldShare { + fn sub_assign(&mut self, rhs: Self) { + self.a -= rhs.a; + } +} + impl std::ops::Sub<&ShamirPrimeFieldShare> for ShamirPrimeFieldShare { type Output = Self; @@ -109,6 +127,12 @@ impl std::ops::Mul for ShamirPrimeFieldShare { } } +impl std::ops::MulAssign for ShamirPrimeFieldShare { + fn mul_assign(&mut self, rhs: F) { + self.a *= rhs; + } +} + impl std::ops::Neg for ShamirPrimeFieldShare { type Output = Self; @@ -123,3 +147,15 @@ impl std::ops::Neg for &ShamirPrimeFieldShare { ShamirPrimeFieldShare:: { a: -self.a } } } + +impl ark_ff::Zero for ShamirPrimeFieldShare { + fn zero() -> Self { + Self { + a: F::zero(), + } + } + + fn is_zero(&self) -> bool { + panic!("is_zero is not a meaningful operation for Rep3PrimeFieldShare, use interative zero check instead"); + } +} diff --git a/mpc-core/src/protocols/shamir/arithmetic/types.rs b/mpc-core/src/protocols/shamir/arithmetic/types.rs index 29ba862e..47ac431b 100644 --- a/mpc-core/src/protocols/shamir/arithmetic/types.rs +++ b/mpc-core/src/protocols/shamir/arithmetic/types.rs @@ -23,6 +23,7 @@ impl ShamirPrimeFieldShare { self.a } + /// Returns a zero share. pub fn zero_share() -> Self { Self { a: F::zero() } } diff --git a/mpc-core/src/protocols/shamir/network.rs b/mpc-core/src/protocols/shamir/network.rs index ca055abe..8484dd23 100644 --- a/mpc-core/src/protocols/shamir/network.rs +++ b/mpc-core/src/protocols/shamir/network.rs @@ -12,7 +12,7 @@ use std::{collections::HashMap, sync::Arc}; use tokio_util::codec::LengthDelimitedCodec; /// This trait defines the network interface for the Shamir protocol. -pub trait ShamirNetwork { +pub trait ShamirNetwork: Send { /// Returns the id of the party. The id is in the range 0 <= id < num_parties fn get_id(&self) -> usize; diff --git a/mpc-core/src/protocols/shamir/pointshare.rs b/mpc-core/src/protocols/shamir/pointshare.rs index 41e885cd..bf8e2172 100644 --- a/mpc-core/src/protocols/shamir/pointshare.rs +++ b/mpc-core/src/protocols/shamir/pointshare.rs @@ -2,38 +2,48 @@ mod ops; pub(super) mod types; use ark_ec::CurveGroup; +use ark_ff::PrimeField; +use rayon::prelude::*; use super::{ - core, network::ShamirNetwork, IoResult, ShamirPrimeFieldShare, ShamirProtocol, ShamirShare, + core, network::ShamirNetwork, IoResult, ShamirPointShare, ShamirPrimeFieldShare, + ShamirProtocol, ShamirShare, }; -pub use types::ShamirPointShare; -type PointShare = types::ShamirPointShare; +type FieldShare = ShamirPrimeFieldShare; +type PointShare = ShamirPointShare; +/// Performs addition between two shares. pub fn add(a: &PointShare, b: &PointShare) -> PointShare { a + b } +/// Performs subtraction between two shares. pub fn sub(a: &PointShare, b: &PointShare) -> PointShare { a - b } +/// Performs addition between two shares and stores the result in `a`. pub fn add_assign(a: &mut PointShare, b: &PointShare) { *a += b; } +/// Performs subtraction between two shares and stores the result in `a`. pub fn sub_assign(a: &mut PointShare, b: &PointShare) { *a -= b; } +/// Performs addition between a share and a public value and stores the result in `a`. pub fn add_assign_public(a: &mut PointShare, b: &C) { a.a += b } +/// Performs subtraction between a share and a public value and stores the result in `a`. pub fn sub_assign_public(a: &mut PointShare, b: &C) { a.a -= b } +/// Performs addition between a share and a public affine value and stores the result in `a`. pub fn add_assign_public_affine( a: &mut PointShare, b: &::Affine, @@ -41,6 +51,7 @@ pub fn add_assign_public_affine( a.a += b } +/// Performs subtraction between a share and a public affine value and stores the result in `a`. pub fn sub_assign_public_affine( a: &mut PointShare, b: &::Affine, @@ -48,6 +59,7 @@ pub fn sub_assign_public_affine( a.a -= b } +/// Performs multiplication between a field share and a public curve group value and stores the result in `a`. pub fn scalar_mul_public_point( shared: ShamirPrimeFieldShare, public: &C, @@ -57,6 +69,7 @@ pub fn scalar_mul_public_point( } } +/// Performs scalar multiplication between a point share and a public scalar. pub fn scalar_mul_public_scalar( a: &PointShare, b: &C::ScalarField, @@ -64,6 +77,7 @@ pub fn scalar_mul_public_scalar( a * b } +/// Performs scalar multiplication between a point share and a field share. pub async fn scalar_mul( a: &PointShare, b: ShamirShare, @@ -73,6 +87,7 @@ pub async fn scalar_mul( shamir.degree_reduce_point(mul).await } +/// Performs opening of a point share. pub async fn open_point( a: &PointShare, shamir: &mut ShamirProtocol, @@ -85,6 +100,7 @@ pub async fn open_point( Ok(res) } +/// Performs opening of a vector of point shares. pub async fn open_point_many( a: &[PointShare], shamir: &mut ShamirProtocol, @@ -110,3 +126,24 @@ pub async fn open_point_many( .collect(); Ok(res) } + +/// Perfoms MSM between curve points and field shares. +pub fn msm_public_points( + points: &[C::Affine], + scalars: &[FieldShare], +) -> PointShare { + // TODO is this fn correct? + tracing::trace!("> MSM public points for {} elements", points.len()); + debug_assert_eq!(points.len(), scalars.len()); + let a_bigints = scalars + .into_par_iter() + .map(|share| share.a.into_bigint()) + .collect::>(); + let mut res_a = None; + rayon::scope(|s| { + s.spawn(|_| res_a = Some(C::msm_bigint(points, &a_bigints))); + }); + tracing::trace!("< MSM public points for {} elements", points.len()); + //we can unwrap as the we have Some values after rayon scope + PointShare::new(res_a.unwrap()) +} diff --git a/tests/tests/mpc/shamir.rs b/tests/tests/mpc/shamir.rs index 1cf48985..3b999bf7 100644 --- a/tests/tests/mpc/shamir.rs +++ b/tests/tests/mpc/shamir.rs @@ -200,7 +200,7 @@ mod field_share { for (net, tx, x, y) in izip!(test_network.get_party_networks(), tx, x_shares, y_shares) { tokio::spawn(async move { let mut shamir = ShamirProtocol::new(threshold, net).unwrap(); - let mul = arithmetic::mul_many(&x, &y, &mut shamir).await.unwrap(); + let mul = arithmetic::mul_vec(&x, &y, &mut shamir).await.unwrap(); tx.send(mul) }); } @@ -252,8 +252,8 @@ mod field_share { for (net, tx, x, y) in izip!(test_network.get_party_networks(), tx, x_shares, y_shares) { tokio::spawn(async move { let mut shamir = ShamirProtocol::new(threshold, net).unwrap(); - let mul = arithmetic::mul_many(&x, &y, &mut shamir).await.unwrap(); - let mul = arithmetic::mul_many(&mul, &y, &mut shamir).await.unwrap(); + let mul = arithmetic::mul_vec(&x, &y, &mut shamir).await.unwrap(); + let mul = arithmetic::mul_vec(&mul, &y, &mut shamir).await.unwrap(); tx.send(mul) }); }