Cleanup alloc / std imports for plonky2 (#1518)

* Cleanup alloc/std versions for plonky2

* Fix import for macro
This commit is contained in:
Robin Salen 2024-02-10 15:48:52 -05:00 committed by GitHub
parent 6b39fc9006
commit b600142cd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
71 changed files with 235 additions and 152 deletions

View File

@ -3,11 +3,16 @@
// put it in `src/bin/`, but then we wouldn't have access to // put it in `src/bin/`, but then we wouldn't have access to
// `[dev-dependencies]`. // `[dev-dependencies]`.
#[cfg(not(feature = "std"))]
extern crate alloc; extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::sync::Arc; use alloc::sync::Arc;
use core::num::ParseIntError; use core::num::ParseIntError;
use core::ops::RangeInclusive; use core::ops::RangeInclusive;
use core::str::FromStr; use core::str::FromStr;
#[cfg(feature = "std")]
use std::sync::Arc;
use anyhow::{anyhow, Context as _, Result}; use anyhow::{anyhow, Context as _, Result};
use itertools::Itertools; use itertools::Itertools;

View File

@ -3,6 +3,7 @@
//! It provides both a native implementation and an in-circuit version //! It provides both a native implementation and an in-circuit version
//! of the FRI verifier for recursive proof composition. //! of the FRI verifier for recursive proof composition.
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use serde::Serialize; use serde::Serialize;

View File

@ -1,5 +1,5 @@
use alloc::format; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{format, vec::Vec};
use itertools::Itertools; use itertools::Itertools;
use plonky2_field::types::Field; use plonky2_field::types::Field;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use hashbrown::HashMap; use hashbrown::HashMap;
use itertools::izip; use itertools::izip;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use plonky2_maybe_rayon::*; use plonky2_maybe_rayon::*;

View File

@ -1,5 +1,5 @@
use alloc::format; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{format, vec::Vec};
use itertools::Itertools; use itertools::Itertools;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use log::debug; use log::debug;
use serde::Serialize; use serde::Serialize;

View File

@ -1,6 +1,7 @@
//! Information about the structure of a FRI instance, in terms of the oracles and polynomials //! Information about the structure of a FRI instance, in terms of the oracles and polynomials
//! involved, and the points they are opened at. //! involved, and the points they are opened at.
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::ops::Range; use core::ops::Range;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use anyhow::{ensure, Result}; use anyhow::{ensure, Result};

View File

@ -1,6 +1,9 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{
use alloc::vec::Vec; string::{String, ToString},
vec,
vec::Vec,
};
use core::borrow::Borrow; use core::borrow::Borrow;
use crate::field::extension::Extendable; use crate::field::extension::Extendable;

View File

@ -1,6 +1,9 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{
use alloc::vec::Vec; string::{String, ToString},
vec,
vec::Vec,
};
use core::borrow::Borrow; use core::borrow::Borrow;
use crate::field::extension::{Extendable, FieldExtension, OEF}; use crate::field::extension::{Extendable, FieldExtension, OEF};

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec; use alloc::vec;
use plonky2_field::extension::Extendable; use plonky2_field::extension::Extendable;

View File

@ -1,5 +1,5 @@
use alloc::borrow::ToOwned; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{borrow::ToOwned, vec};
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
use crate::gates::lookup::LookupGate; use crate::gates::lookup::LookupGate;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use crate::field::extension::Extendable; use crate::field::extension::Extendable;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use crate::field::extension::Extendable; use crate::field::extension::Extendable;

View File

@ -1,6 +1,9 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{
use alloc::vec::Vec; string::{String, ToString},
vec,
vec::Vec,
};
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
use crate::hash::hash_types::RichField; use crate::hash::hash_types::RichField;

View File

@ -1,6 +1,5 @@
use alloc::string::String; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{format, string::String, vec, vec::Vec};
use alloc::{format, vec};
use core::borrow::Borrow; use core::borrow::Borrow;
use itertools::Itertools; use itertools::Itertools;

View File

@ -1,6 +1,9 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{
use alloc::vec::Vec; string::{String, ToString},
vec,
vec::Vec,
};
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
use crate::gates::base_sum::BaseSumGate; use crate::gates::base_sum::BaseSumGate;

View File

@ -1,6 +1,9 @@
use alloc::format; #[cfg(not(feature = "std"))]
use alloc::string::{String, ToString}; use alloc::{
use alloc::vec::Vec; format,
string::{String, ToString},
vec::Vec,
};
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
use crate::field::packed::PackedField; use crate::field::packed::PackedField;

View File

@ -1,6 +1,9 @@
use alloc::format; #[cfg(not(feature = "std"))]
use alloc::string::{String, ToString}; use alloc::{
use alloc::vec::Vec; format,
string::{String, ToString},
vec::Vec,
};
use core::ops::Range; use core::ops::Range;
use crate::field::extension::{Extendable, FieldExtension}; use crate::field::extension::{Extendable, FieldExtension};

View File

@ -1,6 +1,5 @@
use alloc::string::String; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{format, string::String, vec, vec::Vec};
use alloc::{format, vec};
use core::ops::Range; use core::ops::Range;
use crate::field::extension::Extendable; use crate::field::extension::Extendable;

View File

@ -1,6 +1,5 @@
use alloc::string::String; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{format, string::String, vec, vec::Vec};
use alloc::{format, vec};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::marker::PhantomData; use core::marker::PhantomData;
use core::ops::Range; use core::ops::Range;

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::marker::PhantomData; use core::marker::PhantomData;
use crate::field::extension::Extendable; use crate::field::extension::Extendable;

View File

@ -1,11 +1,11 @@
use alloc::string::String; #[cfg(not(feature = "std"))]
use alloc::sync::Arc; use alloc::{string::String, sync::Arc, vec, vec::Vec};
use alloc::vec;
use alloc::vec::Vec;
use core::any::Any; use core::any::Any;
use core::fmt::{Debug, Error, Formatter}; use core::fmt::{Debug, Error, Formatter};
use core::hash::{Hash, Hasher}; use core::hash::{Hash, Hasher};
use core::ops::Range; use core::ops::Range;
#[cfg(feature = "std")]
use std::sync::Arc;
use hashbrown::HashMap; use hashbrown::HashMap;
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use anyhow::{ensure, Result}; use anyhow::{ensure, Result};

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::usize; use core::usize;
use itertools::Itertools; use itertools::Itertools;

View File

@ -1,8 +1,14 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::sync::Arc; use alloc::{
use alloc::vec::Vec; format,
use alloc::{format, vec}; string::{String, ToString},
sync::Arc,
vec,
vec::Vec,
};
use core::usize; use core::usize;
#[cfg(feature = "std")]
use std::sync::Arc;
use itertools::Itertools; use itertools::Itertools;
use keccak_hash::keccak; use keccak_hash::keccak;

View File

@ -1,6 +1,9 @@
use alloc::format; #[cfg(not(feature = "std"))]
use alloc::string::{String, ToString}; use alloc::{
use alloc::vec::Vec; format,
string::{String, ToString},
vec::Vec,
};
use core::ops::Range; use core::ops::Range;
use crate::field::extension::{Extendable, FieldExtension}; use crate::field::extension::{Extendable, FieldExtension};

View File

@ -1,5 +1,5 @@
use alloc::string::String; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{string::String, vec::Vec};
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
use crate::gates::gate::Gate; use crate::gates::gate::Gate;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
use crate::field::packable::Packable; use crate::field::packable::Packable;

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::marker::PhantomData; use core::marker::PhantomData;
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
@ -532,20 +536,13 @@ impl<F: RichField + Extendable<D> + Poseidon, const D: usize> SimpleGenerator<F,
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[cfg(not(feature = "std"))]
use alloc::{vec, vec::Vec};
use anyhow::Result; use anyhow::Result;
use plonky2_field::goldilocks_field::GoldilocksField;
use crate::field::goldilocks_field::GoldilocksField; use super::*;
use crate::field::types::Field;
use crate::gates::gate_testing::{test_eval_fns, test_low_degree}; use crate::gates::gate_testing::{test_eval_fns, test_low_degree};
use crate::gates::poseidon::PoseidonGate;
use crate::hash::poseidon::{Poseidon, SPONGE_WIDTH};
use crate::iop::generator::generate_partial_witness; use crate::iop::generator::generate_partial_witness;
use crate::iop::wire::Wire; use crate::iop::witness::PartialWitness;
use crate::iop::witness::{PartialWitness, Witness, WitnessWrite};
use crate::plonk::circuit_builder::CircuitBuilder;
use crate::plonk::circuit_data::CircuitConfig; use crate::plonk::circuit_data::CircuitConfig;
use crate::plonk::config::{GenericConfig, PoseidonGoldilocksConfig}; use crate::plonk::config::{GenericConfig, PoseidonGoldilocksConfig};

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::marker::PhantomData; use core::marker::PhantomData;
use core::ops::Range; use core::ops::Range;

View File

@ -1,5 +1,5 @@
use alloc::string::String; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{string::String, vec::Vec};
use core::ops::Range; use core::ops::Range;
use crate::field::extension::Extendable; use crate::field::extension::Extendable;

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::marker::PhantomData; use core::marker::PhantomData;
use itertools::Itertools; use itertools::Itertools;

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::ops::Range; use core::ops::Range;
use crate::field::extension::{Extendable, FieldExtension}; use crate::field::extension::{Extendable, FieldExtension};

View File

@ -1,6 +1,10 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{
use alloc::{format, vec}; format,
string::{String, ToString},
vec,
vec::Vec,
};
use core::ops::Range; use core::ops::Range;
use crate::field::extension::{Extendable, FieldExtension}; use crate::field::extension::{Extendable, FieldExtension};

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use core::ops::Range; use core::ops::Range;
use serde::Serialize; use serde::Serialize;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use anyhow::ensure; use anyhow::ensure;

View File

@ -1,5 +1,5 @@
//! Concrete instantiation of a hash function. //! Concrete instantiation of a hash function.
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::fmt::Debug; use core::fmt::Debug;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use core::mem::size_of; use core::mem::size_of;
use itertools::Itertools; use itertools::Itertools;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use anyhow::{ensure, Result}; use anyhow::{ensure, Result};
use itertools::Itertools; use itertools::Itertools;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::mem::MaybeUninit; use core::mem::MaybeUninit;
use core::slice; use core::slice;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use hashbrown::HashMap; use hashbrown::HashMap;
use num::Integer; use num::Integer;

View File

@ -1,8 +1,8 @@
//! Implementation of the Poseidon hash function, as described in //! Implementation of the Poseidon hash function, as described in
//! <https://eprint.iacr.org/2019/458.pdf> //! <https://eprint.iacr.org/2019/458.pdf>
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use core::fmt::Debug; use core::fmt::Debug;
use unroll::unroll_for_loops; use unroll::unroll_for_loops;
@ -753,11 +753,7 @@ impl<F: RichField> AlgebraicHasher<F> for PoseidonHash {
#[cfg(test)] #[cfg(test)]
pub(crate) mod test_helpers { pub(crate) mod test_helpers {
#[cfg(not(feature = "std"))] use super::*;
use alloc::vec::Vec;
use crate::field::types::Field;
use crate::hash::poseidon::{Poseidon, SPONGE_WIDTH};
pub(crate) fn check_test_vectors<F: Field>( pub(crate) fn check_test_vectors<F: Field>(
test_vectors: Vec<([u64; SPONGE_WIDTH], [u64; SPONGE_WIDTH])>, test_vectors: Vec<([u64; SPONGE_WIDTH], [u64; SPONGE_WIDTH])>,

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use core::marker::PhantomData; use core::marker::PhantomData;
use crate::field::extension::{Extendable, FieldExtension}; use crate::field::extension::{Extendable, FieldExtension};

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::ops::Range; use core::ops::Range;

View File

@ -1,7 +1,10 @@
use alloc::boxed::Box; #[cfg(not(feature = "std"))]
use alloc::string::{String, ToString}; use alloc::{
use alloc::vec; boxed::Box,
use alloc::vec::Vec; string::{String, ToString},
vec,
vec::Vec,
};
use core::fmt::Debug; use core::fmt::Debug;
use core::marker::PhantomData; use core::marker::PhantomData;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::ops::Range; use core::ops::Range;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::ops::Range; use core::ops::Range;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use hashbrown::HashMap; use hashbrown::HashMap;
use itertools::{zip_eq, Itertools}; use itertools::{zip_eq, Itertools};

View File

@ -2,6 +2,7 @@
#![allow(clippy::needless_range_loop)] #![allow(clippy::needless_range_loop)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#[cfg(not(feature = "std"))]
pub extern crate alloc; pub extern crate alloc;
/// Re-export of `plonky2_field`. /// Re-export of `plonky2_field`.

View File

@ -1,12 +1,10 @@
//! Logic for building plonky2 circuits. //! Logic for building plonky2 circuits.
use alloc::collections::BTreeMap; #[cfg(not(feature = "std"))]
use alloc::sync::Arc; use alloc::{collections::BTreeMap, sync::Arc, vec, vec::Vec};
use alloc::vec;
use alloc::vec::Vec;
use core::cmp::max; use core::cmp::max;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::time::Instant; use std::{collections::BTreeMap, sync::Arc, time::Instant};
use hashbrown::{HashMap, HashSet}; use hashbrown::{HashMap, HashSet};
use itertools::Itertools; use itertools::Itertools;

View File

@ -12,10 +12,11 @@
//! The verifier data can similarly be extracted by calling [`CircuitData::verifier_data`]. //! The verifier data can similarly be extracted by calling [`CircuitData::verifier_data`].
//! This is useful to allow even small devices to verify plonky2 proofs. //! This is useful to allow even small devices to verify plonky2 proofs.
use alloc::collections::BTreeMap; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{collections::BTreeMap, vec, vec::Vec};
use alloc::vec::Vec;
use core::ops::{Range, RangeFrom}; use core::ops::{Range, RangeFrom};
#[cfg(feature = "std")]
use std::collections::BTreeMap;
use anyhow::Result; use anyhow::Result;
use serde::Serialize; use serde::Serialize;

View File

@ -6,8 +6,8 @@
//! the Poseidon hash function both internally and natively, and one //! the Poseidon hash function both internally and natively, and one
//! mixing Poseidon internally and truncated Keccak externally. //! mixing Poseidon internally and truncated Keccak externally.
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use core::fmt::Debug; use core::fmt::Debug;
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::string::String; use alloc::string::String;
use crate::iop::target::Target; use crate::iop::target::Target;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use hashbrown::HashSet; use hashbrown::HashSet;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use hashbrown::HashMap; use hashbrown::HashMap;

View File

@ -1,7 +1,7 @@
//! Utility methods and constants for Plonk. //! Utility methods and constants for Plonk.
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use crate::field::extension::Extendable; use crate::field::extension::Extendable;
use crate::field::packed::PackedField; use crate::field::packed::PackedField;

View File

@ -4,8 +4,8 @@
//! [`CompressedProof`] or [`CompressedProofWithPublicInputs`] formats. //! [`CompressedProof`] or [`CompressedProofWithPublicInputs`] formats.
//! The latter can be directly passed to a verifier to assert its correctness. //! The latter can be directly passed to a verifier to assert its correctness.
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use anyhow::ensure; use anyhow::ensure;
use plonky2_maybe_rayon::*; use plonky2_maybe_rayon::*;
@ -452,21 +452,22 @@ impl<const D: usize> OpeningSetTarget<D> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use alloc::{sync::Arc, vec}; use alloc::sync::Arc;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::sync::Arc; use std::sync::Arc;
use anyhow::Result; use anyhow::Result;
use itertools::Itertools; use itertools::Itertools;
use plonky2_field::types::Sample;
use crate::field::types::Sample; use super::*;
use crate::fri::reduction_strategies::FriReductionStrategy; use crate::fri::reduction_strategies::FriReductionStrategy;
use crate::gates::lookup_table::LookupTable; use crate::gates::lookup_table::LookupTable;
use crate::gates::noop::NoopGate; use crate::gates::noop::NoopGate;
use crate::iop::witness::PartialWitness; use crate::iop::witness::PartialWitness;
use crate::plonk::circuit_builder::CircuitBuilder; use crate::plonk::circuit_builder::CircuitBuilder;
use crate::plonk::circuit_data::CircuitConfig; use crate::plonk::circuit_data::CircuitConfig;
use crate::plonk::config::{GenericConfig, PoseidonGoldilocksConfig}; use crate::plonk::config::PoseidonGoldilocksConfig;
use crate::plonk::verifier::verify; use crate::plonk::verifier::verify;
#[test] #[test]

View File

@ -1,7 +1,7 @@
//! plonky2 prover implementation. //! plonky2 prover implementation.
use alloc::vec::Vec; #[cfg(not(feature = "std"))]
use alloc::{format, vec}; use alloc::{format, vec, vec::Vec};
use core::cmp::min; use core::cmp::min;
use core::mem::swap; use core::mem::swap;

View File

@ -1,5 +1,5 @@
use alloc::vec::Vec; #[cfg(not(feature = "std"))]
use alloc::{format, vec}; use alloc::{format, vec, vec::Vec};
use core::cmp::min; use core::cmp::min;
use plonky2_field::polynomial::PolynomialCoeffs; use plonky2_field::polynomial::PolynomialCoeffs;

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use itertools::Itertools; use itertools::Itertools;

View File

@ -1,5 +1,6 @@
#![allow(clippy::int_plus_one)] // Makes more sense for some inequalities below. #![allow(clippy::int_plus_one)] // Makes more sense for some inequalities below.
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use anyhow::{ensure, Result}; use anyhow::{ensure, Result};

View File

@ -1,6 +1,9 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{
use alloc::vec::Vec; string::{String, ToString},
vec,
vec::Vec,
};
use hashbrown::HashMap; use hashbrown::HashMap;
use plonky2_field::extension::Extendable; use plonky2_field::extension::Extendable;

View File

@ -1,6 +1,9 @@
use alloc::string::{String, ToString}; #[cfg(not(feature = "std"))]
use alloc::vec; use alloc::{
use alloc::vec::Vec; string::{String, ToString},
vec,
vec::Vec,
};
use log::{log, Level}; use log::{log, Level};

View File

@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
use core::iter; use core::iter;

View File

@ -1,5 +1,5 @@
use alloc::vec; #[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::{vec, vec::Vec};
use core::borrow::Borrow; use core::borrow::Borrow;
use crate::field::extension::{Extendable, FieldExtension}; use crate::field::extension::{Extendable, FieldExtension};

View File

@ -1,6 +1,9 @@
//! A module to help with GateRef serialization //! A module to help with GateRef serialization
#[cfg(not(feature = "std"))]
use alloc::vec::Vec; use alloc::vec::Vec;
#[cfg(feature = "std")]
use std::vec::Vec; // For macros below
use plonky2_field::extension::Extendable; use plonky2_field::extension::Extendable;
@ -76,7 +79,7 @@ macro_rules! impl_gate_serializer {
fn write_gate( fn write_gate(
&self, &self,
buf: &mut $crate::alloc::vec::Vec<u8>, buf: &mut $crate::util::serialization::gate_serialization::Vec<u8>,
gate: &$crate::gates::gate::GateRef<F, D>, gate: &$crate::gates::gate::GateRef<F, D>,
common: &$crate::plonk::circuit_data::CommonCircuitData<F, D>, common: &$crate::plonk::circuit_data::CommonCircuitData<F, D>,
) -> $crate::util::serialization::IoResult<()> { ) -> $crate::util::serialization::IoResult<()> {

View File

@ -1,6 +1,9 @@
//! A module to help with WitnessGeneratorRef serialization //! A module to help with WitnessGeneratorRef serialization
use alloc::vec::Vec; #[cfg(not(feature = "std"))]
pub use alloc::vec::Vec;
#[cfg(feature = "std")]
pub use std::vec::Vec; // For macros below
use plonky2_field::extension::Extendable; use plonky2_field::extension::Extendable;
@ -80,7 +83,7 @@ macro_rules! impl_generator_serializer {
fn write_generator( fn write_generator(
&self, &self,
buf: &mut $crate::alloc::vec::Vec<u8>, buf: &mut $crate::util::serialization::generator_serialization::Vec<u8>,
generator: &$crate::iop::generator::WitnessGeneratorRef<F, D>, generator: &$crate::iop::generator::WitnessGeneratorRef<F, D>,
common: &$crate::plonk::circuit_data::CommonCircuitData<F, D>, common: &$crate::plonk::circuit_data::CommonCircuitData<F, D>,
) -> $crate::util::serialization::IoResult<()> { ) -> $crate::util::serialization::IoResult<()> {

View File

@ -4,14 +4,14 @@ pub mod generator_serialization;
#[macro_use] #[macro_use]
pub mod gate_serialization; pub mod gate_serialization;
use alloc::collections::BTreeMap; #[cfg(not(feature = "std"))]
use alloc::sync::Arc; use alloc::{collections::BTreeMap, sync::Arc, vec, vec::Vec};
use alloc::vec;
use alloc::vec::Vec;
use core::convert::Infallible; use core::convert::Infallible;
use core::fmt::{Debug, Display, Formatter}; use core::fmt::{Debug, Display, Formatter};
use core::mem::size_of; use core::mem::size_of;
use core::ops::Range; use core::ops::Range;
#[cfg(feature = "std")]
use std::{collections::BTreeMap, sync::Arc};
pub use gate_serialization::default::DefaultGateSerializer; pub use gate_serialization::default::DefaultGateSerializer;
pub use gate_serialization::GateSerializer; pub use gate_serialization::GateSerializer;