Skip to content
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
257 changes: 183 additions & 74 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions contrib/codeql/lib/policy.qll
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,17 @@ predicate isSecretType(TypeItem t) {
// Scalar field wrapper holding secret key material
t.getName().getText() = "Fr"
) and
// A share *of a signature* is published, so it holds nothing to protect. Excluded by
// exact name because `BlsSkShare` and `RawShare` match the same Share substring
// and do carry secret scalars.
not t.getName().getText() = "BlsSigShare" and
// Serde artifact to deserialize a tagged enum.
not t.getName().getText() = "__Seed"
not t.getName().getText() =
[
// A share *of a signature* is published, so it's non-secret. Excluded by exact name because
// `BlsSkShare` and `RawShare` match the same Share substring and do carry secret scalars.
"BlsSigShare",
// The identifier a share is issued against is the participant's, known to every member of the
// quorum; only the scalar the share carries is secret.
"BlsShareId",
// Serde artifact to deserialize a tagged enum.
"__Seed"
]
}

/**
Expand Down
11 changes: 7 additions & 4 deletions pkgs/pkc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ license = "MIT"
base58ck = { workspace = true, features = ["alloc"] }
bitcoin_hashes = { workspace = true, features = ["alloc"] }
blst = { version = "0.3", default-features = false, optional = true }
ff = { version = "0.14", default-features = false, optional = true }
group = { version = "0.14", default-features = false, optional = true }
cfg-if = "1"
dash-num = { version = "0.0.0", path = "../num" }
dash-types = { version = "0.0.0", path = "../types", default-features = false }
hex-conservative = { version = "0.3", default-features = false, features = [
"alloc",
] }
k256 = { version = "0.13", default-features = false, features = [
k256 = { version = "0.14", default-features = false, features = [
"arithmetic",
"ecdsa",
"sha256",
], optional = true }
rand_core = { version = "0.6", default-features = false, optional = true }
rand_core = { version = "0.10", default-features = false, optional = true }
rstest = { version = "0.25", optional = true }
serde = { version = "1", default-features = false, features = [
"alloc",
Expand All @@ -36,15 +38,16 @@ zeroize = { version = "1", default-features = false, features = [
bitcoin-consensus-encoding = { workspace = true, features = ["alloc"] }
dash-dev = { version = "0.0.0", path = "../dev", features = ["full"] }
divan = "0.1"
getrandom = { version = "0.4", features = ["sys_rng"] }
hex-conservative = "0.3"
rand_core = { version = "0.6", features = ["getrandom"] }
rand_core = { version = "0.10" }
rstest = "0.25"
serde = { version = "1", features = ["derive"] }

[features]
default = []
std = ["base58ck/std", "bitcoin_hashes/std", "dash-types/std"]
bls = ["dep:blst", "dep:rand_core", "dep:sha2"]
bls = ["dep:blst", "dep:ff", "dep:group", "dep:rand_core", "dep:sha2"]
ecdsa = ["dep:k256", "dep:rand_core"]
serde = ["dep:serde", "dash-num/serde", "dash-types/serde"]
full = ["ecdsa", "bls", "serde", "std", "tests"]
Expand Down
7 changes: 4 additions & 3 deletions pkgs/pkc/bench/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use dash_pkc::bls::tests::{sequential_ids, test_ikm, test_msg};
use dash_pkc::bls::{BlsPublicKey, BlsScChia, BlsScIetf, BlsScheme, BlsSecretKey, BlsSigShare, BlsSignature};
use divan::{counter::ItemsCount, Bencher};
use rand_core::OsRng;
use getrandom::SysRng;
use rand_core::UnwrapErr;

/// Single signature creation.
#[divan::bench(types = [BlsScChia, BlsScIetf])]
Expand Down Expand Up @@ -144,15 +145,15 @@ fn split_threshold<S: BlsScheme>(bencher: Bencher, n: usize) {
let ids = sequential_ids(n);
bencher
.counter(ItemsCount::new(n))
.bench(|| sk.split(threshold, &ids, &mut OsRng));
.bench(|| sk.split(threshold, &ids, &mut UnwrapErr(SysRng)));
}

/// Threshold signature recovery via Lagrange interpolation.
#[divan::bench(types = [BlsScChia, BlsScIetf], args = [3, 5, 10])]
fn recover_threshold<S: BlsScheme>(bencher: Bencher, threshold: usize) {
let sk = BlsSecretKey::<S>::generate(&test_ikm(1)).unwrap();
let ids = sequential_ids(threshold * 2);
let shares = sk.split(threshold, &ids, &mut OsRng).unwrap();
let shares = sk.split(threshold, &ids, &mut UnwrapErr(SysRng)).unwrap();
let msg = test_msg(42);
let sig_shares: Vec<_> = shares.iter().map(|share| share.sign(S::msg_ref(&msg))).collect();
let subset: Vec<&BlsSigShare<S>> = sig_shares.iter().take(threshold).collect();
Expand Down
Loading
Loading