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