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