-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nr
26 lines (25 loc) · 1001 Bytes
/
main.nr
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
fn main(
input: [u8; 64],
input_len: u16,
hash: pub [u8; 32]
) {
let compare_hash = dep::sha2::sha256(input, input_len);
assert(hash == compare_hash);
}
#[test]
fn test_main() {
// Hal Finney was a cypherpunk pioneer
let test_msg: [u8; 64] = [
0x48, 0x61, 0x6c, 0x20, 0x46, 0x69, 0x6e, 0x6e,
0x65, 0x79, 0x20, 0x77, 0x61, 0x73, 0x20, 0x61,
0x20, 0x63, 0x79, 0x70, 0x68, 0x65, 0x72, 0x70,
0x75, 0x6e, 0x6b, 0x20, 0x70, 0x69, 0x6f, 0x6e,
0x65, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
let test_hash: [u8; 32] = [
0xd4, 0x5d, 0xa9, 0xcf, 0x6f, 0xc0, 0xe0, 0x56, 0x7e, 0xa2, 0x7d, 0xf1, 0xbb, 0x17, 0xfb, 0x0a,
0x28, 0x10, 0x29, 0xca, 0x23, 0x17, 0x4f, 0xd0, 0x64, 0xad, 0xc4, 0x9a, 0x98, 0x7f, 0xd9, 0xff];
main(test_msg, 35, test_hash);
}