Trait kimchi::snarky::api::SnarkyCircuit
source · 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§
sourcetype Curve: KimchiCurve
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.
type Proof: OpenProof<Self::Curve>
sourcetype PrivateInput
type PrivateInput
The private input used by the circuit.
sourcetype PublicInput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>
type PublicInput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>
The public input used by the circuit.
sourcetype PublicOutput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>
type PublicOutput: SnarkyType<<Self::Curve as AffineRepr>::ScalarField>
The public output returned by the circuit.
Required Methods§
sourcefn circuit(
&self,
sys: &mut RunState<<Self::Curve as AffineRepr>::ScalarField>,
public_input: Self::PublicInput,
private_input: Option<&Self::PrivateInput>
) -> SnarkyResult<Self::PublicOutput>
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 toNone
for compilation.
It returns a SnarkyResult containing the public output.
Provided Methods§
sourcefn compile_to_indexes(
self
) -> SnarkyResult<(ProverIndexWrapper<Self>, VerifierIndexWrapper<Self>)>where
<Self::Curve as AffineRepr>::BaseField: PrimeField,
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).