Merge pull request from bitcoinjs/bip66

Extract BIP66 module
This commit is contained in:
Daniel Cousens 2015-08-25 14:17:44 +10:00
commit ec1195bcee
6 changed files with 66 additions and 88 deletions

View file

@ -243,14 +243,12 @@ describe('Bitcoin-core', function () {
if (i % 2 !== 0) return
var description = sig_noncanonical[i - 1].slice(0, -1)
if (description === 'too long') return // we support non secp256k1 signatures
var buffer = new Buffer(hex, 'hex')
it('throws on ' + description, function () {
assert.throws(function () {
bitcoin.ECSignature.parseScriptSignature(buffer)
})
}, /Expected DER (integer|sequence)|(R|S) value (excessively padded|is negative)|(R|S|DER sequence) length is (zero|too short|too long|invalid)|Invalid hashType/)
})
})
})

View file

@ -130,37 +130,33 @@
],
"DER": [
{
"exception": "DER sequence too short",
"exception": "DER sequence length is too short",
"hex": "ffffffffffffff"
},
{
"exception": "DER sequence too long",
"exception": "DER sequence length is too long",
"hex": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
"exception": "Invalid sequence length",
"exception": "Expected DER sequence",
"hex": "00ffff0400ffffff020400ffffff"
},
{
"exception": "DER sequence length is invalid",
"hex": "30ff020400ffffff020400ffffff"
},
{
"exception": "Invalid sequence length",
"exception": "DER sequence length is invalid",
"hex": "300c030400ffffff030400ffffff0000"
},
{
"exception": "Expected a DER integer",
"exception": "Expected DER integer",
"hex": "300cff0400ffffff020400ffffff"
},
{
"exception": "Expected a DER integer \\(2\\)",
"exception": "Expected DER integer \\(2\\)",
"hex": "300c020200ffffff020400ffffff"
},
{
"exception": "Invalid DER encoding",
"hex": "300c0204ddffffff020200ffffff"
},
{
"exception": "Invalid DER encoding \\(2\\)",
"hex": "300c020400ffffff02dd00ffffff"
},
{
"exception": "R length is zero",
"hex": "30080200020400ffffff"
@ -169,13 +165,21 @@
"exception": "S length is zero",
"hex": "3008020400ffffff0200"
},
{
"exception": "R length is too long",
"hex": "300c02dd00ffffff020400ffffff"
},
{
"exception": "S length is invalid",
"hex": "300c020400ffffff02dd00ffffff"
},
{
"exception": "R value is negative",
"hex": "300c0204ffffffff020400ffffff"
"hex": "300c020480000000020400ffffff"
},
{
"exception": "S value is negative",
"hex": "300c020400ffffff0204ffffffff"
"hex": "300c020400ffffff020480000000"
},
{
"exception": "R value excessively padded",

View file

@ -178,8 +178,26 @@
],
"isPubKeyInput": [
{
"description": "non-canonical signature",
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf7593ffffffffffffffff"
"description": "non-canonical signature (too short)",
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf7593"
},
{
"description": "non-canonical signature (too long)",
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28ffffffff01"
},
{
"description": "non-canonical signature (invalid hashType)",
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28ff"
}
],
"isPubKeyOutput": [
{
"description": "non-canonical pubkey (too short)",
"scriptPubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce OP_CHECKSIG"
},
{
"description": "non-canonical pubkey (too long)",
"scriptPubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ffffff OP_CHECKSIG"
}
],
"isMultisigOutput": [