spacemeshos / svm

SVM - Spacemesh Virtual Machine
https://spacemesh.io
MIT License
85 stars 14 forks source link

SVM SDK Hasher #443

Open YaronWittenstein opened 2 years ago

YaronWittenstein commented 2 years ago

Depends on: #440 #442 #444

So once we've got the svm_hash function working, we'd like to make it pleasantly accessed within the SVM SDK. Let's assume that the implemented svm_hash output Hashes of 32 byte-length.

Here is an example for an API using Hash.

svm_sdk::Hasher;

let tx: &[u8] = Host::transaction();
let hash: Blob32 = Hasher::hash(tx); 

Of course, it's crucial to write a Template and make sure it abides by the Fixed-Gas Wasm rules.