diff --git a/ecdsa/Cargo.toml b/ecdsa/Cargo.toml index ed84d5de..04dbd19c 100644 --- a/ecdsa/Cargo.toml +++ b/ecdsa/Cargo.toml @@ -1,18 +1,20 @@ [package] name = "plonky2_ecdsa" +description = "ECDSA gadget for Plonky2" version = "0.1.0" +license = "MIT OR Apache-2.0" edition = "2021" [features] -parallel = ["maybe_rayon/parallel", "plonky2/parallel"] +parallel = ["plonky2_maybe_rayon/parallel", "plonky2/parallel"] [dependencies] anyhow = { version = "1.0.40", default-features = false } itertools = { version = "0.10.0", default-features = false } -maybe_rayon = { path = "../maybe_rayon", default-features = false } +plonky2_maybe_rayon = { version = "0.1.0", default-features = false } num = { version = "0.4.0", default-features = false } -plonky2 = { path = "../plonky2", default-features = false } -plonky2_u32 = { path = "../u32", default-features = false } +plonky2 = { version = "0.1.1", default-features = false } +plonky2_u32 = { version = "0.1.0", default-features = false } serde = { version = "1.0", default-features = false, features = ["derive"] } [dev-dependencies] diff --git a/ecdsa/src/curve/curve_msm.rs b/ecdsa/src/curve/curve_msm.rs index 21bcc404..9faa4a79 100644 --- a/ecdsa/src/curve/curve_msm.rs +++ b/ecdsa/src/curve/curve_msm.rs @@ -1,8 +1,8 @@ use alloc::vec::Vec; use itertools::Itertools; -use maybe_rayon::*; use plonky2::field::types::{Field, PrimeField}; +use plonky2_maybe_rayon::*; use crate::curve::curve_summation::affine_multisummation_best; use crate::curve::curve_types::{AffinePoint, Curve, ProjectivePoint}; diff --git a/evm/Cargo.toml b/evm/Cargo.toml index f6494d7a..f2c192c8 100644 --- a/evm/Cargo.toml +++ b/evm/Cargo.toml @@ -2,6 +2,11 @@ name = "plonky2_evm" description = "Implementation of STARKs for the Ethereum Virtual Machine" version = "0.1.0" +authors = ["Daniel Lubarov ", "William Borgeaud "] +readme = "README.md" +repository = "https://github.com/mir-protocol/plonky2" +keywords = ["EVM", "STARK", "Ethereum"] +categories = ["cryptography"] edition = "2021" [dependencies] @@ -15,13 +20,13 @@ hex-literal = "0.3.4" itertools = "0.10.3" keccak-hash = "0.10.0" log = "0.4.14" -maybe_rayon = { path = "../maybe_rayon" } +plonky2_maybe_rayon = "0.1.0" num = "0.4.0" once_cell = "1.13.0" pest = "2.1.3" pest_derive = "2.1.0" -plonky2 = { path = "../plonky2", default-features = false, features = ["timing"] } -plonky2_util = { path = "../util" } +plonky2 = { version = "0.1.1", default-features = false, features = ["timing"] } +plonky2_util = { version = "0.1.0" } rand = "0.8.5" rand_chacha = "0.3.1" rlp = "0.5.1" @@ -42,7 +47,7 @@ sha2 = "0.10.6" [features] default = ["parallel"] asmtools = ["hex"] -parallel = ["plonky2/parallel", "maybe_rayon/parallel"] +parallel = ["plonky2/parallel", "plonky2_maybe_rayon/parallel"] [[bin]] name = "assemble" diff --git a/evm/src/cpu/kernel/assembler.rs b/evm/src/cpu/kernel/assembler.rs index e9432f66..15fb1d4b 100644 --- a/evm/src/cpu/kernel/assembler.rs +++ b/evm/src/cpu/kernel/assembler.rs @@ -41,8 +41,8 @@ impl Kernel { prover_inputs: HashMap, ) -> Self { let code_hash_bytes = keccak(&code).0; - let code_hash = std::array::from_fn(|i| { - u32::from_le_bytes(std::array::from_fn(|j| code_hash_bytes[i * 4 + j])) + let code_hash = core::array::from_fn(|i| { + u32::from_le_bytes(core::array::from_fn(|j| code_hash_bytes[i * 4 + j])) }); let ordered_labels = global_labels .keys() diff --git a/evm/src/cpu/kernel/keccak_util.rs b/evm/src/cpu/kernel/keccak_util.rs index 38361389..18730075 100644 --- a/evm/src/cpu/kernel/keccak_util.rs +++ b/evm/src/cpu/kernel/keccak_util.rs @@ -4,13 +4,13 @@ use crate::keccak_sponge::columns::{KECCAK_WIDTH_BYTES, KECCAK_WIDTH_U32S}; /// Like tiny-keccak's `keccakf`, but deals with `u32` limbs instead of `u64` limbs. pub(crate) fn keccakf_u32s(state_u32s: &mut [u32; KECCAK_WIDTH_U32S]) { - let mut state_u64s: [u64; 25] = std::array::from_fn(|i| { + let mut state_u64s: [u64; 25] = core::array::from_fn(|i| { let lo = state_u32s[i * 2] as u64; let hi = state_u32s[i * 2 + 1] as u64; lo | (hi << 32) }); keccakf(&mut state_u64s); - *state_u32s = std::array::from_fn(|i| { + *state_u32s = core::array::from_fn(|i| { let u64_limb = state_u64s[i / 2]; let is_hi = i % 2; (u64_limb >> (is_hi * 32)) as u32 @@ -20,9 +20,9 @@ pub(crate) fn keccakf_u32s(state_u32s: &mut [u32; KECCAK_WIDTH_U32S]) { /// Like tiny-keccak's `keccakf`, but deals with bytes instead of `u64` limbs. pub(crate) fn keccakf_u8s(state_u8s: &mut [u8; KECCAK_WIDTH_BYTES]) { let mut state_u64s: [u64; 25] = - std::array::from_fn(|i| u64::from_le_bytes(state_u8s[i * 8..][..8].try_into().unwrap())); + core::array::from_fn(|i| u64::from_le_bytes(state_u8s[i * 8..][..8].try_into().unwrap())); keccakf(&mut state_u64s); - *state_u8s = std::array::from_fn(|i| { + *state_u8s = core::array::from_fn(|i| { let u64_limb = state_u64s[i / 8]; u64_limb.to_le_bytes()[i % 8] }); diff --git a/evm/src/cpu/kernel/tests/mpt/hash.rs b/evm/src/cpu/kernel/tests/mpt/hash.rs index 6c6c6f63..1b49dafa 100644 --- a/evm/src/cpu/kernel/tests/mpt/hash.rs +++ b/evm/src/cpu/kernel/tests/mpt/hash.rs @@ -24,7 +24,7 @@ fn mpt_hash_empty() -> Result<()> { #[test] fn mpt_hash_empty_branch() -> Result<()> { - let children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let children = core::array::from_fn(|_| PartialTrie::Empty.into()); let state_trie = PartialTrie::Branch { children, value: vec![], @@ -85,7 +85,7 @@ fn mpt_hash_branch_to_leaf() -> Result<()> { value: test_account_2_rlp(), } .into(); - let mut children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let mut children = core::array::from_fn(|_| PartialTrie::Empty.into()); children[3] = leaf; let state_trie = PartialTrie::Branch { children, diff --git a/evm/src/cpu/kernel/tests/mpt/insert.rs b/evm/src/cpu/kernel/tests/mpt/insert.rs index cf546969..6d6d6951 100644 --- a/evm/src/cpu/kernel/tests/mpt/insert.rs +++ b/evm/src/cpu/kernel/tests/mpt/insert.rs @@ -66,7 +66,7 @@ fn mpt_insert_leaf_leaf_key_extends_insert_key() -> Result<()> { #[test] fn mpt_insert_branch_replacing_empty_child() -> Result<()> { - let children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let children = core::array::from_fn(|_| PartialTrie::Empty.into()); let state_trie = PartialTrie::Branch { children, value: vec![], @@ -81,7 +81,7 @@ fn mpt_insert_branch_replacing_empty_child() -> Result<()> { #[ignore] fn mpt_insert_extension_nonoverlapping_keys() -> Result<()> { // Existing keys are 0xABC, 0xABCDEF; inserted key is 0x12345. - let mut children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let mut children = core::array::from_fn(|_| PartialTrie::Empty.into()); children[0xD] = PartialTrie::Leaf { nibbles: 0xEF_u64.into(), value: test_account_1_rlp(), @@ -104,7 +104,7 @@ fn mpt_insert_extension_nonoverlapping_keys() -> Result<()> { #[ignore] fn mpt_insert_extension_insert_key_extends_node_key() -> Result<()> { // Existing keys are 0xA, 0xABCD; inserted key is 0xABCDEF. - let mut children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let mut children = core::array::from_fn(|_| PartialTrie::Empty.into()); children[0xB] = PartialTrie::Leaf { nibbles: 0xCD_u64.into(), value: test_account_1_rlp(), @@ -129,7 +129,7 @@ fn mpt_insert_branch_to_leaf_same_key() -> Result<()> { } .into(); - let mut children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let mut children = core::array::from_fn(|_| PartialTrie::Empty.into()); children[0] = leaf; let state_trie = PartialTrie::Branch { children, diff --git a/evm/src/cpu/kernel/tests/mpt/load.rs b/evm/src/cpu/kernel/tests/mpt/load.rs index 79b4918f..292de36b 100644 --- a/evm/src/cpu/kernel/tests/mpt/load.rs +++ b/evm/src/cpu/kernel/tests/mpt/load.rs @@ -134,7 +134,7 @@ fn load_all_mpts_hash() -> Result<()> { #[test] fn load_all_mpts_empty_branch() -> Result<()> { - let children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let children = core::array::from_fn(|_| PartialTrie::Empty.into()); let state_trie = PartialTrie::Branch { children, value: vec![], diff --git a/evm/src/fixed_recursive_verifier.rs b/evm/src/fixed_recursive_verifier.rs index 96dc3e93..344b6d1c 100644 --- a/evm/src/fixed_recursive_verifier.rs +++ b/evm/src/fixed_recursive_verifier.rs @@ -178,15 +178,15 @@ where stark_config: &StarkConfig, ) -> RootCircuitData { let inner_common_data: [_; NUM_TABLES] = - std::array::from_fn(|i| &by_table[i].final_circuits()[0].common); + core::array::from_fn(|i| &by_table[i].final_circuits()[0].common); let mut builder = CircuitBuilder::new(CircuitConfig::standard_recursion_config()); let recursive_proofs = - std::array::from_fn(|i| builder.add_virtual_proof_with_pis::(inner_common_data[i])); - let pis: [_; NUM_TABLES] = std::array::from_fn(|i| { + core::array::from_fn(|i| builder.add_virtual_proof_with_pis::(inner_common_data[i])); + let pis: [_; NUM_TABLES] = core::array::from_fn(|i| { PublicInputs::from_vec(&recursive_proofs[i].public_inputs, stark_config) }); - let index_verifier_data = std::array::from_fn(|_i| builder.add_virtual_target()); + let index_verifier_data = core::array::from_fn(|_i| builder.add_virtual_target()); let mut challenger = RecursiveChallenger::::new(&mut builder); for pi in &pis { diff --git a/evm/src/get_challenges.rs b/evm/src/get_challenges.rs index f368b7c2..7e6a1ba7 100644 --- a/evm/src/get_challenges.rs +++ b/evm/src/get_challenges.rs @@ -35,7 +35,7 @@ impl, C: GenericConfig, const D: usize> A let num_permutation_batch_sizes = all_stark.permutation_batch_sizes(); AllProofChallenges { - stark_challenges: std::array::from_fn(|i| { + stark_challenges: core::array::from_fn(|i| { challenger.compact(); self.stark_proofs[i].proof.get_challenges( &mut challenger, diff --git a/evm/src/memory/memory_stark.rs b/evm/src/memory/memory_stark.rs index 8103f883..88dcbf40 100644 --- a/evm/src/memory/memory_stark.rs +++ b/evm/src/memory/memory_stark.rs @@ -1,7 +1,6 @@ use std::marker::PhantomData; use itertools::Itertools; -use maybe_rayon::*; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::field::packed::PackedField; use plonky2::field::polynomial::PolynomialValues; @@ -10,6 +9,7 @@ use plonky2::hash::hash_types::RichField; use plonky2::timed; use plonky2::util::timing::TimingTree; use plonky2::util::transpose; +use plonky2_maybe_rayon::*; use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; use crate::cross_table_lookup::Column; diff --git a/evm/src/permutation.rs b/evm/src/permutation.rs index 4f42a4aa..64223ad7 100644 --- a/evm/src/permutation.rs +++ b/evm/src/permutation.rs @@ -3,7 +3,6 @@ use std::fmt::Debug; use itertools::Itertools; -use maybe_rayon::*; use plonky2::field::batch_util::batch_multiply_inplace; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::field::packed::PackedField; @@ -17,6 +16,7 @@ use plonky2::plonk::circuit_builder::CircuitBuilder; use plonky2::plonk::config::{AlgebraicHasher, GenericConfig, Hasher}; use plonky2::plonk::plonk_common::{reduce_with_powers, reduce_with_powers_ext_circuit}; use plonky2::util::reducing::{ReducingFactor, ReducingFactorTarget}; +use plonky2_maybe_rayon::*; use crate::config::StarkConfig; use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; diff --git a/evm/src/proof.rs b/evm/src/proof.rs index 7025697f..d0f56873 100644 --- a/evm/src/proof.rs +++ b/evm/src/proof.rs @@ -1,6 +1,5 @@ use ethereum_types::{Address, H256, U256}; use itertools::Itertools; -use maybe_rayon::*; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::fri::oracle::PolynomialBatch; use plonky2::fri::proof::{FriChallenges, FriChallengesTarget, FriProof, FriProofTarget}; @@ -13,6 +12,7 @@ use plonky2::hash::merkle_tree::MerkleCap; use plonky2::iop::ext_target::ExtensionTarget; use plonky2::iop::target::Target; use plonky2::plonk::config::GenericConfig; +use plonky2_maybe_rayon::*; use serde::{Deserialize, Serialize}; use crate::all_stark::NUM_TABLES; @@ -29,7 +29,7 @@ pub struct AllProof, C: GenericConfig, co impl, C: GenericConfig, const D: usize> AllProof { pub fn degree_bits(&self, config: &StarkConfig) -> [usize; NUM_TABLES] { - std::array::from_fn(|i| self.stark_proofs[i].proof.recover_degree_bits(config)) + core::array::from_fn(|i| self.stark_proofs[i].proof.recover_degree_bits(config)) } } diff --git a/evm/src/prover.rs b/evm/src/prover.rs index 8a293fb4..b4ea0d90 100644 --- a/evm/src/prover.rs +++ b/evm/src/prover.rs @@ -2,7 +2,6 @@ use std::any::type_name; use anyhow::{ensure, Result}; use itertools::Itertools; -use maybe_rayon::*; use once_cell::sync::Lazy; use plonky2::field::extension::Extendable; use plonky2::field::packable::Packable; @@ -17,6 +16,7 @@ use plonky2::plonk::config::{GenericConfig, Hasher}; use plonky2::timed; use plonky2::util::timing::TimingTree; use plonky2::util::transpose; +use plonky2_maybe_rayon::*; use plonky2_util::{log2_ceil, log2_strict}; use crate::all_stark::{AllStark, Table, NUM_TABLES}; diff --git a/evm/src/recursive_verifier.rs b/evm/src/recursive_verifier.rs index 4de74921..1fba88e3 100644 --- a/evm/src/recursive_verifier.rs +++ b/evm/src/recursive_verifier.rs @@ -107,7 +107,7 @@ impl, C: GenericConfig, const D: usize> where [(); C::Hasher::HASH_SIZE]:, { - let pis: [_; NUM_TABLES] = std::array::from_fn(|i| { + let pis: [_; NUM_TABLES] = core::array::from_fn(|i| { PublicInputs::from_vec(&self.recursive_proofs[i].public_inputs, inner_config) }); @@ -279,7 +279,7 @@ where num_permutation_zs, ); - let init_challenger_state_target = std::array::from_fn(|_| builder.add_virtual_public_input()); + let init_challenger_state_target = core::array::from_fn(|_| builder.add_virtual_public_input()); let mut challenger = RecursiveChallenger::::from_state(init_challenger_state_target); let challenges = proof_target.get_challenges::( diff --git a/evm/src/witness/util.rs b/evm/src/witness/util.rs index 74303359..74970553 100644 --- a/evm/src/witness/util.rs +++ b/evm/src/witness/util.rs @@ -140,7 +140,7 @@ pub(crate) fn stack_pop_with_log_and_fill( return Err(ProgramError::StackUnderflow); } - let result = std::array::from_fn(|i| { + let result = core::array::from_fn(|i| { let address = MemoryAddress::new( state.registers.context, Segment::Stack, diff --git a/evm/tests/basic_smart_contract.rs b/evm/tests/basic_smart_contract.rs index 44b7fb4d..e52b7a76 100644 --- a/evm/tests/basic_smart_contract.rs +++ b/evm/tests/basic_smart_contract.rs @@ -56,7 +56,7 @@ fn test_basic_smart_contract() -> anyhow::Result<()> { }; let state_trie_before = { - let mut children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let mut children = core::array::from_fn(|_| PartialTrie::Empty.into()); children[sender_nibbles.get_nibble(0) as usize] = PartialTrie::Leaf { nibbles: sender_nibbles.truncate_n_nibbles_front(1), value: rlp::encode(&sender_account_before).to_vec(), @@ -110,7 +110,7 @@ fn test_basic_smart_contract() -> anyhow::Result<()> { ..to_account_before }; - let mut children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let mut children = core::array::from_fn(|_| PartialTrie::Empty.into()); children[sender_nibbles.get_nibble(0) as usize] = PartialTrie::Leaf { nibbles: sender_nibbles.truncate_n_nibbles_front(1), value: rlp::encode(&sender_account_after).to_vec(), diff --git a/evm/tests/simple_transfer.rs b/evm/tests/simple_transfer.rs index 72801388..2d27abfe 100644 --- a/evm/tests/simple_transfer.rs +++ b/evm/tests/simple_transfer.rs @@ -83,7 +83,7 @@ fn test_simple_transfer() -> anyhow::Result<()> { ..AccountRlp::default() }; - let mut children = std::array::from_fn(|_| PartialTrie::Empty.into()); + let mut children = core::array::from_fn(|_| PartialTrie::Empty.into()); children[sender_nibbles.get_nibble(0) as usize] = PartialTrie::Leaf { nibbles: sender_nibbles.truncate_n_nibbles_front(1), value: rlp::encode(&sender_account_after).to_vec(), diff --git a/field/Cargo.toml b/field/Cargo.toml index 1242dfe3..afc084e8 100644 --- a/field/Cargo.toml +++ b/field/Cargo.toml @@ -2,13 +2,15 @@ name = "plonky2_field" description = "Finite field arithmetic" version = "0.1.0" +license = "MIT OR Apache-2.0" +authors = ["Daniel Lubarov ", "William Borgeaud ", "Jacqueline Nabaglo ", "Hamish Ivey-Law "] edition = "2021" [dependencies] anyhow = { version = "1.0.40", default-features = false } itertools = { version = "0.10.0", default-features = false, features = ["use_alloc"] } num = { version = "0.4", default-features = false, features = ["alloc", "rand"] } -plonky2_util = { path = "../util", default-features = false } +plonky2_util = { version = "0.1.0", default-features = false } rand = { version = "0.8.5", default-features = false, features = ["getrandom"] } serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } static_assertions = { version = "1.1.0", default-features = false } diff --git a/insertion/Cargo.toml b/insertion/Cargo.toml index c007a975..e39e2bd3 100644 --- a/insertion/Cargo.toml +++ b/insertion/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" [dependencies] anyhow = { version = "1.0.40", default-features = false } -plonky2 = { path = "../plonky2", default-features = false } +plonky2 = { version = "0.1.1", default-features = false } [dev-dependencies] -plonky2 = { path = "../plonky2" } +plonky2 = { version = "0.1.1" } diff --git a/maybe_rayon/Cargo.toml b/maybe_rayon/Cargo.toml index b3c1e78a..11eebc96 100644 --- a/maybe_rayon/Cargo.toml +++ b/maybe_rayon/Cargo.toml @@ -1,5 +1,7 @@ [package] -name = "maybe_rayon" +name = "plonky2_maybe_rayon" +description = "Feature-gated wrapper around rayon" +license = "MIT OR Apache-2.0" version = "0.1.0" edition = "2021" diff --git a/plonky2/Cargo.toml b/plonky2/Cargo.toml index 9474095e..6cbc1b6b 100644 --- a/plonky2/Cargo.toml +++ b/plonky2/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "plonky2" description = "Recursive SNARKs based on PLONK and FRI" -version = "0.1.0" -authors = ["Polygon Zero "] +version = "0.1.1" +license = "MIT OR Apache-2.0" +authors = ["Daniel Lubarov ", "William Borgeaud ", "Nicholas Ward "] readme = "README.md" repository = "https://github.com/mir-protocol/plonky2" keywords = ["cryptography", "SNARK", "PLONK", "FRI"] categories = ["cryptography"] edition = "2021" -default-run = "generate_constants" [features] default = ["gate_testing", "parallel", "rand_chacha", "std", "timing"] gate_testing = [] -parallel = ["hashbrown/rayon", "maybe_rayon/parallel"] +parallel = ["hashbrown/rayon", "plonky2_maybe_rayon/parallel"] std = ["anyhow/std", "rand/std"] timing = ["std"] @@ -24,10 +24,10 @@ hashbrown = { version = "0.12.3", default-features = false, features = ["ahash", 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 } +plonky2_maybe_rayon = { version = "0.1.0", default-features = false } num = { version = "0.4", default-features = false, features = ["rand"] } -plonky2_field = { path = "../field", default-features = false } -plonky2_util = { path = "../util", default-features = false } +plonky2_field = { version = "0.1.0", default-features = false } +plonky2_util = { version = "0.1.0", default-features = false } rand = { version = "0.8.4", default-features = false } rand_chacha = { version = "0.3.1", optional = true, default-features = false } serde = { version = "1.0", default-features = false, features = ["derive"] } @@ -38,7 +38,6 @@ unroll = { version = "0.1.5", default-features = false } criterion = { version = "0.4.0", default-features = false } env_logger = { version = "0.9.0", default-features = false } 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 } serde_cbor = { version = "0.11.2" } diff --git a/plonky2/examples/bench_recursion.rs b/plonky2/examples/bench_recursion.rs index bf6b0e6b..5a1196e1 100644 --- a/plonky2/examples/bench_recursion.rs +++ b/plonky2/examples/bench_recursion.rs @@ -9,7 +9,6 @@ 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, WitnessWrite}; @@ -20,6 +19,7 @@ use plonky2::plonk::proof::{CompressedProofWithPublicInputs, ProofWithPublicInpu use plonky2::plonk::prover::prove; use plonky2::util::timing::TimingTree; use plonky2_field::extension::Extendable; +use plonky2_maybe_rayon::rayon; use rand::rngs::OsRng; use rand::{RngCore, SeedableRng}; use rand_chacha::ChaCha8Rng; diff --git a/plonky2/src/fri/oracle.rs b/plonky2/src/fri/oracle.rs index 90890134..cddcf048 100644 --- a/plonky2/src/fri/oracle.rs +++ b/plonky2/src/fri/oracle.rs @@ -2,8 +2,8 @@ use alloc::format; use alloc::vec::Vec; use itertools::Itertools; -use maybe_rayon::*; use plonky2_field::types::Field; +use plonky2_maybe_rayon::*; use crate::field::extension::Extendable; use crate::field::fft::FftRootTable; diff --git a/plonky2/src/fri/prover.rs b/plonky2/src/fri/prover.rs index e65a9731..9e933528 100644 --- a/plonky2/src/fri/prover.rs +++ b/plonky2/src/fri/prover.rs @@ -1,6 +1,6 @@ use alloc::vec::Vec; -use maybe_rayon::*; +use plonky2_maybe_rayon::*; use crate::field::extension::{flatten, unflatten, Extendable}; use crate::field::polynomial::{PolynomialCoeffs, PolynomialValues}; diff --git a/plonky2/src/gadgets/interpolation.rs b/plonky2/src/gadgets/interpolation.rs index 1ab35660..daf51d21 100644 --- a/plonky2/src/gadgets/interpolation.rs +++ b/plonky2/src/gadgets/interpolation.rs @@ -1,3 +1,5 @@ +use alloc::vec; + use plonky2_field::extension::Extendable; use crate::gates::coset_interpolation::CosetInterpolationGate; diff --git a/plonky2/src/gadgets/random_access.rs b/plonky2/src/gadgets/random_access.rs index 73e3de8c..85d2c714 100644 --- a/plonky2/src/gadgets/random_access.rs +++ b/plonky2/src/gadgets/random_access.rs @@ -57,7 +57,7 @@ impl, const D: usize> CircuitBuilder { access_index: Target, v: Vec, ) -> HashOutTarget { - let selected = std::array::from_fn(|i| { + let selected = core::array::from_fn(|i| { self.random_access( access_index, v.iter().map(|hash| hash.elements[i]).collect(), diff --git a/plonky2/src/hash/merkle_tree.rs b/plonky2/src/hash/merkle_tree.rs index 7a9cd1f3..e0c8e79d 100644 --- a/plonky2/src/hash/merkle_tree.rs +++ b/plonky2/src/hash/merkle_tree.rs @@ -2,7 +2,7 @@ use alloc::vec::Vec; use core::mem::MaybeUninit; use core::slice; -use maybe_rayon::*; +use plonky2_maybe_rayon::*; use serde::{Deserialize, Serialize}; use crate::hash::hash_types::RichField; @@ -84,7 +84,7 @@ fn fill_subtree>( // Split `leaves` between both children. let (left_leaves, right_leaves) = leaves.split_at(leaves.len() / 2); - let (left_digest, right_digest) = maybe_rayon::join( + let (left_digest, right_digest) = plonky2_maybe_rayon::join( || fill_subtree::(left_digests_buf, left_leaves), || fill_subtree::(right_digests_buf, right_leaves), ); diff --git a/plonky2/src/plonk/permutation_argument.rs b/plonky2/src/plonk/permutation_argument.rs index 7052cabe..f8d07d4a 100644 --- a/plonky2/src/plonk/permutation_argument.rs +++ b/plonky2/src/plonk/permutation_argument.rs @@ -1,7 +1,7 @@ use alloc::vec::Vec; use hashbrown::HashMap; -use maybe_rayon::*; +use plonky2_maybe_rayon::*; use crate::field::polynomial::PolynomialValues; use crate::field::types::Field; diff --git a/plonky2/src/plonk/proof.rs b/plonky2/src/plonk/proof.rs index fb9e6cde..ea616e8f 100644 --- a/plonky2/src/plonk/proof.rs +++ b/plonky2/src/plonk/proof.rs @@ -2,7 +2,7 @@ use alloc::vec; use alloc::vec::Vec; use anyhow::ensure; -use maybe_rayon::*; +use plonky2_maybe_rayon::*; use serde::{Deserialize, Serialize}; use crate::field::extension::Extendable; diff --git a/plonky2/src/plonk/prover.rs b/plonky2/src/plonk/prover.rs index d45fa573..f8f66ea1 100644 --- a/plonky2/src/plonk/prover.rs +++ b/plonky2/src/plonk/prover.rs @@ -3,7 +3,7 @@ use alloc::{format, vec}; use core::mem::swap; use anyhow::{ensure, Result}; -use maybe_rayon::*; +use plonky2_maybe_rayon::*; use crate::field::extension::Extendable; use crate::field::polynomial::{PolynomialCoeffs, PolynomialValues}; diff --git a/plonky2/src/recursion/dummy_circuit.rs b/plonky2/src/recursion/dummy_circuit.rs index 38f51aea..c8b98a96 100644 --- a/plonky2/src/recursion/dummy_circuit.rs +++ b/plonky2/src/recursion/dummy_circuit.rs @@ -1,4 +1,5 @@ use alloc::vec; +use alloc::vec::Vec; use hashbrown::HashMap; use plonky2_field::extension::Extendable; diff --git a/plonky2/src/util/serialization.rs b/plonky2/src/util/serialization.rs index c3ad0887..b33ec52e 100644 --- a/plonky2/src/util/serialization.rs +++ b/plonky2/src/util/serialization.rs @@ -804,12 +804,14 @@ impl Buffer { } } +#[cfg(feature = "std")] impl Remaining for Buffer { fn remaining(&self) -> usize { self.bytes.len() - self.pos } } +#[cfg(feature = "std")] impl Read for Buffer { #[inline] fn read_exact(&mut self, bytes: &mut [u8]) -> IoResult<()> { diff --git a/starky/Cargo.toml b/starky/Cargo.toml index cdeb189a..4f459613 100644 --- a/starky/Cargo.toml +++ b/starky/Cargo.toml @@ -2,11 +2,17 @@ name = "starky" description = "Implementation of STARKs" version = "0.1.0" +license = "MIT OR Apache-2.0" +authors = ["Daniel Lubarov ", "William Borgeaud "] +readme = "README.md" +repository = "https://github.com/mir-protocol/plonky2" +keywords = ["cryptography", "STARK", "FRI"] +categories = ["cryptography"] edition = "2021" [features] default = ["parallel", "std", "timing"] -parallel = ["plonky2/parallel", "maybe_rayon/parallel"] +parallel = ["plonky2/parallel", "plonky2_maybe_rayon/parallel"] std = ["anyhow/std", "plonky2/std"] timing = ["plonky2/timing"] @@ -14,8 +20,8 @@ timing = ["plonky2/timing"] anyhow = { version = "1.0.40", default-features = false } itertools = { version = "0.10.0", default-features = false } log = { version = "0.4.14", default-features = false } -maybe_rayon = { path = "../maybe_rayon", default-features = false } -plonky2 = { path = "../plonky2", default-features = false } +plonky2_maybe_rayon = { version = "0.1.0", default-features = false } +plonky2 = { version = "0.1.1", default-features = false } [dev-dependencies] env_logger = { version = "0.9.0", default-features = false } diff --git a/starky/src/permutation.rs b/starky/src/permutation.rs index ee4225f3..bba42712 100644 --- a/starky/src/permutation.rs +++ b/starky/src/permutation.rs @@ -4,7 +4,6 @@ use alloc::vec; use alloc::vec::Vec; use itertools::Itertools; -use maybe_rayon::*; use plonky2::field::batch_util::batch_multiply_inplace; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::field::packed::PackedField; @@ -17,6 +16,7 @@ use plonky2::iop::target::Target; use plonky2::plonk::circuit_builder::CircuitBuilder; use plonky2::plonk::config::{AlgebraicHasher, GenericConfig, Hasher}; use plonky2::util::reducing::{ReducingFactor, ReducingFactorTarget}; +use plonky2_maybe_rayon::*; use crate::config::StarkConfig; use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; diff --git a/starky/src/proof.rs b/starky/src/proof.rs index 86093857..6bd5f787 100644 --- a/starky/src/proof.rs +++ b/starky/src/proof.rs @@ -2,7 +2,6 @@ use alloc::vec; use alloc::vec::Vec; use itertools::Itertools; -use maybe_rayon::*; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::fri::oracle::PolynomialBatch; use plonky2::fri::proof::{ @@ -16,6 +15,7 @@ use plonky2::hash::merkle_tree::MerkleCap; use plonky2::iop::ext_target::ExtensionTarget; use plonky2::iop::target::Target; use plonky2::plonk::config::GenericConfig; +use plonky2_maybe_rayon::*; use crate::config::StarkConfig; use crate::permutation::PermutationChallengeSet; diff --git a/starky/src/prover.rs b/starky/src/prover.rs index dc445f24..2350830c 100644 --- a/starky/src/prover.rs +++ b/starky/src/prover.rs @@ -3,7 +3,6 @@ use core::iter::once; use anyhow::{ensure, Result}; use itertools::Itertools; -use maybe_rayon::*; use plonky2::field::extension::Extendable; use plonky2::field::packable::Packable; use plonky2::field::packed::PackedField; @@ -17,6 +16,7 @@ use plonky2::plonk::config::{GenericConfig, Hasher}; use plonky2::timed; use plonky2::util::timing::TimingTree; use plonky2::util::{log2_ceil, log2_strict, transpose}; +use plonky2_maybe_rayon::*; use crate::config::StarkConfig; use crate::constraint_consumer::ConstraintConsumer; diff --git a/system_zero/Cargo.toml b/system_zero/Cargo.toml index 03aaea20..b8604984 100644 --- a/system_zero/Cargo.toml +++ b/system_zero/Cargo.toml @@ -8,11 +8,11 @@ edition = "2021" anyhow = "1.0.40" itertools = "0.10.0" log = "0.4.14" -plonky2 = { path = "../plonky2" } -plonky2_util = { path = "../util" } +plonky2 = { version = "0.1.1" } +plonky2_util = { version = "0.1.0" } rand = "0.8.4" rand_chacha = "0.3.1" -starky = { path = "../starky" } +starky = { version = "0.1.0" } [dev-dependencies] criterion = "0.4.0" diff --git a/u32/Cargo.toml b/u32/Cargo.toml index 273db263..0fd11a4a 100644 --- a/u32/Cargo.toml +++ b/u32/Cargo.toml @@ -1,14 +1,17 @@ [package] name = "plonky2_u32" +description = "u32 gadget for Plonky2" version = "0.1.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/mir-protocol/plonky2" edition = "2021" [dependencies] anyhow = { version = "1.0.40", default-features = false } itertools = { version = "0.10.0", default-features = false } num = { version = "0.4", default-features = false } -plonky2 = { path = "../plonky2", default-features = false } +plonky2 = { version = "0.1.1", default-features = false } [dev-dependencies] -plonky2 = { path = "../plonky2", default-features = false, features = ["gate_testing"] } +plonky2 = { version = "0.1.1", default-features = false, features = ["gate_testing"] } rand = { version = "0.8.4", default-features = false, features = ["getrandom"] } diff --git a/util/Cargo.toml b/util/Cargo.toml index 4419db2a..f3cb862e 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -2,6 +2,7 @@ name = "plonky2_util" description = "Utilities used by Plonky2" version = "0.1.0" +license = "MIT OR Apache-2.0" edition = "2021" [dev-dependencies] diff --git a/waksman/Cargo.toml b/waksman/Cargo.toml index 7be3f414..98d76a52 100644 --- a/waksman/Cargo.toml +++ b/waksman/Cargo.toml @@ -9,7 +9,7 @@ anyhow = "1.0.40" array_tool = "1.0.3" bimap = "0.6.1" itertools = "0.10.0" -"plonky2" = { path = "../plonky2" } -"plonky2_field" = { path = "../field" } -"plonky2_util" = { path = "../util" } +"plonky2" = { version = "0.1.0" } +"plonky2_field" = { version = "0.1.0" } +"plonky2_util" = { version = "0.1.0" } rand = "0.8.4"