script: use ecc.isPoint for canonical public keys

This commit is contained in:
Daniel Cousens 2018-06-05 17:15:53 +10:00
parent d7eb6c8e77
commit 726e4c53b6

View file

@ -1,5 +1,6 @@
var Buffer = require('safe-buffer').Buffer
var bip66 = require('bip66')
let ecc = require('tiny-secp256k1')
var pushdata = require('pushdata-bitcoin')
var typeforce = require('typeforce')
var types = require('./types')
@ -170,18 +171,7 @@ function toStack (chunks) {
}
function isCanonicalPubKey (buffer) {
if (!Buffer.isBuffer(buffer)) return false
if (buffer.length < 33) return false
switch (buffer[0]) {
case 0x02:
case 0x03:
return buffer.length === 33
case 0x04:
return buffer.length === 65
}
return false
return ecc.isPoint(buffer)
}
function isDefinedHashType (hashType) {