Skip to content

Commit

Permalink
move sign_using_unsafe under tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania authored and ecioppettini committed Oct 6, 2021
1 parent 174e7e0 commit a70cd9c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions chain-impl-mockchain/src/header/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,22 @@ impl HeaderBuilder<HeaderCommonDone> {

impl HeaderBftBuilder<HeaderSetConsensusData> {
pub fn sign_using(self, sk: &SecretKey<Ed25519>) -> HeaderBft {
let pk = sk.to_public();
let sret = self.set_consensus_data(&BftLeaderId(pk));
let sig = sk.sign_slice(sret.get_authenticated_data());

sret.set_signature(BftSignature(sig))
self.sign_using_keys(sk, sk.to_public())
}

/// Method introduced for negative testing. It does not derive public key from secret, but allow
/// not linked public keys
pub fn sign_using_unsafe(self, sk: &SecretKey<Ed25519>, pk: PublicKey<Ed25519>) -> HeaderBft {
fn sign_using_keys(self, sk: &SecretKey<Ed25519>, pk: PublicKey<Ed25519>) -> HeaderBft {
let sret = self.set_consensus_data(&BftLeaderId(pk));
let sig = sk.sign_slice(sret.get_authenticated_data());
sret.set_signature(BftSignature(sig))
}

#[cfg(test)]
pub fn sign_using_unsafe(self, sk: &SecretKey<Ed25519>, pk: PublicKey<Ed25519>) -> HeaderBft {
self.sign_using_keys(sk, pk)
}

pub fn set_consensus_data(
self,
bft_leaderid: &BftLeaderId,
Expand Down

0 comments on commit a70cd9c

Please sign in to comment.