1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::TxContext;
use dharitri_wasm::api::CryptoApi;
use dharitri_wasm::types::H256;
use sha2::Sha256;
use sha3::{Digest, Keccak256};

impl CryptoApi for TxContext {
	fn sha256(&self, data: &[u8]) -> H256 {
		let mut hasher = Sha256::new();
		hasher.update(data);
		let hash: [u8; 32] = hasher.finalize().into();
		hash.into()
	}

	fn keccak256(&self, data: &[u8]) -> H256 {
		let mut hasher = Keccak256::new();
		hasher.update(data);
		let hash: [u8; 32] = hasher.finalize().into();
		hash.into()
	}

	fn verify_bls(&self, _key: &[u8], _message: &[u8], _signature: &[u8]) -> bool {
		panic!("verify_bls not implemented yet!")
	}

	fn verify_ed25519(&self, _key: &[u8], _message: &[u8], _signature: &[u8]) -> bool {
		panic!("verify_ed25519 not implemented yet!")
	}

	fn verify_secp256k1(&self, _key: &[u8], _message: &[u8], _signature: &[u8]) -> bool {
		panic!("verify_secp256k1 not implemented yet!")
	}
}