Browse Source

Isolates test/ec.js ECPointFp.decodeFrom tests

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
873dc95321
  1. 24
      test/ec.js

24
test/ec.js

@ -5,7 +5,6 @@ var ecparams = sec('secp256k1')
var BigInteger = require('..').BigInteger var BigInteger = require('..').BigInteger
var ECPointFp = require('../').ECPointFp var ECPointFp = require('../').ECPointFp
var ECKey = require('../').ECKey
describe('ec', function() { describe('ec', function() {
describe('ECPointFp', function() { describe('ECPointFp', function() {
@ -26,19 +25,18 @@ describe('ec', function() {
}) })
describe('decodeFrom', function() { describe('decodeFrom', function() {
it('decodes valid ECPoints', function() { it('decodes compressed ECPoints', function() {
var p1 = ECKey.makeRandom(false).pub.toBuffer() var s = new Buffer('02789ece95adf35fb3de994b8b16c90166736d70913a18378fff79503e8c5db7fb', 'hex')
assert.equal(p1.length, 65) var Q = ECPointFp.decodeFrom(ecparams.getCurve(), s)
assert.ok(Q)
var p1_q = ECPointFp.decodeFrom(ecparams.getCurve(), p1) assert.ok(Q.validate())
assert.ok(p1_q) })
assert.ok(p1_q.validate())
var p2 = new Buffer('0486f356006a38b847bedec1bf47013776925d939d5a35a97a4d1263e550c7f1ab5aba44ab74d22892097a0e851addf07ba97e33416df5affaceeb35d5607cd23c', 'hex')
var p2_q = ECPointFp.decodeFrom(ecparams.getCurve(), p2) it('decodes uncompressed ECPoints', function() {
assert.ok(p2_q) var s = new Buffer('0486f356006a38b847bedec1bf47013776925d939d5a35a97a4d1263e550c7f1ab5aba44ab74d22892097a0e851addf07ba97e33416df5affaceeb35d5607cd23c', 'hex')
assert.ok(p2_q.validate()) var Q = ECPointFp.decodeFrom(ecparams.getCurve(), s)
assert.ok(Q)
assert.ok(Q.validate())
}) })
}) })
}) })

Loading…
Cancel
Save