diff --git a/substrate/client/consensus/beefy/Cargo.toml b/substrate/client/consensus/beefy/Cargo.toml index ad43a541b00d9..f2d806147e4ef 100644 --- a/substrate/client/consensus/beefy/Cargo.toml +++ b/substrate/client/consensus/beefy/Cargo.toml @@ -47,12 +47,3 @@ serde = { workspace = true, default-features = true } sp-mmr-primitives = { workspace = true, default-features = true } sp-tracing = { workspace = true, default-features = true } substrate-test-runtime-client = { workspace = true } - -[features] -# This feature adds BLS crypto primitives. It should not be used in production since -# the BLS implementation and interface may still be subject to significant change. -bls-experimental = [ - "sp-application-crypto/bls-experimental", - "sp-consensus-beefy/bls-experimental", - "sp-core/bls-experimental", -] diff --git a/substrate/client/consensus/beefy/src/keystore.rs b/substrate/client/consensus/beefy/src/keystore.rs index 888a11db89cbe..4b5ed1f60ee71 100644 --- a/substrate/client/consensus/beefy/src/keystore.rs +++ b/substrate/client/consensus/beefy/src/keystore.rs @@ -19,9 +19,7 @@ use codec::Decode; use log::warn; use sp_application_crypto::{key_types::BEEFY as BEEFY_KEY_TYPE, AppCrypto, RuntimeAppPublic}; -#[cfg(feature = "bls-experimental")] -use sp_core::ecdsa_bls381; -use sp_core::{ecdsa, keccak_256}; +use sp_core::{ecdsa, ecdsa_bls381, keccak_256}; use sp_keystore::KeystorePtr; use std::marker::PhantomData; @@ -99,7 +97,6 @@ impl BeefyKeystore { sig_ref.to_vec() }, - #[cfg(feature = "bls-experimental")] ecdsa_bls381::CRYPTO_ID => { let public: ecdsa_bls381::Public = ecdsa_bls381::Public::try_from(public.as_slice()).unwrap(); @@ -145,7 +142,6 @@ impl BeefyKeystore { )) }), - #[cfg(feature = "bls-experimental")] ecdsa_bls381::CRYPTO_ID => store .ecdsa_bls381_public_keys(BEEFY_KEY_TYPE) .drain(..) @@ -183,10 +179,8 @@ impl From> for BeefyKeystore< #[cfg(test)] pub mod tests { - #[cfg(feature = "bls-experimental")] - use sp_consensus_beefy::ecdsa_bls_crypto; use sp_consensus_beefy::{ - ecdsa_crypto, + ecdsa_bls_crypto, ecdsa_crypto, test_utils::{BeefySignerAuthority, Keyring}, }; use sp_core::Pair as PairT; @@ -253,7 +247,6 @@ pub mod tests { let pk = store.ecdsa_generate_new(key_type, optional_seed.as_deref()).ok().unwrap(); AuthorityId::decode(&mut pk.as_ref()).unwrap() }, - #[cfg(feature = "bls-experimental")] ecdsa_bls381::CRYPTO_ID => { let pk = store .ecdsa_bls381_generate_new(key_type, optional_seed.as_deref()) @@ -270,7 +263,6 @@ pub mod tests { pair_verify_should_work::(); } - #[cfg(feature = "bls-experimental")] #[test] fn pair_verify_should_work_ecdsa_n_bls() { pair_verify_should_work::(); @@ -338,7 +330,6 @@ pub mod tests { pair_works::(); } - #[cfg(feature = "bls-experimental")] #[test] fn ecdsa_n_bls_pair_works() { pair_works::(); @@ -379,7 +370,6 @@ pub mod tests { authority_id_works::(); } - #[cfg(feature = "bls-experimental")] #[test] fn authority_id_works_for_ecdsa_n_bls() { authority_id_works::(); @@ -414,7 +404,6 @@ pub mod tests { sign_works::(); } - #[cfg(feature = "bls-experimental")] #[test] fn sign_works_for_ecdsa_n_bls() { sign_works::(); @@ -449,7 +438,6 @@ pub mod tests { sign_error::("ecdsa_sign_prehashed() failed"); } - #[cfg(feature = "bls-experimental")] #[test] fn sign_error_for_ecdsa_n_bls() { sign_error::("bls381_sign() failed"); @@ -498,7 +486,6 @@ pub mod tests { verify_works::(); } - #[cfg(feature = "bls-experimental")] #[test] fn verify_works_for_ecdsa_n_bls() { @@ -550,7 +537,6 @@ pub mod tests { public_keys_works::(); } - #[cfg(feature = "bls-experimental")] #[test] fn public_keys_works_for_ecdsa_n_bls() { diff --git a/substrate/client/keystore/Cargo.toml b/substrate/client/keystore/Cargo.toml index 8a5fa29c5485d..0488ab5dd2462 100644 --- a/substrate/client/keystore/Cargo.toml +++ b/substrate/client/keystore/Cargo.toml @@ -29,14 +29,6 @@ thiserror = { workspace = true } tempfile = { workspace = true } [features] -# This feature adds BLS crypto primitives. -# It should not be used in production since the implementation and interface may still -# be subject to significant changes. -bls-experimental = [ - "sp-core/bls-experimental", - "sp-keystore/bls-experimental", -] - # This feature adds Bandersnatch crypto primitives. # It should not be used in production since the implementation and interface may still # be subject to significant changes. diff --git a/substrate/client/keystore/src/local.rs b/substrate/client/keystore/src/local.rs index 0bde323ffcbb8..75634140d1ae7 100644 --- a/substrate/client/keystore/src/local.rs +++ b/substrate/client/keystore/src/local.rs @@ -37,9 +37,9 @@ sp_keystore::bandersnatch_experimental_enabled! { use sp_core::bandersnatch; } -sp_keystore::bls_experimental_enabled! { -use sp_core::{bls381, ecdsa_bls381, KeccakHasher, proof_of_possession::ProofOfPossessionGenerator}; -} +use sp_core::{ + bls381, ecdsa_bls381, proof_of_possession::ProofOfPossessionGenerator, KeccakHasher, +}; use crate::{Error, Result}; @@ -142,20 +142,18 @@ impl LocalKeystore { Ok(pre_output) } - sp_keystore::bls_experimental_enabled! { - fn generate_proof_of_possession( - &self, - key_type: KeyTypeId, - public: &T::Public, - owner: &[u8], - ) -> std::result::Result, TraitError> { - let proof_of_possession = self - .0 - .read() - .key_pair_by_type::(public, key_type)? - .map(|mut pair| pair.generate_proof_of_possession(owner)); - Ok(proof_of_possession) - } + fn generate_proof_of_possession( + &self, + key_type: KeyTypeId, + public: &T::Public, + owner: &[u8], + ) -> std::result::Result, TraitError> { + let proof_of_possession = self + .0 + .read() + .key_pair_by_type::(public, key_type)? + .map(|mut pair| pair.generate_proof_of_possession(owner)); + Ok(proof_of_possession) } } @@ -349,92 +347,93 @@ impl Keystore for LocalKeystore { } } - sp_keystore::bls_experimental_enabled! { - fn bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { - self.public_keys::(key_type) - } + fn bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { + self.public_keys::(key_type) + } - /// Generate a new pair compatible with the 'bls381' signature scheme. - /// - /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. - fn bls381_generate_new( - &self, - key_type: KeyTypeId, - seed: Option<&str>, - ) -> std::result::Result { - self.generate_new::(key_type, seed) - } + /// Generate a new pair compatible with the 'bls381' signature scheme. + /// + /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. + fn bls381_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> std::result::Result { + self.generate_new::(key_type, seed) + } - fn bls381_sign( - &self, - key_type: KeyTypeId, - public: &bls381::Public, - msg: &[u8], - ) -> std::result::Result, TraitError> { - self.sign::(key_type, public, msg) - } + fn bls381_sign( + &self, + key_type: KeyTypeId, + public: &bls381::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + self.sign::(key_type, public, msg) + } - fn bls381_generate_proof_of_possession( - &self, - key_type: KeyTypeId, - public: &bls381::Public, - owner: &[u8], - ) -> std::result::Result, TraitError> { - self.generate_proof_of_possession::(key_type, public, owner) - } + fn bls381_generate_proof_of_possession( + &self, + key_type: KeyTypeId, + public: &bls381::Public, + owner: &[u8], + ) -> std::result::Result, TraitError> { + self.generate_proof_of_possession::(key_type, public, owner) + } - fn ecdsa_bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { - self.public_keys::(key_type) - } + fn ecdsa_bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { + self.public_keys::(key_type) + } - /// Generate a new pair of paired-keys compatible with the '(ecdsa,bls381)' signature scheme. - /// - /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. - fn ecdsa_bls381_generate_new( - &self, - key_type: KeyTypeId, - seed: Option<&str>, - ) -> std::result::Result { - let pubkey = self.generate_new::(key_type, seed)?; + /// Generate a new pair of paired-keys compatible with the '(ecdsa,bls381)' signature scheme. + /// + /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. + fn ecdsa_bls381_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> std::result::Result { + let pubkey = self.generate_new::(key_type, seed)?; - let s = self - .0 - .read() - .additional - .get(&(key_type, pubkey.to_vec())) - .map(|s| s.to_string()) - .expect("Can retrieve seed"); - - // This is done to give the keystore access to individual keys, this is necessary to avoid - // unnecessary host functions for paired keys and re-use host functions implemented for each - // element of the pair. - self.generate_new::(key_type, Some(&*s)).expect("seed slice is valid"); - self.generate_new::(key_type, Some(&*s)).expect("seed slice is valid"); - - Ok(pubkey) - } + let s = self + .0 + .read() + .additional + .get(&(key_type, pubkey.to_vec())) + .map(|s| s.to_string()) + .expect("Can retrieve seed"); - fn ecdsa_bls381_sign( - &self, - key_type: KeyTypeId, - public: &ecdsa_bls381::Public, - msg: &[u8], - ) -> std::result::Result, TraitError> { - self.sign::(key_type, public, msg) - } + // This is done to give the keystore access to individual keys, this is necessary to avoid + // unnecessary host functions for paired keys and re-use host functions implemented for each + // element of the pair. + self.generate_new::(key_type, Some(&*s)) + .expect("seed slice is valid"); + self.generate_new::(key_type, Some(&*s)) + .expect("seed slice is valid"); - fn ecdsa_bls381_sign_with_keccak256( - &self, - key_type: KeyTypeId, - public: &ecdsa_bls381::Public, - msg: &[u8], - ) -> std::result::Result, TraitError> { - let sig = self.0 + Ok(pubkey) + } + + fn ecdsa_bls381_sign( + &self, + key_type: KeyTypeId, + public: &ecdsa_bls381::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + self.sign::(key_type, public, msg) + } + + fn ecdsa_bls381_sign_with_keccak256( + &self, + key_type: KeyTypeId, + public: &ecdsa_bls381::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + let sig = self + .0 .read() .key_pair_by_type::(public, key_type)? .map(|pair| pair.sign_with_hasher::(msg)); - Ok(sig) - } + Ok(sig) } } @@ -861,7 +860,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_generate_with_none_works() { use sp_core::testing::ECDSA_BLS381; @@ -889,7 +887,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_generate_with_seed_works() { use sp_core::testing::ECDSA_BLS381; diff --git a/substrate/primitives/application-crypto/Cargo.toml b/substrate/primitives/application-crypto/Cargo.toml index e9f3d47024710..ab03a323a7ad2 100644 --- a/substrate/primitives/application-crypto/Cargo.toml +++ b/substrate/primitives/application-crypto/Cargo.toml @@ -48,11 +48,6 @@ full_crypto = [ "sp-io/disable_panic_handler", ] -# This feature adds BLS crypto primitives. -# It should not be used in production since the implementation and interface may still -# be subject to significant changes. -bls-experimental = ["sp-core/bls-experimental", "sp-io/bls-experimental"] - # This feature adds Bandersnatch crypto primitives. # It should not be used in production since the implementation and interface may still # be subject to significant changes. diff --git a/substrate/primitives/application-crypto/check-features-variants.sh b/substrate/primitives/application-crypto/check-features-variants.sh index 811f124d926bc..679c10f363a1c 100755 --- a/substrate/primitives/application-crypto/check-features-variants.sh +++ b/substrate/primitives/application-crypto/check-features-variants.sh @@ -10,5 +10,3 @@ cargo check --release --target=$T --no-default-features --features="full_crypto cargo check --release --target=$T --no-default-features --features="serde" cargo check --release --target=$T --no-default-features --features="serde,full_crypto" cargo check --release --target=$T --no-default-features --features="bandersnatch-experimental" -cargo check --release --target=$T --no-default-features --features="bls-experimental" -cargo check --release --target=$T --no-default-features --features="bls-experimental,full_crypto" diff --git a/substrate/primitives/application-crypto/src/lib.rs b/substrate/primitives/application-crypto/src/lib.rs index 5c51bad18ac9f..2269678eefef4 100644 --- a/substrate/primitives/application-crypto/src/lib.rs +++ b/substrate/primitives/application-crypto/src/lib.rs @@ -46,10 +46,8 @@ pub use serde; #[cfg(feature = "bandersnatch-experimental")] pub mod bandersnatch; -#[cfg(feature = "bls-experimental")] pub mod bls381; pub mod ecdsa; -#[cfg(feature = "bls-experimental")] pub mod ecdsa_bls381; pub mod ed25519; pub mod sr25519; diff --git a/substrate/primitives/application-crypto/test/Cargo.toml b/substrate/primitives/application-crypto/test/Cargo.toml index 22f9655a4917b..7429136dfef92 100644 --- a/substrate/primitives/application-crypto/test/Cargo.toml +++ b/substrate/primitives/application-crypto/test/Cargo.toml @@ -22,6 +22,3 @@ sp-core = { workspace = true } sp-keystore = { workspace = true } sp-tracing = { workspace = true, default-features = true } substrate-test-runtime-client = { workspace = true } - -[features] -bls-experimental = ["substrate-test-runtime-client/bls-experimental"] diff --git a/substrate/primitives/application-crypto/test/src/lib.rs b/substrate/primitives/application-crypto/test/src/lib.rs index 008092393971c..8be8d40254ffa 100644 --- a/substrate/primitives/application-crypto/test/src/lib.rs +++ b/substrate/primitives/application-crypto/test/src/lib.rs @@ -17,7 +17,7 @@ //! Integration tests for application crypto -#[cfg(all(test, feature = "bls-experimental"))] +#[cfg(test)] mod bls381; #[cfg(test)] mod ecdsa; @@ -26,5 +26,5 @@ mod ed25519; #[cfg(test)] mod sr25519; -#[cfg(all(test, feature = "bls-experimental"))] +#[cfg(test)] mod ecdsa_bls381; diff --git a/substrate/primitives/consensus/beefy/Cargo.toml b/substrate/primitives/consensus/beefy/Cargo.toml index 572e46d8de8d8..366d522bf6b6b 100644 --- a/substrate/primitives/consensus/beefy/Cargo.toml +++ b/substrate/primitives/consensus/beefy/Cargo.toml @@ -59,10 +59,3 @@ serde = [ "sp-core/serde", "sp-runtime/serde", ] - -# This feature adds BLS crypto primitives. It should not be used in production since -# the BLS implementation and interface may still be subject to significant change. -bls-experimental = [ - "sp-application-crypto/bls-experimental", - "sp-core/bls-experimental", -] diff --git a/substrate/primitives/consensus/beefy/src/commitment.rs b/substrate/primitives/consensus/beefy/src/commitment.rs index 49547ed877ecc..b72609cbe096b 100644 --- a/substrate/primitives/consensus/beefy/src/commitment.rs +++ b/substrate/primitives/consensus/beefy/src/commitment.rs @@ -340,7 +340,6 @@ mod tests { use sp_core::Pair; use sp_crypto_hashing::keccak_256; - #[cfg(feature = "bls-experimental")] use crate::bls_crypto::Signature as BlsSignature; type TestCommitment = Commitment; @@ -351,16 +350,9 @@ mod tests { type TestEcdsaSignedCommitment = SignedCommitment; type TestVersionedFinalityProof = VersionedFinalityProof; - // Types for commitment supporting aggregatable bls signature - #[cfg(feature = "bls-experimental")] - #[derive(Clone, Debug, PartialEq, codec::Encode, codec::Decode)] - struct BlsAggregatableSignature(BlsSignature); - - #[cfg(feature = "bls-experimental")] #[derive(Clone, Debug, PartialEq, codec::Encode, codec::Decode)] struct EcdsaBlsSignaturePair(EcdsaSignature, BlsSignature); - #[cfg(feature = "bls-experimental")] type TestBlsSignedCommitment = SignedCommitment; // Generates mock aggregatable ecdsa signature for generating test commitment @@ -379,7 +371,6 @@ mod tests { // Generates mock aggregatable bls signature for generating test commitment // BLS signatures - #[cfg(feature = "bls-experimental")] fn mock_bls_signatures() -> (BlsSignature, BlsSignature) { let alice = sp_core::bls::Pair::from_string("//Alice", None).unwrap(); @@ -450,7 +441,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn signed_commitment_encode_decode_ecdsa_n_bls() { // given let payload = diff --git a/substrate/primitives/consensus/beefy/src/lib.rs b/substrate/primitives/consensus/beefy/src/lib.rs index fe7ef724c1fa7..2ca638c106a39 100644 --- a/substrate/primitives/consensus/beefy/src/lib.rs +++ b/substrate/primitives/consensus/beefy/src/lib.rs @@ -140,7 +140,6 @@ pub mod ecdsa_crypto { /// Your code should use the above types as concrete types for all crypto related /// functionality. -#[cfg(feature = "bls-experimental")] pub mod bls_crypto { use super::{AuthorityIdBound, BeefyAuthorityId, Hash, RuntimeAppPublic, KEY_TYPE}; use sp_application_crypto::{app_crypto, bls381}; @@ -182,7 +181,6 @@ pub mod bls_crypto { /// /// Your code should use the above types as concrete types for all crypto related /// functionality. -#[cfg(feature = "bls-experimental")] pub mod ecdsa_bls_crypto { use super::{AuthorityIdBound, BeefyAuthorityId, Hash, RuntimeAppPublic, KEY_TYPE}; use sp_application_crypto::{app_crypto, ecdsa_bls381}; @@ -612,7 +610,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn bls_beefy_verify_works() { let msg = &b"test-message"[..]; let (pair, _) = bls_crypto::Pair::generate(); @@ -628,7 +625,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn ecdsa_bls_beefy_verify_works() { let msg = &b"test-message"[..]; let (pair, _) = ecdsa_bls_crypto::Pair::generate(); diff --git a/substrate/primitives/consensus/beefy/src/test_utils.rs b/substrate/primitives/consensus/beefy/src/test_utils.rs index 4460bcefd45f9..b353d977e93b9 100644 --- a/substrate/primitives/consensus/beefy/src/test_utils.rs +++ b/substrate/primitives/consensus/beefy/src/test_utils.rs @@ -15,11 +15,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(feature = "bls-experimental")] -use crate::ecdsa_bls_crypto; use crate::{ - ecdsa_crypto, AuthorityIdBound, BeefySignatureHasher, Commitment, DoubleVotingProof, - ForkVotingProof, FutureBlockVotingProof, Payload, ValidatorSetId, VoteMessage, + ecdsa_bls_crypto, ecdsa_crypto, AuthorityIdBound, BeefySignatureHasher, Commitment, + DoubleVotingProof, ForkVotingProof, FutureBlockVotingProof, Payload, ValidatorSetId, + VoteMessage, }; use sp_application_crypto::{AppCrypto, AppPair, RuntimeAppPublic, Wraps}; use sp_core::{ecdsa, Pair}; @@ -63,7 +62,6 @@ where } } -#[cfg(feature = "bls-experimental")] impl BeefySignerAuthority for ::Pair where MsgHash: Hash, diff --git a/substrate/primitives/consensus/beefy/src/witness.rs b/substrate/primitives/consensus/beefy/src/witness.rs index f27660cc0ca53..804a4a1e97d16 100644 --- a/substrate/primitives/consensus/beefy/src/witness.rs +++ b/substrate/primitives/consensus/beefy/src/witness.rs @@ -84,10 +84,8 @@ mod tests { use crate::{ecdsa_crypto::Signature as EcdsaSignature, known_payloads, Payload}; - #[cfg(feature = "bls-experimental")] use crate::bls_crypto::Signature as BlsSignature; - #[cfg(feature = "bls-experimental")] use w3f_bls::{ single_pop_aggregator::SignatureAggregatorAssumingPoP, Message, SerializableToBytes, Signed, TinyBLS381, @@ -100,14 +98,11 @@ mod tests { type TestEcdsaSignedCommitmentWitness = SignedCommitmentWitness>>; - #[cfg(feature = "bls-experimental")] #[derive(Clone, Debug, PartialEq, codec::Encode, codec::Decode)] struct EcdsaBlsSignaturePair(EcdsaSignature, BlsSignature); // types for commitment containing bls signature along side ecdsa signature - #[cfg(feature = "bls-experimental")] type TestBlsSignedCommitment = SignedCommitment; - #[cfg(feature = "bls-experimental")] type TestBlsSignedCommitmentWitness = SignedCommitmentWitness>; // The mock signatures are equivalent to the ones produced by the BEEFY keystore @@ -125,7 +120,6 @@ mod tests { // Generates mock aggregatable bls signature for generating test commitment // BLS signatures - #[cfg(feature = "bls-experimental")] fn mock_bls_signatures() -> (BlsSignature, BlsSignature) { let alice = sp_core::bls::Pair::from_string("//Alice", None).unwrap(); @@ -151,7 +145,6 @@ mod tests { SignedCommitment { commitment, signatures: vec![None, None, Some(sigs.0), Some(sigs.1)] } } - #[cfg(feature = "bls-experimental")] fn ecdsa_and_bls_signed_commitment() -> TestBlsSignedCommitment { let payload = Payload::from_single_entry( known_payloads::MMR_ROOT_ID, @@ -188,7 +181,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn should_convert_dually_signed_commitment_to_witness() { // given let signed = ecdsa_and_bls_signed_commitment(); diff --git a/substrate/primitives/core/Cargo.toml b/substrate/primitives/core/Cargo.toml index 892990b0e293a..0ec53fb49c613 100644 --- a/substrate/primitives/core/Cargo.toml +++ b/substrate/primitives/core/Cargo.toml @@ -65,8 +65,8 @@ k256 = { features = ["alloc", "ecdsa"], workspace = true } secp256k1 = { features = ["alloc", "recovery"], optional = true, workspace = true } # bls crypto -sha2 = { optional = true, workspace = true } -w3f-bls = { optional = true, workspace = true } +sha2 = { workspace = true } +w3f-bls = { workspace = true } # bandersnatch crypto ark-vrf = { optional = true, workspace = true, features = ["bandersnatch", "ring"] } @@ -114,7 +114,7 @@ std = [ "secp256k1/global-context", "secp256k1/std", "serde/std", - "sha2?/std", + "sha2/std", "sp-crypto-hashing/std", "sp-debug-derive/std", "sp-externalities/std", @@ -124,7 +124,7 @@ std = [ "substrate-bip39/std", "thiserror", "tracing", - "w3f-bls?/std", + "w3f-bls/std", "zeroize/alloc", "zeroize/std", ] @@ -149,11 +149,6 @@ full_crypto = [ "blake2", ] -# This feature adds BLS crypto primitives. -# It should not be used in production since the implementation and interface may still -# be subject to significant changes. -bls-experimental = ["sha2", "w3f-bls"] - # This feature adds Bandersnatch crypto primitives. # It should not be used in production since the implementation and interface may still # be subject to significant changes. diff --git a/substrate/primitives/core/check-features-variants.sh b/substrate/primitives/core/check-features-variants.sh index 860d8365be386..038b6b092dc68 100755 --- a/substrate/primitives/core/check-features-variants.sh +++ b/substrate/primitives/core/check-features-variants.sh @@ -3,8 +3,6 @@ export RUSTFLAGS="-Cdebug-assertions=y -Dwarnings --cfg substrate_runtime" T=wasm32-unknown-unknown -cargo check --target=$T --release --no-default-features --features="bls-experimental" -cargo check --target=$T --release --no-default-features --features="full_crypto,bls-experimental" cargo check --target=$T --release --no-default-features --features="bandersnatch-experimental" cargo check --target=$T --release --no-default-features --features="full_crypto,serde,bandersnatch-experimental" cargo check --target=$T --release --no-default-features --features="full_crypto,serde" diff --git a/substrate/primitives/core/src/lib.rs b/substrate/primitives/core/src/lib.rs index 1b232b31e9786..0275b267752bd 100644 --- a/substrate/primitives/core/src/lib.rs +++ b/substrate/primitives/core/src/lib.rs @@ -70,7 +70,6 @@ pub mod uint; #[cfg(feature = "bandersnatch-experimental")] pub mod bandersnatch; -#[cfg(feature = "bls-experimental")] pub mod bls; pub mod crypto_bytes; pub mod ecdsa; @@ -78,9 +77,7 @@ pub mod ed25519; pub mod paired_crypto; pub mod sr25519; -#[cfg(feature = "bls-experimental")] pub use bls::{bls377, bls381}; -#[cfg(feature = "bls-experimental")] pub use paired_crypto::{ecdsa_bls377, ecdsa_bls381}; pub use self::{ diff --git a/substrate/primitives/core/src/paired_crypto.rs b/substrate/primitives/core/src/paired_crypto.rs index e7cab11a3b66c..9282c0ffd2e31 100644 --- a/substrate/primitives/core/src/paired_crypto.rs +++ b/substrate/primitives/core/src/paired_crypto.rs @@ -29,14 +29,10 @@ use crate::proof_of_possession::{ProofOfPossessionGenerator, ProofOfPossessionVe use alloc::vec::Vec; /// ECDSA and BLS12-377 paired crypto scheme -#[cfg(feature = "bls-experimental")] pub mod ecdsa_bls377 { - use crate::{bls377, crypto::CryptoTypeId, ecdsa}; #[cfg(feature = "full_crypto")] - use crate::{ - crypto::{Pair as PairT, UncheckedFrom}, - Hasher, - }; + use crate::crypto::UncheckedFrom; + use crate::{bls377, crypto::CryptoTypeId, ecdsa, Hasher, Pair as PairT}; /// An identifier used to match public keys against BLS12-377 keys pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"ecb7"); @@ -89,13 +85,13 @@ pub mod ecdsa_bls377 { type Pair = Pair; } - #[cfg(feature = "full_crypto")] impl Pair { /// Hashes the `message` with the specified [`Hasher`] before signing with the ECDSA secret /// component. /// /// The hasher does not affect the BLS12-377 component. This generates BLS12-377 Signature /// according to IETF standard. + #[cfg(feature = "full_crypto")] pub fn sign_with_hasher(&self, message: &[u8]) -> Signature where H: Hasher, @@ -145,14 +141,10 @@ pub mod ecdsa_bls377 { } /// ECDSA and BLS12-381 paired crypto scheme -#[cfg(feature = "bls-experimental")] pub mod ecdsa_bls381 { - use crate::{bls381, crypto::CryptoTypeId, ecdsa}; #[cfg(feature = "full_crypto")] - use crate::{ - crypto::{Pair as PairT, UncheckedFrom}, - Hasher, - }; + use crate::crypto::UncheckedFrom; + use crate::{bls381, crypto::CryptoTypeId, ecdsa, Hasher, Pair as PairT}; /// An identifier used to match public keys against BLS12-381 keys pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"ecb8"); @@ -210,13 +202,13 @@ pub mod ecdsa_bls381 { type Pair = Pair; } - #[cfg(feature = "full_crypto")] impl Pair { /// Hashes the `message` with the specified [`Hasher`] before signing with the ECDSA secret /// component. /// /// The hasher does not affect the BLS12-381 component. This generates BLS12-381 Signature /// according to IETF standard. + #[cfg(feature = "full_crypto")] pub fn sign_with_hasher(&self, message: &[u8]) -> Signature where H: Hasher, @@ -522,7 +514,7 @@ where } // Test set exercising the (ECDSA,BLS12-377) implementation -#[cfg(all(test, feature = "bls-experimental"))] +#[cfg(test)] mod tests { use super::*; #[cfg(feature = "serde")] diff --git a/substrate/primitives/io/Cargo.toml b/substrate/primitives/io/Cargo.toml index 57c71d92abcb7..5099288ca58b9 100644 --- a/substrate/primitives/io/Cargo.toml +++ b/substrate/primitives/io/Cargo.toml @@ -110,11 +110,6 @@ disable_allocator = [] # runtime without first upgrading your host client! improved_panic_error_reporting = [] -# This feature adds BLS crypto primitives. -# It should not be used in production since the implementation and interface may still -# be subject to significant changes. -bls-experimental = ["sp-core/bls-experimental", "sp-keystore/bls-experimental"] - # This feature adds Bandersnatch crypto primitives. # It should not be used in production since the implementation and interface may still # be subject to significant changes. diff --git a/substrate/primitives/io/src/lib.rs b/substrate/primitives/io/src/lib.rs index fbd627fb40b50..09ece02dbfd2d 100644 --- a/substrate/primitives/io/src/lib.rs +++ b/substrate/primitives/io/src/lib.rs @@ -109,7 +109,6 @@ use sp_core::{ LogLevelFilter, OpaquePeerId, RuntimeInterfaceLogLevel, H256, }; -#[cfg(feature = "bls-experimental")] use sp_core::{bls381, ecdsa_bls381}; #[cfg(not(substrate_runtime))] @@ -2761,36 +2760,143 @@ pub trait Crypto { /// /// The `seed` needs to be a valid utf8. /// - /// Returns the public key. - #[cfg(feature = "bls-experimental")] + /// Stores the public key in the provided output buffer. + #[wrapped] fn bls381_generate( &mut self, id: PassPointerAndReadCopy, seed: PassFatPointerAndDecode>>, - ) -> AllocateAndReturnPointer { + out: PassPointerAndWrite<&mut bls381::Public, 144>, + ) { let seed = seed.as_ref().map(|s| core::str::from_utf8(s).expect("Seed is valid utf8!")); - self.extension::() - .expect("No `keystore` associated for the current context!") - .bls381_generate_new(id, seed) - .expect("`bls381_generate` failed") + out.0.copy_from_slice( + &self + .extension::() + .expect("No `keystore` associated for the current context!") + .bls381_generate_new(id, seed) + .expect("`bls381_generate` failed"), + ); + } + + /// A convenience wrapper providing a developer-friendly interface for the `bls381_generate` + /// host function. + #[wrapper] + fn bls381_generate(id: KeyTypeId, seed: Option>) -> bls381::Public { + let mut public = bls381::Public::default(); + bls381_generate__wrapped(id, seed, &mut public); + public } /// Generate a 'bls12-381' Proof Of Possession for the corresponding public key. /// - /// Returns the Proof Of Possession as an option of the ['bls381::Signature'] type - /// or 'None' if an error occurs. - #[cfg(feature = "bls-experimental")] + /// Stores the Proof Of Possession in the provided output buffer. + /// Returns 0 on success, -1 on error. + #[wrapped] fn bls381_generate_proof_of_possession( &mut self, id: PassPointerAndReadCopy, pub_key: PassPointerAndRead<&bls381::Public, 144>, owner: PassFatPointerAndRead<&[u8]>, - ) -> AllocateAndReturnByCodec> { + out: PassPointerAndWrite<&mut bls381::ProofOfPossession, 224>, + ) -> ConvertAndReturnAs, RIIntResult, i64> { self.extension::() .expect("No `keystore` associated for the current context!") .bls381_generate_proof_of_possession(id, pub_key, owner) .ok() .flatten() + .map(|pop| { + out.0.copy_from_slice(&pop); + }) + .ok_or(()) + } + + /// A convenience wrapper providing a developer-friendly interface for the + /// `bls381_generate_proof_of_possession` host function. + #[wrapper] + fn bls381_generate_proof_of_possession( + id: KeyTypeId, + pub_key: &bls381::Public, + owner: &[u8], + ) -> Option { + let mut pop = bls381::ProofOfPossession::default(); + bls381_generate_proof_of_possession__wrapped(id, pub_key, owner, &mut pop).ok()?; + Some(pop) + } + + /// Returns the number of `bls12-381` public keys for the given key type in the keystore. + fn bls381_num_public_keys(&mut self, id: PassPointerAndReadCopy) -> u32 { + self.extension::() + .expect("No `keystore` associated for the current context!") + .bls381_public_keys(id) + .len() as u32 + } + + /// Returns the `bls12-381` public key for the given key type and index in the keystore. + /// Panics if the key index is out of bounds. + fn bls381_public_key( + &mut self, + id: PassPointerAndReadCopy, + index: u32, + out: PassPointerAndWrite<&mut bls381::Public, 144>, + ) { + out.0.copy_from_slice( + self.extension::() + .expect("No `keystore` associated for the current context!") + .bls381_public_keys(id) + .get(index as usize) + .expect("Key index out of bounds!"), + ); + } + + /// A convenience wrapper providing a developer-friendly interface for the obsoleted + /// `bls381_public_keys` host function + #[wrapper] + fn bls381_public_keys(id: KeyTypeId) -> Vec { + let num_keys = bls381_num_public_keys(id); + let mut keys = Vec::new(); + for i in 0..num_keys { + let mut key = bls381::Public::default(); + bls381_public_key(id, i, &mut key); + keys.push(key); + } + keys + } + + /// Sign the given `msg` with the `bls12-381` key that corresponds to the given public key and + /// key type in the keystore. + /// + /// Stores the signature in the provided output buffer. + /// Returns 0 on success, -1 on error. + #[wrapped] + fn bls381_sign( + &mut self, + id: PassPointerAndReadCopy, + pub_key: PassPointerAndRead<&bls381::Public, 144>, + msg: PassFatPointerAndRead<&[u8]>, + out: PassPointerAndWrite<&mut bls381::Signature, 112>, + ) -> ConvertAndReturnAs, RIIntResult, i64> { + self.extension::() + .expect("No `keystore` associated for the current context!") + .bls381_sign(id, pub_key, msg) + .ok() + .flatten() + .map(|sig| { + out.0.copy_from_slice(&sig); + }) + .ok_or(()) + } + + /// A convenience wrapper providing a developer-friendly interface for the `bls381_sign` host + /// function. + #[wrapper] + fn bls381_sign( + id: KeyTypeId, + pub_key: &bls381::Public, + message: &[u8], + ) -> Option { + let mut signature = bls381::Signature::default(); + bls381_sign__wrapped(id, pub_key, message, &mut signature).ok()?; + Some(signature) } /// Generate combination `ecdsa & bls12-381` key for the given key type using an optional `seed` @@ -2798,18 +2904,145 @@ pub trait Crypto { /// /// The `seed` needs to be a valid utf8. /// - /// Returns the public key. - #[cfg(feature = "bls-experimental")] + /// Stores the public key in the provided output buffer. + #[wrapped] fn ecdsa_bls381_generate( &mut self, id: PassPointerAndReadCopy, seed: PassFatPointerAndDecode>>, - ) -> AllocateAndReturnPointer { + out: PassPointerAndWrite<&mut ecdsa_bls381::Public, 177>, + ) { let seed = seed.as_ref().map(|s| core::str::from_utf8(s).expect("Seed is valid utf8!")); + out.0.copy_from_slice( + &self + .extension::() + .expect("No `keystore` associated for the current context!") + .ecdsa_bls381_generate_new(id, seed) + .expect("`ecdsa_bls381_generate` failed"), + ); + } + + /// A convenience wrapper providing a developer-friendly interface for the + /// `ecdsa_bls381_generate` host function. + #[wrapper] + fn ecdsa_bls381_generate(id: KeyTypeId, seed: Option>) -> ecdsa_bls381::Public { + let mut public = ecdsa_bls381::Public::default(); + ecdsa_bls381_generate__wrapped(id, seed, &mut public); + public + } + + /// Returns the number of `ecdsa & bls12-381` public keys for the given key type in the + /// keystore. + fn ecdsa_bls381_num_public_keys(&mut self, id: PassPointerAndReadCopy) -> u32 { + self.extension::() + .expect("No `keystore` associated for the current context!") + .ecdsa_bls381_public_keys(id) + .len() as u32 + } + + /// Returns the `ecdsa & bls12-381` public key for the given key type and index in the keystore. + /// Panics if the key index is out of bounds. + fn ecdsa_bls381_public_key( + &mut self, + id: PassPointerAndReadCopy, + index: u32, + out: PassPointerAndWrite<&mut ecdsa_bls381::Public, 177>, + ) { + out.0.copy_from_slice( + self.extension::() + .expect("No `keystore` associated for the current context!") + .ecdsa_bls381_public_keys(id) + .get(index as usize) + .expect("Key index out of bounds!"), + ); + } + + /// A convenience wrapper providing a developer-friendly interface for the obsoleted + /// `ecdsa_bls381_public_keys` host function + #[wrapper] + fn ecdsa_bls381_public_keys(id: KeyTypeId) -> Vec { + let num_keys = ecdsa_bls381_num_public_keys(id); + let mut keys = Vec::new(); + for i in 0..num_keys { + let mut key = ecdsa_bls381::Public::default(); + ecdsa_bls381_public_key(id, i, &mut key); + keys.push(key); + } + keys + } + + /// Sign the given `msg` with the `ecdsa & bls12-381` key that corresponds to the given public + /// key and key type in the keystore. + /// + /// Stores the signature in the provided output buffer. + /// Returns 0 on success, -1 on error. + #[wrapped] + fn ecdsa_bls381_sign( + &mut self, + id: PassPointerAndReadCopy, + pub_key: PassPointerAndRead<&ecdsa_bls381::Public, 177>, + msg: PassFatPointerAndRead<&[u8]>, + out: PassPointerAndWrite<&mut ecdsa_bls381::Signature, 177>, + ) -> ConvertAndReturnAs, RIIntResult, i64> { self.extension::() .expect("No `keystore` associated for the current context!") - .ecdsa_bls381_generate_new(id, seed) - .expect("`ecdsa_bls381_generate` failed") + .ecdsa_bls381_sign(id, pub_key, msg) + .ok() + .flatten() + .map(|sig| { + out.0.copy_from_slice(&sig); + }) + .ok_or(()) + } + + /// A convenience wrapper providing a developer-friendly interface for the `ecdsa_bls381_sign` + /// host function. + #[wrapper] + fn ecdsa_bls381_sign( + id: KeyTypeId, + pub_key: &ecdsa_bls381::Public, + message: &[u8], + ) -> Option { + let mut signature = ecdsa_bls381::Signature::default(); + ecdsa_bls381_sign__wrapped(id, pub_key, message, &mut signature).ok()?; + Some(signature) + } + + /// Sign the given `msg` with the `ecdsa & bls12-381` key that corresponds to the given public + /// key and key type in the keystore using keccak256 hash for the ECDSA component. + /// + /// Stores the signature in the provided output buffer. + /// Returns 0 on success, -1 on error. + #[wrapped] + fn ecdsa_bls381_sign_with_keccak256( + &mut self, + id: PassPointerAndReadCopy, + pub_key: PassPointerAndRead<&ecdsa_bls381::Public, 177>, + msg: PassFatPointerAndRead<&[u8]>, + out: PassPointerAndWrite<&mut ecdsa_bls381::Signature, 177>, + ) -> ConvertAndReturnAs, RIIntResult, i64> { + self.extension::() + .expect("No `keystore` associated for the current context!") + .ecdsa_bls381_sign_with_keccak256(id, pub_key, msg) + .ok() + .flatten() + .map(|sig| { + out.0.copy_from_slice(&sig); + }) + .ok_or(()) + } + + /// A convenience wrapper providing a developer-friendly interface for the + /// `ecdsa_bls381_sign_with_keccak256` host function. + #[wrapper] + fn ecdsa_bls381_sign_with_keccak256( + id: KeyTypeId, + pub_key: &ecdsa_bls381::Public, + message: &[u8], + ) -> Option { + let mut signature = ecdsa_bls381::Signature::default(); + ecdsa_bls381_sign_with_keccak256__wrapped(id, pub_key, message, &mut signature).ok()?; + Some(signature) } /// Generate a `bandersnatch` key pair for the given key type using an optional diff --git a/substrate/primitives/keystore/Cargo.toml b/substrate/primitives/keystore/Cargo.toml index 3dae5cc2abcbd..c9c677bc44c44 100644 --- a/substrate/primitives/keystore/Cargo.toml +++ b/substrate/primitives/keystore/Cargo.toml @@ -25,11 +25,6 @@ sp-externalities = { workspace = true } default = ["std"] std = ["codec/std", "dep:parking_lot", "sp-core/std", "sp-externalities/std"] -# This feature adds BLS crypto primitives. -# It should not be used in production since the implementation and interface may still -# be subject to significant changes. -bls-experimental = ["sp-core/bls-experimental"] - # This feature adds Bandersnatch crypto primitives. # It should not be used in production since the implementation and interface may still # be subject to significant changes. diff --git a/substrate/primitives/keystore/src/lib.rs b/substrate/primitives/keystore/src/lib.rs index e7224bfc2ca1c..43dd96a28d7e0 100644 --- a/substrate/primitives/keystore/src/lib.rs +++ b/substrate/primitives/keystore/src/lib.rs @@ -26,11 +26,10 @@ pub mod testing; #[cfg(feature = "bandersnatch-experimental")] use sp_core::bandersnatch; -#[cfg(feature = "bls-experimental")] -use sp_core::{bls381, ecdsa_bls381}; use sp_core::{ + bls381, crypto::{ByteArray, CryptoTypeId, KeyTypeId}, - ecdsa, ed25519, sr25519, + ecdsa, ecdsa_bls381, ed25519, sr25519, }; use alloc::{string::String, sync::Arc, vec::Vec}; @@ -277,18 +276,15 @@ pub trait Keystore: Send + Sync { ) -> Result, Error>; /// Returns all bls12-381 public keys for the given key type. - #[cfg(feature = "bls-experimental")] fn bls381_public_keys(&self, id: KeyTypeId) -> Vec; /// Returns all (ecdsa,bls12-381) paired public keys for the given key type. - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_public_keys(&self, id: KeyTypeId) -> Vec; /// Generate a new bls381 key pair for the given key type and an optional seed. /// /// Returns an `bls381::Public` key of the generated key pair or an `Err` if /// something failed during key generation. - #[cfg(feature = "bls-experimental")] fn bls381_generate_new( &self, key_type: KeyTypeId, @@ -299,7 +295,6 @@ pub trait Keystore: Send + Sync { /// /// Returns an `ecdsa_bls381::Public` key of the generated key pair or an `Err` if /// something failed during key generation. - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_generate_new( &self, key_type: KeyTypeId, @@ -314,7 +309,6 @@ pub trait Keystore: Send + Sync { /// Returns an [`bls381::Signature`] or `None` in case the given `key_type` /// and `public` combination doesn't exist in the keystore. /// An `Err` will be returned if generating the signature itself failed. - #[cfg(feature = "bls-experimental")] fn bls381_sign( &self, key_type: KeyTypeId, @@ -330,7 +324,6 @@ pub trait Keystore: Send + Sync { /// Returns an ['bls381::Signature'] or 'None' in case the given 'key_type' /// and 'public' combination doesn't exist in the keystore. /// An 'Err' will be returned if generating the proof of possession itself failed. - #[cfg(feature = "bls-experimental")] fn bls381_generate_proof_of_possession( &self, key_type: KeyTypeId, @@ -346,7 +339,6 @@ pub trait Keystore: Send + Sync { /// Returns an [`ecdsa_bls381::Signature`] or `None` in case the given `key_type` /// and `public` combination doesn't exist in the keystore. /// An `Err` will be returned if generating the signature itself failed. - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_sign( &self, key_type: KeyTypeId, @@ -364,7 +356,6 @@ pub trait Keystore: Send + Sync { /// Returns an [`ecdsa_bls381::Signature`] or `None` in case the given `key_type` /// and `public` combination doesn't exist in the keystore. /// An `Err` will be returned if generating the signature itself failed. - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_sign_with_keccak256( &self, key_type: KeyTypeId, @@ -434,13 +425,11 @@ pub trait Keystore: Send + Sync { .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; self.bandersnatch_sign(id, &public, msg)?.map(|s| s.encode()) }, - #[cfg(feature = "bls-experimental")] bls381::CRYPTO_ID => { let public = bls381::Public::from_slice(public) .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; self.bls381_sign(id, &public, msg)?.map(|s| s.encode()) }, - #[cfg(feature = "bls-experimental")] ecdsa_bls381::CRYPTO_ID => { let public = ecdsa_bls381::Public::from_slice(public) .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; @@ -598,17 +587,14 @@ impl Keystore for Arc { (**self).bandersnatch_ring_vrf_sign(key_type, public, input, prover) } - #[cfg(feature = "bls-experimental")] fn bls381_public_keys(&self, id: KeyTypeId) -> Vec { (**self).bls381_public_keys(id) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_public_keys(&self, id: KeyTypeId) -> Vec { (**self).ecdsa_bls381_public_keys(id) } - #[cfg(feature = "bls-experimental")] fn bls381_generate_new( &self, key_type: KeyTypeId, @@ -617,7 +603,6 @@ impl Keystore for Arc { (**self).bls381_generate_new(key_type, seed) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_generate_new( &self, key_type: KeyTypeId, @@ -626,7 +611,6 @@ impl Keystore for Arc { (**self).ecdsa_bls381_generate_new(key_type, seed) } - #[cfg(feature = "bls-experimental")] fn bls381_sign( &self, key_type: KeyTypeId, @@ -636,7 +620,6 @@ impl Keystore for Arc { (**self).bls381_sign(key_type, public, msg) } - #[cfg(feature = "bls-experimental")] fn bls381_generate_proof_of_possession( &self, key_type: KeyTypeId, @@ -646,7 +629,6 @@ impl Keystore for Arc { (**self).bls381_generate_proof_of_possession(key_type, public, owner) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_sign( &self, key_type: KeyTypeId, @@ -656,7 +638,6 @@ impl Keystore for Arc { (**self).ecdsa_bls381_sign(key_type, public, msg) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_sign_with_keccak256( &self, key_type: KeyTypeId, @@ -706,9 +687,3 @@ sp_core::generate_feature_enabled_macro!( feature = "bandersnatch-experimental", $ ); - -sp_core::generate_feature_enabled_macro!( - bls_experimental_enabled, - feature = "bls-experimental", - $ -); diff --git a/substrate/primitives/keystore/src/testing.rs b/substrate/primitives/keystore/src/testing.rs index b2ef12d267689..46ddd6b6acebc 100644 --- a/substrate/primitives/keystore/src/testing.rs +++ b/substrate/primitives/keystore/src/testing.rs @@ -21,13 +21,12 @@ use crate::{Error, Keystore, KeystorePtr}; #[cfg(feature = "bandersnatch-experimental")] use sp_core::bandersnatch; -#[cfg(feature = "bls-experimental")] -use sp_core::{ - bls381, ecdsa_bls381, proof_of_possession::ProofOfPossessionGenerator, KeccakHasher, -}; use sp_core::{ + bls381, crypto::{ByteArray, KeyTypeId, Pair, VrfSecret}, - ecdsa, ed25519, sr25519, + ecdsa, ecdsa_bls381, ed25519, + proof_of_possession::ProofOfPossessionGenerator, + sr25519, KeccakHasher, }; use parking_lot::RwLock; @@ -128,7 +127,6 @@ impl MemoryKeystore { Ok(pre_output) } - #[cfg(feature = "bls-experimental")] fn generate_proof_of_possession( &self, key_type: KeyTypeId, @@ -292,12 +290,10 @@ impl Keystore for MemoryKeystore { self.vrf_pre_output::(key_type, public, input) } - #[cfg(feature = "bls-experimental")] fn bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { self.public_keys::(key_type) } - #[cfg(feature = "bls-experimental")] fn bls381_generate_new( &self, key_type: KeyTypeId, @@ -306,7 +302,6 @@ impl Keystore for MemoryKeystore { self.generate_new::(key_type, seed) } - #[cfg(feature = "bls-experimental")] fn bls381_sign( &self, key_type: KeyTypeId, @@ -316,7 +311,6 @@ impl Keystore for MemoryKeystore { self.sign::(key_type, public, msg) } - #[cfg(feature = "bls-experimental")] fn bls381_generate_proof_of_possession( &self, key_type: KeyTypeId, @@ -326,12 +320,10 @@ impl Keystore for MemoryKeystore { self.generate_proof_of_possession::(key_type, public, owner) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { self.public_keys::(key_type) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_generate_new( &self, key_type: KeyTypeId, @@ -357,7 +349,6 @@ impl Keystore for MemoryKeystore { Ok(pubkey) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_sign( &self, key_type: KeyTypeId, @@ -367,7 +358,6 @@ impl Keystore for MemoryKeystore { self.sign::(key_type, public, msg) } - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_sign_with_keccak256( &self, key_type: KeyTypeId, @@ -528,7 +518,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_sign_with_keccak_works() { use sp_core::testing::ECDSA_BLS377; @@ -560,7 +549,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_generate_with_none_works() { use sp_core::testing::ECDSA_BLS381; @@ -588,7 +576,6 @@ mod tests { } #[test] - #[cfg(feature = "bls-experimental")] fn ecdsa_bls381_generate_with_seed_works() { use sp_core::testing::ECDSA_BLS381; diff --git a/substrate/test-utils/runtime/Cargo.toml b/substrate/test-utils/runtime/Cargo.toml index 91bf368f573cd..eb57dfb2a1e42 100644 --- a/substrate/test-utils/runtime/Cargo.toml +++ b/substrate/test-utils/runtime/Cargo.toml @@ -122,8 +122,3 @@ std = [ # Special feature to disable logging disable-logging = ["sp-api/disable-logging"] - -# This feature adds BLS crypto primitives. -# It should not be used in production since the implementation and interface may still -# be subject to significant changes. -bls-experimental = ["sp-application-crypto/bls-experimental"] diff --git a/substrate/test-utils/runtime/client/Cargo.toml b/substrate/test-utils/runtime/client/Cargo.toml index 8aa87aad2859b..5dd3c304f4a8e 100644 --- a/substrate/test-utils/runtime/client/Cargo.toml +++ b/substrate/test-utils/runtime/client/Cargo.toml @@ -26,6 +26,3 @@ sp-core = { workspace = true, default-features = true } sp-runtime = { workspace = true, default-features = true } substrate-test-client = { workspace = true } substrate-test-runtime = { workspace = true } - -[features] -bls-experimental = ["substrate-test-runtime/bls-experimental"] diff --git a/substrate/test-utils/runtime/src/lib.rs b/substrate/test-utils/runtime/src/lib.rs index 172c626efc301..eea5cf82ac5a9 100644 --- a/substrate/test-utils/runtime/src/lib.rs +++ b/substrate/test-utils/runtime/src/lib.rs @@ -51,7 +51,6 @@ use sp_keyring::Sr25519Keyring; use sp_application_crypto::{ecdsa, ed25519, sr25519, RuntimeAppPublic}; -#[cfg(feature = "bls-experimental")] use sp_application_crypto::{bls381, ecdsa_bls381}; use sp_core::OpaqueMetadata; @@ -189,7 +188,6 @@ pub type Header = sp_runtime::generic::Header; /// Balance of an account. pub type Balance = u64; -#[cfg(feature = "bls-experimental")] mod bls { use sp_application_crypto::{bls381, ecdsa_bls381}; pub type Bls381Public = bls381::AppPublic; @@ -197,13 +195,6 @@ mod bls { pub type EcdsaBls381Public = ecdsa_bls381::AppPublic; pub type EcdsaBls381Pop = ecdsa_bls381::AppProofOfPossession; } -#[cfg(not(feature = "bls-experimental"))] -mod bls { - pub type Bls381Public = (); - pub type Bls381Pop = (); - pub type EcdsaBls381Public = (); - pub type EcdsaBls381Pop = (); -} pub use bls::*; decl_runtime_apis! { @@ -624,26 +615,14 @@ impl_runtime_apis! { test_ecdsa_crypto() } - #[cfg(feature = "bls-experimental")] fn test_bls381_crypto() -> (Bls381Pop, Bls381Public) { test_bls381_crypto() } - #[cfg(feature = "bls-experimental")] fn test_ecdsa_bls381_crypto() -> (EcdsaBls381Pop, EcdsaBls381Public) { test_ecdsa_bls381_crypto() } - #[cfg(not(feature = "bls-experimental"))] - fn test_bls381_crypto() -> (Bls381Pop, Bls381Public) { - ((),()) - } - - #[cfg(not(feature = "bls-experimental"))] - fn test_ecdsa_bls381_crypto() -> (EcdsaBls381Pop, EcdsaBls381Public) { - ((), ()) - } - fn test_storage() { test_read_storage(); test_read_child_storage(); @@ -887,7 +866,6 @@ fn test_ecdsa_crypto() -> (ecdsa::AppSignature, ecdsa::AppPublic, ecdsa::AppProo (signature, public0, proof_of_possession) } -#[cfg(feature = "bls-experimental")] fn test_bls381_crypto() -> (Bls381Pop, Bls381Public) { let mut public0 = bls381::AppPublic::generate_pair(None); @@ -899,7 +877,6 @@ fn test_bls381_crypto() -> (Bls381Pop, Bls381Public) { (proof_of_possession, public0) } -#[cfg(feature = "bls-experimental")] fn test_ecdsa_bls381_crypto() -> (EcdsaBls381Pop, EcdsaBls381Public) { let mut public0 = ecdsa_bls381::AppPublic::generate_pair(None);