Browse Source

script: use bip66 for signature checking

hk-custom-address
Daniel Cousens 9 years ago
parent
commit
abac254d0d
  1. 2
      package.json
  2. 14
      src/script.js

2
package.json

@ -46,7 +46,7 @@
},
"dependencies": {
"bigi": "^1.4.0",
"bip66": "^1.0.8",
"bip66": "^1.1.0",
"bs58check": "^1.0.5",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.3",

14
src/script.js

@ -1,8 +1,8 @@
var bip66 = require('bip66')
var bufferutils = require('./bufferutils')
var typeforce = require('typeforce')
var types = require('./types')
var ECSignature = require('./ecsignature')
var ecurve = require('ecurve')
var curve = ecurve.getCurveByName('secp256k1')
@ -135,17 +135,7 @@ function isCanonicalPubKey (buffer) {
function isCanonicalSignature (buffer) {
if (!Buffer.isBuffer(buffer)) return false
try {
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
return bip66.check(buffer.slice(0, -1))
}
function isPubKeyHashInput (script) {

Loading…
Cancel
Save