Skip to content

Commit

Permalink
Add ability to verify signature in xfile dchange.
Browse files Browse the repository at this point in the history
Every round, the master node checks the federations file to add xfield and
member nodes verify their federations file signature and block xfield before signing the block
Add tests to verify max block size and aggregated pubkey changes with signatures
  • Loading branch information
Naviabheeman committed Dec 4, 2023
1 parent 1e6ada4 commit e522d66
Show file tree
Hide file tree
Showing 10 changed files with 831 additions and 173 deletions.
13 changes: 12 additions & 1 deletion src/bin/tapyrus-signerd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ mod tests {
}

#[test]
fn test_load_federations_has_max_block_size() {
fn test_load_federations_ihas_max_block_size() {
let pubkey = PublicKey::from_str(
"0302f5584e30d2ee32e772d04ff8ee1efc90a7a91ac5b7c4025da7a42a67d06a25",
)
Expand All @@ -266,4 +266,15 @@ mod tests {
load_federations(&pubkey, path);
}

#[test]
#[should_panic(expected = "federations_file: InvalidSig")]
fn test_load_federations_has_invalid_signature() {
let pubkey = PublicKey::from_str(
"039af53a49a365576de41a2e70cc148353d7d1f4cad45f888fd8bc6d2c94a97657",
)
.unwrap();

let path = Path::new("tests/resources/federations_has_invalid_signature.toml");
load_federations(&pubkey, path);
}
}
4 changes: 2 additions & 2 deletions src/crypto/vss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ impl Vss {
let local_sig_for_positive = Sign::sign_xfield(
&shared_keys_for_positive,
&priv_shared_keys,
xfield.signature_hash()?,
xfield.signature_hash().unwrap(),
);

let shared_keys_for_negative =
Sign::verify_vss_and_construct_key(&shared_block_secrets.for_negative(), &index)?;
let local_sig_for_negative = Sign::sign_xfield(
&shared_keys_for_negative,
&priv_shared_keys,
xfield.signature_hash()?,
xfield.signature_hash().unwrap(),
);
Self::create_local_sig_from_shares(
priv_shared_keys,
Expand Down
4 changes: 3 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ pub enum Error {
/// Error when the aggregated public key included the candidate block is invalid.
InvalidAggregatedPublicKey,
/// xField is not supported by signer.
UnsupportedXField,
UnsupportedXField(String),
UnauthorizedFederationChange(u32),
XfieldFederationMismatch(Option<u32>, &'static str),
}

impl std::fmt::Display for Error {
Expand Down
Loading

0 comments on commit e522d66

Please sign in to comment.