ECSignature: use types.tuple for arguments
This commit is contained in:
parent
33a9dc4cce
commit
92d16142d1
@ -4,8 +4,7 @@ var types = require('./types')
|
|||||||
var BigInteger = require('bigi')
|
var BigInteger = require('bigi')
|
||||||
|
|
||||||
function ECSignature (r, s) {
|
function ECSignature (r, s) {
|
||||||
typeforce(types.BigInt, r)
|
typeforce(types.tuple(types.BigInt, types.BigInt), arguments)
|
||||||
typeforce(types.BigInt, s)
|
|
||||||
|
|
||||||
this.r = r
|
this.r = r
|
||||||
this.s = s
|
this.s = s
|
||||||
@ -40,7 +39,7 @@ ECSignature.fromDER = function (buffer) {
|
|||||||
if (buffer[1] !== buffer.length - 2) throw new Error('Invalid sequence length')
|
if (buffer[1] !== buffer.length - 2) throw new Error('Invalid sequence length')
|
||||||
if (buffer[2] !== 0x02) throw new Error('Expected a DER integer')
|
if (buffer[2] !== 0x02) throw new Error('Expected a DER integer')
|
||||||
|
|
||||||
var lenR = buffer.readUInt8(3)
|
var lenR = buffer[3]
|
||||||
if (lenR === 0) throw new Error('R length is zero')
|
if (lenR === 0) throw new Error('R length is zero')
|
||||||
if (5 + lenR >= buffer.length) throw new Error('Invalid DER encoding')
|
if (5 + lenR >= buffer.length) throw new Error('Invalid DER encoding')
|
||||||
if (buffer[4 + lenR] !== 0x02) throw new Error('Expected a DER integer (2)')
|
if (buffer[4 + lenR] !== 0x02) throw new Error('Expected a DER integer (2)')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user