@@ -14,9 +14,9 @@ export interface KeyPairParams {
1414 // accountId?: number;
1515}
1616
17- // export function hexEqual(hex1: string, hex2: string) {
18- // return hex1.toLowerCase( ) === hex2.toLowerCase( );
19- // }
17+ export function hexEqual ( hex1 : string , hex2 : string ) {
18+ return BigInt ( hex1 ) === BigInt ( hex2 ) ;
19+ }
2020
2121export async function generateKeyPair ( {
2222 signMessageAsync,
@@ -36,23 +36,23 @@ export async function generateKeyPair({
3636 chainId
3737 ) ;
3838
39- const generatedKeyPair = await generateKeyPairWasm ( result . signature ) ;
39+ let generatedKeyPair = await generateKeyPairWasm ( result . signature ) ;
4040
41- // if (
42- // publicKey &&
43- // result.signature.length > 3 &&
44- // publicKey.x &&
45- // publicKey.y &&
46- // (!hexEqual(generatedKeyPair.formatedPx, publicKey.x) ||
47- // !hexEqual(generatedKeyPair.formatedPy, publicKey.y))
48- // ) {
49- // const value = result.signature.split('');
50- // let end = value.splice(result.signature.length - 2, 2).join('');
51- // end = end == '1c' ? '01' : '1c';
52- // generatedKeyPair = await generateKeyPairWasm(
53- // value.concat(end.split('')).join('')
54- // );
55- // }
41+ if (
42+ publicKey &&
43+ result . signature . length > 3 &&
44+ publicKey . x &&
45+ publicKey . y &&
46+ ( ! hexEqual ( generatedKeyPair . formatedPx , publicKey . x ) ||
47+ ! hexEqual ( generatedKeyPair . formatedPy , publicKey . y ) )
48+ ) {
49+ const value = result . signature . split ( '' ) ;
50+ let end = value . splice ( result . signature . length - 2 , 2 ) . join ( '' ) ;
51+ end = end == '1c' ? '01' : '1c' ;
52+ generatedKeyPair = await generateKeyPairWasm (
53+ value . concat ( end . split ( '' ) ) . join ( '' )
54+ ) ;
55+ }
5656
5757 return {
5858 counterFactualInfo : result . counterFactualInfo ,
0 commit comments