|
1 | 1 | use bls_signatures::{BasicSchemeMPL, G1Element, G2Element, Scheme}; |
2 | 2 | use blsful::Bls12381G2Impl; |
3 | | -use hashes::{Hash, sha256d}; |
| 3 | +use hashes::Hash; |
4 | 4 |
|
5 | | -use crate::bls_sig_utils::BLSSignature; |
6 | 5 | use crate::sml::masternode_list_entry::MasternodeListEntry; |
7 | | -use crate::sml::message_verification_error::MessageVerificationError; |
8 | 6 | use crate::sml::quorum_entry::qualified_quorum_entry::QualifiedQuorumEntry; |
9 | 7 | use crate::sml::quorum_validation_error::QuorumValidationError; |
10 | 8 |
|
@@ -112,56 +110,6 @@ impl QualifiedQuorumEntry { |
112 | 110 | .map_err(|e| QuorumValidationError::ThresholdSignatureNotValid(e.to_string())) |
113 | 111 | } |
114 | 112 |
|
115 | | - /// Verifies a message digest using a BLS threshold signature. |
116 | | - /// |
117 | | - /// This function checks whether the provided BLS signature is valid for the given |
118 | | - /// `message_digest` using the quorum's public key. It converts the stored quorum public key |
119 | | - /// and the provided BLS signature into the appropriate types before performing the verification. |
120 | | - /// |
121 | | - /// # Arguments |
122 | | - /// |
123 | | - /// * `message_digest` - A SHA-256 double-hashed (`sha256d::Hash`) digest of the message to be verified. |
124 | | - /// * `signature` - The BLS signature (`BLSSignature`) that should authenticate the message. |
125 | | - /// |
126 | | - /// # Returns |
127 | | - /// |
128 | | - /// * `Ok(())` if the signature is valid for the given digest and quorum public key. |
129 | | - /// * `Err(MessageVerificationError::ThresholdSignatureNotValid)` if the signature verification fails. |
130 | | - /// |
131 | | - /// # Errors |
132 | | - /// |
133 | | - /// Returns `MessageVerificationError::ThresholdSignatureNotValid` if: |
134 | | - /// - The quorum's public key cannot be converted to the required `blsful::PublicKey<Bls12381G2Impl>`. |
135 | | - /// - The provided signature cannot be converted to `blsful::Signature<Bls12381G2Impl>`. |
136 | | - /// - The BLS verification process determines that the signature is invalid. |
137 | | - /// |
138 | | - /// # Implementation Details |
139 | | - /// |
140 | | - /// - The function retrieves the quorum's public key and attempts to convert it into the expected `blsful::PublicKey` type. |
141 | | - /// - It converts the provided `BLSSignature` into a `blsful::Signature`. |
142 | | - /// - It then calls the `verify` method, which checks if the signature is valid for the given message digest. |
143 | | - /// - If verification fails, it returns a `MessageVerificationError::ThresholdSignatureNotValid` with relevant details. |
144 | | - /// |
145 | | - pub fn verify_message_digest( |
146 | | - &self, |
147 | | - message_digest: [u8; 32], |
148 | | - signature: BLSSignature, |
149 | | - ) -> Result<(), MessageVerificationError> { |
150 | | - let public_key: blsful::PublicKey<Bls12381G2Impl> = |
151 | | - self.quorum_entry.quorum_public_key.try_into()?; |
152 | | - let bls_signature: blsful::Signature<Bls12381G2Impl> = signature.try_into()?; |
153 | | - bls_signature.verify(&public_key, message_digest).map_err(|e| { |
154 | | - MessageVerificationError::ThresholdSignatureNotValid( |
155 | | - signature, |
156 | | - sha256d::Hash::from_byte_array(message_digest), |
157 | | - self.quorum_entry.quorum_public_key, |
158 | | - self.quorum_entry.quorum_hash, |
159 | | - self.quorum_entry.llmq_type, |
160 | | - e.to_string(), |
161 | | - ) |
162 | | - }) |
163 | | - } |
164 | | - |
165 | 113 | /// Performs full quorum validation by verifying all necessary signatures. |
166 | 114 | /// |
167 | 115 | /// This function validates the quorum by checking: |
|
0 commit comments