mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -17,12 +17,12 @@ eth2_hashing = "0.3.0"
|
||||
ethereum-types = "0.12.1"
|
||||
arbitrary = { version = "1.0", features = ["derive"], optional = true }
|
||||
zeroize = { version = "1.4.2", features = ["zeroize_derive"] }
|
||||
blst = "0.3.3"
|
||||
blst = { version = "0.3.3", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["supranational"]
|
||||
fake_crypto = []
|
||||
milagro = ["milagro_bls"]
|
||||
supranational = []
|
||||
supranational = ["blst"]
|
||||
supranational-portable = ["supranational", "blst/portable"]
|
||||
supranational-force-adx = ["supranational", "blst/force-adx"]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#[cfg(feature = "supranational")]
|
||||
pub mod blst;
|
||||
pub mod fake_crypto;
|
||||
#[cfg(feature = "milagro")]
|
||||
|
||||
@@ -41,6 +41,7 @@ pub use generic_signature::{INFINITY_SIGNATURE, SIGNATURE_BYTES_LEN};
|
||||
pub use get_withdrawal_credentials::get_withdrawal_credentials;
|
||||
pub use zeroize_hash::ZeroizeHash;
|
||||
|
||||
#[cfg(feature = "supranational")]
|
||||
use blst::BLST_ERROR as BlstError;
|
||||
#[cfg(feature = "milagro")]
|
||||
use milagro_bls::AmclError;
|
||||
@@ -53,6 +54,7 @@ pub enum Error {
|
||||
#[cfg(feature = "milagro")]
|
||||
MilagroError(AmclError),
|
||||
/// An error was raised from the Supranational BLST BLS library.
|
||||
#[cfg(feature = "supranational")]
|
||||
BlstError(BlstError),
|
||||
/// The provided bytes were an incorrect length.
|
||||
InvalidByteLength { got: usize, expected: usize },
|
||||
@@ -71,6 +73,7 @@ impl From<AmclError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "supranational")]
|
||||
impl From<BlstError> for Error {
|
||||
fn from(e: BlstError) -> Error {
|
||||
Error::BlstError(e)
|
||||
@@ -130,6 +133,7 @@ macro_rules! define_mod {
|
||||
|
||||
#[cfg(feature = "milagro")]
|
||||
define_mod!(milagro_implementations, crate::impls::milagro::types);
|
||||
#[cfg(feature = "supranational")]
|
||||
define_mod!(blst_implementations, crate::impls::blst::types);
|
||||
#[cfg(feature = "fake_crypto")]
|
||||
define_mod!(
|
||||
|
||||
@@ -8,9 +8,9 @@ description = "Hashing primitives used in Ethereum 2.0"
|
||||
|
||||
[dependencies]
|
||||
lazy_static = { version = "1.4.0", optional = true }
|
||||
cpufeatures = { version = "0.2.2", optional = true }
|
||||
ring = "0.16.19"
|
||||
sha2 = "0.10.2"
|
||||
cpufeatures = "0.2.2"
|
||||
|
||||
[dev-dependencies]
|
||||
rustc-hex = "2.1.0"
|
||||
@@ -19,5 +19,6 @@ rustc-hex = "2.1.0"
|
||||
wasm-bindgen-test = "0.3.18"
|
||||
|
||||
[features]
|
||||
default = ["zero_hash_cache"]
|
||||
default = ["zero_hash_cache", "detect-cpufeatures"]
|
||||
zero_hash_cache = ["lazy_static"]
|
||||
detect-cpufeatures = ["cpufeatures"]
|
||||
|
||||
@@ -127,15 +127,15 @@ pub enum DynamicImpl {
|
||||
// Runtime latch for detecting the availability of SHA extensions on x86_64.
|
||||
//
|
||||
// Inspired by the runtime switch within the `sha2` crate itself.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[cfg(all(feature = "detect-cpufeatures", target_arch = "x86_64"))]
|
||||
cpufeatures::new!(x86_sha_extensions, "sha", "sse2", "ssse3", "sse4.1");
|
||||
|
||||
#[inline(always)]
|
||||
pub fn have_sha_extensions() -> bool {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[cfg(all(feature = "detect-cpufeatures", target_arch = "x86_64"))]
|
||||
return x86_sha_extensions::get();
|
||||
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
#[cfg(not(all(feature = "detect-cpufeatures", target_arch = "x86_64")))]
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,10 @@ impl Kdf {
|
||||
}
|
||||
|
||||
/// PRF for use in `pbkdf2`.
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Default)]
|
||||
pub enum Prf {
|
||||
#[serde(rename = "hmac-sha256")]
|
||||
#[default]
|
||||
HmacSha256,
|
||||
}
|
||||
|
||||
@@ -73,12 +74,6 @@ impl Prf {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Prf {
|
||||
fn default() -> Self {
|
||||
Prf::HmacSha256
|
||||
}
|
||||
}
|
||||
|
||||
/// Parameters for `pbkdf2` key derivation.
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
||||
Reference in New Issue
Block a user