@@ -7,8 +7,10 @@ use starknet::secp256k1::Secp256k1Point;
77use crate :: cheatcode :: execute_cheatcode_and_deserialize;
88use super :: SignError ;
99
10+ pub type Secp256k1CurveKeyPair = KeyPair <u256 , Secp256k1Point >;
11+
1012pub impl Secp256k1CurveKeyPairImpl of KeyPairTrait <u256 , Secp256k1Point > {
11- fn generate () -> KeyPair < u256 , Secp256k1Point > {
13+ fn generate () -> Secp256k1CurveKeyPair {
1214 let (secret_key , pk_x , pk_y ) = execute_cheatcode_and_deserialize :: <
1315 ' generate_ecdsa_keys' , (u256 , u256 , u256 ),
1416 >(array! [' Secp256k1' ]. span ());
@@ -18,7 +20,7 @@ pub impl Secp256k1CurveKeyPairImpl of KeyPairTrait<u256, Secp256k1Point> {
1820 KeyPair { secret_key , public_key }
1921 }
2022
21- fn from_secret_key (secret_key : u256 ) -> KeyPair < u256 , Secp256k1Point > {
23+ fn from_secret_key (secret_key : u256 ) -> Secp256k1CurveKeyPair {
2224 if (secret_key == 0_u256
2325 || secret_key >= Secp256Trait :: <Secp256k1Point >:: get_curve_size ()) {
2426 core :: panic_with_felt252 (' invalid secret_key' );
@@ -32,12 +34,8 @@ pub impl Secp256k1CurveKeyPairImpl of KeyPairTrait<u256, Secp256k1Point> {
3234 }
3335}
3436
35- pub impl Secp256k1CurveSignerImpl of SignerTrait <
36- KeyPair <u256 , Secp256k1Point >, u256 , (u256 , u256 ),
37- > {
38- fn sign (
39- self : KeyPair <u256 , Secp256k1Point >, message_hash : u256 ,
40- ) -> Result <(u256 , u256 ), SignError > {
37+ pub impl Secp256k1CurveSignerImpl of SignerTrait <Secp256k1CurveKeyPair , u256 , (u256 , u256 )> {
38+ fn sign (self : Secp256k1CurveKeyPair , message_hash : u256 ) -> Result <(u256 , u256 ), SignError > {
4139 let mut input = array! [' Secp256k1' ];
4240 self . secret_key. serialize (ref input );
4341 message_hash . serialize (ref input );
@@ -46,12 +44,8 @@ pub impl Secp256k1CurveSignerImpl of SignerTrait<
4644 }
4745}
4846
49- pub impl Secp256k1CurveVerifierImpl of VerifierTrait <
50- KeyPair <u256 , Secp256k1Point >, u256 , (u256 , u256 ),
51- > {
52- fn verify (
53- self : KeyPair <u256 , Secp256k1Point >, message_hash : u256 , signature : (u256 , u256 ),
54- ) -> bool {
47+ pub impl Secp256k1CurveVerifierImpl of VerifierTrait <Secp256k1CurveKeyPair , u256 , (u256 , u256 )> {
48+ fn verify (self : Secp256k1CurveKeyPair , message_hash : u256 , signature : (u256 , u256 )) -> bool {
5549 let (r , s ) = signature ;
5650 is_valid_signature :: <Secp256k1Point >(message_hash , r , s , self . public_key)
5751 }
0 commit comments