Browse Source
Move lowR to public writable attribute
psbt-tx-getters
junderw
6 years ago
No known key found for this signature in database
GPG Key ID: B256185D3A971908
3 changed files with
10 additions and
2 deletions
-
src/ecpair.js
-
ts_src/ecpair.ts
-
types/ecpair.d.ts
|
|
@ -16,6 +16,7 @@ class ECPair { |
|
|
|
constructor(__D, __Q, options) { |
|
|
|
this.__D = __D; |
|
|
|
this.__Q = __Q; |
|
|
|
this.lowR = false; |
|
|
|
if (options === undefined) options = {}; |
|
|
|
this.compressed = |
|
|
|
options.compressed === undefined ? true : options.compressed; |
|
|
@ -33,8 +34,9 @@ class ECPair { |
|
|
|
if (!this.__D) throw new Error('Missing private key'); |
|
|
|
return wif.encode(this.network.wif, this.__D, this.compressed); |
|
|
|
} |
|
|
|
sign(hash, lowR = false) { |
|
|
|
sign(hash, lowR) { |
|
|
|
if (!this.__D) throw new Error('Missing private key'); |
|
|
|
if (lowR === undefined) lowR = this.lowR; |
|
|
|
if (lowR === false) { |
|
|
|
return ecc.sign(hash, this.__D); |
|
|
|
} else { |
|
|
|
|
|
@ -36,6 +36,7 @@ export interface SignerAsync { |
|
|
|
export interface ECPairInterface extends Signer { |
|
|
|
compressed: boolean; |
|
|
|
network: Network; |
|
|
|
lowR: boolean; |
|
|
|
privateKey?: Buffer; |
|
|
|
toWIF(): string; |
|
|
|
verify(hash: Buffer, signature: Buffer): boolean; |
|
|
@ -44,12 +45,14 @@ export interface ECPairInterface extends Signer { |
|
|
|
class ECPair implements ECPairInterface { |
|
|
|
compressed: boolean; |
|
|
|
network: Network; |
|
|
|
lowR: boolean; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private __D?: Buffer, |
|
|
|
private __Q?: Buffer, |
|
|
|
options?: ECPairOptions, |
|
|
|
) { |
|
|
|
this.lowR = false; |
|
|
|
if (options === undefined) options = {}; |
|
|
|
this.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); |
|
|
|
} |
|
|
|
|
|
|
|
sign(hash: Buffer, lowR: boolean = false): Buffer { |
|
|
|
sign(hash: Buffer, lowR?: boolean): Buffer { |
|
|
|
if (!this.__D) throw new Error('Missing private key'); |
|
|
|
if (lowR === undefined) lowR = this.lowR; |
|
|
|
if (lowR === false) { |
|
|
|
return ecc.sign(hash, this.__D); |
|
|
|
} else { |
|
|
|
|
|
@ -20,6 +20,7 @@ export interface SignerAsync { |
|
|
|
export interface ECPairInterface extends Signer { |
|
|
|
compressed: boolean; |
|
|
|
network: Network; |
|
|
|
lowR: boolean; |
|
|
|
privateKey?: Buffer; |
|
|
|
toWIF(): string; |
|
|
|
verify(hash: Buffer, signature: Buffer): boolean; |
|
|
@ -29,6 +30,7 @@ declare class ECPair implements ECPairInterface { |
|
|
|
private __Q?; |
|
|
|
compressed: boolean; |
|
|
|
network: Network; |
|
|
|
lowR: boolean; |
|
|
|
constructor(__D?: Buffer | undefined, __Q?: Buffer | undefined, options?: ECPairOptions); |
|
|
|
readonly privateKey: Buffer | undefined; |
|
|
|
readonly publicKey: Buffer; |
|
|
|