@@ -2846,7 +2846,61 @@ fn gas_call_runtime_reentrancy_guarded() {
2846
2846
2847
2847
#[ test]
2848
2848
fn ecdsa_recover ( ) {
2849
- let ( wasm, _code_hash) = compile_module :: < Test > ( "ecdsa_recover" ) . unwrap ( ) ;
2849
+ #[ rustfmt:: skip]
2850
+ let signature: [ u8 ; 65 ] = [
2851
+ 161 , 234 , 203 , 74 , 147 , 96 , 51 , 212 , 5 , 174 , 231 , 9 , 142 , 48 , 137 , 201 ,
2852
+ 162 , 118 , 192 , 67 , 239 , 16 , 71 , 216 , 125 , 86 , 167 , 139 , 70 , 7 , 86 , 241 ,
2853
+ 33 , 87 , 154 , 251 , 81 , 29 , 160 , 4 , 176 , 239 , 88 , 211 , 244 , 232 , 232 , 52 ,
2854
+ 211 , 234 , 100 , 115 , 230 , 47 , 80 , 44 , 152 , 166 , 62 , 50 , 8 , 13 , 86 , 175 ,
2855
+ 28 ,
2856
+ ] ;
2857
+ #[ rustfmt:: skip]
2858
+ let message_hash: [ u8 ; 32 ] = [
2859
+ 162 , 28 , 244 , 179 , 96 , 76 , 244 , 178 , 188 , 83 , 230 , 248 , 143 , 106 , 77 , 117 ,
2860
+ 239 , 95 , 244 , 171 , 65 , 95 , 62 , 153 , 174 , 166 , 182 , 28 , 130 , 73 , 196 , 208
2861
+ ] ;
2862
+ #[ rustfmt:: skip]
2863
+ let expected_compressed_public_key: [ u8 ; 33 ] = [
2864
+ 2 , 121 , 190 , 102 , 126 , 249 , 220 , 187 , 172 , 85 , 160 , 98 , 149 , 206 , 135 , 11 ,
2865
+ 7 , 2 , 155 , 252 , 219 , 45 , 206 , 40 , 217 , 89 , 242 , 129 , 91 , 22 , 248 , 23 ,
2866
+ 152 ,
2867
+ ] ;
2868
+
2869
+ signature_recover ( "ecdsa_recover" , & signature, & message_hash, & expected_compressed_public_key) ;
2870
+ }
2871
+
2872
+ #[ test]
2873
+ fn sr25519_recover ( ) {
2874
+ #[ rustfmt:: skip]
2875
+ let signature: [ u8 ; 65 ] = [
2876
+ 161 , 234 , 203 , 74 , 147 , 96 , 51 , 212 , 5 , 174 , 231 , 9 , 142 , 48 , 137 , 201 ,
2877
+ 162 , 118 , 192 , 67 , 239 , 16 , 71 , 216 , 125 , 86 , 167 , 139 , 70 , 7 , 86 , 241 ,
2878
+ 33 , 87 , 154 , 251 , 81 , 29 , 160 , 4 , 176 , 239 , 88 , 211 , 244 , 232 , 232 , 52 ,
2879
+ 211 , 234 , 100 , 115 , 230 , 47 , 80 , 44 , 152 , 166 , 62 , 50 , 8 , 13 , 86 , 175 ,
2880
+ 28 ,
2881
+ ] ;
2882
+ #[ rustfmt:: skip]
2883
+ let message_hash: [ u8 ; 32 ] = [
2884
+ 162 , 28 , 244 , 179 , 96 , 76 , 244 , 178 , 188 , 83 , 230 , 248 , 143 , 106 , 77 , 117 ,
2885
+ 239 , 95 , 244 , 171 , 65 , 95 , 62 , 153 , 174 , 166 , 182 , 28 , 130 , 73 , 196 , 208
2886
+ ] ;
2887
+ #[ rustfmt:: skip]
2888
+ let expected_compressed_public_key: [ u8 ; 33 ] = [
2889
+ 2 , 121 , 190 , 102 , 126 , 249 , 220 , 187 , 172 , 85 , 160 , 98 , 149 , 206 , 135 , 11 ,
2890
+ 7 , 2 , 155 , 252 , 219 , 45 , 206 , 40 , 217 , 89 , 242 , 129 , 91 , 22 , 248 , 23 ,
2891
+ 152 ,
2892
+ ] ;
2893
+
2894
+ signature_recover ( "ecdsa_recover" , & signature, & message_hash, & expected_compressed_public_key) ;
2895
+ }
2896
+
2897
+ fn signature_recover (
2898
+ fixture : & str ,
2899
+ signature : & [ u8 ] ,
2900
+ message_hash : & [ u8 ] ,
2901
+ expected_compressed_public_key : & [ u8 ] ,
2902
+ ) {
2903
+ let ( wasm, _code_hash) = compile_module :: < Test > ( fixture) . unwrap ( ) ;
2850
2904
2851
2905
ExtBuilder :: default ( ) . existential_deposit ( 50 ) . build ( ) . execute_with ( || {
2852
2906
let _ = Balances :: deposit_creating ( & ALICE , 1_000_000 ) ;
@@ -2866,25 +2920,6 @@ fn ecdsa_recover() {
2866
2920
. unwrap ( )
2867
2921
. account_id ;
2868
2922
2869
- #[ rustfmt:: skip]
2870
- let signature: [ u8 ; 65 ] = [
2871
- 161 , 234 , 203 , 74 , 147 , 96 , 51 , 212 , 5 , 174 , 231 , 9 , 142 , 48 , 137 , 201 ,
2872
- 162 , 118 , 192 , 67 , 239 , 16 , 71 , 216 , 125 , 86 , 167 , 139 , 70 , 7 , 86 , 241 ,
2873
- 33 , 87 , 154 , 251 , 81 , 29 , 160 , 4 , 176 , 239 , 88 , 211 , 244 , 232 , 232 , 52 ,
2874
- 211 , 234 , 100 , 115 , 230 , 47 , 80 , 44 , 152 , 166 , 62 , 50 , 8 , 13 , 86 , 175 ,
2875
- 28 ,
2876
- ] ;
2877
- #[ rustfmt:: skip]
2878
- let message_hash: [ u8 ; 32 ] = [
2879
- 162 , 28 , 244 , 179 , 96 , 76 , 244 , 178 , 188 , 83 , 230 , 248 , 143 , 106 , 77 , 117 ,
2880
- 239 , 95 , 244 , 171 , 65 , 95 , 62 , 153 , 174 , 166 , 182 , 28 , 130 , 73 , 196 , 208
2881
- ] ;
2882
- #[ rustfmt:: skip]
2883
- const EXPECTED_COMPRESSED_PUBLIC_KEY : [ u8 ; 33 ] = [
2884
- 2 , 121 , 190 , 102 , 126 , 249 , 220 , 187 , 172 , 85 , 160 , 98 , 149 , 206 , 135 , 11 ,
2885
- 7 , 2 , 155 , 252 , 219 , 45 , 206 , 40 , 217 , 89 , 242 , 129 , 91 , 22 , 248 , 23 ,
2886
- 152 ,
2887
- ] ;
2888
2923
let mut params = vec ! [ ] ;
2889
2924
params. extend_from_slice ( & signature) ;
2890
2925
params. extend_from_slice ( & message_hash) ;
@@ -2902,7 +2937,7 @@ fn ecdsa_recover() {
2902
2937
. result
2903
2938
. unwrap ( ) ;
2904
2939
assert ! ( !result. did_revert( ) ) ;
2905
- assert_eq ! ( result. data, EXPECTED_COMPRESSED_PUBLIC_KEY ) ;
2940
+ assert_eq ! ( result. data, expected_compressed_public_key ) ;
2906
2941
} )
2907
2942
}
2908
2943
0 commit comments