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