testnumbat_wasm/api/
crypto_api.rs

1use crate::types::{BoxedBytes, MessageHashType, H256};
2use alloc::boxed::Box;
3
4pub trait CryptoApi {
5    fn sha256(&self, data: &[u8]) -> H256;
6
7    fn keccak256(&self, data: &[u8]) -> H256;
8
9    fn ripemd160(&self, data: &[u8]) -> Box<[u8; 20]>;
10
11    fn verify_bls(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool;
12
13    fn verify_ed25519(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool;
14
15    /// Note: the signature is minimum 2 bytes in length,
16    /// the second byte encodes the length of the remaining signature bytes.
17    fn verify_secp256k1(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool;
18
19    fn verify_custom_secp256k1(
20        &self,
21        key: &[u8],
22        message: &[u8],
23        signature: &[u8],
24        hash_type: MessageHashType,
25    ) -> bool;
26
27    fn encode_secp256k1_der_signature(&self, r: &[u8], s: &[u8]) -> BoxedBytes;
28}