mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 07:31:03 +00:00
sp-core: Rename VrfOutput to VrfPreOutput (#2534)
This will make more sense after https://github.com/paritytech/polkadot-sdk/pull/2524 since the schnorrkel type for VRF outputs is also renamed in the latest version. Can be reviewed independently though. Can be merged after https://github.com/paritytech/polkadot-sdk/pull/1577 so that there is less pain for @davxy. --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -249,7 +249,7 @@ fn claim_primary_slot(
|
||||
.make_bytes::<AUTHORING_SCORE_LENGTH>(
|
||||
AUTHORING_SCORE_VRF_CONTEXT,
|
||||
&data.as_ref(),
|
||||
&vrf_signature.output,
|
||||
&vrf_signature.pre_output,
|
||||
)
|
||||
.map(|bytes| u128::from_le_bytes(bytes) < threshold)
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -580,7 +580,7 @@ fn claim_vrf_check() {
|
||||
};
|
||||
let data = make_vrf_sign_data(&epoch.randomness.clone(), 0.into(), epoch.epoch_index);
|
||||
let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap();
|
||||
assert_eq!(pre_digest.vrf_signature.output, sign.output);
|
||||
assert_eq!(pre_digest.vrf_signature.pre_output, sign.pre_output);
|
||||
|
||||
// We expect a SecondaryVRF claim for slot 1
|
||||
let pre_digest = match claim_slot(1.into(), &epoch, &keystore).unwrap().0 {
|
||||
@@ -589,7 +589,7 @@ fn claim_vrf_check() {
|
||||
};
|
||||
let data = make_vrf_sign_data(&epoch.randomness.clone(), 1.into(), epoch.epoch_index);
|
||||
let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap();
|
||||
assert_eq!(pre_digest.vrf_signature.output, sign.output);
|
||||
assert_eq!(pre_digest.vrf_signature.pre_output, sign.pre_output);
|
||||
|
||||
// Check that correct epoch index has been used if epochs are skipped (primary VRF)
|
||||
let slot = Slot::from(103);
|
||||
@@ -601,7 +601,7 @@ fn claim_vrf_check() {
|
||||
let data = make_vrf_sign_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index);
|
||||
let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap();
|
||||
assert_eq!(fixed_epoch.epoch_index, 11);
|
||||
assert_eq!(claim.vrf_signature.output, sign.output);
|
||||
assert_eq!(claim.vrf_signature.pre_output, sign.pre_output);
|
||||
|
||||
// Check that correct epoch index has been used if epochs are skipped (secondary VRF)
|
||||
let slot = Slot::from(100);
|
||||
@@ -613,7 +613,7 @@ fn claim_vrf_check() {
|
||||
let data = make_vrf_sign_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index);
|
||||
let sign = keystore.sr25519_vrf_sign(AuthorityId::ID, &public, &data).unwrap().unwrap();
|
||||
assert_eq!(fixed_epoch.epoch_index, 11);
|
||||
assert_eq!(pre_digest.vrf_signature.output, sign.output);
|
||||
assert_eq!(pre_digest.vrf_signature.pre_output, sign.pre_output);
|
||||
}
|
||||
|
||||
// Propose and import a new BABE block on top of the given parent.
|
||||
|
||||
@@ -185,7 +185,7 @@ fn check_primary_header<B: BlockT + Sized>(
|
||||
.make_bytes::<AUTHORING_SCORE_LENGTH>(
|
||||
AUTHORING_SCORE_VRF_CONTEXT,
|
||||
&data.as_ref(),
|
||||
&pre_digest.vrf_signature.output,
|
||||
&pre_digest.vrf_signature.pre_output,
|
||||
)
|
||||
.map(u128::from_le_bytes)
|
||||
.map_err(|_| babe_err(Error::VrfVerificationFailed))?;
|
||||
|
||||
@@ -120,18 +120,18 @@ impl LocalKeystore {
|
||||
Ok(sig)
|
||||
}
|
||||
|
||||
fn vrf_output<T: CorePair + VrfSecret>(
|
||||
fn vrf_pre_output<T: CorePair + VrfSecret>(
|
||||
&self,
|
||||
key_type: KeyTypeId,
|
||||
public: &T::Public,
|
||||
input: &T::VrfInput,
|
||||
) -> std::result::Result<Option<T::VrfOutput>, TraitError> {
|
||||
let preout = self
|
||||
) -> std::result::Result<Option<T::VrfPreOutput>, TraitError> {
|
||||
let pre_output = self
|
||||
.0
|
||||
.read()
|
||||
.key_pair_by_type::<T>(public, key_type)?
|
||||
.map(|pair| pair.vrf_output(input));
|
||||
Ok(preout)
|
||||
.map(|pair| pair.vrf_pre_output(input));
|
||||
Ok(pre_output)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,13 +188,13 @@ impl Keystore for LocalKeystore {
|
||||
self.vrf_sign::<sr25519::Pair>(key_type, public, data)
|
||||
}
|
||||
|
||||
fn sr25519_vrf_output(
|
||||
fn sr25519_vrf_pre_output(
|
||||
&self,
|
||||
key_type: KeyTypeId,
|
||||
public: &sr25519::Public,
|
||||
input: &sr25519::vrf::VrfInput,
|
||||
) -> std::result::Result<Option<sr25519::vrf::VrfOutput>, TraitError> {
|
||||
self.vrf_output::<sr25519::Pair>(key_type, public, input)
|
||||
) -> std::result::Result<Option<sr25519::vrf::VrfPreOutput>, TraitError> {
|
||||
self.vrf_pre_output::<sr25519::Pair>(key_type, public, input)
|
||||
}
|
||||
|
||||
fn ed25519_public_keys(&self, key_type: KeyTypeId) -> Vec<ed25519::Public> {
|
||||
@@ -293,13 +293,13 @@ impl Keystore for LocalKeystore {
|
||||
self.vrf_sign::<bandersnatch::Pair>(key_type, public, data)
|
||||
}
|
||||
|
||||
fn bandersnatch_vrf_output(
|
||||
fn bandersnatch_vrf_pre_output(
|
||||
&self,
|
||||
key_type: KeyTypeId,
|
||||
public: &bandersnatch::Public,
|
||||
input: &bandersnatch::vrf::VrfInput,
|
||||
) -> std::result::Result<Option<bandersnatch::vrf::VrfOutput>, TraitError> {
|
||||
self.vrf_output::<bandersnatch::Pair>(key_type, public, input)
|
||||
) -> std::result::Result<Option<bandersnatch::vrf::VrfPreOutput>, TraitError> {
|
||||
self.vrf_pre_output::<bandersnatch::Pair>(key_type, public, input)
|
||||
}
|
||||
|
||||
fn bandersnatch_ring_vrf_sign(
|
||||
|
||||
Reference in New Issue
Block a user