Skip to content

Commit

Permalink
fix: log warning on invalid header signature from peer
Browse files Browse the repository at this point in the history
  • Loading branch information
joschisan authored and maan2003 committed Jan 25, 2024
1 parent 4b0f47c commit 85637e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fedimint-server/src/atomic_broadcast/keychain.rs
Expand Up @@ -3,7 +3,7 @@ use std::io::Write;

use aleph_bft::Keychain as KeychainTrait;
use fedimint_core::session_outcome::{consensus_hash_sha256, SchnorrSignature};
use fedimint_core::{BitcoinHash, PeerId};
use fedimint_core::{BitcoinHash, NumPeers, PeerId};
use secp256k1_zkp::hashes::sha256;
use secp256k1_zkp::{schnorr, All, KeyPair, Message, PublicKey, Secp256k1, SecretKey};

Expand Down Expand Up @@ -37,11 +37,11 @@ impl Keychain {
}

pub fn peer_count(&self) -> usize {
self.public_keys.len()
self.public_keys.total()
}

pub fn threshold(&self) -> usize {
(2 * self.peer_count()) / 3 + 1
self.public_keys.threshold()
}

fn tagged_hash(&self, message: &[u8]) -> Message {
Expand Down
2 changes: 2 additions & 0 deletions fedimint-server/src/consensus/server.rs
Expand Up @@ -484,6 +484,8 @@ impl ConsensusServer {
if self.keychain.verify(&header, &signature, to_node_index(peer)){
// since the signature is valid the node index can be converted to a peer id
signatures.insert(peer, signature);
} else {
warn!(target: LOG_CONSENSUS, "Received invalid signature from peer {peer}");
}
}
}
Expand Down

0 comments on commit 85637e8

Please sign in to comment.