mirror of
https://github.com/arnaucube/sonobe.git
synced 2026-01-28 06:53:48 +01:00
HyperNova: add multi-instances folding to AugmentedFCircuit & IVC (#119)
- Adds the logic to support multi-instances folding in HyperNova's AugmentedFCircuit & IVC. - Adds also methods to generate new LCCCS & CCCS instances that don't depend on the main folding chain, to be folded in in the next step - Updates CycleFold circuit & methods to work other folding schemes than Nova, adapting it to fold multiple points per circuit (instead of 2-to-1 as till now) - Handle multi-instances folding in the FoldingScheme trait interface, which expects 'None' in Nova, and 'Some' in HyperNova & other multi-folding schemes.
This commit is contained in:
@@ -69,6 +69,8 @@ pub enum Error {
|
||||
NotEnoughSteps,
|
||||
#[error("Evaluation failed")]
|
||||
EvaluationFail,
|
||||
#[error("{0} can not be zero")]
|
||||
CantBeZero(String),
|
||||
|
||||
// Commitment errors
|
||||
#[error("Pedersen parameters length is not sufficient (generators.len={0} < vector.len={1} unsatisfied)")]
|
||||
@@ -97,6 +99,10 @@ pub enum Error {
|
||||
BigIntConversionError(String),
|
||||
#[error("Failed to serde: {0}")]
|
||||
JSONSerdeError(String),
|
||||
#[error("Multi instances folding not supported in this scheme")]
|
||||
NoMultiInstances,
|
||||
#[error("Missing 'other' instances, since this is a multi-instances folding scheme")]
|
||||
MissingOtherInstances,
|
||||
}
|
||||
|
||||
/// FoldingScheme defines trait that is implemented by the diverse folding schemes. It is defined
|
||||
@@ -116,6 +122,7 @@ where
|
||||
type VerifierParam: Debug + Clone;
|
||||
type RunningInstance: Debug; // contains the CommittedInstance + Witness
|
||||
type IncomingInstance: Debug; // contains the CommittedInstance + Witness
|
||||
type MultiCommittedInstanceWithWitness: Debug; // type used for the extra instances in the multi-instance folding setting
|
||||
type CFInstance: Debug; // CycleFold CommittedInstance & Witness
|
||||
|
||||
fn preprocess(
|
||||
@@ -124,7 +131,7 @@ where
|
||||
) -> Result<(Self::ProverParam, Self::VerifierParam), Error>;
|
||||
|
||||
fn init(
|
||||
params: (Self::ProverParam, Self::VerifierParam),
|
||||
params: &(Self::ProverParam, Self::VerifierParam),
|
||||
step_circuit: FC,
|
||||
z_0: Vec<C1::ScalarField>, // initial state
|
||||
) -> Result<Self, Error>;
|
||||
@@ -133,6 +140,7 @@ where
|
||||
&mut self,
|
||||
rng: impl RngCore,
|
||||
external_inputs: Vec<C1::ScalarField>,
|
||||
other_instances: Option<Self::MultiCommittedInstanceWithWitness>,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
// returns the state at the current step
|
||||
@@ -160,6 +168,35 @@ where
|
||||
) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
/// Trait with auxiliary methods for multi-folding schemes (ie. HyperNova, ProtoGalaxy, etc),
|
||||
/// allowing to create new instances for the multifold.
|
||||
pub trait MultiFolding<C1: CurveGroup, C2: CurveGroup, FC>: Clone + Debug
|
||||
where
|
||||
C1: CurveGroup<BaseField = C2::ScalarField, ScalarField = C2::BaseField>,
|
||||
C2::BaseField: PrimeField,
|
||||
FC: FCircuit<C1::ScalarField>,
|
||||
{
|
||||
type RunningInstance: Debug;
|
||||
type IncomingInstance: Debug;
|
||||
type MultiInstance: Debug;
|
||||
|
||||
/// Creates a new RunningInstance for the given state, to be folded in the multi-folding step.
|
||||
fn new_running_instance(
|
||||
&self,
|
||||
rng: impl RngCore,
|
||||
state: Vec<C1::ScalarField>,
|
||||
external_inputs: Vec<C1::ScalarField>,
|
||||
) -> Result<Self::RunningInstance, Error>;
|
||||
|
||||
/// Creates a new IncomingInstance for the given state, to be folded in the multi-folding step.
|
||||
fn new_incoming_instance(
|
||||
&self,
|
||||
rng: impl RngCore,
|
||||
state: Vec<C1::ScalarField>,
|
||||
external_inputs: Vec<C1::ScalarField>,
|
||||
) -> Result<Self::IncomingInstance, Error>;
|
||||
}
|
||||
|
||||
pub trait Decider<
|
||||
C1: CurveGroup,
|
||||
C2: CurveGroup,
|
||||
|
||||
Reference in New Issue
Block a user