Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny-secp256k1

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-secp256k1 - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc