From 064f56d952ad88cca37b804805c9dfc6890a368e Mon Sep 17 00:00:00 2001 From: Aaron Feickert <66188213+AaronFeickert@users.noreply.github.com> Date: Wed, 20 Sep 2023 16:58:24 -0500 Subject: [PATCH] Fixes --- .../src/consensus/consensus_encoding/hashing.rs | 4 ++-- .../side_chain/validator_node_signature.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/base_layer/core/src/consensus/consensus_encoding/hashing.rs b/base_layer/core/src/consensus/consensus_encoding/hashing.rs index 5fb0d2a650..8c66d25b67 100644 --- a/base_layer/core/src/consensus/consensus_encoding/hashing.rs +++ b/base_layer/core/src/consensus/consensus_encoding/hashing.rs @@ -147,7 +147,7 @@ mod tests { #[test] fn it_hashes_using_the_domain_hasher() { - let mut hasher = Blake2b::::default(); + let mut hasher = Blake2b::::default(); TestHashDomain::add_domain_separation_tag(&mut hasher, "foo"); let expected_hash = hasher.chain_update(b"\xff\x00\x00\x00\x00\x00\x00\x00").finalize(); @@ -162,7 +162,7 @@ mod tests { fn it_adds_to_hash_challenge_in_complete_chunks() { // Script is chosen because the consensus encoding impl for TariScript has 2 writes let test_subject = script!(Nop); - let mut hasher = Blake2b::::default(); + let mut hasher = Blake2b::::default(); TestHashDomain::add_domain_separation_tag(&mut hasher, "foo"); let expected_hash = hasher.chain_update(b"\x01\x73").finalize(); diff --git a/base_layer/core/src/transactions/transaction_components/side_chain/validator_node_signature.rs b/base_layer/core/src/transactions/transaction_components/side_chain/validator_node_signature.rs index cc74ff4f8e..e06e89f594 100644 --- a/base_layer/core/src/transactions/transaction_components/side_chain/validator_node_signature.rs +++ b/base_layer/core/src/transactions/transaction_components/side_chain/validator_node_signature.rs @@ -22,10 +22,10 @@ use blake2::Blake2b; use borsh::{BorshDeserialize, BorshSerialize}; -use digest::consts::U32; +use digest::consts::U64; use rand::rngs::OsRng; use serde::{Deserialize, Serialize}; -use tari_common_types::types::{FixedHash, PrivateKey, PublicKey, Signature}; +use tari_common_types::types::{PrivateKey, PublicKey, Signature}; use tari_crypto::{hash_domain, hashing::DomainSeparatedHasher, keys::PublicKey as PublicKeyT}; use tari_utilities::ByteArray; @@ -50,13 +50,13 @@ impl ValidatorNodeSignature { let (secret_nonce, public_nonce) = PublicKey::random_keypair(&mut OsRng); let public_key = PublicKey::from_secret_key(private_key); let challenge = Self::construct_challenge(&public_key, &public_nonce, msg); - let signature = Signature::sign_raw(private_key, secret_nonce, &*challenge) - .expect("Sign cannot fail with 32-byte challenge and a RistrettoPublicKey"); + let signature = Signature::sign_raw(private_key, secret_nonce, &challenge) + .expect("Sign cannot fail with 64-byte challenge and a RistrettoPublicKey"); Self { public_key, signature } } - fn construct_challenge(public_key: &PublicKey, public_nonce: &PublicKey, msg: &[u8]) -> FixedHash { - let hasher = DomainSeparatedHasher::, ValidatorNodeHashDomain>::new_with_label("registration") + fn construct_challenge(public_key: &PublicKey, public_nonce: &PublicKey, msg: &[u8]) -> [u8; 64] { + let hasher = DomainSeparatedHasher::, ValidatorNodeHashDomain>::new_with_label("registration") .chain(public_key.as_bytes()) .chain(public_nonce.as_bytes()) .chain(msg); @@ -65,7 +65,7 @@ impl ValidatorNodeSignature { pub fn is_valid_signature_for(&self, msg: &[u8]) -> bool { let challenge = Self::construct_challenge(&self.public_key, self.signature.get_public_nonce(), msg); - self.signature.verify_challenge(&self.public_key, &*challenge) + self.signature.verify_challenge(&self.public_key, &challenge) } pub fn public_key(&self) -> &PublicKey {