mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 21:57:55 +00:00
VRF refactory (#13889)
* First iteration to encapsulate schnorrkel and merlin usage * Remove schnorkel direct dependency from BABE pallet * Remove schnorrkel direct dependency from BABE client * Trivial renaming for VrfTranscript data and value * Better errors * Expose a function to get a schnorrkel friendly transcript * Keep the vrf signature stuff together (preventing some clones around) * Fix tests * Remove vrf agnostic transcript and define it as an associated type for VrfSigner and VrfVerifier * Fix babe pallet mock * Inner types are required to be public for polkadot * Update client/consensus/babe/src/verification.rs Co-authored-by: Koute <koute@users.noreply.github.com> * Nit * Remove Deref implementations * make_bytes as a method * Trigger CI --------- Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
@@ -28,11 +28,8 @@ use rand::{rngs::OsRng, RngCore};
|
||||
#[cfg(feature = "std")]
|
||||
use regex::Regex;
|
||||
use scale_info::TypeInfo;
|
||||
/// Trait for accessing reference to `SecretString`.
|
||||
pub use secrecy::ExposeSecret;
|
||||
/// A store for sensitive data.
|
||||
#[cfg(feature = "std")]
|
||||
pub use secrecy::SecretString;
|
||||
pub use secrecy::{ExposeSecret, SecretString};
|
||||
use sp_runtime_interface::pass_by::PassByInner;
|
||||
#[doc(hidden)]
|
||||
pub use sp_std::ops::Deref;
|
||||
@@ -1102,6 +1099,27 @@ impl<'a> TryFrom<&'a str> for KeyTypeId {
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait grouping types shared by a VRF signer and verifiers.
|
||||
pub trait VrfCrypto {
|
||||
/// Associated signature type.
|
||||
type VrfSignature;
|
||||
|
||||
/// Vrf input data. Generally some form of transcript.
|
||||
type VrfInput;
|
||||
}
|
||||
|
||||
/// VRF Signer.
|
||||
pub trait VrfSigner: VrfCrypto {
|
||||
/// Sign input data.
|
||||
fn vrf_sign(&self, data: &Self::VrfInput) -> Self::VrfSignature;
|
||||
}
|
||||
|
||||
/// VRF Verifier.
|
||||
pub trait VrfVerifier: VrfCrypto {
|
||||
/// Verify input data signature.
|
||||
fn vrf_verify(&self, data: &Self::VrfInput, signature: &Self::VrfSignature) -> bool;
|
||||
}
|
||||
|
||||
/// An identifier for a specific cryptographic algorithm used by a key pair
|
||||
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
|
||||
|
||||
Reference in New Issue
Block a user