Skip to content

Commit

Permalink
sign_pop
Browse files Browse the repository at this point in the history
  • Loading branch information
pompon0 committed Aug 22, 2024
1 parent fa035ec commit 554b13e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion node/libs/crypto/src/bls12_381/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ impl SecretKey {
/// Produces a proof of possession for the public key corresponding to this [`SecretKey`]
pub fn sign_pop(&self) -> ProofOfPossession {
let msg = self.public().encode();

ProofOfPossession(self.0.sign(&msg, DST_POP, &[]))
}

Expand Down
7 changes: 6 additions & 1 deletion node/libs/roles/src/validator/keys/secret_key.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{PublicKey, Signature};
use super::{ProofOfPossession, PublicKey, Signature};
use crate::validator::messages::{Msg, MsgHash, Signed};
use std::{fmt, sync::Arc};
use zksync_consensus_crypto::{bls12_381, ByteFmt, Text, TextFmt};
Expand Down Expand Up @@ -35,6 +35,11 @@ impl SecretKey {
pub fn sign_hash(&self, msg_hash: &MsgHash) -> Signature {
Signature(self.0.sign(&ByteFmt::encode(msg_hash)))
}

/// Signa a proof of possession.
pub fn sign_pop(&self) -> ProofOfPossession {
ProofOfPossession(self.0.sign_pop())
}
}

impl ByteFmt for SecretKey {
Expand Down
2 changes: 1 addition & 1 deletion node/libs/roles/src/validator/keys/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct ProofOfPossession(pub(crate) bls12_381::ProofOfPossession);

impl ProofOfPossession {
/// Verifies the proof against the public key.
pub fn verify(&self, pk: PublicKey) -> anyhow::Result<()> {
pub fn verify(&self, pk: &PublicKey) -> anyhow::Result<()> {
self.0.verify(&pk.0)
}
}
Expand Down

0 comments on commit 554b13e

Please sign in to comment.