[][src]Trait zkp::toolbox::SchnorrCS

pub trait SchnorrCS {
    type ScalarVar: Copy;
    type PointVar: Copy;
    fn constrain(
        &mut self,
        lhs: Self::PointVar,
        linear_combination: Vec<(Self::ScalarVar, Self::PointVar)>
    ); }

An interface for specifying proof statements, common between provers and verifiers.

The variables for the constraint system are provided as associated types, allowing different implementations to have different point and scalar types. For instance, the batch verifier has two types of point variables, one for points common to all proofs in the batch, and one for points varying per-proof.

This is why variable allocation is not included in the trait, as different roles may have different behaviour -- for instance, a prover needs to supply assignments to the scalar variables, but a verifier doesn't have access to the prover's secret scalars.

To specify a proof statement using this trait, write a generic function that takes a constraint system as a parameter and adds the statements. For instance, to specify an equality of discrete logarithms, one could write

This example is not tested
fn dleq_statement<CS: SchnorrCS>(
    cs: &mut CS,
    x: CS::ScalarVar,
    A: CS::PointVar,
    G: CS::PointVar,
    B: CS::PointVar,
    H: CS::PointVar,
) {
    cs.constrain(A, vec![(x, B)]);
    cs.constrain(G, vec![(x, H)]);
}

This means that multiple statements can be added to the same proof, independently of the specification of the statement, by constructing a constraint system and then passing it to multiple statement functions.

Associated Types

type ScalarVar: Copy

A handle for a scalar variable in the constraint system.

type PointVar: Copy

A handle for a point variable in the constraint system.

Loading content...

Required methods

fn constrain(
    &mut self,
    lhs: Self::PointVar,
    linear_combination: Vec<(Self::ScalarVar, Self::PointVar)>
)

Add a constraint of the form lhs = linear_combination.

Loading content...

Implementors

impl<'a> SchnorrCS for BatchVerifier<'a>[src]

type ScalarVar = ScalarVar

type PointVar = PointVar

impl<'a> SchnorrCS for Prover<'a>[src]

type ScalarVar = ScalarVar

type PointVar = PointVar

impl<'a> SchnorrCS for Verifier<'a>[src]

type ScalarVar = ScalarVar

type PointVar = PointVar

Loading content...