[bug] implement a from_merkle_root method for ValidationHash instead of from_byte_array

This commit is contained in:
Sosthene 2024-12-03 22:33:24 +01:00
parent 72a3230952
commit e47059668d

View File

@ -6,8 +6,6 @@ use sp_client::bitcoin::key::Secp256k1;
use sp_client::bitcoin::secp256k1::schnorr::Signature;
use sp_client::bitcoin::secp256k1::{Keypair, Message, PublicKey, SecretKey};
use crate::pcd::AnkPcdHash;
sha256t_hash_newtype! {
pub struct AnkMessageTag = hash_str("4nk/Message");
@ -34,17 +32,17 @@ impl AnkMessageHash {
}
impl AnkValidationYesHash {
pub fn from_commitment(commitment: AnkPcdHash) -> Self {
pub fn from_merkle_root(merkle_root: [u8; 32]) -> Self {
let mut eng = AnkValidationYesHash::engine();
eng.input(&commitment.to_byte_array());
eng.input(&merkle_root);
AnkValidationYesHash::from_engine(eng)
}
}
impl AnkValidationNoHash {
pub fn from_commitment(commitment: AnkPcdHash) -> Self {
pub fn from_merkle_root(merkle_root: [u8; 32]) -> Self {
let mut eng = AnkValidationNoHash::engine();
eng.input(&commitment.to_byte_array());
eng.input(&merkle_root);
AnkValidationNoHash::from_engine(eng)
}
}