add sig_noncanonical.json tests
This commit is contained in:
parent
e39543b730
commit
c272412df2
|
@ -127,12 +127,12 @@ ScriptInterpreter.castToBool = function(buf) {
|
|||
ScriptInterpreter.prototype.checkSignatureEncoding = function(buf) {
|
||||
var sig;
|
||||
if ((this.flags & (ScriptInterpreter.SCRIPT_VERIFY_DERSIG | ScriptInterpreter.SCRIPT_VERIFY_LOW_S | ScriptInterpreter.SCRIPT_VERIFY_STRICTENC)) !== 0 && !Signature.isTxDER(buf)) {
|
||||
this.errstr = 'SCRIPT_ERR_SIG_DER';
|
||||
this.errstr = 'SCRIPT_ERR_SIG_DER_INVALID_FORMAT';
|
||||
return false;
|
||||
} else if ((this.flags & ScriptInterpreter.SCRIPT_VERIFY_LOW_S) !== 0) {
|
||||
sig = Signature().fromTxFormat(buf);
|
||||
sig = Signature.fromTxFormat(buf);
|
||||
if (!sig.hasLowS()) {
|
||||
this.errstr = 'SCRIPT_ERR_SIG_DER';
|
||||
this.errstr = 'SCRIPT_ERR_SIG_DER_HIGH_S';
|
||||
return false;
|
||||
}
|
||||
} else if ((this.flags & ScriptInterpreter.SCRIPT_VERIFY_STRICTENC) !== 0) {
|
||||
|
|
|
@ -5,6 +5,7 @@ var bitcore = require('../..');
|
|||
var BN = bitcore.crypto.BN;
|
||||
var Signature = bitcore.crypto.Signature;
|
||||
var JSUtil = bitcore.util.js;
|
||||
var ScriptInterpreter = bitcore.ScriptInterpreter;
|
||||
|
||||
var sig_canonical = require('../data/bitcoind/sig_canonical');
|
||||
var sig_noncanonical = require('../data/bitcoind/sig_noncanonical');
|
||||
|
@ -217,13 +218,17 @@ describe('Signature', function() {
|
|||
}
|
||||
it('should be ' + (expected ? '' : 'in') + 'valid for fixture #' + i, function() {
|
||||
var sighex = vector;
|
||||
Signature.isTxDER(new Buffer(sighex, 'hex')).should.equal(expected);
|
||||
var interp = ScriptInterpreter();
|
||||
interp.flags = ScriptInterpreter.SCRIPT_VERIFY_DERSIG |
|
||||
ScriptInterpreter.SCRIPT_VERIFY_STRICTENC;
|
||||
var result = interp.checkSignatureEncoding(new Buffer(sighex, 'hex'));
|
||||
result.should.equal(expected);
|
||||
});
|
||||
i++;
|
||||
});
|
||||
};
|
||||
test_sigs(sig_canonical, true);
|
||||
//test_sigs(sig_noncanonical, false);
|
||||
test_sigs(sig_noncanonical, false);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue