numbat_wasm_debug/api/
crypto_api_mock.rs

1use crate::TxContext;
2use numbat_wasm::{
3    api::CryptoApi,
4    types::{BoxedBytes, MessageHashType, H256},
5};
6use sha2::Sha256;
7use sha3::{Digest, Keccak256};
8
9impl CryptoApi for TxContext {
10    fn sha256(&self, data: &[u8]) -> H256 {
11        let mut hasher = Sha256::new();
12        hasher.update(data);
13        let hash: [u8; 32] = hasher.finalize().into();
14        hash.into()
15    }
16
17    fn keccak256(&self, data: &[u8]) -> H256 {
18        let mut hasher = Keccak256::new();
19        hasher.update(data);
20        let hash: [u8; 32] = hasher.finalize().into();
21        hash.into()
22    }
23
24    fn ripemd160(&self, _data: &[u8]) -> Box<[u8; 20]> {
25        panic!("ripemd160 not implemented yet!")
26    }
27
28    fn verify_bls(&self, _key: &[u8], _message: &[u8], _signature: &[u8]) -> bool {
29        panic!("verify_bls not implemented yet!")
30    }
31
32    fn verify_ed25519(&self, _key: &[u8], _message: &[u8], _signature: &[u8]) -> bool {
33        panic!("verify_ed25519 not implemented yet!")
34    }
35
36    fn verify_secp256k1(&self, _key: &[u8], _message: &[u8], _signature: &[u8]) -> bool {
37        panic!("verify_secp256k1 not implemented yet!")
38    }
39
40    fn verify_custom_secp256k1(
41        &self,
42        _key: &[u8],
43        _message: &[u8],
44        _signature: &[u8],
45        _hash_type: MessageHashType,
46    ) -> bool {
47        panic!("verify_custom_secp256k1 not implemented yet!")
48    }
49
50    fn encode_secp256k1_der_signature(&self, _r: &[u8], _s: &[u8]) -> BoxedBytes {
51        panic!("encode_secp256k1_signature not implemented yet!")
52    }
53}