arnaucube
arnaucube/sonobePublic Self-hosted repository
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;
11
12#[derive(Debug, Error)]
13pub enum Error {
14    #[error("Relation not satisfied")]
15    NotSatisfied,
16}
17
18/// FoldingScheme defines trait that is implemented by the diverse folding schemes. It is defined
19/// over a cycle of curves (C1, C2), where:
20/// - C1 is the main curve, which ScalarField we use as our F for al the field operations
21/// - C2 is the auxiliary curve, which we use for the commitments, whose BaseField (for point
22/// coordinates) are in the C1::ScalarField
23pub trait FoldingScheme<C1: CurveGroup, C2: CurveGroup>: Clone + Debug
24where
25    C1: CurveGroup<BaseField = C2::ScalarField, ScalarField = C2::BaseField>,
26    C2::BaseField: PrimeField,
27{
28    // type PCS: PolynomialCommitmentScheme<C>; // maybe not needed, just PedersenCommitment
29    type PreprocessorParam: Debug;
30    type ProverParam: Debug;
31    type VerifierParam: Debug;
32    type FreshInstance: Debug;
33    type PublicInput: Debug;
34    type CommittedInstanceWithWitness: Debug;
35    type CommittedInstance: Clone + Debug;
36
37    fn preprocess(
38        // pcs_param: &<Self::CS as PolynomialCommitmentScheme<C>>::Param,
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::FreshInstance],
50        transcript: &mut impl Transcript<C1::ScalarField>,
51        rng: impl RngCore,
52    ) -> Result<(), Error>;
53
54    fn verify(
55        vp: &Self::VerifierParam,
56        running_instance: &mut Self::CommittedInstance,
57        incomming_instances: &[Self::PublicInput],
58        transcript: &mut impl Transcript<C1::ScalarField>,
59        rng: impl RngCore,
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::ScalarField>,
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::ScalarField>,
83        rng: impl RngCore,
84    ) -> Result<(), Error>;
85}