2014-03-31 05:47:47 +02:00
|
|
|
var assert = require('assert')
|
|
|
|
var sec = require('../src/jsbn/sec')
|
|
|
|
var ecdsa = require('../').ecdsa
|
2013-02-17 06:39:15 +01:00
|
|
|
|
2014-03-31 05:47:47 +02:00
|
|
|
var ecparams = sec('secp256k1')
|
2013-02-17 06:39:15 +01:00
|
|
|
|
2014-04-08 19:58:55 +02:00
|
|
|
describe('EC', function() {
|
2014-03-31 05:47:47 +02:00
|
|
|
it('handles point multiplication', function() {
|
|
|
|
var G = ecparams.getG()
|
|
|
|
var n = ecparams.getN()
|
2013-02-17 06:39:15 +01:00
|
|
|
|
2014-03-31 05:47:47 +02:00
|
|
|
assert.ok(G.multiply(n).isInfinity(), "Gn is infinite")
|
2013-02-17 06:39:15 +01:00
|
|
|
|
2014-03-31 05:47:47 +02:00
|
|
|
var k = ecdsa.getBigRandom(n)
|
|
|
|
var P = G.multiply(k)
|
|
|
|
assert.ok(!P.isInfinity(), "kG is not infinite")
|
|
|
|
assert.ok(P.isOnCurve(), "kG on curve")
|
|
|
|
assert.ok(P.multiply(n).isInfinity(), "kGn is infinite")
|
2013-02-17 06:39:15 +01:00
|
|
|
|
2014-03-31 05:47:47 +02:00
|
|
|
assert.ok(P.validate(), "kG validates as a public key")
|
|
|
|
})
|
2014-01-11 07:57:43 +01:00
|
|
|
})
|