2
2
use core:: hint:: black_box;
3
3
4
4
use hex:: FromHex ;
5
- use openvm_sha2:: sha256;
5
+ use openvm_sha2:: { sha256, sha384 , sha512 } ;
6
6
// ANCHOR_END: imports
7
7
8
8
// ANCHOR: main
@@ -12,12 +12,26 @@ pub fn main() {
12
12
let test_vectors = [ (
13
13
"" ,
14
14
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ,
15
+ "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ,
16
+ "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ,
15
17
) ] ;
16
- for ( input, expected_output) in test_vectors. iter ( ) {
18
+ for ( input, expected_output_sha256, expected_output_sha512, expected_output_sha384) in
19
+ test_vectors. iter ( )
20
+ {
17
21
let input = Vec :: from_hex ( input) . unwrap ( ) ;
18
- let expected_output = Vec :: from_hex ( expected_output) . unwrap ( ) ;
19
- let output = sha256 ( & black_box ( input) ) ;
20
- if output != * expected_output {
22
+ let expected_output_sha256 = Vec :: from_hex ( expected_output_sha256) . unwrap ( ) ;
23
+ let expected_output_sha512 = Vec :: from_hex ( expected_output_sha512) . unwrap ( ) ;
24
+ let expected_output_sha384 = Vec :: from_hex ( expected_output_sha384) . unwrap ( ) ;
25
+ let output = sha256 ( black_box ( & input) ) ;
26
+ if output != * expected_output_sha256 {
27
+ panic ! ( ) ;
28
+ }
29
+ let output = sha512 ( black_box ( & input) ) ;
30
+ if output != * expected_output_sha512 {
31
+ panic ! ( ) ;
32
+ }
33
+ let output = sha384 ( black_box ( & input) ) ;
34
+ if output != * expected_output_sha384 {
21
35
panic ! ( ) ;
22
36
}
23
37
}
0 commit comments