Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update schnorrkel to 0.11.4 #2524

Merged
merged 5 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
975 changes: 91 additions & 884 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions polkadot/node/core/approval-voting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ parity-scale-codec = { version = "3.6.1", default-features = false, features = [
gum = { package = "tracing-gum", path = "../../gum" }
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
schnellru = "0.2.1"
merlin = "2.0"
schnorrkel = "0.9.1"
merlin = "3.0"
schnorrkel = "0.11.4"
kvdb = "0.13.0"
derive_more = "0.99.17"
thiserror = "1.0.48"
Expand All @@ -35,15 +35,14 @@ sp-consensus = { path = "../../../../substrate/primitives/consensus/common", def
sp-consensus-slots = { path = "../../../../substrate/primitives/consensus/slots", default-features = false }
sp-application-crypto = { path = "../../../../substrate/primitives/application-crypto", default-features = false, features = ["full_crypto"] }
sp-runtime = { path = "../../../../substrate/primitives/runtime", default-features = false }
rand_core = "0.5.1"
# should match schnorrkel
rand_core = "0.6.2"
rand_chacha = { version = "0.3.1" }
rand = "0.8.5"

[dev-dependencies]
async-trait = "0.1.57"
parking_lot = "0.12.0"
# rand_core should match schnorrkel
rand_core = "0.5.1"
sp-keyring = { path = "../../../../substrate/primitives/keyring" }
sp-keystore = { path = "../../../../substrate/primitives/keystore" }
sp-core = { path = "../../../../substrate/primitives/core" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use polkadot_node_primitives::approval::{
v1::{AssignmentCert, AssignmentCertKind, VrfProof, VrfSignature, RELAY_VRF_MODULO_CONTEXT},
v2::VrfPreOutput,
};

pub fn make_bitvec(len: usize) -> BitVec<u8, BitOrderLsb0> {
bitvec::bitvec![u8, BitOrderLsb0; 0; len]
}
Expand All @@ -30,10 +31,10 @@ pub 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_preout();

AssignmentCert {
kind,
vrf: VrfSignature { pre_output: VrfPreOutput(out), proof: VrfProof(proof) },
vrf: VrfSignature { pre_output: VrfPreOutput(preout), proof: VrfProof(proof) },
}
}
6 changes: 3 additions & 3 deletions polkadot/node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ fn compute_relay_vrf_modulo_assignments_v1(
let cert = AssignmentCert {
kind: AssignmentCertKind::RelayVRFModulo { sample: rvm_sample },
vrf: VrfSignature {
pre_output: VrfPreOutput(vrf_in_out.to_output()),
pre_output: VrfPreOutput(vrf_in_out.to_preout()),
proof: VrfProof(vrf_proof),
},
};
Expand Down Expand Up @@ -543,7 +543,7 @@ fn compute_relay_vrf_modulo_assignments_v2(
core_bitfield: assignment_bitfield.clone(),
},
vrf: VrfSignature {
pre_output: VrfPreOutput(vrf_in_out.to_output()),
pre_output: VrfPreOutput(vrf_in_out.to_preout()),
proof: VrfProof(vrf_proof),
},
};
Expand Down Expand Up @@ -578,7 +578,7 @@ fn compute_relay_vrf_delay_assignments(
let cert = AssignmentCertV2 {
kind: AssignmentCertKindV2::RelayVRFDelay { core_index: core },
vrf: VrfSignature {
pre_output: VrfPreOutput(vrf_in_out.to_output()),
pre_output: VrfPreOutput(vrf_in_out.to_preout()),
proof: VrfProof(vrf_proof),
},
};
Expand Down
4 changes: 2 additions & 2 deletions polkadot/node/core/approval-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ 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 preout = inout.to_output();
let preout = inout.to_preout();

AssignmentCert {
kind,
Expand All @@ -432,7 +432,7 @@ 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 preout = inout.to_output();
let preout = inout.to_preout();

AssignmentCertV2 {
kind,
Expand Down
4 changes: 2 additions & 2 deletions polkadot/node/network/approval-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" }

assert_matches = "1.4.0"
schnorrkel = { version = "0.9.1", default-features = false }
schnorrkel = { version = "0.11.4", default-features = false }
# rand_core should match schnorrkel
rand_core = "0.5.1"
rand_core = "0.6.2"
rand_chacha = "0.3.1"
env_logger = "0.9.0"
log = "0.4.17"
4 changes: 2 additions & 2 deletions polkadot/node/network/approval-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn fake_assignment_cert(block_hash: Hash, validator: ValidatorIndex) -> Indirect
let mut prng = rand_core::OsRng;
let keypair = schnorrkel::Keypair::generate_with(&mut prng);
let (inout, proof, _) = keypair.vrf_sign(ctx.bytes(msg));
let preout = inout.to_output();
let preout = inout.to_preout();

IndirectAssignmentCert {
block_hash,
Expand All @@ -319,7 +319,7 @@ fn fake_assignment_cert_v2(
let mut prng = rand_core::OsRng;
let keypair = schnorrkel::Keypair::generate_with(&mut prng);
let (inout, proof, _) = keypair.vrf_sign(ctx.bytes(msg));
let preout = inout.to_output();
let preout = inout.to_preout();

IndirectAssignmentCertV2 {
block_hash,
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sp-keystore = { path = "../../../substrate/primitives/keystore" }
sp-maybe-compressed-blob = { path = "../../../substrate/primitives/maybe-compressed-blob" }
sp-runtime = { path = "../../../substrate/primitives/runtime" }
polkadot-parachain-primitives = { path = "../../parachain", default-features = false }
schnorrkel = "0.9.1"
schnorrkel = "0.11.4"
thiserror = "1.0.48"
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
serde = { version = "1.0.193", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
futures = "0.3.21"
futures-timer = "3.0.1"
ip_network = "0.4.1"
libp2p = { version = "0.51.3", features = ["ed25519", "kad"] }
libp2p = { version = "0.51.4", features = ["ed25519", "kad"] }
multihash = { version = "0.18.1", default-features = false, features = [
"sha2",
"std",
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ targets = ["x86_64-unknown-linux-gnu"]
ahash = "0.8.2"
futures = "0.3.21"
futures-timer = "3.0.1"
libp2p = "0.51.3"
libp2p = "0.51.4"
log = "0.4.17"
schnellru = "0.2.1"
tracing = "0.1.29"
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fnv = "1.0.6"
futures = "0.3.21"
futures-timer = "3.0.2"
ip_network = "0.4.1"
libp2p = { version = "0.51.3", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "request-response", "tcp", "tokio", "websocket", "yamux"] }
libp2p = { version = "0.51.4", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "request-response", "tcp", "tokio", "websocket", "yamux"] }
linked_hash_set = "0.1.3"
log = "0.4.17"
mockall = "0.11.3"
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network/statement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ array-bytes = "6.1"
async-channel = "1.8.0"
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] }
futures = "0.3.21"
libp2p = "0.51.3"
libp2p = "0.51.4"
log = "0.4.17"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus" }
sc-network-common = { path = "../common" }
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async-trait = "0.1.58"
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] }
futures = "0.3.21"
futures-timer = "3.0.2"
libp2p = "0.51.3"
libp2p = "0.51.4"
log = "0.4.17"
mockall = "0.11.3"
prost = "0.11"
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tokio = "1.22.0"
async-trait = "0.1.57"
futures = "0.3.21"
futures-timer = "3.0.1"
libp2p = "0.51.3"
libp2p = "0.51.4"
log = "0.4.17"
parking_lot = "0.12.1"
rand = "0.8.5"
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network/transactions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
array-bytes = "6.1"
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] }
futures = "0.3.21"
libp2p = "0.51.3"
libp2p = "0.51.4"
log = "0.4.17"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus" }
sc-network = { path = ".." }
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ futures = "0.3.21"
futures-timer = "3.0.2"
hyper = { version = "0.14.16", features = ["http2", "stream"] }
hyper-rustls = { version = "0.24.0", features = ["http2"] }
libp2p = "0.51.3"
libp2p = "0.51.4"
num_cpus = "1.13"
once_cell = "1.8"
parking_lot = "0.12.1"
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
chrono = "0.4.27"
futures = "0.3.21"
libp2p = { version = "0.51.3", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] }
libp2p = { version = "0.51.4", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] }
log = "0.4.17"
parking_lot = "0.12.1"
pin-project = "1.0.12"
Expand Down
4 changes: 2 additions & 2 deletions substrate/primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ array-bytes = { version = "6.1", optional = true }
ed25519-zebra = { version = "3.1.0", default-features = false, optional = true }
blake2 = { version = "0.10.4", default-features = false, optional = true }
libsecp256k1 = { version = "0.7", default-features = false, features = ["static-context"], optional = true }
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false }
merlin = { version = "2.0", default-features = false }
schnorrkel = { version = "0.11.4", features = ["preaudit_deprecated"], default-features = false }
merlin = { version = "3.0", default-features = false }
secp256k1 = { version = "0.28.0", default-features = false, features = ["alloc", "recovery"], optional = true }
sp-core-hashing = { path = "hashing", default-features = false, optional = true }
sp-runtime-interface = { path = "../runtime-interface", default-features = false }
Expand Down
19 changes: 10 additions & 9 deletions substrate/primitives/core/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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> {
Expand All @@ -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()
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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 } =>
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ tracing = { version = "0.1.29", default-features = false }
tracing-core = { version = "0.1.32", default-features = false }

# Required for backwards compatibility reason, but only used for verifying when `UseDalekExt` is set.
ed25519-dalek = { version = "2.0", default-features = false, optional = true }
ed25519-dalek = { version = "2.1", default-features = false, optional = true }

[build-dependencies]
rustversion = "1.0.6"
Expand Down
6 changes: 3 additions & 3 deletions substrate/primitives/statement-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ sp-externalities = { path = "../externalities", default-features = false }
thiserror = { version = "1.0", optional = true }

# ECIES dependencies
ed25519-dalek = { version = "2.0.0", optional = true }
x25519-dalek = { version = "2.0.0", optional = true, features = ["static_secrets"] }
curve25519-dalek = { version = "4.0.0", optional = true }
ed25519-dalek = { version = "2.1", optional = true }
x25519-dalek = { version = "2.0", optional = true, features = ["static_secrets"] }
curve25519-dalek = { version = "4.1.1", optional = true }
aes-gcm = { version = "0.10", optional = true }
hkdf = { version = "0.12.0", optional = true }
sha2 = { version = "0.10.7", optional = true }
Expand Down
Loading