Minor fixes

This commit is contained in:
wborgeaud 2021-05-18 16:23:44 +02:00
parent 96a880193c
commit 4f6f2192ab
5 changed files with 42 additions and 95 deletions

View File

@ -111,10 +111,7 @@ impl Field for QuadraticCrandallField {
// otherwise the FFT doesn't commute with field inclusion.
fn primitive_root_of_unity(n_log: usize) -> Self {
if n_log <= CrandallField::TWO_ADICITY {
Self([
CrandallField::primitive_root_of_unity(n_log),
CrandallField::ZERO,
])
CrandallField::primitive_root_of_unity(n_log).into()
} else {
// The root of unity isn't in the base field so we need to compute it manually.
assert!(n_log <= Self::TWO_ADICITY);

View File

@ -149,12 +149,7 @@ impl Field for QuarticCrandallField {
// otherwise the FFT doesn't commute with field inclusion.
fn primitive_root_of_unity(n_log: usize) -> Self {
if n_log <= CrandallField::TWO_ADICITY {
Self([
CrandallField::primitive_root_of_unity(n_log),
CrandallField::ZERO,
CrandallField::ZERO,
CrandallField::ZERO,
])
CrandallField::primitive_root_of_unity(n_log).into()
} else {
// The root of unity isn't in the base field so we need to compute it manually.
assert!(n_log <= Self::TWO_ADICITY);

View File

@ -96,7 +96,7 @@ mod tests {
coset_lde
.values
.into_iter()
.map(|x| F::Extension::from(x))
.map(F::Extension::from)
.collect(),
);
let root = tree.root;
@ -155,34 +155,28 @@ mod tests {
mod base {
use super::*;
type F = CrandallField;
const D: usize = 1;
#[test]
fn test_fri_multi_params() -> Result<()> {
check_fri_multi_params::<F, D>()
check_fri_multi_params::<CrandallField, 1>()
}
}
mod quadratic {
use super::*;
type F = CrandallField;
const D: usize = 2;
#[test]
fn test_fri_multi_params() -> Result<()> {
check_fri_multi_params::<F, D>()
check_fri_multi_params::<CrandallField, 2>()
}
}
mod quartic {
use super::*;
type F = CrandallField;
const D: usize = 4;
#[test]
fn test_fri_multi_params() -> Result<()> {
check_fri_multi_params::<F, D>()
check_fri_multi_params::<CrandallField, 4>()
}
}
}

View File

@ -95,13 +95,6 @@ impl<F: Field> Challenger<F> {
(0..n).map(|_| self.get_challenge()).collect()
}
pub fn get_n_extension_challenges<const D: usize>(&mut self, n: usize) -> Vec<F::Extension>
where
F: Extendable<D>,
{
(0..n).map(|_| self.get_extension_challenge()).collect()
}
pub fn get_hash(&mut self) -> Hash<F> {
Hash {
elements: [
@ -122,6 +115,13 @@ impl<F: Field> Challenger<F> {
F::Extension::from_basefield_array(arr)
}
pub fn get_n_extension_challenges<const D: usize>(&mut self, n: usize) -> Vec<F::Extension>
where
F: Extendable<D>,
{
(0..n).map(|_| self.get_extension_challenge()).collect()
}
/// Absorb any buffered inputs. After calling this, the input buffer will be empty.
fn absorb_buffered_inputs(&mut self) {
if self.input_buffer.is_empty() {

View File

@ -511,81 +511,42 @@ mod tests {
)
}
macro_rules! tests_commitments {
($F:ty, $D:expr) => {
use super::*;
#[test]
fn test_polynomial_commitment() -> Result<()> {
check_polynomial_commitment::<$F, $D>()
}
#[test]
fn test_polynomial_commitment_blinding() -> Result<()> {
check_polynomial_commitment_blinding::<$F, $D>()
}
#[test]
fn test_batch_polynomial_commitment() -> Result<()> {
check_batch_polynomial_commitment::<$F, $D>()
}
#[test]
fn test_batch_polynomial_commitment_blinding() -> Result<()> {
check_batch_polynomial_commitment_blinding::<$F, $D>()
}
};
}
mod base {
use super::*;
type F = CrandallField;
const D: usize = 1;
#[test]
fn test_polynomial_commitment() -> Result<()> {
check_polynomial_commitment::<F, D>()
}
#[test]
fn test_polynomial_commitment_blinding() -> Result<()> {
check_polynomial_commitment_blinding::<F, D>()
}
#[test]
fn test_batch_polynomial_commitment() -> Result<()> {
check_batch_polynomial_commitment::<F, D>()
}
#[test]
fn test_batch_polynomial_commitment_blinding() -> Result<()> {
check_batch_polynomial_commitment_blinding::<F, D>()
}
tests_commitments!(crate::field::crandall_field::CrandallField, 1);
}
mod quadratic {
use super::*;
type F = CrandallField;
const D: usize = 2;
#[test]
fn test_polynomial_commitment() -> Result<()> {
check_polynomial_commitment::<F, D>()
}
#[test]
fn test_polynomial_commitment_blinding() -> Result<()> {
check_polynomial_commitment_blinding::<F, D>()
}
#[test]
fn test_batch_polynomial_commitment() -> Result<()> {
check_batch_polynomial_commitment::<F, D>()
}
#[test]
fn test_batch_polynomial_commitment_blinding() -> Result<()> {
check_batch_polynomial_commitment_blinding::<F, D>()
}
tests_commitments!(crate::field::crandall_field::CrandallField, 2);
}
mod quartic {
use super::*;
type F = CrandallField;
const D: usize = 4;
#[test]
fn test_polynomial_commitment() -> Result<()> {
check_polynomial_commitment::<F, D>()
}
#[test]
fn test_polynomial_commitment_blinding() -> Result<()> {
check_polynomial_commitment_blinding::<F, D>()
}
#[test]
fn test_batch_polynomial_commitment() -> Result<()> {
check_batch_polynomial_commitment::<F, D>()
}
#[test]
fn test_batch_polynomial_commitment_blinding() -> Result<()> {
check_batch_polynomial_commitment_blinding::<F, D>()
}
tests_commitments!(crate::field::crandall_field::CrandallField, 4);
}
}