@@ -31,11 +31,12 @@ mod tests {
31
31
use super :: * ;
32
32
use crate :: {
33
33
Field ,
34
+ Group ,
34
35
Scalar ,
35
36
test:: create_native_field_vector,
36
37
types:: native:: { BHP256Native , BHP512Native , BHP768Native , BHP1024Native } ,
37
38
} ;
38
- use snarkvm_console:: algorithms:: { Commit , Hash , ToBits } ;
39
+ use snarkvm_console:: algorithms:: { Commit , CommitUncompressed , Hash , HashUncompressed , ToBits } ;
39
40
40
41
use js_sys:: Array ;
41
42
use wasm_bindgen:: JsValue ;
@@ -76,30 +77,54 @@ mod tests {
76
77
let hash_512 = bhp512. hash ( bit_array. clone ( ) ) . unwrap ( ) ;
77
78
let hash_768 = bhp768. hash ( bit_array. clone ( ) ) . unwrap ( ) ;
78
79
let hash_1024 = bhp1024. hash ( bit_array. clone ( ) ) . unwrap ( ) ;
80
+ let hash_to_group_256 = bhp256. hash_to_group ( bit_array. clone ( ) ) . unwrap ( ) ;
81
+ let hash_to_group_512 = bhp512. hash_to_group ( bit_array. clone ( ) ) . unwrap ( ) ;
82
+ let hash_to_group_768 = bhp768. hash_to_group ( bit_array. clone ( ) ) . unwrap ( ) ;
83
+ let hash_to_group_1024 = bhp1024. hash_to_group ( bit_array. clone ( ) ) . unwrap ( ) ;
79
84
let commit_256 = bhp256. commit ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
80
85
let commit_512 = bhp512. commit ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
81
86
let commit_768 = bhp768. commit ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
82
87
let commit_1024 = bhp1024. commit ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
88
+ let commit_to_group_256 = bhp256. commit_to_group ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
89
+ let commit_to_group_512 = bhp512. commit_to_group ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
90
+ let commit_to_group_768 = bhp768. commit_to_group ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
91
+ let commit_to_group_1024 = bhp1024. commit_to_group ( bit_array. clone ( ) , scalar. clone ( ) ) . unwrap ( ) ;
83
92
84
93
// Hash and commit to the field element using all native BHP hasher instances.
85
94
let native_hash_256 = native_bhp256. hash ( & bit_vector) . unwrap ( ) ;
86
95
let native_hash_512 = native_bhp512. hash ( & bit_vector) . unwrap ( ) ;
87
96
let native_hash_768 = native_bhp768. hash ( & bit_vector) . unwrap ( ) ;
88
97
let native_hash_1024 = native_bhp1024. hash ( & bit_vector) . unwrap ( ) ;
98
+ let native_hash_to_group_256 = native_bhp256. hash_uncompressed ( & bit_vector) . unwrap ( ) ;
99
+ let native_hash_to_group_512 = native_bhp512. hash_uncompressed ( & bit_vector) . unwrap ( ) ;
100
+ let native_hash_to_group_768 = native_bhp768. hash_uncompressed ( & bit_vector) . unwrap ( ) ;
101
+ let native_hash_to_group_1024 = native_bhp1024. hash_uncompressed ( & bit_vector) . unwrap ( ) ;
89
102
let native_commit_256 = native_bhp256. commit ( & bit_vector, & scalar) . unwrap ( ) ;
90
103
let native_commit_512 = native_bhp512. commit ( & bit_vector, & scalar) . unwrap ( ) ;
91
104
let native_commit_768 = native_bhp768. commit ( & bit_vector, & scalar) . unwrap ( ) ;
92
105
let native_commit_1024 = native_bhp1024. commit ( & bit_vector, & scalar) . unwrap ( ) ;
106
+ let native_commit_to_group_256 = native_bhp256. commit_uncompressed ( & bit_vector, & scalar) . unwrap ( ) ;
107
+ let native_commit_to_group_512 = native_bhp512. commit_uncompressed ( & bit_vector, & scalar) . unwrap ( ) ;
108
+ let native_commit_to_group_768 = native_bhp768. commit_uncompressed ( & bit_vector, & scalar) . unwrap ( ) ;
109
+ let native_commit_to_group_1024 = native_bhp1024. commit_uncompressed ( & bit_vector, & scalar) . unwrap ( ) ;
93
110
94
111
// Assert native and exported results are equal.
95
112
assert_eq ! ( hash_256, Field :: from( native_hash_256) ) ;
96
113
assert_eq ! ( hash_512, Field :: from( native_hash_512) ) ;
97
114
assert_eq ! ( hash_768, Field :: from( native_hash_768) ) ;
98
115
assert_eq ! ( hash_1024, Field :: from( native_hash_1024) ) ;
116
+ assert_eq ! ( hash_to_group_256, Group :: from( native_hash_to_group_256) ) ;
117
+ assert_eq ! ( hash_to_group_512, Group :: from( native_hash_to_group_512) ) ;
118
+ assert_eq ! ( hash_to_group_768, Group :: from( native_hash_to_group_768) ) ;
119
+ assert_eq ! ( hash_to_group_1024, Group :: from( native_hash_to_group_1024) ) ;
99
120
assert_eq ! ( commit_256, Field :: from( native_commit_256) ) ;
100
121
assert_eq ! ( commit_512, Field :: from( native_commit_512) ) ;
101
122
assert_eq ! ( commit_768, Field :: from( native_commit_768) ) ;
102
123
assert_eq ! ( commit_1024, Field :: from( native_commit_1024) ) ;
124
+ assert_eq ! ( commit_to_group_256, Group :: from( native_commit_to_group_256) ) ;
125
+ assert_eq ! ( commit_to_group_512, Group :: from( native_commit_to_group_512) ) ;
126
+ assert_eq ! ( commit_to_group_768, Group :: from( native_commit_to_group_768) ) ;
127
+ assert_eq ! ( commit_to_group_1024, Group :: from( native_commit_to_group_1024) ) ;
103
128
}
104
129
}
105
130
}
0 commit comments