|
|
@ -4,6 +4,10 @@ var should = require('chai').should(); |
|
|
|
var bitcore = require('../..'); |
|
|
|
var BN = bitcore.crypto.BN; |
|
|
|
var Signature = bitcore.crypto.Signature; |
|
|
|
var JSUtil = bitcore.util.js; |
|
|
|
|
|
|
|
var sig_canonical = require('../data/bitcoind/sig_canonical'); |
|
|
|
var sig_noncanonical = require('../data/bitcoind/sig_noncanonical'); |
|
|
|
|
|
|
|
describe('Signature', function() { |
|
|
|
|
|
|
@ -201,6 +205,26 @@ describe('Signature', function() { |
|
|
|
sigbuf[0] = 0x31; |
|
|
|
Signature.isTxDER(sigbuf).should.equal(false); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('bitcoind fixtures', function() { |
|
|
|
var test_sigs = function(set, expected) { |
|
|
|
var i = 0; |
|
|
|
set.forEach(function(vector) { |
|
|
|
if (!JSUtil.isHexa(vector)) { |
|
|
|
// non-hex strings are ignored
|
|
|
|
return; |
|
|
|
} |
|
|
|
it('should be ' + (expected ? '' : 'in') + 'valid for fixture #' + i, function() { |
|
|
|
var sighex = vector; |
|
|
|
Signature.isTxDER(new Buffer(sighex, 'hex')).should.equal(expected); |
|
|
|
}); |
|
|
|
i++; |
|
|
|
}); |
|
|
|
}; |
|
|
|
test_sigs(sig_canonical, true); |
|
|
|
//test_sigs(sig_noncanonical, false);
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
describe('#hasLowS', function() { |
|
|
|
it('should detect high and low S', function() { |
|
|
|