pub trait SnarkyCircuit: Sized {
    type Curve: KimchiCurve;
    type Proof: OpenProof<Self::Curve>;
    type PrivateInput;
    type PublicInput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>;
    type PublicOutput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>;

    // Required method
    fn circuit(
        &self,
        sys: &mut RunState<<Self::Curve as AffineRepr>::ScalarField>,
        public_input: Self::PublicInput,
        private_input: Option<&Self::PrivateInput>
    ) -> SnarkyResult<Self::PublicOutput>;

    // Provided method
    fn compile_to_indexes(
        self
    ) -> SnarkyResult<(ProverIndexWrapper<Self>, VerifierIndexWrapper<Self>)>
       where <Self::Curve as AffineRepr>::BaseField: PrimeField { ... }
}
Expand description

The main trait. Implement this on your circuit to get access to more functions (specifically Self::compile_to_indexes).

Required Associated Types§

source

type Curve: KimchiCurve

A circuit must be defined for a specific field, as it might be incorrect to use a different field. Currently we specify the field by the curve, which is more strict and needed due to implementation details in kimchi.

source

type Proof: OpenProof<Self::Curve>

source

type PrivateInput

The private input used by the circuit.

source

type PublicInput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>

The public input used by the circuit.

source

type PublicOutput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>

The public output returned by the circuit.

Required Methods§

source

fn circuit( &self, sys: &mut RunState<<Self::Curve as AffineRepr>::ScalarField>, public_input: Self::PublicInput, private_input: Option<&Self::PrivateInput> ) -> SnarkyResult<Self::PublicOutput>

The circuit. It takes:

  • self: to parameterize it at compile time.
  • sys: to construct the circuit or generate the witness (dpeending on mode)
  • public_input: the public input (as defined above)
  • private_input: the private input as an option, set to None for compilation.

It returns a SnarkyResult containing the public output.

Provided Methods§

source

fn compile_to_indexes( self ) -> SnarkyResult<(ProverIndexWrapper<Self>, VerifierIndexWrapper<Self>)>where <Self::Curve as AffineRepr>::BaseField: PrimeField,

Compiles the circuit to a prover index (ProverIndexWrapper) and a verifier index (VerifierIndexWrapper).

Implementors§