Skip to content

Commit

Permalink
Update fastcrypto in sui + related tbls usage for random beacon (Myst…
Browse files Browse the repository at this point in the history
  • Loading branch information
aschran authored Dec 16, 2023
1 parent 272859f commit 399df17
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 50 deletions.
41 changes: 21 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ nexlint-lints = { git = "https://github.com/nextest-rs/nexlint.git", rev = "94da
nonempty = "0.9.0"
notify = "6.1.1"
ntest = "0.9.0"
num-bigint = "0.4.3"
num-bigint = "0.4.4"
num_cpus = "1.15.0"
num_enum = "0.6.1"
object_store = { version = "0.7", features = [
Expand Down Expand Up @@ -538,9 +538,9 @@ move-stackless-bytecode = { path = "external-crates/move/crates/move-stackless-b
move-symbol-pool = { path = "external-crates/move/crates/move-symbol-pool" }
move-abstract-stack = { path = "external-crates/move/crates/move-abstract-stack" }

fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f" }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f"}
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f", package = "fastcrypto-zkp" }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193" }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193"}
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193", package = "fastcrypto-zkp" }

# anemo dependencies
anemo = { git = "https://github.com/mystenlabs/anemo.git", rev = "1169850e6af127397068cd86764c29b1d49dbe35" }
Expand Down
14 changes: 7 additions & 7 deletions crates/workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ expect-test = { version = "1", default-features = false }
eyre = { version = "0.6" }
fail = { version = "0.4", default-features = false }
fast_chemail = { version = "0.9", default-features = false }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f", features = ["beacon-dkg", "copy_key"] }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f", default-features = false }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193", features = ["beacon-dkg", "copy_key"] }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193", default-features = false }
fastrand-dff4ba8e3ae991db = { package = "fastrand", version = "1", default-features = false }
fastrand-f595c2ba2a3f28df = { package = "fastrand", version = "2" }
fd-lock = { version = "3", default-features = false }
Expand Down Expand Up @@ -1159,10 +1159,10 @@ expect-test = { version = "1", default-features = false }
eyre = { version = "0.6" }
fail = { version = "0.4", default-features = false }
fast_chemail = { version = "0.9", default-features = false }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f", features = ["beacon-dkg", "copy_key"] }
fastcrypto-derive = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f", default-features = false }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "643831ec3b67bdd2b5f998c0bec1b7c91823351f", default-features = false }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193", features = ["beacon-dkg", "copy_key"] }
fastcrypto-derive = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193", default-features = false }
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "9579a60fbffe15c0f65626ae55998bf8ef42e193", default-features = false }
fastrand-dff4ba8e3ae991db = { package = "fastrand", version = "1", default-features = false }
fastrand-f595c2ba2a3f28df = { package = "fastrand", version = "2" }
fd-lock = { version = "3", default-features = false }
Expand Down
26 changes: 7 additions & 19 deletions narwhal/primary/src/state_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl RandomnessState {
.expect("validity threshold should fit in u16"),
protocol_config.random_beacon_reduction_allowed_delta(),
);
let total_weight = nodes.n();
let total_weight = nodes.total_weight();
let num_nodes = nodes.num_nodes();
let prefix_str = format!(
"dkg {} {}",
Expand Down Expand Up @@ -343,7 +343,7 @@ impl RandomnessState {
self.cached_sigs = Some((
randomness_round,
ThresholdBls12381MinSig::partial_sign_batch(
shares,
shares.iter(),
&randomness_round.signature_message(),
),
));
Expand Down Expand Up @@ -438,16 +438,10 @@ impl RandomnessState {
// If we have enough partial signatures, aggregate them.
let mut sig = match ThresholdBls12381MinSig::aggregate(
self.party.t(),
// TODO: ThresholdBls12381MinSig::aggregate immediately just makes an iterator of the
// given slice. Can we change its interface to accept an iterator directly, to avoid
// all the extra copying?
&self
.partial_sigs
self.partial_sigs
.iter()
.filter(|&((round, _), _)| *round == randomness_round)
.flat_map(|(_, sigs)| sigs)
.cloned()
.collect::<Vec<_>>(),
.flat_map(|(_, sigs)| sigs),
) {
Ok(sig) => sig,
Err(fastcrypto::error::FastCryptoError::NotEnoughInputs) => return, // wait for more input
Expand All @@ -466,7 +460,7 @@ impl RandomnessState {
if ThresholdBls12381MinSig::partial_verify_batch(
vss_pk,
&r.signature_message(),
partial_sigs.as_slice(),
partial_sigs.iter(),
&mut rand::thread_rng(),
)
.is_err()
Expand All @@ -478,16 +472,10 @@ impl RandomnessState {
});
sig = match ThresholdBls12381MinSig::aggregate(
self.party.t(),
// TODO: ThresholdBls12381MinSig::aggregate immediately just makes an iterator of the
// given slice. Can we change its interface to accept an iterator directly, to avoid
// all the extra copying?
&self
.partial_sigs
self.partial_sigs
.iter()
.filter(|&((round, _), _)| *round == randomness_round)
.flat_map(|(_, sigs)| sigs)
.cloned()
.collect::<Vec<_>>(),
.flat_map(|(_, sigs)| sigs),
) {
Ok(sig) => sig,
Err(fastcrypto::error::FastCryptoError::NotEnoughInputs) => return, // wait for more input
Expand Down

0 comments on commit 399df17

Please sign in to comment.