Browse Source
Merge pull request #1442 from bitcoinjs/lowRECPair
Move lowR to public writable attribute
psbt-tx-getters
Jonathan Underwood
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
16 additions and
8 deletions
-
package-lock.json
-
package.json
-
src/ecpair.js
-
ts_src/ecpair.ts
-
types/ecpair.d.ts
|
|
@ -1,6 +1,6 @@ |
|
|
|
{ |
|
|
|
"name": "bitcoinjs-lib", |
|
|
|
"version": "5.1.1", |
|
|
|
"version": "5.1.2", |
|
|
|
"lockfileVersion": 1, |
|
|
|
"requires": true, |
|
|
|
"dependencies": { |
|
|
@ -205,9 +205,9 @@ |
|
|
|
"integrity": "sha512-AaoWrkYtv6A2y8H+qzs6NvRWypzNbADT8PQGpM9rnP+jLzeol+uzhe3Myeuq/dwrHYtmsW8V71HmX2oXhQGagw==" |
|
|
|
}, |
|
|
|
"bip32": { |
|
|
|
"version": "2.0.3", |
|
|
|
"resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.3.tgz", |
|
|
|
"integrity": "sha512-Tg4dHUXiYBkJyCQq4g++C2PqKcZRveVqy7cKxyl88Uai7MmmknFGaF88odYrXcXk5EMyrlXLuAMC3yEiLxRnNA==", |
|
|
|
"version": "2.0.4", |
|
|
|
"resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.4.tgz", |
|
|
|
"integrity": "sha512-ioPytarPDIrWckWMuK4RNUtvwhvWEc2fvuhnO0WEwu732k5OLjUXv4rXi2c/KJHw9ZMNQMkYRJrBw81RujShGQ==", |
|
|
|
"requires": { |
|
|
|
"@types/node": "10.12.18", |
|
|
|
"bs58check": "^2.1.1", |
|
|
|
|
|
@ -1,6 +1,6 @@ |
|
|
|
{ |
|
|
|
"name": "bitcoinjs-lib", |
|
|
|
"version": "5.1.1", |
|
|
|
"version": "5.1.2", |
|
|
|
"description": "Client-side Bitcoin JavaScript library", |
|
|
|
"main": "./src/index.js", |
|
|
|
"types": "./types/index.d.ts", |
|
|
@ -48,7 +48,7 @@ |
|
|
|
"@types/node": "10.12.18", |
|
|
|
"bech32": "^1.1.2", |
|
|
|
"bip174": "^1.0.0", |
|
|
|
"bip32": "^2.0.3", |
|
|
|
"bip32": "^2.0.4", |
|
|
|
"bip66": "^1.1.0", |
|
|
|
"bitcoin-ops": "^1.4.0", |
|
|
|
"bs58check": "^2.0.0", |
|
|
|
|
|
@ -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; |
|
|
|