implement blake2b hash

This commit is contained in:
2026-01-04 11:56:50 +01:00
parent 420f296ca5
commit 65913868b0
2 changed files with 121 additions and 1 deletions

View File

@@ -1,4 +1,13 @@
func main[] : i64
// Blake2b
let out: ptr = crypto.blake2b.hash(32, 0, 0, "Hello, World!", 13)
io.print("Blake2b-256: ")
io.println(str.hex_encode(out, 32))
io.print("Blake2b-512: ")
out = crypto.blake2b.hash(64, 0, 0, "Hello, World!", 13)
io.println(str.hex_encode(out, 64))
// XChaCha20
let key: ptr = str.hex_decode("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
let nonce: ptr = str.hex_decode("000102030405060708090a0b0c0d0e0f1011121314151617")
@@ -14,7 +23,7 @@ func main[] : i64
let point: ptr = str.hex_decode("e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c")
let expected: ptr = str.hex_decode("c3da55379de9c6908e94ea4df28d084f32eccf03491c71f754b4075577a28552")
let out: ptr = crypto.x25519.scalarmult(scalar, point)
out = crypto.x25519.scalarmult(scalar, point)
io.print("Computed: ")
io.println(str.hex_encode(out, 32))