pub struct RandomizedMultChecker<G: AffineRepr> { /* private fields */ }Expand description
Represents a scalar multiplication check of the form G1 * a1 + G2 * a2 + G3 * a3 + ... = T.
Several checks can be added of forms either G1 * a1 = T1 or G1 * a1 + H1 * b1 = T2 or G1 * a1 + H1 * b1 + J1 * c1 = T3
These checks can be aggregated together using random linear combination. The efficiency comes from converting all these
scalar multiplications in a single multi-scalar multiplication.
For each check, multiply the check by a power of a random element created during initialization.
eg. for these 4 checks G1 * a1 = T1, G1 * a2 + H1 * b2 = T2 and G1 * a3 + H2 * b3 + J1 * c3 = T3, G1 * a4 + H2 * b4 + J2 * c4 = T4,
a single check is created as G1 * a1 - T1 + G1 * a2 * r + H1 * b2 * r - T2 * r + G1 * a3 * r^2 + H2 * b3 * r^2 + J1 * c3 * r^2 - T3 * r^2 + G1 * a4 * r^3 + H2 * b4 * r^3 + J2 * c4 * r^3 - T4 * r^3 = 0
where r is a random value and so arer^2, r^3
The single check above is simplified by combining terms of G1, H1, etc to reduce the size of the multi-scalar multiplication
Implementations§
Source§impl<G: AffineRepr> RandomizedMultChecker<G>
impl<G: AffineRepr> RandomizedMultChecker<G>
pub fn new(random: G::ScalarField) -> Self
pub fn new_using_rng<R: Rng>(rng: &mut R) -> Self
Sourcepub fn add_1(&mut self, p: G, s: &G::ScalarField, t: G)
pub fn add_1(&mut self, p: G, s: &G::ScalarField, t: G)
Add a check of the form p * s = t. Converts it to p * s * r - t * r = 0 where r is the current randomness.
Sourcepub fn add_2(
&mut self,
p1: G,
s1: &G::ScalarField,
p2: G,
s2: &G::ScalarField,
t: G,
)
pub fn add_2( &mut self, p1: G, s1: &G::ScalarField, p2: G, s2: &G::ScalarField, t: G, )
Add a check of the form p1 * s1 + p2 * s2 = t. Converts it to p1 * s1 * r + p2 * s2 * r - t * r = 0 where r is the current randomness.
Sourcepub fn add_3(
&mut self,
p1: G,
s1: &G::ScalarField,
p2: G,
s2: &G::ScalarField,
p3: G,
s3: &G::ScalarField,
t: G,
)
pub fn add_3( &mut self, p1: G, s1: &G::ScalarField, p2: G, s2: &G::ScalarField, p3: G, s3: &G::ScalarField, t: G, )
Add a check of the form p1 * s1 + p2 * s2 + p3 * s3 = t. Converts it to p1 * s1 * r + p2 * s2 * r + p3 * s3 * r - t * r = 0 where r is the current randomness.
Sourcepub fn add_many<'a>(
&mut self,
a: impl IntoIterator<Item = G>,
b: impl IntoIterator<Item = &'a G::ScalarField>,
t: G,
)
pub fn add_many<'a>( &mut self, a: impl IntoIterator<Item = G>, b: impl IntoIterator<Item = &'a G::ScalarField>, t: G, )
Add a check of the form <a, b> = t. Expects a and b to be of the same length
Sourcepub fn verify(&self) -> bool
pub fn verify(&self) -> bool
Combine all the checks into a multi-scalar multiplication and return true if the result is 0.
pub fn len(&self) -> usize
Trait Implementations§
Source§impl<G: Clone + AffineRepr> Clone for RandomizedMultChecker<G>where
G::ScalarField: Clone,
impl<G: Clone + AffineRepr> Clone for RandomizedMultChecker<G>where
G::ScalarField: Clone,
Source§fn clone(&self) -> RandomizedMultChecker<G>
fn clone(&self) -> RandomizedMultChecker<G>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more