|
|
@ -11,6 +11,7 @@ var BN = require('../crypto/bn'); |
|
|
|
var Hash = require('../crypto/hash'); |
|
|
|
var ECDSA = require('../crypto/ecdsa'); |
|
|
|
var $ = require('../util/preconditions'); |
|
|
|
var _ = require('lodash'); |
|
|
|
|
|
|
|
var SIGHASH_SINGLE_BUG = '0000000000000000000000000000000000000000000000000000000000000001'; |
|
|
|
var BITS_64_ON = 'ffffffffffffffff'; |
|
|
@ -122,8 +123,8 @@ function sign(transaction, privateKey, sighashType, inputIndex, subscript) { |
|
|
|
* @return {boolean} |
|
|
|
*/ |
|
|
|
function verify(transaction, signature, publicKey, inputIndex, subscript) { |
|
|
|
$.checkArgument(transaction); |
|
|
|
$.checkArgument(signature && signature.nhashtype); |
|
|
|
$.checkArgument(!_.isUndefined(transaction)); |
|
|
|
$.checkArgument(!_.isUndefined(signature) && !_.isUndefined(signature.nhashtype)); |
|
|
|
var hashbuf = sighash(transaction, signature.nhashtype, inputIndex, subscript); |
|
|
|
return ECDSA.verify(hashbuf, signature, publicKey, 'little'); |
|
|
|
} |
|
|
|