11import { Network } from './networks' ;
22import * as networks from './networks' ;
33import * as types from './types' ;
4- // import randomBytes from 'randombytes';
54import * as wif from 'wif' ;
65import { testEcc } from './testecc' ;
76export { networks } ;
@@ -12,15 +11,15 @@ const ECPairOptionsSchema = v.optional(
1211 v . object ( {
1312 compressed : v . optional ( v . boolean ( ) ) ,
1413 network : v . optional ( types . NetworkSchema ) ,
15- //https://github.com/fabian-hiller/valibot/issues/243#issuecomment-2182514063
14+ // https://github.com/fabian-hiller/valibot/issues/243#issuecomment-2182514063
1615 rng : v . optional (
1716 v . pipe (
1817 v . instance ( Function ) ,
1918 v . transform ( ( func ) => {
2019 return ( arg ?: number ) => {
2120 const parsedArg = v . parse ( v . optional ( v . number ( ) ) , arg ) ;
22- const return_ = func ( parsedArg ) ;
23- const parsedReturn = v . parse ( v . instance ( Uint8Array ) , return_ ) ;
21+ const returnedValue = func ( parsedArg ) ;
22+ const parsedReturn = v . parse ( v . instance ( Uint8Array ) , returnedValue ) ;
2423 return parsedReturn ;
2524 } ;
2625 } ) ,
@@ -32,20 +31,18 @@ const ECPairOptionsSchema = v.optional(
3231type ECPairOptions = v . InferOutput < typeof ECPairOptionsSchema > ;
3332
3433const toXOnly = ( pubKey : Uint8Array ) =>
35- pubKey . length === 32 ? pubKey : pubKey . slice ( 1 , 33 ) ;
34+ pubKey . length === 32 ? pubKey : pubKey . subarray ( 1 , 33 ) ;
3635
3736export interface Signer {
3837 publicKey : Uint8Array ;
3938 network ?: any ;
4039 sign ( hash : Uint8Array , lowR ?: boolean ) : Uint8Array ;
41- getPublicKey ?( ) : Uint8Array ;
4240}
4341
4442export interface SignerAsync {
4543 publicKey : Uint8Array ;
4644 network ?: any ;
4745 sign ( hash : Uint8Array , lowR ?: boolean ) : Promise < Uint8Array > ;
48- getPublicKey ?( ) : Uint8Array ;
4946}
5047
5148export interface ECPairInterface extends Signer {
@@ -190,8 +187,7 @@ export function ECPairFactory(ecc: TinySecp256k1Interface): ECPairAPI {
190187 options . compressed === undefined ? true : options . compressed ;
191188 this . network = options . network || networks . bitcoin ;
192189
193- if ( __Q !== undefined )
194- this . __Q = Uint8Array . from ( ecc . pointCompress ( __Q , this . compressed ) ) ;
190+ if ( __Q !== undefined ) this . __Q = ecc . pointCompress ( __Q , this . compressed ) ;
195191 }
196192
197193 get privateKey ( ) : Uint8Array | undefined {
@@ -290,7 +286,7 @@ export function ECPairFactory(ecc: TinySecp256k1Interface): ECPairAPI {
290286 const tweakedPrivateKey = ecc . privateAdd ( privateKey ! , t ) ;
291287 if ( ! tweakedPrivateKey ) throw new Error ( 'Invalid tweaked private key!' ) ;
292288
293- return fromPrivateKey ( Uint8Array . from ( tweakedPrivateKey ) , {
289+ return fromPrivateKey ( tweakedPrivateKey , {
294290 network : this . network ,
295291 compressed : this . compressed ,
296292 } ) ;
0 commit comments