mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Update schnorrkel to 0.11.4 (#2524)
This commit is contained in:
@@ -555,7 +555,7 @@ pub mod vrf {
|
||||
use crate::crypto::{VrfCrypto, VrfPublic};
|
||||
use schnorrkel::{
|
||||
errors::MultiSignatureStage,
|
||||
vrf::{VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH},
|
||||
vrf::{VRF_PREOUT_LENGTH, VRF_PROOF_LENGTH},
|
||||
SignatureError,
|
||||
};
|
||||
|
||||
@@ -636,7 +636,7 @@ pub mod vrf {
|
||||
|
||||
/// VRF pre-output type suitable for schnorrkel operations.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct VrfPreOutput(pub schnorrkel::vrf::VRFOutput);
|
||||
pub struct VrfPreOutput(pub schnorrkel::vrf::VRFPreOut);
|
||||
|
||||
impl Encode for VrfPreOutput {
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
@@ -646,19 +646,19 @@ pub mod vrf {
|
||||
|
||||
impl Decode for VrfPreOutput {
|
||||
fn decode<R: codec::Input>(i: &mut R) -> Result<Self, codec::Error> {
|
||||
let decoded = <[u8; VRF_OUTPUT_LENGTH]>::decode(i)?;
|
||||
Ok(Self(schnorrkel::vrf::VRFOutput::from_bytes(&decoded).map_err(convert_error)?))
|
||||
let decoded = <[u8; VRF_PREOUT_LENGTH]>::decode(i)?;
|
||||
Ok(Self(schnorrkel::vrf::VRFPreOut::from_bytes(&decoded).map_err(convert_error)?))
|
||||
}
|
||||
}
|
||||
|
||||
impl MaxEncodedLen for VrfPreOutput {
|
||||
fn max_encoded_len() -> usize {
|
||||
<[u8; VRF_OUTPUT_LENGTH]>::max_encoded_len()
|
||||
<[u8; VRF_PREOUT_LENGTH]>::max_encoded_len()
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeInfo for VrfPreOutput {
|
||||
type Identity = [u8; VRF_OUTPUT_LENGTH];
|
||||
type Identity = [u8; VRF_PREOUT_LENGTH];
|
||||
|
||||
fn type_info() -> scale_info::Type {
|
||||
Self::Identity::type_info()
|
||||
@@ -717,11 +717,11 @@ pub mod vrf {
|
||||
|
||||
let proof = self.0.dleq_proove(extra, &inout, true).0;
|
||||
|
||||
VrfSignature { pre_output: VrfPreOutput(inout.to_output()), proof: VrfProof(proof) }
|
||||
VrfSignature { pre_output: VrfPreOutput(inout.to_preout()), proof: VrfProof(proof) }
|
||||
}
|
||||
|
||||
fn vrf_pre_output(&self, input: &Self::VrfInput) -> Self::VrfPreOutput {
|
||||
let pre_output = self.0.vrf_create_hash(input.0.clone()).to_output();
|
||||
let pre_output = self.0.vrf_create_hash(input.0.clone()).to_preout();
|
||||
VrfPreOutput(pre_output)
|
||||
}
|
||||
}
|
||||
@@ -762,6 +762,7 @@ pub mod vrf {
|
||||
ScalarFormatError => "Signature error: `ScalarFormatError`".into(),
|
||||
NotMarkedSchnorrkel => "Signature error: `NotMarkedSchnorrkel`".into(),
|
||||
BytesLengthError { .. } => "Signature error: `BytesLengthError`".into(),
|
||||
InvalidKey => "Signature error: `InvalidKey`".into(),
|
||||
MuSigAbsent { musig_stage: Commitment } =>
|
||||
"Signature error: `MuSigAbsent` at stage `Commitment`".into(),
|
||||
MuSigAbsent { musig_stage: Reveal } =>
|
||||
@@ -1141,7 +1142,7 @@ mod tests {
|
||||
})
|
||||
.unwrap();
|
||||
let signature2 =
|
||||
VrfSignature { pre_output: VrfPreOutput(inout.to_output()), proof: VrfProof(proof) };
|
||||
VrfSignature { pre_output: VrfPreOutput(inout.to_preout()), proof: VrfProof(proof) };
|
||||
|
||||
assert!(public.vrf_verify(&data, &signature2));
|
||||
assert_eq!(signature.pre_output, signature2.pre_output);
|
||||
|
||||
Reference in New Issue
Block a user