mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 15:21:05 +00:00
Bandersnatch VRF (#14412)
* Introduce bandersnatch vrf * Some documentation * Fix tests * Fix docs refs * Some more docs * Comments about key derivation * Make clippy happy * Fix ring context enc/dec test * Fix docs * Switch to upstream ring-vrf * Use sub-domains to construct VrfInput * Bandersnatch VRF experimental feature * Restore upstream dep * Fix feature flags * Apply typo fix Co-authored-by: Anton <anton.kalyaev@gmail.com> * Bump bandersnatch-vrfs * Weiestrass form has been selected * Rename bandersnatch testing app crypto id * Support for seed recovery * Clarified domain size <-> key size relationship * cargo fmt * Trigger CI * Some required tweaks to crypto types * Remove leftovers from Cargo.toml * Remove some TODO notes * Simplification of structs construction * Trigger CI * Apply review suggestion Co-authored-by: Koute <koute@users.noreply.github.com> * Docs typo * Fix keystore tests * Consistence * Add ref to git rependency * Static check of MAX_VRF_IOS value * Clarify behavior for out of ring keys signatures * Add test for ring-vrf to the keystore * Fix docs --------- Co-authored-by: Anton <anton.kalyaev@gmail.com> Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
@@ -93,8 +93,16 @@ 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 BLS implementation and interface may still be subject to significant change.
|
||||
# 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-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.
|
||||
bandersnatch-experimental = [
|
||||
"sp-keystore/bandersnatch-experimental",
|
||||
]
|
||||
|
||||
@@ -92,6 +92,8 @@ use sp_core::{
|
||||
#[cfg(feature = "std")]
|
||||
use sp_keystore::KeystoreExt;
|
||||
|
||||
#[cfg(feature = "bandersnatch-experimental")]
|
||||
use sp_core::bandersnatch;
|
||||
use sp_core::{
|
||||
crypto::KeyTypeId,
|
||||
ecdsa, ed25519,
|
||||
@@ -1190,13 +1192,13 @@ pub trait Crypto {
|
||||
Ok(pubkey.serialize())
|
||||
}
|
||||
|
||||
#[cfg(feature = "bls-experimental")]
|
||||
/// Generate an `bls12-377` key for the given key type using an optional `seed` and
|
||||
/// store it in the keystore.
|
||||
///
|
||||
/// The `seed` needs to be a valid utf8.
|
||||
///
|
||||
/// Returns the public key.
|
||||
#[cfg(feature = "bls-experimental")]
|
||||
fn bls377_generate(&mut self, id: KeyTypeId, seed: Option<Vec<u8>>) -> bls377::Public {
|
||||
let seed = seed.as_ref().map(|s| std::str::from_utf8(s).expect("Seed is valid utf8!"));
|
||||
self.extension::<KeystoreExt>()
|
||||
@@ -1204,6 +1206,25 @@ pub trait Crypto {
|
||||
.bls377_generate_new(id, seed)
|
||||
.expect("`bls377_generate` failed")
|
||||
}
|
||||
|
||||
/// Generate a `bandersnatch` key pair for the given key type using an optional
|
||||
/// `seed` and store it in the keystore.
|
||||
///
|
||||
/// The `seed` needs to be a valid utf8.
|
||||
///
|
||||
/// Returns the public key.
|
||||
#[cfg(feature = "bandersnatch-experimental")]
|
||||
fn bandersnatch_generate(
|
||||
&mut self,
|
||||
id: KeyTypeId,
|
||||
seed: Option<Vec<u8>>,
|
||||
) -> bandersnatch::Public {
|
||||
let seed = seed.as_ref().map(|s| std::str::from_utf8(s).expect("Seed is valid utf8!"));
|
||||
self.extension::<KeystoreExt>()
|
||||
.expect("No `keystore` associated for the current context!")
|
||||
.bandersnatch_generate_new(id, seed)
|
||||
.expect("`bandernatch_generate` failed")
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface that provides functions for hashing with different algorithms.
|
||||
|
||||
Reference in New Issue
Block a user