mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 17:21:08 +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:
@@ -18,7 +18,8 @@
|
||||
use super::*;
|
||||
use crate::backend::Backend;
|
||||
use polkadot_node_primitives::approval::v1::{
|
||||
AssignmentCert, AssignmentCertKind, VrfOutput, VrfProof, VrfSignature, RELAY_VRF_MODULO_CONTEXT,
|
||||
AssignmentCert, AssignmentCertKind, VrfPreOutput, VrfProof, VrfSignature,
|
||||
RELAY_VRF_MODULO_CONTEXT,
|
||||
};
|
||||
use polkadot_node_subsystem_util::database::Database;
|
||||
use sp_application_crypto::sp_core::H256;
|
||||
@@ -30,9 +31,12 @@ fn dummy_assignment_cert(kind: AssignmentCertKind) -> AssignmentCert {
|
||||
let mut prng = rand_core::OsRng;
|
||||
let keypair = schnorrkel::Keypair::generate_with(&mut prng);
|
||||
let (inout, proof, _) = keypair.vrf_sign(ctx.bytes(msg));
|
||||
let out = inout.to_output();
|
||||
let preout = inout.to_output();
|
||||
|
||||
AssignmentCert { kind, vrf: VrfSignature { output: VrfOutput(out), proof: VrfProof(proof) } }
|
||||
AssignmentCert {
|
||||
kind,
|
||||
vrf: VrfSignature { pre_output: VrfPreOutput(preout), proof: VrfProof(proof) },
|
||||
}
|
||||
}
|
||||
|
||||
fn make_block_entry_v1(
|
||||
|
||||
@@ -21,7 +21,9 @@ use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_node_primitives::approval::{
|
||||
self as approval_types,
|
||||
v1::{AssignmentCert, AssignmentCertKind, DelayTranche, RelayVRFStory},
|
||||
v2::{AssignmentCertKindV2, AssignmentCertV2, CoreBitfield, VrfOutput, VrfProof, VrfSignature},
|
||||
v2::{
|
||||
AssignmentCertKindV2, AssignmentCertV2, CoreBitfield, VrfPreOutput, VrfProof, VrfSignature,
|
||||
},
|
||||
};
|
||||
use polkadot_primitives::{
|
||||
AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex, IndexedVec, SessionInfo,
|
||||
@@ -459,7 +461,7 @@ fn compute_relay_vrf_modulo_assignments_v1(
|
||||
let cert = AssignmentCert {
|
||||
kind: AssignmentCertKind::RelayVRFModulo { sample: rvm_sample },
|
||||
vrf: VrfSignature {
|
||||
output: VrfOutput(vrf_in_out.to_output()),
|
||||
pre_output: VrfPreOutput(vrf_in_out.to_output()),
|
||||
proof: VrfProof(vrf_proof),
|
||||
},
|
||||
};
|
||||
@@ -539,7 +541,7 @@ fn compute_relay_vrf_modulo_assignments_v2(
|
||||
core_bitfield: assignment_bitfield.clone(),
|
||||
},
|
||||
vrf: VrfSignature {
|
||||
output: VrfOutput(vrf_in_out.to_output()),
|
||||
pre_output: VrfPreOutput(vrf_in_out.to_output()),
|
||||
proof: VrfProof(vrf_proof),
|
||||
},
|
||||
};
|
||||
@@ -574,7 +576,7 @@ fn compute_relay_vrf_delay_assignments(
|
||||
let cert = AssignmentCertV2 {
|
||||
kind: AssignmentCertKindV2::RelayVRFDelay { core_index: core },
|
||||
vrf: VrfSignature {
|
||||
output: VrfOutput(vrf_in_out.to_output()),
|
||||
pre_output: VrfPreOutput(vrf_in_out.to_output()),
|
||||
proof: VrfProof(vrf_proof),
|
||||
},
|
||||
};
|
||||
@@ -689,7 +691,7 @@ pub(crate) fn check_assignment_cert(
|
||||
}
|
||||
}
|
||||
|
||||
let vrf_output = &assignment.vrf.output;
|
||||
let vrf_pre_output = &assignment.vrf.pre_output;
|
||||
let vrf_proof = &assignment.vrf.proof;
|
||||
let first_claimed_core_index =
|
||||
claimed_core_indices.first_one().expect("Checked above; qed") as u32;
|
||||
@@ -704,7 +706,7 @@ pub(crate) fn check_assignment_cert(
|
||||
let (vrf_in_out, _) = public
|
||||
.vrf_verify_extra(
|
||||
relay_vrf_modulo_transcript_v2(relay_vrf_story),
|
||||
&vrf_output.0,
|
||||
&vrf_pre_output.0,
|
||||
&vrf_proof.0,
|
||||
assigned_cores_transcript(core_bitfield),
|
||||
)
|
||||
@@ -753,7 +755,7 @@ pub(crate) fn check_assignment_cert(
|
||||
let (vrf_in_out, _) = public
|
||||
.vrf_verify_extra(
|
||||
relay_vrf_modulo_transcript_v1(relay_vrf_story, *sample),
|
||||
&vrf_output.0,
|
||||
&vrf_pre_output.0,
|
||||
&vrf_proof.0,
|
||||
assigned_core_transcript(CoreIndex(first_claimed_core_index)),
|
||||
)
|
||||
@@ -791,7 +793,7 @@ pub(crate) fn check_assignment_cert(
|
||||
let (vrf_in_out, _) = public
|
||||
.vrf_verify(
|
||||
relay_vrf_delay_transcript(relay_vrf_story, *core_index),
|
||||
&vrf_output.0,
|
||||
&vrf_pre_output.0,
|
||||
&vrf_proof.0,
|
||||
)
|
||||
.map_err(|_| InvalidAssignment(Reason::VRFDelayOutputMismatch))?;
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::backend::V1ReadBackend;
|
||||
use polkadot_node_primitives::{
|
||||
approval::{
|
||||
v1::{
|
||||
AssignmentCert, AssignmentCertKind, DelayTranche, VrfOutput, VrfProof, VrfSignature,
|
||||
AssignmentCert, AssignmentCertKind, DelayTranche, VrfPreOutput, VrfProof, VrfSignature,
|
||||
RELAY_VRF_MODULO_CONTEXT,
|
||||
},
|
||||
v2::{AssignmentCertKindV2, AssignmentCertV2},
|
||||
@@ -415,9 +415,12 @@ fn garbage_assignment_cert(kind: AssignmentCertKind) -> AssignmentCert {
|
||||
let mut prng = rand_core::OsRng;
|
||||
let keypair = schnorrkel::Keypair::generate_with(&mut prng);
|
||||
let (inout, proof, _) = keypair.vrf_sign(ctx.bytes(msg));
|
||||
let out = inout.to_output();
|
||||
let preout = inout.to_output();
|
||||
|
||||
AssignmentCert { kind, vrf: VrfSignature { output: VrfOutput(out), proof: VrfProof(proof) } }
|
||||
AssignmentCert {
|
||||
kind,
|
||||
vrf: VrfSignature { pre_output: VrfPreOutput(preout), proof: VrfProof(proof) },
|
||||
}
|
||||
}
|
||||
|
||||
fn garbage_assignment_cert_v2(kind: AssignmentCertKindV2) -> AssignmentCertV2 {
|
||||
@@ -426,9 +429,12 @@ fn garbage_assignment_cert_v2(kind: AssignmentCertKindV2) -> AssignmentCertV2 {
|
||||
let mut prng = rand_core::OsRng;
|
||||
let keypair = schnorrkel::Keypair::generate_with(&mut prng);
|
||||
let (inout, proof, _) = keypair.vrf_sign(ctx.bytes(msg));
|
||||
let out = inout.to_output();
|
||||
let preout = inout.to_output();
|
||||
|
||||
AssignmentCertV2 { kind, vrf: VrfSignature { output: VrfOutput(out), proof: VrfProof(proof) } }
|
||||
AssignmentCertV2 {
|
||||
kind,
|
||||
vrf: VrfSignature { pre_output: VrfPreOutput(preout), proof: VrfProof(proof) },
|
||||
}
|
||||
}
|
||||
|
||||
fn sign_approval(
|
||||
|
||||
Reference in New Issue
Block a user