diff --git a/Cargo.toml b/Cargo.toml index 2cb70293..cb4ae2bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,14 +12,14 @@ keywords = ["cryptography", "crypto", "ristretto", "zero-knowledge", "bulletproo description = "A pure-Rust implementation of Bulletproofs using Ristretto" [dependencies] -curve25519-dalek = { version = "1.2", default-features = false, features = ["u64_backend", "nightly", "serde"] } +curve25519-dalek = { version = "1.2", default-features = false, features = ["u64_backend", "nightly", "serde", "alloc"] } subtle = { version = "2", default-features = false } sha3 = { version = "0.8", default-features = false } digest = { version = "0.8", default-features = false } -rand_core = { version = "0.4", default-features = false } +rand_core = { version = "0.4", default-features = false, features = ["alloc"] } rand = { version = "0.6", default-features = false } byteorder = { version = "1", default-features = false } -serde = { version = "1", default-features = false } +serde = { version = "1", default-features = false, features = ["alloc"] } serde_derive = { version = "1", default-features = false } failure = { version = "0.1", default-features = false, features = ["derive"] } merlin = { version = "1.2", default-features = false } @@ -35,8 +35,7 @@ rand_chacha = "0.1" default = ["std", "avx2_backend"] avx2_backend = ["curve25519-dalek/avx2_backend"] yoloproofs = [] -std = ["rand/std", "serde/std", "merlin/std", "curve25519-dalek/std"] -alloc = ["rand_core/alloc", "serde/alloc", "curve25519-dalek/alloc"] +std = ["rand/std"] [[test]] name = "range_proof" diff --git a/src/errors.rs b/src/errors.rs index ad1ec50b..b20fbb61 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,8 +1,6 @@ //! Errors related to proving and verifying proofs. -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::vec::Vec; /// Represents an error in proof creation, verification, or parsing. diff --git a/src/generators.rs b/src/generators.rs index 38d1630d..11b418fb 100644 --- a/src/generators.rs +++ b/src/generators.rs @@ -4,18 +4,14 @@ #![allow(non_snake_case)] #![deny(missing_docs)] -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::vec::Vec; - use curve25519_dalek::constants::RISTRETTO_BASEPOINT_COMPRESSED; use curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT; use curve25519_dalek::ristretto::RistrettoPoint; use curve25519_dalek::scalar::Scalar; use curve25519_dalek::traits::MultiscalarMul; - use digest::{ExtendableOutput, Input, XofReader}; use sha3::{Sha3XofReader, Sha3_512, Shake256}; diff --git a/src/inner_product_proof.rs b/src/inner_product_proof.rs index 75443819..4e3f1013 100644 --- a/src/inner_product_proof.rs +++ b/src/inner_product_proof.rs @@ -1,15 +1,10 @@ #![allow(non_snake_case)] #![doc(include = "../docs/inner-product-protocol.md")] -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::vec::Vec; -#[cfg(feature = "alloc")] use alloc::borrow::Borrow; -#[cfg(feature = "std")] -use std::borrow::Borrow; use core::iter; use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint}; diff --git a/src/lib.rs b/src/lib.rs index bfabb072..2d18d359 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(feature = "alloc", feature(alloc))] #![feature(nll)] #![feature(external_doc)] #![feature(try_trait)] @@ -9,7 +8,6 @@ extern crate byteorder; -#[cfg(feature = "alloc")] extern crate alloc; #[cfg(feature = "std")] @@ -54,9 +52,6 @@ mod inner_product_proof; mod range_proof; mod transcript; -#[cfg(feature = "alloc")] -use alloc::vec::Vec; - pub use errors::ProofError; pub use generators::{BulletproofGens, BulletproofGensShare, PedersenGens}; pub use range_proof::RangeProof; diff --git a/src/range_proof/dealer.rs b/src/range_proof/dealer.rs index 896b9efa..c8460a3f 100644 --- a/src/range_proof/dealer.rs +++ b/src/range_proof/dealer.rs @@ -6,10 +6,8 @@ use core::iter; -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::vec::Vec; use curve25519_dalek::ristretto::RistrettoPoint; diff --git a/src/range_proof/messages.rs b/src/range_proof/messages.rs index ff6431c6..be609d75 100644 --- a/src/range_proof/messages.rs +++ b/src/range_proof/messages.rs @@ -4,10 +4,8 @@ //! For more explanation of how the `dealer`, `party`, and `messages` modules orchestrate the protocol execution, see //! [the API for the aggregated multiparty computation protocol](../aggregation/index.html#api-for-the-aggregated-multiparty-computation-protocol). -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::vec::Vec; use core::iter; use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint}; diff --git a/src/range_proof/mod.rs b/src/range_proof/mod.rs index 964f00c0..47b62f79 100644 --- a/src/range_proof/mod.rs +++ b/src/range_proof/mod.rs @@ -1,12 +1,10 @@ #![allow(non_snake_case)] #![doc(include = "../../docs/range-proof-protocol.md")] -#[cfg(feature = "alloc")] extern crate alloc; #[cfg(feature = "std")] extern crate rand; -#[cfg(feature = "alloc")] use alloc::vec::Vec; #[cfg(feature = "std")] use self::rand::thread_rng; diff --git a/src/range_proof/party.rs b/src/range_proof/party.rs index cc9a9d2c..8128448f 100644 --- a/src/range_proof/party.rs +++ b/src/range_proof/party.rs @@ -10,10 +10,8 @@ //! modules orchestrate the protocol execution, see the documentation //! in the [`aggregation`](::range_proof_mpc) module. -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::vec::Vec; use core::iter; use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint}; diff --git a/src/util.rs b/src/util.rs index b7920e85..ac5330ac 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,12 +1,9 @@ #![deny(missing_docs)] #![allow(non_snake_case)] -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::vec; -#[cfg(feature = "alloc")] use alloc::vec::Vec; use clear_on_drop::clear::Clear; use curve25519_dalek::scalar::Scalar;