File tree 1 file changed +21
-3
lines changed
1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,28 @@ export const isValidPrivateKey = (privateKey: Uint8Array): boolean => {
19
19
return secp256k1 . utils . isValidPrivateKey ( privateKey ) ;
20
20
} ;
21
21
22
- export const getPublicKey = (
22
+ const getGetPublicKey = ( ) : ( (
23
23
privateKey : Uint8Array ,
24
- compressed = false ,
25
- ) : Uint8Array => secp256k1 . getPublicKey ( privateKey , compressed ) ;
24
+ compressed ?: boolean ,
25
+ ) => Uint8Array ) => {
26
+ let hasSetWindowSize = false ;
27
+
28
+ const getPublicKey = (
29
+ privateKey : Uint8Array ,
30
+ compressed = false ,
31
+ ) : Uint8Array => {
32
+ if ( ! hasSetWindowSize ) {
33
+ secp256k1 . ProjectivePoint . BASE . _setWindowSize ( 4 ) ;
34
+ hasSetWindowSize = true ;
35
+ }
36
+ return secp256k1 . getPublicKey ( privateKey , compressed ) ;
37
+ } ;
38
+
39
+ return getPublicKey ;
40
+ } ;
41
+
42
+
43
+ export const getPublicKey = getGetPublicKey ( ) ;
26
44
27
45
export const publicAdd = (
28
46
publicKey : Uint8Array ,
You can’t perform that action at this time.
0 commit comments