Skip to content

Commit

Permalink
Implement Nova's NIFS.P & NIFS.V
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaucube committed Aug 23, 2023
1 parent 240b916 commit a675b4b
Show file tree
Hide file tree
Showing 4 changed files with 400 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/folding/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod nova;
62 changes: 62 additions & 0 deletions src/folding/nova/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use ark_crypto_primitives::sponge::Absorb;
use ark_ec::{CurveGroup, Group};
use ark_std::fmt::Debug;
use ark_std::{One, Zero};

use crate::pedersen::{Params as PedersenParams, Pedersen};

pub mod nifs;

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct CommittedInstance<C: CurveGroup> {
pub cmE: C,
pub u: C::ScalarField,
pub cmW: C,
pub x: Vec<C::ScalarField>,
}
impl<C: CurveGroup> CommittedInstance<C> {
pub fn empty() -> Self {
CommittedInstance {
cmE: C::generator(),
u: C::ScalarField::one(),
cmW: C::generator(),
x: Vec::new(),
}
}
}

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Witness<C: CurveGroup> {
pub E: Vec<C::ScalarField>,
pub rE: C::ScalarField,
pub W: Vec<C::ScalarField>,
pub rW: C::ScalarField,
}

impl<C: CurveGroup> Witness<C>
where
<C as Group>::ScalarField: Absorb,
{
pub fn new(w: Vec<C::ScalarField>, e_len: usize) -> Self {
Self {
E: vec![C::ScalarField::zero(); e_len],
rE: C::ScalarField::one(),
W: w,
rW: C::ScalarField::one(),
}
}
pub fn commit(
&self,
params: &PedersenParams<C>,
x: Vec<C::ScalarField>,
) -> CommittedInstance<C> {
let cmE = Pedersen::commit(params, &self.E, &self.rE);
let cmW = Pedersen::commit(params, &self.W, &self.rW);
CommittedInstance {
cmE,
u: C::ScalarField::one(),
cmW,
x,
}
}
}
Loading

0 comments on commit a675b4b

Please sign in to comment.