Skip to main content

miden_node_proto/domain/
validator.rs

1use miden_protobuf::{BuildUnchecked, ConversionError, ConversionResultExt, Verify};
2use miden_protocol::Word;
3use miden_protocol::crypto::dsa::ecdsa_k256_keccak::{PublicKey, Signature};
4
5use crate::generated as proto;
6
7/// A single validator's response to a `sign_block` request.
8#[derive(Debug, Clone)]
9pub struct SignBlockResponse {
10    pub signature: Signature,
11    pub block_commitment: Word,
12    pub public_key: PublicKey,
13}
14
15impl BuildUnchecked for proto::miden::validator::v1::DecodedSignBlockResponse {
16    type Output = SignBlockResponse;
17    type Error = ConversionError;
18
19    /// Decode the signature and key without authenticating the response. The caller must match the
20    /// commitment to its proposed block and verify the signature against the trusted parent
21    /// validator set.
22    fn build_unchecked(self) -> Result<Self::Output, Self::Error> {
23        Ok(SignBlockResponse {
24            signature: self.signature.verify().context("signature")?,
25            block_commitment: self.block_commitment,
26            public_key: self.public_key.verify().context("public_key")?,
27        })
28    }
29}