sonobe/src/lib.rs
src/lib.rsRaw
1#![allow(non_snake_case)]
2#![allow(non_upper_case_globals)]
3
4use ark_ec::CurveGroup;
5use ark_ff::PrimeField;
6use ark_std::{fmt::Debug, rand::RngCore};
7use thiserror::Error;
8
9pub mod transcript;
10use transcript::Transcript;
11pub mod pedersen;
12pub mod utils;
13
14#[derive(Debug, Error)]
15pub enum Error {
16 #[error("Relation not satisfied")]
17 NotSatisfied,
18}
19
20/// FoldingScheme defines trait that is implemented by the diverse folding schemes. It is defined
21/// over a cycle of curves (C1, C2), where:
22/// - C1 is the main curve, which ScalarField we use as our F for al the field operations
23/// - C2 is the auxiliary curve, which we use for the commitments, whose BaseField (for point
24/// coordinates) are in the C1::ScalarField.
25/// In other words, C1.Fq == C2.Fr, and C1.Fr == C2.Fq.
26pub trait FoldingScheme<C1: CurveGroup, C2: CurveGroup>: Clone + Debug
27where
28 C1: CurveGroup<BaseField = C2::ScalarField, ScalarField = C2::BaseField>,
29 C2::BaseField: PrimeField,
30{
31 type PreprocessorParam: Debug;
32 type ProverParam: Debug;
33 type VerifierParam: Debug;
34 type Witness: Debug;
35 type CommittedInstanceWithWitness: Debug;
36 type CommittedInstance: Clone + Debug;
37
38 fn preprocess(
39 prep_param: &Self::PreprocessorParam,
40 ) -> Result<(Self::ProverParam, Self::VerifierParam), Error>;
41
42 fn init_accumulator(
43 pp: &Self::ProverParam,
44 ) -> Result<Self::CommittedInstanceWithWitness, Error>;
45
46 fn prove(
47 pp: &Self::ProverParam,
48 running_instance: &mut Self::CommittedInstanceWithWitness,
49 incomming_instances: &[Self::Witness],
50 transcript: &mut impl Transcript<C1>,
51 ) -> Result<(), Error>;
52
53 fn verify(
54 vp: &Self::VerifierParam,
55 running_instance: &mut Self::CommittedInstance,
56 incomming_instances: &[Self::CommittedInstance],
57 transcript: &mut impl Transcript<C1>,
58 ) -> Result<(), Error>;
59}
60
61pub trait Decider<C: CurveGroup>: Clone + Debug {
62 type PreprocessorParam: Debug;
63 type ProverParam: Debug;
64 type VerifierParam: Debug;
65 type FreshInstance: Debug;
66 type PublicInput: Debug;
67 type CommittedInstanceWithWitness: Debug;
68 type CommittedInstance: Clone + Debug;
69
70 fn prove(
71 pp: &Self::ProverParam,
72 running_instance: &Self::CommittedInstanceWithWitness,
73 transcript: &mut impl Transcript<C>,
74 rng: impl RngCore,
75 ) -> Result<(), Error>;
76
77 fn verify(
78 vp: &Self::VerifierParam,
79 running_instance: &Self::CommittedInstance,
80 transcript: &mut impl Transcript<C>,
81 rng: impl RngCore,
82 ) -> Result<(), Error>;
83}