Skip to content

Commit

Permalink
fix: unique pubkeys verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Itshyphen committed Oct 8, 2024
1 parent 66647a3 commit 441f1d8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,27 @@ module xcall::cluster_state {
let threshold=self.get_validator_threshold();
let validators=self.get_validators().map!(|validator| validator.pub_key);
assert!(signatures.length() >= threshold, NotEnoughSignatures);
let mut total=0;
let mut i = 0;
let mut unique_verified_pubkey = vector::empty();
while (i < signatures.length()) {
let signature = signatures.borrow(i);
let pub_key = get_pubkey_from_signature(signature);
if (validators.contains(&pub_key)) {

if (verify_signature(&pub_key,signature,&msg)){
total=total+1;

if (total >= threshold) {
if (!unique_verified_pubkey.contains(&pub_key)){
unique_verified_pubkey.push_back(pub_key);
};

if (unique_verified_pubkey.length() >= threshold) {
return
};
};
};
i=i+1;
};
assert!(total >= threshold, VerifiedSignaturesLessThanThreshold);
assert!(unique_verified_pubkey.length() >= threshold, VerifiedSignaturesLessThanThreshold);
}

public(package) fun get_validator_threshold(self:&State):u64{
Expand Down

0 comments on commit 441f1d8

Please sign in to comment.