-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Implement Fiat-Shamir Abstraction 2. Implement non-interactive sumcheck.
- Loading branch information
1 parent
584fa37
commit 8b7726a
Showing
22 changed files
with
1,120 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,21 @@ | ||
use bls12_381::Scalar; | ||
|
||
pub struct Prover{ | ||
|
||
} | ||
pub struct Prover {} | ||
|
||
impl Prover { | ||
|
||
|
||
// At the start of the protocol, P sends a function D: {0,1}k0 → F claimed to equal W0 | ||
// (the function mapping output gate labels to output values). | ||
pub fn proof(&self) -> () { | ||
|
||
} | ||
pub fn proof(&self) -> () {} | ||
|
||
pub fn round_1(&self) -> () { | ||
todo!() | ||
} | ||
|
||
|
||
// total d round: i=0,1,...,d−1 | ||
pub fn round_i(&self) -> () { | ||
pub fn round_i(&self) -> () { | ||
todo!() | ||
} | ||
|
||
|
||
// Define the (2ki+1)-variate polynomial | ||
pub fn gen_f_ri(){ | ||
|
||
} | ||
|
||
|
||
|
||
|
||
} | ||
pub fn gen_f_ri() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
use rand_core::{OsRng, RngCore}; | ||
|
||
pub struct Verifier{ | ||
|
||
} | ||
|
||
impl Verifier{ | ||
pub struct Verifier {} | ||
|
||
impl Verifier { | ||
// generate r1, r2, ..., rv | ||
fn gen_challenge() -> usize { | ||
let k = OsRng.next_u32() % 1000; | ||
k as usize | ||
} | ||
|
||
// picks a random r0∈Fk0 and lets m0←D ̃(r0). | ||
fn round_i(){ | ||
|
||
} | ||
|
||
fn round_i() {} | ||
|
||
// V checks m_d = W_d (r_d ) | ||
fn check(){ | ||
|
||
} | ||
|
||
fn check() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,6 @@ | |
|
||
mod gkr; | ||
|
||
|
||
|
||
|
||
#[cfg(test)] | ||
mod test { | ||
#[test] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,6 @@ mod test { | |
|
||
let mut sumcheck = SumCheck::new(mpoly); | ||
|
||
// todo! meet error | ||
sumcheck.run_protocol(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "Fiat_Shamir" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
sha3 = "0.10.6" | ||
|
||
[dev-dependencies] | ||
ff = "0.13.0" | ||
bls12_381 = "0.8.0" | ||
rand = "0.8.5" | ||
rand_core = { version = "0.6.4", default-features = false, features = ["std"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use crate::Transcript; | ||
use sha3::{Digest, Keccak256}; | ||
|
||
pub struct Keccak256Transcript { | ||
hasher: Keccak256, | ||
} | ||
|
||
impl Transcript for Keccak256Transcript { | ||
fn append(&mut self, new_data: &[u8]) { | ||
self.hasher.update(&mut new_data.to_owned()); | ||
} | ||
|
||
fn challenge(&mut self) -> [u8; 32] { | ||
let mut result_hash = [0_u8; 32]; | ||
result_hash.copy_from_slice(&self.hasher.finalize_reset()); | ||
result_hash.reverse(); | ||
self.hasher.update(result_hash); | ||
result_hash | ||
} | ||
} | ||
|
||
impl Default for Keccak256Transcript { | ||
fn default() -> Self { | ||
Self { | ||
hasher: Keccak256::new(), | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use bls12_381::Scalar; | ||
use ff::Field; | ||
use rand_core::OsRng; | ||
|
||
#[test] | ||
fn test() { | ||
let mut rng = OsRng; | ||
let s_one = Scalar::random(rng); | ||
let s_two = Scalar::random(rng); | ||
|
||
let mut transcript1 = Keccak256Transcript::default(); | ||
transcript1.append(&s_one.to_bytes()); | ||
transcript1.append(&s_two.to_bytes()); | ||
|
||
let challenge_1 = transcript1.challenge(); | ||
|
||
let mut transcript2 = Keccak256Transcript::default(); | ||
transcript2.append(&s_one.to_bytes()); | ||
transcript2.append(&s_two.to_bytes()); | ||
|
||
let challenge_2 = transcript2.challenge(); | ||
|
||
assert_eq!(challenge_1, challenge_2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![allow(non_snake_case)] | ||
pub mod default; | ||
|
||
pub trait Transcript { | ||
fn append(&mut self, new_data: &[u8]); | ||
fn challenge(&mut self) -> [u8; 32]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "ni_sumcheck" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "non-interactive sumcheck" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
ff = "0.13.0" | ||
bls12_381 = "0.8.0" | ||
rand = "0.8.5" | ||
rand_core = { version = "0.6.4", default-features = false, features = ["std"] } | ||
rayon = "1.7.0" | ||
log = "0.4.19" | ||
sha3 = "0.10.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#![allow(non_snake_case)] | ||
|
||
mod poly; | ||
mod sumcheck; | ||
mod transcript; | ||
mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod multivar_poly; | ||
pub mod univar_poly; |
Oops, something went wrong.