Skip to content

Commit

Permalink
update QuorumCertifiedUpdate struct
Browse files Browse the repository at this point in the history
  • Loading branch information
zjma committed Feb 4, 2024
1 parent a9a8c68 commit d39ef7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
16 changes: 2 additions & 14 deletions aptos-move/aptos-vm/src/validator_txns/jwk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ use crate::{
},
AptosVM,
};
use aptos_bitvec::BitVec;
use aptos_types::{
aggregate_signature::AggregateSignature,
fee_statement::FeeStatement,
jwks,
jwks::{Issuer, ObservedJWKs, ProviderJWKs, QuorumCertifiedUpdate},
Expand Down Expand Up @@ -94,7 +92,6 @@ impl AptosVM {
let verifier = ValidatorVerifier::from(&validator_set);

let QuorumCertifiedUpdate {
authors,
update: observed,
multi_sig,
} = update;
Expand All @@ -104,13 +101,7 @@ impl AptosVM {
return Err(Expected(IncorrectVersion));
}

let signer_bit_vec = BitVec::from(
verifier
.get_ordered_account_addresses()
.into_iter()
.map(|addr| authors.contains(&addr))
.collect::<Vec<_>>(),
);
let authors = multi_sig.get_signers_addresses(&verifier.get_ordered_account_addresses());

// Check voting power.
verifier
Expand All @@ -119,10 +110,7 @@ impl AptosVM {

// Verify multi-sig.
verifier
.verify_multi_signatures(
&observed,
&AggregateSignature::new(signer_bit_vec, Some(multi_sig)),
)
.verify_multi_signatures(&observed, &multi_sig)
.map_err(|_| Expected(MultiSigVerificationFailed))?;

Check warning on line 114 in aptos-move/aptos-vm/src/validator_txns/jwk.rs

View check run for this annotation

Codecov / codecov/patch

aptos-move/aptos-vm/src/validator_txns/jwk.rs#L112-L114

Added lines #L112 - L114 were not covered by tests

// All verification passed. Apply the `observed`.
Expand Down
15 changes: 7 additions & 8 deletions types/src/jwks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// Copyright © Aptos Foundation

use self::jwk::JWK;
use crate::{move_utils::as_move_value::AsMoveValue, on_chain_config::OnChainConfig};
use crate::{
aggregate_signature::AggregateSignature, move_utils::as_move_value::AsMoveValue,
on_chain_config::OnChainConfig,
};
use anyhow::{bail, Context};
use aptos_crypto::bls12381;
use aptos_crypto_derive::{BCSCryptoHash, CryptoHasher};
use jwk::JWKMoveStruct;
use move_core_types::{
account_address::AccountAddress,
ident_str,
identifier::IdentStr,
move_resource::MoveStructType,
value::{MoveStruct, MoveValue},
};
use serde::{Deserialize, Serialize};
use std::{
collections::{BTreeSet, HashMap},
collections::HashMap,
fmt::{Debug, Formatter},
};

Expand Down Expand Up @@ -190,18 +191,16 @@ impl MoveStructType for PatchedJWKs {
/// A JWK update in format of `ProviderJWKs` and a multi-signature of it as a quorum certificate.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, CryptoHasher, BCSCryptoHash)]

Check warning on line 192 in types/src/jwks/mod.rs

View check run for this annotation

Codecov / codecov/patch

types/src/jwks/mod.rs#L192

Added line #L192 was not covered by tests
pub struct QuorumCertifiedUpdate {
pub authors: BTreeSet<AccountAddress>,
pub update: ProviderJWKs,
pub multi_sig: bls12381::Signature,
pub multi_sig: AggregateSignature,
}

impl QuorumCertifiedUpdate {
#[cfg(any(test, feature = "fuzzing"))]
pub fn dummy() -> Self {
Self {
authors: Default::default(),
update: ProviderJWKs::new(dummy_issuer()),
multi_sig: bls12381::Signature::dummy_signature(),
multi_sig: AggregateSignature::empty(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion types/src/validator_txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#[cfg(any(test, feature = "fuzzing"))]
use crate::dkg::DKGTranscriptMetadata;
use crate::{DKGTranscript, jwks};
use crate::{dkg::DKGTranscript, jwks};
use aptos_crypto_derive::{BCSCryptoHash, CryptoHasher};
#[cfg(any(test, feature = "fuzzing"))]
use move_core_types::account_address::AccountAddress;
Expand Down

0 comments on commit d39ef7e

Please sign in to comment.