Skip to main content

RandomizedMultChecker

Struct RandomizedMultChecker 

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

Source

pub fn new(random: G::ScalarField) -> Self

Source

pub fn new_using_rng<R: Rng>(rng: &mut R) -> Self

Source

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.

Source

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.

Source

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.

Source

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

Source

pub fn verify(&self) -> bool

Combine all the checks into a multi-scalar multiplication and return true if the result is 0.

Source

pub fn len(&self) -> usize

Trait Implementations§

Source§

impl<G: Clone + AffineRepr> Clone for RandomizedMultChecker<G>
where G::ScalarField: Clone,

Source§

fn clone(&self) -> RandomizedMultChecker<G>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<G: Debug + AffineRepr> Debug for RandomizedMultChecker<G>
where G::ScalarField: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SendIfParallel for T
where T: Send,

Source§

impl<T> SyncIfParallel for T
where T: Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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