mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 17:53:06 +00:00
Couple tweaks for Goldilocks (#274)
- impl `RichField` - Fix missing imports (easy to miss since they're conditionally compiled) - Have the benchmarks use Goldilocks
This commit is contained in:
parent
bd38ada0d1
commit
3d39925973
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::field::extension_field::quadratic::QuadraticExtension;
|
||||
use crate::field::extension_field::quartic::QuarticExtension;
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::field::field_types::{Field, PrimeField};
|
||||
use crate::field::field_types::{Field, PrimeField, RichField};
|
||||
use crate::field::inversion::try_inverse_u64;
|
||||
|
||||
const EPSILON: u64 = (1 << 32) - 1;
|
||||
@ -245,6 +245,8 @@ impl Extendable<4> for GoldilocksField {
|
||||
[Self(0), Self(0), Self(0), Self(12587610116473453104)];
|
||||
}
|
||||
|
||||
impl RichField for GoldilocksField {}
|
||||
|
||||
/// Reduces to a 64-bit value. The result might not be in canonical form; it could be in between the
|
||||
/// field order and `2^64`.
|
||||
#[inline]
|
||||
|
||||
@ -4,9 +4,6 @@
|
||||
//! `poseidon_constants.sage` script in the `mir-protocol/hash-constants`
|
||||
//! repository.
|
||||
|
||||
#[cfg(any(target_feature = "avx2", target_feature = "neon"))]
|
||||
use std::convert::TryInto;
|
||||
|
||||
use crate::field::crandall_field::CrandallField;
|
||||
use crate::hash::poseidon::{Poseidon, N_PARTIAL_ROUNDS};
|
||||
|
||||
@ -152,6 +149,9 @@ impl Poseidon<8> for CrandallField {
|
||||
#[cfg(target_feature="avx2")]
|
||||
#[inline(always)]
|
||||
fn constant_layer(state: &mut [Self; 8], round_ctr: usize) {
|
||||
use std::convert::TryInto;
|
||||
use crate::hash::poseidon::ALL_ROUND_CONSTANTS;
|
||||
|
||||
// This assumes that every element of ALL_ROUND_CONSTANTS is in 0..CrandallField::ORDER.
|
||||
unsafe { crate::hash::poseidon_avx2::crandall_poseidon_const_avx2::<2>(state,
|
||||
ALL_ROUND_CONSTANTS[8 * round_ctr..8 * round_ctr + 8].try_into().unwrap()); }
|
||||
@ -160,6 +160,9 @@ impl Poseidon<8> for CrandallField {
|
||||
#[cfg(target_feature="neon")]
|
||||
#[inline(always)]
|
||||
fn constant_layer(state: &mut [Self; 8], round_ctr: usize) {
|
||||
use std::convert::TryInto;
|
||||
use crate::hash::poseidon::ALL_ROUND_CONSTANTS;
|
||||
|
||||
// This assumes that every element of ALL_ROUND_CONSTANTS is in 0..CrandallField::ORDER.
|
||||
unsafe { crate::hash::poseidon_neon::crandall_poseidon_const_neon::<4>(state,
|
||||
ALL_ROUND_CONSTANTS[8 * round_ctr..8 * round_ctr + 8].try_into().unwrap()); }
|
||||
@ -391,6 +394,9 @@ impl Poseidon<12> for CrandallField {
|
||||
#[cfg(target_feature="avx2")]
|
||||
#[inline(always)]
|
||||
fn constant_layer(state: &mut [Self; 12], round_ctr: usize) {
|
||||
use std::convert::TryInto;
|
||||
use crate::hash::poseidon::ALL_ROUND_CONSTANTS;
|
||||
|
||||
// This assumes that every element of ALL_ROUND_CONSTANTS is in 0..CrandallField::ORDER.
|
||||
unsafe { crate::hash::poseidon_avx2::crandall_poseidon_const_avx2::<3>(state,
|
||||
ALL_ROUND_CONSTANTS[12 * round_ctr..12 * round_ctr + 12].try_into().unwrap()); }
|
||||
@ -399,6 +405,9 @@ impl Poseidon<12> for CrandallField {
|
||||
#[cfg(target_feature="neon")]
|
||||
#[inline(always)]
|
||||
fn constant_layer(state: &mut [Self; 12], round_ctr: usize) {
|
||||
use std::convert::TryInto;
|
||||
use crate::hash::poseidon::ALL_ROUND_CONSTANTS;
|
||||
|
||||
// This assumes that every element of ALL_ROUND_CONSTANTS is in 0..CrandallField::ORDER.
|
||||
unsafe { crate::hash::poseidon_neon::crandall_poseidon_const_neon::<6>(state,
|
||||
ALL_ROUND_CONSTANTS[12 * round_ctr..12 * round_ctr + 12].try_into().unwrap()); }
|
||||
|
||||
@ -128,6 +128,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::field::crandall_field::CrandallField;
|
||||
use crate::field::goldilocks_field::GoldilocksField;
|
||||
use crate::fri::proof::{
|
||||
FriInitialTreeProofTarget, FriProofTarget, FriQueryRoundTarget, FriQueryStepTarget,
|
||||
};
|
||||
@ -358,7 +359,7 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_recursive_verifier() -> Result<()> {
|
||||
env_logger::init();
|
||||
type F = CrandallField;
|
||||
type F = GoldilocksField;
|
||||
const D: usize = 4;
|
||||
let config = CircuitConfig {
|
||||
num_wires: 143,
|
||||
@ -413,7 +414,7 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_recursive_recursive_verifier() -> Result<()> {
|
||||
env_logger::init();
|
||||
type F = CrandallField;
|
||||
type F = GoldilocksField;
|
||||
const D: usize = 4;
|
||||
let config = CircuitConfig {
|
||||
num_wires: 143,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user