Skip to content

Commit

Permalink
fiddling
Browse files Browse the repository at this point in the history
  • Loading branch information
adr1anh committed Jan 30, 2024
1 parent de73636 commit 40968c8
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 535 deletions.
141 changes: 0 additions & 141 deletions src/parafold/circuit.rs

This file was deleted.

6 changes: 5 additions & 1 deletion src/parafold/cycle_fold/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ use crate::parafold::nifs_secondary::AllocatedSecondaryRelaxedR1CSInstance;
use crate::parafold::transcript::circuit::AllocatedTranscript;
use crate::traits::Engine;

impl<E1: Engine, E2: Engine<Base = E1::Scalar>> AllocatedScalarMulAccumulator<E1, E2> {
impl<E1, E2> AllocatedScalarMulAccumulator<E1, E2>
where
E1: Engine,
E2: Engine<Base = E1::Scalar>,
{
/// Compute the result `C <- A + x * B` by folding a proof over the secondary curve.
pub fn scalar_mul<CS>(
&mut self,
Expand Down
23 changes: 12 additions & 11 deletions src/parafold/cycle_fold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use crate::parafold::nifs_secondary::{
AllocatedSecondaryFoldProof, AllocatedSecondaryMergeProof, AllocatedSecondaryRelaxedR1CSInstance,
};
use crate::parafold::nifs_secondary::{SecondaryFoldProof, SecondaryMergeProof};
use crate::parafold::transcript::prover::TranscriptRepresentable;
use crate::traits::commitment::CommitmentTrait;
use crate::traits::Engine;
use crate::Commitment;
use crate::parafold::transcript;

pub mod circuit;
mod circuit_alloc;
Expand Down Expand Up @@ -70,7 +70,7 @@ pub struct AllocatedHashedCommitment<E1: Engine> {
hash: BigNat<E1::Scalar>,
}

impl<E1: Engine> crate::parafold::transcript::circuit::TranscriptRepresentable<E1::Scalar>
impl<E1: Engine> transcript::circuit::TranscriptRepresentable<E1::Scalar>
for AllocatedHashedCommitment<E1>
{
fn to_field_vec(&self) -> Vec<AllocatedNum<E1::Scalar>> {
Expand Down Expand Up @@ -101,12 +101,17 @@ impl<E1: Engine> HashedCommitment<E1> {
}
}

impl<E1: Engine> TranscriptRepresentable<E1::Scalar> for HashedCommitment<E1> {
impl<E1: Engine> transcript::prover::TranscriptRepresentable<E1::Scalar> for HashedCommitment<E1> {
fn to_field_vec(&self) -> Vec<E1::Scalar> {
self.hash_limbs.clone()
}
}

#[derive(Debug, Clone, PartialEq)]
pub struct ScalarMulAccumulatorInstance<E2: Engine> {
acc: SecondaryRelaxedR1CSInstance<E2>,
}

/// Circuit representation of a RelaxedR1CS accumulator of the non-native scalar multiplication circuit.
///
/// # Future work
Expand All @@ -127,12 +132,7 @@ impl<E1: Engine> TranscriptRepresentable<E1::Scalar> for HashedCommitment<E1> {
/// of deferred instances.
#[derive(Debug, Clone)]
pub struct AllocatedScalarMulAccumulator<E1: Engine, E2: Engine> {
pub acc: AllocatedSecondaryRelaxedR1CSInstance<E1, E2>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct ScalarMulAccumulatorInstance<E2: Engine> {
acc: SecondaryRelaxedR1CSInstance<E2>,
acc: AllocatedSecondaryRelaxedR1CSInstance<E1, E2>,
}

/// A proof for a non-native group operation C = A + x * B, where x is a native scalar
Expand All @@ -145,10 +145,11 @@ pub struct ScalarMulFoldProof<E1: Engine, E2: Engine> {

#[derive(Debug, Clone)]
pub struct AllocatedScalarMulFoldProof<E1: Engine, E2: Engine> {
pub output: AllocatedHashedCommitment<E1>,
pub proof: AllocatedSecondaryFoldProof<E1, E2>,
output: AllocatedHashedCommitment<E1>,
proof: AllocatedSecondaryFoldProof<E1, E2>,
}

///
#[derive(Debug, Clone)]
pub struct ScalarMulMergeProof<E1: Engine, E2: Engine> {
proof: SecondaryMergeProof<E2>,
Expand Down
2 changes: 1 addition & 1 deletion src/parafold/cycle_fold/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<E2: Engine> ScalarMulAccumulator<E2> {
/// Compute
pub fn merge<E1: Engine<Scalar = E2::Base>>(
self,
_other: Self,
_other: &Self,
_transcript: &mut Transcript<E1>,
) -> (Self, ScalarMulMergeProof<E1, E2>) {
// self and other will not need to be added to the transcript since they are obtained from an accumulator
Expand Down
2 changes: 0 additions & 2 deletions src/parafold/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#[allow(dead_code)]
mod circuit;
#[allow(dead_code)]
mod cycle_fold;
#[allow(dead_code)]
mod ecc;
Expand Down
5 changes: 3 additions & 2 deletions src/parafold/nifs_primary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct AllocatedRelaxedR1CSInstance<E1: Engine> {
E: AllocatedHashedCommitment<E1>,
}


/// A proof for folding a statement X of a circuit C into a Relaxed-R1CS circuit for the same circuit C
#[derive(Debug, Clone, Default)]
pub struct FoldProof<E1: Engine, E2: Engine> {
Expand All @@ -35,8 +36,7 @@ pub struct FoldProof<E1: Engine, E2: Engine> {
E_sm_proof: ScalarMulFoldProof<E1, E2>,
}

/// An allocated Nova folding proof, for either folding an [R1CSInstance] or a [RelaxedR1CSInstance] into
/// another [RelaxedR1CSInstance]
/// Allocated [FoldProof]
#[derive(Debug, Clone)]
pub struct AllocatedFoldProof<E1: Engine, E2: Engine> {
pub W: AllocatedHashedCommitment<E1>,
Expand All @@ -54,6 +54,7 @@ pub struct MergeProof<E1: Engine, E2: Engine> {
E2_sm_proof: ScalarMulFoldProof<E1, E2>,
}

/// Allocated [MergeProof]
#[derive(Debug, Clone)]
pub struct AllocatedMergeProof<E1: Engine, E2: Engine> {
T: AllocatedHashedCommitment<E1>,
Expand Down
Loading

0 comments on commit 40968c8

Please sign in to comment.