Browse Source

Merge pull request #1388 from jolestar/patch-1

fix bug:ECPair.verify should return boolean
bumpver
Jonathan Underwood 6 years ago
committed by GitHub
parent
commit
4e7e364092
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ts_src/ecpair.ts
  2. 4
      types/ecpair.d.ts

4
ts_src/ecpair.ts

@ -26,7 +26,7 @@ export interface ECPairInterface {
publicKey?: Buffer; publicKey?: Buffer;
toWIF(): string; toWIF(): string;
sign(hash: Buffer): Buffer; sign(hash: Buffer): Buffer;
verify(hash: Buffer, signature: Buffer): Buffer; verify(hash: Buffer, signature: Buffer): boolean;
getPublicKey?(): Buffer; getPublicKey?(): Buffer;
} }
@ -66,7 +66,7 @@ class ECPair implements ECPairInterface {
return ecc.sign(hash, this.__D); return ecc.sign(hash, this.__D);
} }
verify(hash: Buffer, signature: Buffer): Buffer { verify(hash: Buffer, signature: Buffer): boolean {
return ecc.verify(hash, this.publicKey, signature); return ecc.verify(hash, this.publicKey, signature);
} }
} }

4
types/ecpair.d.ts

@ -12,7 +12,7 @@ export interface ECPairInterface {
publicKey?: Buffer; publicKey?: Buffer;
toWIF(): string; toWIF(): string;
sign(hash: Buffer): Buffer; sign(hash: Buffer): Buffer;
verify(hash: Buffer, signature: Buffer): Buffer; verify(hash: Buffer, signature: Buffer): boolean;
getPublicKey?(): Buffer; getPublicKey?(): Buffer;
} }
declare class ECPair implements ECPairInterface { declare class ECPair implements ECPairInterface {
@ -25,7 +25,7 @@ declare class ECPair implements ECPairInterface {
readonly publicKey: Buffer | undefined; readonly publicKey: Buffer | undefined;
toWIF(): string; toWIF(): string;
sign(hash: Buffer): Buffer; sign(hash: Buffer): Buffer;
verify(hash: Buffer, signature: Buffer): Buffer; verify(hash: Buffer, signature: Buffer): boolean;
} }
declare function fromPrivateKey(buffer: Buffer, options?: ECPairOptions): ECPair; declare function fromPrivateKey(buffer: Buffer, options?: ECPairOptions): ECPair;
declare function fromPublicKey(buffer: Buffer, options?: ECPairOptions): ECPair; declare function fromPublicKey(buffer: Buffer, options?: ECPairOptions): ECPair;

Loading…
Cancel
Save