script: use bip66 for signature checking
This commit is contained in:
parent
e1cb5e6152
commit
abac254d0d
2 changed files with 3 additions and 13 deletions
|
@ -46,7 +46,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bigi": "^1.4.0",
|
"bigi": "^1.4.0",
|
||||||
"bip66": "^1.0.8",
|
"bip66": "^1.1.0",
|
||||||
"bs58check": "^1.0.5",
|
"bs58check": "^1.0.5",
|
||||||
"create-hash": "^1.1.0",
|
"create-hash": "^1.1.0",
|
||||||
"create-hmac": "^1.1.3",
|
"create-hmac": "^1.1.3",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
var bip66 = require('bip66')
|
||||||
var bufferutils = require('./bufferutils')
|
var bufferutils = require('./bufferutils')
|
||||||
var typeforce = require('typeforce')
|
var typeforce = require('typeforce')
|
||||||
var types = require('./types')
|
var types = require('./types')
|
||||||
|
|
||||||
var ECSignature = require('./ecsignature')
|
|
||||||
var ecurve = require('ecurve')
|
var ecurve = require('ecurve')
|
||||||
var curve = ecurve.getCurveByName('secp256k1')
|
var curve = ecurve.getCurveByName('secp256k1')
|
||||||
|
|
||||||
|
@ -135,17 +135,7 @@ function isCanonicalPubKey (buffer) {
|
||||||
function isCanonicalSignature (buffer) {
|
function isCanonicalSignature (buffer) {
|
||||||
if (!Buffer.isBuffer(buffer)) return false
|
if (!Buffer.isBuffer(buffer)) return false
|
||||||
|
|
||||||
try {
|
return bip66.check(buffer.slice(0, -1))
|
||||||
ECSignature.parseScriptSignature(buffer)
|
|
||||||
} catch (e) {
|
|
||||||
if (!(e.message.match(/Not a DER sequence|Invalid sequence length|Expected a DER integer|R length is zero|S length is zero|R value excessively padded|S value excessively padded|R value is negative|S value is negative|Invalid hashType/))) {
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPubKeyHashInput (script) {
|
function isPubKeyHashInput (script) {
|
||||||
|
|
Loading…
Reference in a new issue