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