mirror of
https://github.com/arnaucube/shockwave-plus.git
synced 2026-01-12 09:01:31 +01:00
chore: cleanup
This commit is contained in:
@@ -3,3 +3,4 @@ members = [
|
|||||||
"tensor_pcs",
|
"tensor_pcs",
|
||||||
"shockwave_plus"
|
"shockwave_plus"
|
||||||
]
|
]
|
||||||
|
resolver = "2"
|
||||||
|
|||||||
1
rust-toolchain
Normal file
1
rust-toolchain
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1.71.0
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
mod polynomial;
|
mod polynomial;
|
||||||
mod r1cs;
|
mod r1cs;
|
||||||
mod sumcheck;
|
mod sumcheck;
|
||||||
mod utils;
|
|
||||||
|
|
||||||
use ark_std::{end_timer, start_timer};
|
use ark_std::{end_timer, start_timer};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ pub struct MlPoly<F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<F: FieldExt> MlPoly<F> {
|
impl<F: FieldExt> MlPoly<F> {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn new(evals: Vec<F>) -> Self {
|
pub fn new(evals: Vec<F>) -> Self {
|
||||||
assert!(evals.len().is_power_of_two());
|
assert!(evals.len().is_power_of_two());
|
||||||
let num_vars = (evals.len() as f64).log2() as usize;
|
let num_vars = (evals.len() as f64).log2() as usize;
|
||||||
Self { evals, num_vars }
|
Self { evals, num_vars }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn dot_prod(x: &[F], y: &[F]) -> F {
|
fn dot_prod(x: &[F], y: &[F]) -> F {
|
||||||
assert_eq!(x.len(), y.len());
|
assert_eq!(x.len(), y.len());
|
||||||
let mut result = F::ZERO;
|
let mut result = F::ZERO;
|
||||||
@@ -27,6 +29,7 @@ impl<F: FieldExt> MlPoly<F> {
|
|||||||
// Evaluate the multilinear extension of the polynomial `a`, at point `t`.
|
// Evaluate the multilinear extension of the polynomial `a`, at point `t`.
|
||||||
// `a` is in evaluation form.
|
// `a` is in evaluation form.
|
||||||
// `t` should be in big-endian form.
|
// `t` should be in big-endian form.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn eval(&self, t: &[F]) -> F {
|
pub fn eval(&self, t: &[F]) -> F {
|
||||||
let n = self.evals.len();
|
let n = self.evals.len();
|
||||||
debug_assert_eq!((n as f64).log2() as usize, t.len());
|
debug_assert_eq!((n as f64).log2() as usize, t.len());
|
||||||
|
|||||||
@@ -256,12 +256,29 @@ mod tests {
|
|||||||
|
|
||||||
use halo2curves::ff::Field;
|
use halo2curves::ff::Field;
|
||||||
|
|
||||||
use crate::utils::boolean_hypercube;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
type F = halo2curves::secp256k1::Fp;
|
type F = halo2curves::secp256k1::Fp;
|
||||||
use crate::polynomial::ml_poly::MlPoly;
|
use crate::polynomial::ml_poly::MlPoly;
|
||||||
|
|
||||||
|
// Returns a vector of vectors of length m, where each vector is a boolean vector (big endian)
|
||||||
|
fn boolean_hypercube<F: FieldExt>(m: usize) -> Vec<Vec<F>> {
|
||||||
|
let n = 2usize.pow(m as u32);
|
||||||
|
|
||||||
|
let mut boolean_hypercube = Vec::<Vec<F>>::with_capacity(n);
|
||||||
|
|
||||||
|
for i in 0..n {
|
||||||
|
let mut tmp = Vec::with_capacity(m);
|
||||||
|
for j in 0..m {
|
||||||
|
let i_b = F::from((i >> j & 1) as u64);
|
||||||
|
tmp.push(i_b);
|
||||||
|
}
|
||||||
|
tmp.reverse();
|
||||||
|
boolean_hypercube.push(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean_hypercube
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_r1cs() {
|
fn test_r1cs() {
|
||||||
let num_cons = 10;
|
let num_cons = 10;
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
use crate::FieldExt;
|
|
||||||
|
|
||||||
// Returns a vector of vectors of length m, where each vector is a boolean vector (big endian)
|
|
||||||
pub fn boolean_hypercube<F: FieldExt>(m: usize) -> Vec<Vec<F>> {
|
|
||||||
let n = 2usize.pow(m as u32);
|
|
||||||
|
|
||||||
let mut boolean_hypercube = Vec::<Vec<F>>::with_capacity(n);
|
|
||||||
|
|
||||||
for i in 0..n {
|
|
||||||
let mut tmp = Vec::with_capacity(m);
|
|
||||||
for j in 0..m {
|
|
||||||
let i_b = F::from((i >> j & 1) as u64);
|
|
||||||
tmp.push(i_b);
|
|
||||||
}
|
|
||||||
tmp.reverse();
|
|
||||||
boolean_hypercube.push(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean_hypercube
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
use crate::FieldExt;
|
use crate::FieldExt;
|
||||||
use halo2curves::ff::Field;
|
|
||||||
use std::vec;
|
|
||||||
|
|
||||||
pub fn fft<F>(coeffs: &[F], domain: &[F]) -> Vec<F>
|
pub fn fft<F>(coeffs: &[F], domain: &[F]) -> Vec<F>
|
||||||
where
|
where
|
||||||
@@ -11,7 +9,6 @@ where
|
|||||||
return coeffs.to_vec();
|
return coeffs.to_vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Just borrow the values
|
|
||||||
// Split into evens and odds
|
// Split into evens and odds
|
||||||
let L = coeffs
|
let L = coeffs
|
||||||
.iter()
|
.iter()
|
||||||
@@ -46,7 +43,14 @@ where
|
|||||||
return evals_L;
|
return evals_L;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ifft<F: FieldExt + Field>(domain: &[F], evals: &[F]) -> Vec<F> {
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use halo2curves::ff::Field;
|
||||||
|
use halo2curves::ff::PrimeField;
|
||||||
|
use halo2curves::pasta::Fp;
|
||||||
|
|
||||||
|
// Test the fft function by running the inverse fft
|
||||||
|
fn ifft<F: FieldExt + Field>(domain: &[F], evals: &[F]) -> Vec<F> {
|
||||||
let mut coeffs = vec![];
|
let mut coeffs = vec![];
|
||||||
let len_mod_inv = F::from(domain.len() as u64).invert().unwrap();
|
let len_mod_inv = F::from(domain.len() as u64).invert().unwrap();
|
||||||
let vals = fft(&evals, &domain);
|
let vals = fft(&evals, &domain);
|
||||||
@@ -59,11 +63,6 @@ pub fn ifft<F: FieldExt + Field>(domain: &[F], evals: &[F]) -> Vec<F> {
|
|||||||
coeffs
|
coeffs
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use halo2curves::ff::PrimeField;
|
|
||||||
use halo2curves::pasta::Fp;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fft_ifft() {
|
fn test_fft_ifft() {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![allow(non_snake_case)]
|
||||||
mod fft;
|
mod fft;
|
||||||
mod polynomial;
|
mod polynomial;
|
||||||
pub mod rs_config;
|
pub mod rs_config;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pub struct CommittedTensorCode<F: FieldExt> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<F: FieldExt> CommittedTensorCode<F> {
|
impl<F: FieldExt> CommittedTensorCode<F> {
|
||||||
pub fn query_column(&self, column: usize, num_cols: usize) -> Vec<F> {
|
pub fn query_column(&self, column: usize) -> Vec<F> {
|
||||||
let num_rows = self.tensor_codeword.0.len();
|
let num_rows = self.tensor_codeword.0.len();
|
||||||
|
|
||||||
let leaves =
|
let leaves =
|
||||||
|
|||||||
@@ -297,14 +297,12 @@ impl<F: FieldExt> TensorMultilinearPCS<F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_phase(&self, indices: &[usize], u_hat_comm: &CommittedTensorCode<F>) -> Vec<Vec<F>> {
|
fn test_phase(&self, indices: &[usize], u_hat_comm: &CommittedTensorCode<F>) -> Vec<Vec<F>> {
|
||||||
let num_cols = self.config.num_cols() * 2;
|
|
||||||
|
|
||||||
// Query the columns of u_hat
|
// Query the columns of u_hat
|
||||||
let num_indices = self.config.l;
|
let num_indices = self.config.l;
|
||||||
|
|
||||||
let u_hat_openings = indices
|
let u_hat_openings = indices
|
||||||
.iter()
|
.iter()
|
||||||
.map(|index| u_hat_comm.query_column(*index, num_cols))
|
.map(|index| u_hat_comm.query_column(*index))
|
||||||
.collect::<Vec<Vec<F>>>();
|
.collect::<Vec<Vec<F>>>();
|
||||||
|
|
||||||
debug_assert_eq!(u_hat_openings.len(), num_indices);
|
debug_assert_eq!(u_hat_openings.len(), num_indices);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use crate::FieldExt;
|
use crate::FieldExt;
|
||||||
use halo2curves::ff::PrimeField;
|
|
||||||
use merlin::Transcript as MerlinTranscript;
|
use merlin::Transcript as MerlinTranscript;
|
||||||
use std::{io::Repeat, marker::PhantomData, panic::UnwindSafe};
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Transcript<F: FieldExt> {
|
pub struct Transcript<F: FieldExt> {
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
use core::num;
|
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use super::utils::hash_two;
|
|
||||||
use crate::{utils::hash_all, FieldExt};
|
use crate::{utils::hash_all, FieldExt};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,6 @@ pub fn dot_prod<F: FieldExt>(x: &[F], y: &[F]) -> F {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hash_two(values: &[[u8; 32]; 2]) -> [u8; 32] {
|
|
||||||
let mut hasher = Keccak::v256();
|
|
||||||
hasher.update(&values[0]);
|
|
||||||
hasher.update(&values[1]);
|
|
||||||
let mut hash = [0u8; 32];
|
|
||||||
hasher.finalize(&mut hash);
|
|
||||||
hash
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn hash_all(values: &[[u8; 32]]) -> [u8; 32] {
|
pub fn hash_all(values: &[[u8; 32]]) -> [u8; 32] {
|
||||||
let mut hasher = Keccak::v256();
|
let mut hasher = Keccak::v256();
|
||||||
for value in values {
|
for value in values {
|
||||||
|
|||||||
Reference in New Issue
Block a user