tiny-secp256k1
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "tiny-secp256k1", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
let ecurve = require('../ecurve') | ||
// let elliptic = require('elliptic') // for reference | ||
// let native = require('bindings')('secp256k1') | ||
let native = require('bindings')('secp256k1') | ||
let tape = require('tape') | ||
@@ -10,37 +10,38 @@ | ||
function summary (x) { | ||
return x.slice(0, x.length / 4) + '...' + x.slice(x.length * (3 / 4)) | ||
} | ||
function test (binding) { | ||
tape('isPrivate', (t) => { | ||
fprivates.valid.isPrivate.forEach((f) => { | ||
let d = Buffer.from(f.d, 'hex') | ||
fprivates.valid.isPrivate.forEach((f) => { | ||
let d = Buffer.from(f.d, 'hex') | ||
t.equal(binding.isPrivate(d), f.expected, `${f.d} is ${f.expected ? 'OK' : 'rejected'}`) | ||
}) | ||
tape(`${summary(f.d)} is ${f.expected ? 'OK' : 'rejected'}`, (t) => { | ||
t.plan(1) | ||
t.equal(ecurve.isPrivate(d), f.expected) | ||
t.end() | ||
}) | ||
}) | ||
fprivates.valid.privateAdd.forEach((f) => { | ||
let d = Buffer.from(f.d, 'hex') | ||
let tweak = Buffer.from(f.tweak, 'hex') | ||
let expected = f.expected ? Buffer.from(f.expected, 'hex') : null | ||
let tdescription = `${summary(f.d)} + ${summary(f.tweak)} = ${f.expected ? summary(f.expected) : null}` | ||
tape('privateAdd', (t) => { | ||
fprivates.valid.privateAdd.forEach((f) => { | ||
let d = Buffer.from(f.d, 'hex') | ||
let tweak = Buffer.from(f.tweak, 'hex') | ||
let expected = f.expected ? Buffer.from(f.expected, 'hex') : null | ||
let description = `${f.d} + ${f.tweak} = ${f.expected ? f.expected : null}` | ||
if (f.description) description += ` (${f.description})` | ||
tape(`${f.description ? f.description : ''} ` + tdescription, (t) => { | ||
t.plan(1) | ||
t.same(ecurve.privateAdd(d, tweak), expected) | ||
}) | ||
}) | ||
t.same(binding.privateAdd(d, tweak), expected, description) | ||
}) | ||
fprivates.invalid.privateAdd.forEach((f) => { | ||
let d = Buffer.from(f.d, 'hex') | ||
let tweak = Buffer.from(f.tweak, 'hex') | ||
fprivates.invalid.privateAdd.forEach((f) => { | ||
let d = Buffer.from(f.d, 'hex') | ||
let tweak = Buffer.from(f.tweak, 'hex') | ||
tape(`${f.description} throws ${f.exception}`, (t) => { | ||
t.plan(1) | ||
t.throws(() => { | ||
ecurve.privateAdd(d, tweak) | ||
}, new RegExp(f.exception)) | ||
t.throws(() => { | ||
binding.privateAdd(d, tweak) | ||
}, new RegExp(f.exception), `${f.description} throws ${f.exception}`) | ||
}) | ||
t.end() | ||
}) | ||
}) | ||
} | ||
test(ecurve) | ||
test(native) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
862864
223