Skip to content

Commit

Permalink
add support for supernova
Browse files Browse the repository at this point in the history
  • Loading branch information
tyshkor committed Apr 25, 2024
1 parent 1d82d8b commit 98fc7c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/cyclefold/nifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

use std::marker::PhantomData;

use rand_core::OsRng;
use ff::Field;

use crate::{
constants::{NIO_CYCLE_FOLD, NUM_CHALLENGE_BITS, NUM_FE_IN_EMULATED_POINT},
errors::NovaError,
Expand Down Expand Up @@ -66,15 +69,16 @@ where

absorb_primary_r1cs::<E1, E2>(U2, &mut ro);

let (T, comm_T) = S.commit_T(ck, U1, W1, U2, W2)?;
let r_T = E1::Scalar::random(&mut OsRng);
let (T, comm_T) = S.commit_T(ck, U1, W1, U2, W2, &r_T)?;

absorb_primary_commitment::<E1, E2>(&comm_T, &mut ro);

let r = scalar_as_base::<E2>(ro.squeeze(NUM_CHALLENGE_BITS));

let U = U1.fold(U2, &comm_T, &r);

let W = W1.fold(W2, &T, &r)?;
let W = W1.fold(W2, &T, &r_T, &r)?;

Ok((
Self {
Expand Down Expand Up @@ -131,7 +135,8 @@ impl<E: Engine> CycleFoldNIFS<E> {
absorb_cyclefold_r1cs(U2, &mut ro);

// compute a commitment to the cross-term
let (T, comm_T) = S.commit_T(ck, U1, W1, U2, W2)?;
let r_T = E::Scalar::random(&mut OsRng);
let (T, comm_T) = S.commit_T(ck, U1, W1, U2, W2, &r_T)?;

// append `comm_T` to the transcript and obtain a challenge
comm_T.absorb_in_ro(&mut ro);
Expand All @@ -143,7 +148,7 @@ impl<E: Engine> CycleFoldNIFS<E> {
let U = U1.fold(U2, &comm_T, &r);

// fold the witness using `r` and `T`
let W = W1.fold(W2, &T, &r)?;
let W = W1.fold(W2, &T, &r_T, &r)?;

// return the folded instance and witness
Ok((
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub mod r1cs;
pub mod spartan;
pub mod traits;

// pub mod cyclefold;
// pub mod supernova;
pub mod cyclefold;
pub mod supernova;

use once_cell::sync::OnceCell;
use traits::{CurveCycleEquipped, Dual};
Expand Down

0 comments on commit 98fc7c8

Please sign in to comment.