types: enforce consistent type checking
This commit is contained in:
parent
166053a3e5
commit
35542e115d
10 changed files with 99 additions and 44 deletions
src
|
@ -1,14 +1,17 @@
|
|||
var assert = require('assert')
|
||||
var crypto = require('./crypto')
|
||||
var enforceType = require('./types')
|
||||
|
||||
var BigInteger = require('bigi')
|
||||
var ECSignature = require('./ecsignature')
|
||||
|
||||
// https://tools.ietf.org/html/rfc6979#section-3.2
|
||||
function deterministicGenerateK(curve, hash, d) {
|
||||
assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
|
||||
enforceType('Buffer', hash)
|
||||
enforceType(BigInteger, d)
|
||||
|
||||
// sanity check
|
||||
assert.equal(hash.length, 32, 'Hash must be 256 bit')
|
||||
assert(d instanceof BigInteger, 'Private key must be a BigInteger')
|
||||
|
||||
var x = d.toBuffer(32)
|
||||
var k = new Buffer(32)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue