diff --git a/chain-impl-mockchain/src/header/builder.rs b/chain-impl-mockchain/src/header/builder.rs index 90a5e89e9..f2d3bb0e8 100644 --- a/chain-impl-mockchain/src/header/builder.rs +++ b/chain-impl-mockchain/src/header/builder.rs @@ -146,21 +146,22 @@ impl HeaderBuilder { impl HeaderBftBuilder { pub fn sign_using(self, sk: &SecretKey) -> 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, pk: PublicKey) -> HeaderBft { + fn sign_using_keys(self, sk: &SecretKey, pk: PublicKey) -> 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, pk: PublicKey) -> HeaderBft { + self.sign_using_keys(sk, pk) + } + pub fn set_consensus_data( self, bft_leaderid: &BftLeaderId,