miden_protocol/block/signer.rs
1use crate::block::BlockHeader;
2use crate::crypto::dsa::ecdsa_k256_keccak as ecdsa;
3use crate::crypto::dsa::ecdsa_k256_keccak::SecretKey;
4
5// BLOCK SIGNER
6// ================================================================================================
7
8/// Trait which abstracts the signing of block headers with ECDSA signatures.
9///
10/// Production-level implementations will involve some sort of secure remote backend. The trait also
11/// allows for testing with local and ephemeral signers.
12pub trait BlockSigner {
13 fn sign(&self, header: &BlockHeader) -> ecdsa::Signature;
14 fn public_key(&self) -> ecdsa::PublicKey;
15}
16
17// SECRET KEY BLOCK SIGNER
18// ================================================================================================
19
20impl BlockSigner for SecretKey {
21 fn sign(&self, header: &BlockHeader) -> ecdsa::Signature {
22 self.sign(header.commitment())
23 }
24
25 fn public_key(&self) -> ecdsa::PublicKey {
26 self.public_key()
27 }
28}