Blake3 syscall (#17358)

This commit is contained in:
Arthur Greef
2021-06-08 11:04:10 -07:00
committed by GitHub
parent 7b58dcac14
commit 28fdfed1ba
11 changed files with 355 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ documentation = "https://docs.rs/solana-bpf-rust-sha"
edition = "2018"
[dependencies]
blake3 = "0.3.7"
solana-program = { path = "../../../../sdk/program", version = "=1.8.0" }
[lib]

11
programs/bpf/rust/sha/src/lib.rs Normal file → Executable file
View File

@@ -19,12 +19,22 @@ fn test_keccak256_hasher() {
assert_eq!(hashv(vals), hasher.result());
}
fn test_blake3_hasher() {
use solana_program::blake3::hashv;
let v0: &[u8] = b"Gaggablaghblagh!";
let v1: &[u8] = b"flurbos!";
let vals: &[&[u8]] = &[v0, v1];
let hash = blake3::hash(&[v0, v1].concat());
assert_eq!(hashv(vals).0, *hash.as_bytes());
}
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
msg!("sha");
test_sha256_hasher();
test_keccak256_hasher();
test_blake3_hasher();
0
}
@@ -39,5 +49,6 @@ mod test {
fn test_sha() {
test_sha256_hasher();
test_keccak256_hasher();
test_blake3_hasher();
}
}