mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 13:53:07 +00:00
feat: move to alloc for Vec/String/Box
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
This commit is contained in:
parent
6fd0da216a
commit
7a81c5d46a
@ -5,15 +5,15 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["rand"]
|
||||
rand = ["dep:rand"]
|
||||
default = []
|
||||
rand = ["dep:rand", "num/rand"]
|
||||
|
||||
[dependencies]
|
||||
plonky2_util = { path = "../util" }
|
||||
anyhow = "1.0.40"
|
||||
itertools = "0.10.0"
|
||||
num = { version = "0.4", features = [ "rand" ] }
|
||||
rand = { optional = true, version = "0.8.4" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
unroll = "0.1.5"
|
||||
static_assertions = "1.1.0"
|
||||
anyhow = { version = "1.0.40", default-features = false }
|
||||
itertools = { version = "0.10.0", default-features = false }
|
||||
num = { version = "0.4", default-features = false, features = ["alloc"] }
|
||||
plonky2_util = { path = "../util", default-features = false }
|
||||
rand = { version = "0.8.5", optional = true, default-features = false, features = ["getrandom"] }
|
||||
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
|
||||
static_assertions = { version = "1.1.0", default-features = false }
|
||||
unroll = { version = "0.1.5", default-features = false }
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
use core::arch::x86_64::*;
|
||||
use std::fmt;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::mem::transmute;
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use core::fmt;
|
||||
use core::fmt::{Debug, Formatter};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::mem::transmute;
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use crate::goldilocks_field::GoldilocksField;
|
||||
use crate::ops::Square;
|
||||
use crate::packed::PackedField;
|
||||
use crate::types::{Field, Field64};
|
||||
|
||||
// Ideally `Avx2GoldilocksField` would wrap `__m256i`. Unfortunately, `__m256i` has an alignment of
|
||||
// 32B, which would preclude us from casting `[GoldilocksField; 4]` (alignment 8B) to
|
||||
// `Avx2GoldilocksField`. We need to ensure that `Avx2GoldilocksField` has the same alignment as
|
||||
// `GoldilocksField`. Thus we wrap `[GoldilocksField; 4]` and use the `new` and `get` methods to
|
||||
// convert to and from `__m256i`.
|
||||
/// AVX2 Goldilocks Field
|
||||
///
|
||||
/// Ideally `Avx2GoldilocksField` would wrap `__m256i`. Unfortunately, `__m256i` has an alignment of
|
||||
/// 32B, which would preclude us from casting `[GoldilocksField; 4]` (alignment 8B) to
|
||||
/// `Avx2GoldilocksField`. We need to ensure that `Avx2GoldilocksField` has the same alignment as
|
||||
/// `GoldilocksField`. Thus we wrap `[GoldilocksField; 4]` and use the `new` and `get` methods to
|
||||
/// convert to and from `__m256i`.
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(transparent)]
|
||||
pub struct Avx2GoldilocksField(pub [GoldilocksField; 4]);
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
use core::arch::x86_64::*;
|
||||
use std::fmt;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::mem::transmute;
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use core::fmt;
|
||||
use core::fmt::{Debug, Formatter};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::mem::transmute;
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use crate::goldilocks_field::GoldilocksField;
|
||||
use crate::ops::Square;
|
||||
use crate::packed::PackedField;
|
||||
use crate::types::{Field, Field64};
|
||||
|
||||
// Ideally `Avx512GoldilocksField` would wrap `__m512i`. Unfortunately, `__m512i` has an alignment
|
||||
// of 64B, which would preclude us from casting `[GoldilocksField; 8]` (alignment 8B) to
|
||||
// `Avx512GoldilocksField`. We need to ensure that `Avx512GoldilocksField` has the same alignment as
|
||||
// `GoldilocksField`. Thus we wrap `[GoldilocksField; 8]` and use the `new` and `get` methods to
|
||||
// convert to and from `__m512i`.
|
||||
/// AVX512 Goldilocks Field
|
||||
///
|
||||
/// Ideally `Avx512GoldilocksField` would wrap `__m512i`. Unfortunately, `__m512i` has an alignment
|
||||
/// of 64B, which would preclude us from casting `[GoldilocksField; 8]` (alignment 8B) to
|
||||
/// `Avx512GoldilocksField`. We need to ensure that `Avx512GoldilocksField` has the same alignment as
|
||||
/// `GoldilocksField`. Thus we wrap `[GoldilocksField; 8]` and use the `new` and `get` methods to
|
||||
/// convert to and from `__m512i`.
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(transparent)]
|
||||
pub struct Avx512GoldilocksField(pub [GoldilocksField; 8]);
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use num::bigint::BigUint;
|
||||
|
||||
use crate::types::Field;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::{self, Debug, Display, Formatter};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use crate::extension::OEF;
|
||||
|
||||
@ -42,7 +43,7 @@ impl<F: OEF<D>, const D: usize> From<F> for ExtensionAlgebra<F, D> {
|
||||
}
|
||||
|
||||
impl<F: OEF<D>, const D: usize> Display for ExtensionAlgebra<F, D> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "({})", self.0[0])?;
|
||||
for i in 1..D {
|
||||
write!(f, " + ({})*b^{i}", self.0[i])?;
|
||||
@ -52,7 +53,7 @@ impl<F: OEF<D>, const D: usize> Display for ExtensionAlgebra<F, D> {
|
||||
}
|
||||
|
||||
impl<F: OEF<D>, const D: usize> Debug for ExtensionAlgebra<F, D> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::convert::TryInto;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::types::Field;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use core::fmt::{self, Debug, Display, Formatter};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use num::bigint::BigUint;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -101,19 +101,19 @@ impl<F: Extendable<2>> Field for QuadraticExtension<F> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand_from_rng<R: rand::Rng>(rng: &mut R) -> Self {
|
||||
fn rand_from_rng<R: rand::RngCore>(rng: &mut R) -> Self {
|
||||
Self([F::rand_from_rng(rng), F::rand_from_rng(rng)])
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Extendable<2>> Display for QuadraticExtension<F> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{} + {}*a", self.0[0], self.0[1])
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: Extendable<2>> Debug for QuadraticExtension<F> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use core::fmt::{self, Debug, Display, Formatter};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use num::bigint::BigUint;
|
||||
use num::traits::Pow;
|
||||
@ -106,7 +106,7 @@ impl<F: Extendable<4>> Field for QuarticExtension<F> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand_from_rng<R: rand::Rng>(rng: &mut R) -> Self {
|
||||
fn rand_from_rng<R: rand::RngCore>(rng: &mut R) -> Self {
|
||||
Self::from_basefield_array([
|
||||
F::rand_from_rng(rng),
|
||||
F::rand_from_rng(rng),
|
||||
@ -117,7 +117,7 @@ impl<F: Extendable<4>> Field for QuarticExtension<F> {
|
||||
}
|
||||
|
||||
impl<F: Extendable<4>> Display for QuarticExtension<F> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{} + {}*a + {}*a^2 + {}*a^3",
|
||||
@ -127,7 +127,7 @@ impl<F: Extendable<4>> Display for QuarticExtension<F> {
|
||||
}
|
||||
|
||||
impl<F: Extendable<4>> Debug for QuarticExtension<F> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use core::fmt::{self, Debug, Display, Formatter};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use num::bigint::BigUint;
|
||||
use num::traits::Pow;
|
||||
@ -112,7 +112,7 @@ impl<F: Extendable<5>> Field for QuinticExtension<F> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand_from_rng<R: rand::Rng>(rng: &mut R) -> Self {
|
||||
fn rand_from_rng<R: rand::RngCore>(rng: &mut R) -> Self {
|
||||
Self::from_basefield_array([
|
||||
F::rand_from_rng(rng),
|
||||
F::rand_from_rng(rng),
|
||||
@ -124,7 +124,7 @@ impl<F: Extendable<5>> Field for QuinticExtension<F> {
|
||||
}
|
||||
|
||||
impl<F: Extendable<5>> Display for QuinticExtension<F> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{} + {}*a + {}*a^2 + {}*a^3 + {}*a^4",
|
||||
@ -134,7 +134,7 @@ impl<F: Extendable<5>> Display for QuinticExtension<F> {
|
||||
}
|
||||
|
||||
impl<F: Extendable<5>> Debug for QuinticExtension<F> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use std::cmp::{max, min};
|
||||
use std::option::Option;
|
||||
use alloc::vec::Vec;
|
||||
use core::cmp::{max, min};
|
||||
|
||||
use plonky2_util::{log2_strict, reverse_index_bits_in_place};
|
||||
use unroll::unroll_for_loops;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::ops::Mul;
|
||||
use core::ops::Mul;
|
||||
|
||||
use static_assertions::const_assert;
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
use std::fmt;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use core::fmt::{self, Debug, Display, Formatter};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use num::{BigUint, Integer};
|
||||
use plonky2_util::{assume, branch_hint};
|
||||
@ -105,7 +104,8 @@ impl Field for GoldilocksField {
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand_from_rng<R: rand::Rng>(rng: &mut R) -> Self {
|
||||
fn rand_from_rng<R: rand::RngCore>(rng: &mut R) -> Self {
|
||||
use rand::Rng;
|
||||
Self::from_canonical_u64(rng.gen_range(0..Self::ORDER))
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ impl DivAssign for GoldilocksField {
|
||||
#[inline(always)]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
unsafe fn add_no_canonicalize_trashing_input(x: u64, y: u64) -> u64 {
|
||||
use std::arch::asm;
|
||||
use core::arch::asm;
|
||||
let res_wrapped: u64;
|
||||
let adjustment: u64;
|
||||
asm!(
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_util::log2_ceil;
|
||||
|
||||
use crate::fft::ifft;
|
||||
|
||||
@ -6,8 +6,8 @@ use crate::types::PrimeField64;
|
||||
#[inline(always)]
|
||||
fn safe_iteration(f: &mut u64, g: &mut u64, c: &mut i128, d: &mut i128, k: &mut u32) {
|
||||
if f < g {
|
||||
std::mem::swap(f, g);
|
||||
std::mem::swap(c, d);
|
||||
core::mem::swap(f, g);
|
||||
core::mem::swap(c, d);
|
||||
}
|
||||
if *f & 3 == *g & 3 {
|
||||
// f - g = 0 (mod 4)
|
||||
@ -36,8 +36,8 @@ fn safe_iteration(f: &mut u64, g: &mut u64, c: &mut i128, d: &mut i128, k: &mut
|
||||
#[inline(always)]
|
||||
unsafe fn unsafe_iteration(f: &mut u64, g: &mut u64, c: &mut i128, d: &mut i128, k: &mut u32) {
|
||||
if *f < *g {
|
||||
std::mem::swap(f, g);
|
||||
std::mem::swap(c, d);
|
||||
core::mem::swap(f, g);
|
||||
core::mem::swap(c, d);
|
||||
}
|
||||
if *f & 3 == *g & 3 {
|
||||
// f - g = 0 (mod 4)
|
||||
|
||||
@ -8,8 +8,14 @@
|
||||
#![feature(generic_const_exprs)]
|
||||
#![feature(specialization)]
|
||||
#![feature(stdsimd)]
|
||||
#![no_std]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
mod inversion;
|
||||
|
||||
pub(crate) mod arch;
|
||||
|
||||
pub mod batch_util;
|
||||
pub mod cosets;
|
||||
pub mod extension;
|
||||
@ -17,7 +23,6 @@ pub mod fft;
|
||||
pub mod goldilocks_extensions;
|
||||
pub mod goldilocks_field;
|
||||
pub mod interpolation;
|
||||
mod inversion;
|
||||
pub mod ops;
|
||||
pub mod packable;
|
||||
pub mod packed;
|
||||
@ -29,5 +34,6 @@ pub mod zero_poly_coset;
|
||||
|
||||
#[cfg(test)]
|
||||
mod field_testing;
|
||||
|
||||
#[cfg(test)]
|
||||
mod prime_field_testing;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::ops::Mul;
|
||||
use core::ops::Mul;
|
||||
|
||||
pub trait Square {
|
||||
fn square(&self) -> Self;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use std::fmt::Debug;
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use std::slice;
|
||||
use core::fmt::Debug;
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use core::slice;
|
||||
|
||||
use crate::ops::Square;
|
||||
use crate::types::Field;
|
||||
@ -82,7 +82,7 @@ where
|
||||
);
|
||||
let buf_ptr = buf.as_ptr().cast::<Self>();
|
||||
let n = buf.len() / Self::WIDTH;
|
||||
unsafe { std::slice::from_raw_parts(buf_ptr, n) }
|
||||
unsafe { slice::from_raw_parts(buf_ptr, n) }
|
||||
}
|
||||
fn pack_slice_mut(buf: &mut [Self::Scalar]) -> &mut [Self] {
|
||||
assert!(
|
||||
@ -93,7 +93,7 @@ where
|
||||
);
|
||||
let buf_ptr = buf.as_mut_ptr().cast::<Self>();
|
||||
let n = buf.len() / Self::WIDTH;
|
||||
unsafe { std::slice::from_raw_parts_mut(buf_ptr, n) }
|
||||
unsafe { slice::from_raw_parts_mut(buf_ptr, n) }
|
||||
}
|
||||
|
||||
fn doubles(&self) -> Self {
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_util::log2_ceil;
|
||||
|
||||
use crate::polynomial::PolynomialCoeffs;
|
||||
@ -68,7 +71,7 @@ impl<F: Field> PolynomialCoeffs<F> {
|
||||
}
|
||||
|
||||
/// Let `self=p(X)`, this returns `(p(X)-p(z))/(X-z)`.
|
||||
/// See https://en.wikipedia.org/wiki/Horner%27s_method
|
||||
/// See <https://en.wikipedia.org/wiki/Horner%27s_method>
|
||||
pub fn divide_by_linear(&self, z: F) -> PolynomialCoeffs<F> {
|
||||
let mut bs = self
|
||||
.coeffs
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
pub(crate) mod division;
|
||||
|
||||
use std::cmp::max;
|
||||
use std::iter::Sum;
|
||||
use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::cmp::max;
|
||||
use core::iter::Sum;
|
||||
use core::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use itertools::Itertools;
|
||||
|
||||
@ -68,7 +68,7 @@ where
|
||||
macro_rules! test_prime_field_arithmetic {
|
||||
($field:ty) => {
|
||||
mod prime_field_arithmetic {
|
||||
use std::ops::{Add, Mul, Neg, Sub};
|
||||
use core::ops::{Add, Mul, Neg, Sub};
|
||||
|
||||
use $crate::ops::Square;
|
||||
use $crate::types::{Field, Field64};
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
use std::fmt;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::{self, Debug, Display, Formatter};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use itertools::Itertools;
|
||||
use num::bigint::BigUint;
|
||||
@ -133,7 +133,7 @@ impl Field for Secp256K1Base {
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand_from_rng<R: rand::Rng>(rng: &mut R) -> Self {
|
||||
fn rand_from_rng<R: rand::RngCore>(rng: &mut R) -> Self {
|
||||
use num::bigint::RandBigInt;
|
||||
Self::from_noncanonical_biguint(rng.gen_biguint_below(&Self::order()))
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
use std::convert::TryInto;
|
||||
use std::fmt;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::{self, Debug, Display, Formatter};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use itertools::Itertools;
|
||||
use num::bigint::BigUint;
|
||||
@ -142,7 +141,7 @@ impl Field for Secp256K1Scalar {
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand_from_rng<R: rand::Rng>(rng: &mut R) -> Self {
|
||||
fn rand_from_rng<R: rand::RngCore>(rng: &mut R) -> Self {
|
||||
use num::bigint::RandBigInt;
|
||||
Self::from_noncanonical_biguint(rng.gen_biguint_below(&Self::order()))
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
use std::fmt::{Debug, Display};
|
||||
use std::hash::Hash;
|
||||
use std::iter::{Product, Sum};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::{Debug, Display};
|
||||
use core::hash::Hash;
|
||||
use core::iter::{Product, Sum};
|
||||
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
use num::bigint::BigUint;
|
||||
use num::{Integer, One, ToPrimitive, Zero};
|
||||
@ -318,7 +320,7 @@ pub trait Field:
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand_from_rng<R: rand::Rng>(rng: &mut R) -> Self;
|
||||
fn rand_from_rng<R: rand::RngCore>(rng: &mut R) -> Self;
|
||||
|
||||
fn exp_power_of_2(&self, power_log: usize) -> Self {
|
||||
let mut res = *self;
|
||||
@ -399,7 +401,7 @@ pub trait Field:
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
fn rand() -> Self {
|
||||
Self::rand_from_rng(&mut rand::thread_rng())
|
||||
Self::rand_from_rng(&mut rand::rngs::OsRng)
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::packed::PackedField;
|
||||
use crate::types::Field;
|
||||
|
||||
|
||||
@ -11,29 +11,40 @@ edition = "2021"
|
||||
default-run = "generate_constants"
|
||||
|
||||
[features]
|
||||
default = ["parallel", "rand", "rand_chacha", "timing", "gate_testing"]
|
||||
parallel = ["maybe_rayon/parallel"]
|
||||
rand = ["dep:rand", "plonky2_field/rand"]
|
||||
default = [
|
||||
"gate_testing",
|
||||
"parallel",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"std",
|
||||
"timing",
|
||||
]
|
||||
rand = [
|
||||
"dep:rand",
|
||||
"num/rand",
|
||||
"plonky2_field/rand"
|
||||
]
|
||||
gate_testing = ["rand"]
|
||||
rand_chacha = ["dep:rand_chacha"]
|
||||
parallel = ["maybe_rayon/parallel"]
|
||||
std = ["anyhow/std"]
|
||||
timing = []
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.40"
|
||||
anyhow = { version = "1.0.40", default-features = false }
|
||||
derivative = { version = "2.2.0", default-features = false, features = ["use_core"] }
|
||||
itertools = "0.10.0"
|
||||
keccak-hash = "0.8.0"
|
||||
log = "0.4.14"
|
||||
maybe_rayon = { path = "../maybe_rayon" }
|
||||
num = { version = "0.4", features = [ "rand" ] }
|
||||
plonky2_field = { path = "../field" }
|
||||
plonky2_util = { path = "../util" }
|
||||
rand = { version = "0.8.4", optional = true }
|
||||
rand_chacha = { version = "0.3.1", optional = true }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_cbor = "0.11.1"
|
||||
static_assertions = "1.1.0"
|
||||
unroll = "0.1.5"
|
||||
itertools = { version = "0.10.0", default-features = false }
|
||||
keccak-hash = { version = "0.8.0", default-features = false }
|
||||
log = { version = "0.4.14", default-features = false }
|
||||
maybe_rayon = { path = "../maybe_rayon", default-features = false }
|
||||
num = { version = "0.4", default-features = false }
|
||||
plonky2_field = { path = "../field", default-features = false }
|
||||
plonky2_util = { path = "../util", default-features = false }
|
||||
rand = { version = "0.8.4", optional = true, default-features = false }
|
||||
rand_chacha = { version = "0.3.1", optional = true, default-features = false }
|
||||
serde = { version = "1.0", default-features = false, features = ["derive"] }
|
||||
serde_cbor = { version = "0.11.1", default-features = false }
|
||||
static_assertions = { version = "1.1.0", default-features = false }
|
||||
unroll = { version = "0.1.5", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3.5"
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::polynomial::PolynomialCoeffs;
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::fri::reduction_strategies::FriReductionStrategy;
|
||||
|
||||
mod challenges;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::format;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use itertools::Itertools;
|
||||
use maybe_rayon::*;
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use itertools::izip;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use itertools::Itertools;
|
||||
use maybe_rayon::*;
|
||||
use plonky2_field::extension::{flatten, unflatten, Extendable};
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
|
||||
use itertools::Itertools;
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_util::{log2_strict, reverse_index_bits_in_place};
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
#[cfg(feature = "timing")]
|
||||
use std::time::Instant;
|
||||
|
||||
use log::debug;
|
||||
@ -63,11 +66,13 @@ fn min_size_arity_bits(
|
||||
// in an optimal sequence, we would need a really massive polynomial.
|
||||
let max_arity_bits = opt_max_arity_bits.unwrap_or(4);
|
||||
|
||||
#[cfg(feature = "timing")]
|
||||
let start = Instant::now();
|
||||
let (mut arity_bits, fri_proof_size) =
|
||||
min_size_arity_bits_helper(degree_bits, rate_bits, num_queries, max_arity_bits, vec![]);
|
||||
arity_bits.shrink_to_fit();
|
||||
|
||||
#[cfg(feature = "timing")]
|
||||
debug!(
|
||||
"min_size_arity_bits took {:.3}s",
|
||||
start.elapsed().as_secs_f32()
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
//! Information about the structure of a FRI instance, in terms of the oracles and polynomials
|
||||
//! involved, and the points they are opened at.
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use crate::field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use plonky2_field::extension::{flatten, Extendable, FieldExtension};
|
||||
use plonky2_field::interpolation::{barycentric_weights, interpolate};
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::borrow::Borrow;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::borrow::Borrow;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension, OEF};
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
use crate::hash::hash_types::RichField;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_util::log2_strict;
|
||||
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
use crate::hash::hash_types::RichField;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::borrow::Borrow;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_util::ceil_div_usize;
|
||||
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::format;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::packed::PackedField;
|
||||
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::format;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::packed::PackedField;
|
||||
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::{Debug, Error, Formatter};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::ops::Range;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use plonky2_field::batch_util::batch_multiply_inplace;
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::marker::PhantomData;
|
||||
use core::ops::Range;
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::marker::PhantomData;
|
||||
use core::ops::Range;
|
||||
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::format;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
use crate::gates::gate::Gate;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::packable::Packable;
|
||||
use plonky2_field::packed::PackedField;
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::marker::PhantomData;
|
||||
use core::ops::Range;
|
||||
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#![allow(clippy::assertions_on_constants)]
|
||||
|
||||
use std::arch::aarch64::*;
|
||||
use std::arch::asm;
|
||||
use std::mem::transmute;
|
||||
use core::arch::aarch64::*;
|
||||
use core::arch::asm;
|
||||
use core::mem::transmute;
|
||||
|
||||
use plonky2_field::goldilocks_field::GoldilocksField;
|
||||
use plonky2_util::branch_hint;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::goldilocks_field::GoldilocksField;
|
||||
use plonky2_field::types::{Field, PrimeField64};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
//! Concrete instantiation of a hash function.
|
||||
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
use crate::hash::hash_types::{HashOut, HashOutTarget, RichField};
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::iter;
|
||||
use core::mem::size_of;
|
||||
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use plonky2_field::extension::Extendable;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use core::mem::MaybeUninit;
|
||||
use core::slice;
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use num::Integer;
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
//! Implementation of the Poseidon hash function, as described in
|
||||
//! <https://eprint.iacr.org/2019/458.pdf>
|
||||
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
use plonky2_field::types::{Field, PrimeField64};
|
||||
use unroll::unroll_for_loops;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use core::convert::TryInto;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use plonky2_field::extension::algebra::ExtensionAlgebra;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Debug;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
//! Logic common to multiple IOPs.
|
||||
|
||||
pub mod challenger;
|
||||
pub mod ext_target;
|
||||
pub mod generator;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use crate::iop::ext_target::ExtensionTarget;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use crate::plonk::circuit_data::CircuitConfig;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
#![allow(clippy::needless_range_loop)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub use plonky2_field as field;
|
||||
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::cmp::max;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::time::Instant;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
use alloc::boxed::Box;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::{Range, RangeFrom};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use anyhow::Result;
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Debug;
|
||||
|
||||
use plonky2_field::extension::quadratic::QuadraticExtension;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::string::String;
|
||||
|
||||
use crate::iop::target::Target;
|
||||
|
||||
/// A named copy constraint.
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use maybe_rayon::*;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::extension::Extendable;
|
||||
use plonky2_field::packed::PackedField;
|
||||
use plonky2_field::types::Field;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use anyhow::ensure;
|
||||
use maybe_rayon::*;
|
||||
use plonky2_field::extension::Extendable;
|
||||
@ -223,12 +226,14 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
C::InnerHasher::hash_no_pad(&self.public_inputs)
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub fn to_bytes(&self) -> anyhow::Result<Vec<u8>> {
|
||||
let mut buffer = Buffer::new(Vec::new());
|
||||
buffer.write_compressed_proof_with_public_inputs(self)?;
|
||||
Ok(buffer.bytes())
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub fn from_bytes(
|
||||
bytes: Vec<u8>,
|
||||
common_data: &CommonCircuitData<F, D>,
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
use core::mem::swap;
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, vec};
|
||||
|
||||
use plonky2_field::batch_util::batch_add_inplace;
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
use plonky2_field::types::Field;
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use itertools::Itertools;
|
||||
use plonky2_field::extension::Extendable;
|
||||
@ -186,7 +189,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
h1: HashOutTarget,
|
||||
) -> HashOutTarget {
|
||||
HashOutTarget {
|
||||
elements: std::array::from_fn(|i| self.select(b, h0.elements[i], h1.elements[i])),
|
||||
elements: core::array::from_fn(|i| self.select(b, h0.elements[i], h1.elements[i])),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#![allow(clippy::int_plus_one)] // Makes more sense for some inequalities below.
|
||||
|
||||
use alloc::vec;
|
||||
|
||||
use anyhow::{ensure, Result};
|
||||
use itertools::Itertools;
|
||||
use plonky2_field::extension::Extendable;
|
||||
@ -47,7 +50,7 @@ impl<C: GenericConfig<D>, const D: usize> VerifierOnlyCircuitData<C, D> {
|
||||
let constants_sigmas_cap = MerkleCap(
|
||||
(0..cap_len)
|
||||
.map(|i| HashOut {
|
||||
elements: std::array::from_fn(|j| slice[len - 4 * (cap_len - i) + j]),
|
||||
elements: core::array::from_fn(|j| slice[len - 4 * (cap_len - i) + j]),
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
@ -72,12 +75,12 @@ impl VerifierCircuitTarget {
|
||||
let constants_sigmas_cap = MerkleCapTarget(
|
||||
(0..cap_len)
|
||||
.map(|i| HashOutTarget {
|
||||
elements: std::array::from_fn(|j| slice[len - 4 * (cap_len - i) + j]),
|
||||
elements: core::array::from_fn(|j| slice[len - 4 * (cap_len - i) + j]),
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
let circuit_digest = HashOutTarget {
|
||||
elements: std::array::from_fn(|i| slice[len - 4 - 4 * cap_len + i]),
|
||||
elements: core::array::from_fn(|i| slice[len - 4 - 4 * cap_len + i]),
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
@ -420,7 +423,7 @@ mod tests {
|
||||
let mut h: [F; 4] = initial_hash.try_into().unwrap();
|
||||
assert_eq!(
|
||||
hash,
|
||||
std::iter::repeat_with(|| {
|
||||
core::iter::repeat_with(|| {
|
||||
h = hash_n_to_hash_no_pad::<F, PoseidonPermutation>(&h).elements;
|
||||
h
|
||||
})
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use log::{log, Level};
|
||||
|
||||
/// The hierarchy of contexts, and the gate count contributed by each one. Useful for debugging.
|
||||
|
||||
@ -1,13 +1,18 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use plonky2_field::polynomial::PolynomialValues;
|
||||
use plonky2_field::types::Field;
|
||||
|
||||
pub(crate) mod context_tree;
|
||||
pub(crate) mod partial_products;
|
||||
pub mod reducing;
|
||||
pub mod serialization;
|
||||
pub mod strided_view;
|
||||
pub mod timing;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub mod serialization;
|
||||
|
||||
pub(crate) fn transpose_poly_values<F: Field>(polys: Vec<PolynomialValues<F>>) -> Vec<Vec<F>> {
|
||||
let poly_values = polys.into_iter().map(|p| p.values).collect::<Vec<_>>();
|
||||
transpose(&poly_values)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use core::iter;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use core::borrow::Borrow;
|
||||
|
||||
use plonky2_field::extension::{Extendable, FieldExtension};
|
||||
|
||||
@ -4,16 +4,20 @@
|
||||
#![allow(clippy::len_without_is_empty)]
|
||||
#![allow(clippy::needless_range_loop)]
|
||||
#![allow(clippy::return_self_not_must_use)]
|
||||
#![no_std]
|
||||
|
||||
use std::arch::asm;
|
||||
use std::hint::unreachable_unchecked;
|
||||
use std::mem::size_of;
|
||||
use std::ptr::{swap, swap_nonoverlapping};
|
||||
extern crate alloc;
|
||||
|
||||
mod transpose_util;
|
||||
use alloc::vec::Vec;
|
||||
use core::arch::asm;
|
||||
use core::hint::unreachable_unchecked;
|
||||
use core::mem::size_of;
|
||||
use core::ptr::{swap, swap_nonoverlapping};
|
||||
|
||||
use crate::transpose_util::transpose_in_place_square;
|
||||
|
||||
mod transpose_util;
|
||||
|
||||
pub fn bits_u64(n: u64) -> usize {
|
||||
(64 - n.leading_zeros()) as usize
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::ptr::swap;
|
||||
use core::ptr::swap;
|
||||
|
||||
const LB_BLOCK_SIZE: usize = 3;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user