mirror of
https://github.com/arnaucube/shockwave-plus.git
synced 2026-01-12 17:11:30 +01:00
chore: cleanup
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
use crate::FieldExt;
|
||||
use halo2curves::ff::Field;
|
||||
use std::vec;
|
||||
|
||||
pub fn fft<F>(coeffs: &[F], domain: &[F]) -> Vec<F>
|
||||
where
|
||||
@@ -11,7 +9,6 @@ where
|
||||
return coeffs.to_vec();
|
||||
}
|
||||
|
||||
// TODO: Just borrow the values
|
||||
// Split into evens and odds
|
||||
let L = coeffs
|
||||
.iter()
|
||||
@@ -46,24 +43,26 @@ where
|
||||
return evals_L;
|
||||
}
|
||||
|
||||
pub fn ifft<F: FieldExt + Field>(domain: &[F], evals: &[F]) -> Vec<F> {
|
||||
let mut coeffs = vec![];
|
||||
let len_mod_inv = F::from(domain.len() as u64).invert().unwrap();
|
||||
let vals = fft(&evals, &domain);
|
||||
|
||||
coeffs.push(vals[0] * len_mod_inv);
|
||||
for val in vals[1..].iter().rev() {
|
||||
coeffs.push(*val * len_mod_inv);
|
||||
}
|
||||
|
||||
coeffs
|
||||
}
|
||||
|
||||
#[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 len_mod_inv = F::from(domain.len() as u64).invert().unwrap();
|
||||
let vals = fft(&evals, &domain);
|
||||
|
||||
coeffs.push(vals[0] * len_mod_inv);
|
||||
for val in vals[1..].iter().rev() {
|
||||
coeffs.push(*val * len_mod_inv);
|
||||
}
|
||||
|
||||
coeffs
|
||||
}
|
||||
|
||||
use super::*;
|
||||
#[test]
|
||||
fn test_fft_ifft() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(non_snake_case)]
|
||||
mod fft;
|
||||
mod polynomial;
|
||||
pub mod rs_config;
|
||||
|
||||
@@ -32,7 +32,7 @@ pub struct CommittedTensorCode<F: FieldExt> {
|
||||
}
|
||||
|
||||
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 leaves =
|
||||
|
||||
@@ -297,14 +297,12 @@ impl<F: FieldExt> TensorMultilinearPCS<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
|
||||
let num_indices = self.config.l;
|
||||
|
||||
let u_hat_openings = indices
|
||||
.iter()
|
||||
.map(|index| u_hat_comm.query_column(*index, num_cols))
|
||||
.map(|index| u_hat_comm.query_column(*index))
|
||||
.collect::<Vec<Vec<F>>>();
|
||||
|
||||
debug_assert_eq!(u_hat_openings.len(), num_indices);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::FieldExt;
|
||||
use halo2curves::ff::PrimeField;
|
||||
use merlin::Transcript as MerlinTranscript;
|
||||
use std::{io::Repeat, marker::PhantomData, panic::UnwindSafe};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(Clone)]
|
||||
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 serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
@@ -23,15 +23,6 @@ pub fn dot_prod<F: FieldExt>(x: &[F], y: &[F]) -> F {
|
||||
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] {
|
||||
let mut hasher = Keccak::v256();
|
||||
for value in values {
|
||||
|
||||
Reference in New Issue
Block a user