Skip to content

Commit

Permalink
comment unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Sep 5, 2015
1 parent 4f8a8e9 commit 2c68e08
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,46 @@ function ecSign (hash, priv) {
var out = key.sign(hash)
return new Buffer(out.toDER())
}
function dsaSign (hash, priv, algo) {
var x = priv.params.priv_key
var p = priv.params.p
var q = priv.params.q
var montq = BN.mont(q)
var g = priv.params.g
var r = new BN(0)
var k
var H = bits2int(hash, q).mod(q)
var s = false
var kv = getKey(x, q, hash, algo)
while (s === false) {
k = makeKey(q, kv, algo)
r = makeR(g, k, p, q)
s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
if (!s.cmpn(0)) {
s = false
r = new BN(0)
}
}
return toDER(r, s)
}
function toDER (r, s) {
r = r.toArray()
s = s.toArray()

// Pad values
if (r[0] & 0x80)
r = [ 0 ].concat(r)
// Pad values
if (s[0] & 0x80)
s = [0].concat(s)

var total = r.length + s.length + 4
var res = [ 0x30, total, 0x02, r.length ]
res = res.concat(r, [ 0x02, s.length ], s)
return new Buffer(res)
}
module.exports.getKey = getKey

// function dsaSign (hash, priv, algo) {
// var x = priv.params.priv_key
// var p = priv.params.p
// var q = priv.params.q
// var g = priv.params.g
// var r = new BN(0)
// var k
// var H = bits2int(hash, q).mod(q)
// var s = false
// var kv = getKey(x, q, hash, algo)
// while (s === false) {
// k = makeKey(q, kv, algo)
// r = makeR(g, k, p, q)
// s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
// if (!s.cmpn(0)) {
// s = false
// r = new BN(0)
// }
// }
// return toDER(r, s)
// }

// function toDER (r, s) {
// r = r.toArray()
// s = s.toArray()
//
// // Pad values
// if (r[0] & 0x80)
// r = [ 0 ].concat(r)
// // Pad values
// if (s[0] & 0x80)
// s = [0].concat(s)
//
// var total = r.length + s.length + 4
// var res = [ 0x30, total, 0x02, r.length ]
// res = res.concat(r, [ 0x02, s.length ], s)
// return new Buffer(res)
// }

function getKey (x, q, hash, algo) {
x = new Buffer(x.toArray())
if (x.length < q.byteLength()) {
Expand Down

0 comments on commit 2c68e08

Please sign in to comment.