|
@ -36,6 +36,7 @@ export interface SignerAsync { |
|
|
export interface ECPairInterface extends Signer { |
|
|
export interface ECPairInterface extends Signer { |
|
|
compressed: boolean; |
|
|
compressed: boolean; |
|
|
network: Network; |
|
|
network: Network; |
|
|
|
|
|
lowR: boolean; |
|
|
privateKey?: Buffer; |
|
|
privateKey?: Buffer; |
|
|
toWIF(): string; |
|
|
toWIF(): string; |
|
|
verify(hash: Buffer, signature: Buffer): boolean; |
|
|
verify(hash: Buffer, signature: Buffer): boolean; |
|
@ -44,12 +45,14 @@ export interface ECPairInterface extends Signer { |
|
|
class ECPair implements ECPairInterface { |
|
|
class ECPair implements ECPairInterface { |
|
|
compressed: boolean; |
|
|
compressed: boolean; |
|
|
network: Network; |
|
|
network: Network; |
|
|
|
|
|
lowR: boolean; |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
private __D?: Buffer, |
|
|
private __D?: Buffer, |
|
|
private __Q?: Buffer, |
|
|
private __Q?: Buffer, |
|
|
options?: ECPairOptions, |
|
|
options?: ECPairOptions, |
|
|
) { |
|
|
) { |
|
|
|
|
|
this.lowR = false; |
|
|
if (options === undefined) options = {}; |
|
|
if (options === undefined) options = {}; |
|
|
this.compressed = |
|
|
this.compressed = |
|
|
options.compressed === undefined ? true : options.compressed; |
|
|
options.compressed === undefined ? true : options.compressed; |
|
@ -73,8 +76,9 @@ class ECPair implements ECPairInterface { |
|
|
return wif.encode(this.network.wif, this.__D, this.compressed); |
|
|
return wif.encode(this.network.wif, this.__D, this.compressed); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sign(hash: Buffer, lowR: boolean = false): Buffer { |
|
|
sign(hash: Buffer, lowR?: boolean): Buffer { |
|
|
if (!this.__D) throw new Error('Missing private key'); |
|
|
if (!this.__D) throw new Error('Missing private key'); |
|
|
|
|
|
if (lowR === undefined) lowR = this.lowR; |
|
|
if (lowR === false) { |
|
|
if (lowR === false) { |
|
|
return ecc.sign(hash, this.__D); |
|
|
return ecc.sign(hash, this.__D); |
|
|
} else { |
|
|
} else { |
|
|