wip: start moving starky to no-std

Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
This commit is contained in:
Brandon H. Gomes 2022-11-03 12:17:03 -07:00
parent 38e467f1c0
commit fc3f63398d
No known key found for this signature in database
GPG Key ID: 773D44E6A904B222
15 changed files with 23 additions and 37 deletions

View File

@ -3,6 +3,9 @@ name = "plonky2_ecdsa"
version = "0.1.0"
edition = "2021"
[features]
parallel = ["maybe_rayon/parallel", "plonky2/parallel"]
[dependencies]
anyhow = { version = "1.0.40", default-features = false }
itertools = { version = "0.10.0", default-features = false }

View File

@ -1,7 +1,7 @@
use alloc::vec::Vec;
use itertools::Itertools;
use maybe_rayon::{MaybeIntoParIter, MaybeParChunks};
use maybe_rayon::*;
use plonky2::field::types::{Field, PrimeField};
use crate::curve::curve_summation::affine_multisummation_best;

View File

@ -7,7 +7,6 @@
#![allow(clippy::return_self_not_must_use)]
#![feature(generic_const_exprs)]
#![feature(specialization)]
#![feature(stdsimd)]
#![cfg_attr(not(test), no_std)]
extern crate alloc;

View File

@ -1,5 +1,5 @@
use std::marker::PhantomData;
use std::ops::Range;
use core::marker::PhantomData;
use core::ops::Range;
use plonky2::field::extension::{Extendable, FieldExtension};
use plonky2::field::types::Field;

View File

@ -3,7 +3,6 @@ name = "maybe_rayon"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
parallel = ["rayon"]

View File

@ -1,13 +1,16 @@
#[cfg(not(feature = "parallel"))]
use std::{
use core::{
iter::{FlatMap, IntoIterator, Iterator},
slice::{Chunks, ChunksExact, ChunksExactMut, ChunksMut},
};
#[cfg(feature = "parallel")]
pub use rayon::prelude::{
IndexedParallelIterator, ParallelDrainFull, ParallelDrainRange, ParallelExtend,
ParallelIterator,
pub use rayon::{
self,
prelude::{
IndexedParallelIterator, ParallelDrainFull, ParallelDrainRange, ParallelExtend,
ParallelIterator,
},
};
#[cfg(feature = "parallel")]
use rayon::{

View File

@ -41,7 +41,6 @@ num_cpus = { version = "1.14.0", default-features = false }
plonky2 = { path = "." }
rand = { version = "0.8.4", default-features = false, features = ["getrandom"] }
rand_chacha = { version = "0.3.1", default-features = false }
rayon = { version = "1.5.1", default-features = false }
serde_cbor = { version = "0.11.2" }
structopt = { version = "0.3.26", default-features = false }
tynm = { version = "0.1.6", default-features = false }

View File

@ -1,6 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
mod allocator;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};

View File

@ -1,6 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
mod allocator;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
@ -14,10 +11,7 @@ use tynm::type_name;
const ELEMS_PER_LEAF: usize = 135;
pub(crate) fn bench_merkle_tree<F: RichField, H: Hasher<F>>(c: &mut Criterion)
where
[(); H::HASH_SIZE]:,
{
pub(crate) fn bench_merkle_tree<F: RichField, H: Hasher<F>>(c: &mut Criterion) {
let mut group = c.benchmark_group(&format!(
"merkle-tree<{}, {}>",
type_name::<F>(),

View File

@ -2,8 +2,6 @@
// custom CLI argument parsing (even with harness disabled). We could also have
// put it in `src/bin/`, but then we wouldn't have access to
// `[dev-dependencies]`.
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use core::num::ParseIntError;
use core::ops::RangeInclusive;
@ -11,6 +9,7 @@ use core::str::FromStr;
use anyhow::{anyhow, Context as _, Result};
use log::{info, Level, LevelFilter};
use maybe_rayon::rayon;
use plonky2::gates::noop::NoopGate;
use plonky2::hash::hash_types::RichField;
use plonky2::iop::witness::{PartialWitness, Witness};
@ -18,7 +17,7 @@ use plonky2::plonk::circuit_builder::CircuitBuilder;
use plonky2::plonk::circuit_data::{
CircuitConfig, CommonCircuitData, VerifierCircuitTarget, VerifierOnlyCircuitData,
};
use plonky2::plonk::config::{AlgebraicHasher, GenericConfig, Hasher, PoseidonGoldilocksConfig};
use plonky2::plonk::config::{AlgebraicHasher, GenericConfig, PoseidonGoldilocksConfig};
use plonky2::plonk::proof::{CompressedProofWithPublicInputs, ProofWithPublicInputs};
use plonky2::plonk::prover::prove;
use plonky2::util::timing::TimingTree;
@ -65,10 +64,7 @@ struct Options {
fn dummy_proof<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>(
config: &CircuitConfig,
log2_size: usize,
) -> Result<ProofTuple<F, C, D>>
where
[(); C::Hasher::HASH_SIZE]:,
{
) -> Result<ProofTuple<F, C, D>> {
// 'size' is in degree, but we want number of noop gates. A non-zero amount of padding will be added and size will be rounded to the next power of two. To hit our target size, we go just under the previous power of two and hope padding is less than half the proof.
let num_dummy_gates = match log2_size {
0 => return Err(anyhow!("size must be at least 1")),
@ -106,7 +102,6 @@ fn recursive_proof<
) -> Result<ProofTuple<F, C, D>>
where
InnerC::Hasher: AlgebraicHasher<F>,
[(); C::Hasher::HASH_SIZE]:,
{
let (inner_proof, inner_vd, inner_cd) = inner;
let mut builder = CircuitBuilder::<F, D>::new(config.clone());
@ -150,10 +145,7 @@ fn test_serialization<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>,
proof: &ProofWithPublicInputs<F, C, D>,
vd: &VerifierOnlyCircuitData<C, D>,
cd: &CommonCircuitData<F, D>,
) -> Result<()>
where
[(); C::Hasher::HASH_SIZE]:,
{
) -> Result<()> {
let proof_bytes = proof.to_bytes();
info!("Proof length: {} bytes", proof_bytes.len());
let proof_from_bytes = ProofWithPublicInputs::from_bytes(proof_bytes, cd)?;

View File

@ -1,4 +1,4 @@
use std::marker::PhantomData;
use core::marker::PhantomData;
use plonky2::field::extension::Extendable;
use plonky2::field::packed::PackedField;

View File

@ -1,4 +1,4 @@
use std::marker::PhantomData;
use core::marker::PhantomData;
use plonky2::field::extension::{Extendable, FieldExtension};
use plonky2::field::packed::PackedField;

View File

@ -1,4 +1,4 @@
use std::iter::once;
use core::iter::once;
use anyhow::{ensure, Result};
use itertools::Itertools;

View File

@ -1,4 +1,4 @@
use std::iter::once;
use core::iter::once;
use anyhow::{ensure, Result};
use itertools::Itertools;

View File

@ -1,4 +1,4 @@
use std::iter::once;
use core::iter::once;
use anyhow::{anyhow, ensure, Result};
use itertools::Itertools;