Add verify_merkle_proof()
This commit is contained in:
parent
8868529963
commit
b656531dd1
@ -1,4 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use rs_merkle::{algorithms::Sha256, MerkleProof};
|
||||||
use sp_client::silentpayments::{
|
use sp_client::silentpayments::{
|
||||||
bitcoin_hashes::{sha256t_hash_newtype, Hash, HashEngine},
|
bitcoin_hashes::{sha256t_hash_newtype, Hash, HashEngine},
|
||||||
secp256k1::PublicKey,
|
secp256k1::PublicKey,
|
||||||
@ -61,3 +62,8 @@ pub fn decrypt_with_key(key: &[u8; 32], ciphertext: &[u8]) -> Result<Vec<u8>> {
|
|||||||
|
|
||||||
Ok(plaintext)
|
Ok(plaintext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn verify_merkle_proof(proof: &[u8], root: &[u8; 32], index: usize, hash: &[u8; 32], total_leaves_count: usize) -> Result<bool> {
|
||||||
|
let proof = MerkleProof::<Sha256>::from_bytes(proof)?;
|
||||||
|
Ok(proof.verify(*root, &[index], &[*hash], total_leaves_count))
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user