Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secp256r1 support #1

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# secp256k1-js
[![CircleCI](https://circleci.com/gh/enumatech/secp256k1-js.svg?style=svg)](https://circleci.com/gh/enumatech/secp256k1-js)
# secp256r1-js
[![CircleCI](https://circleci.com/gh/trustedkey/secp256r1-js.svg?style=svg)](https://circleci.com/gh/trustedkey/secp256r1-js)

Pure JS implementation of secp256k1 signing, verification, recovery ECDSA.
Pure JS implementation of secp256r1 signing, verification, recovery ECDSA.

The code works as-is both in browsers and NodeJS, without the need of a bundler.

## Usage
```sh
npm install @enumatech/secp256k1-js
npm install @trustedkey/secp256r1-js
```
or
```html
<script src="https://unpkg.com/bn.js@4.11.8/lib/bn.js" type="text/javascript"></script>
<script src="https://unpkg.com/@enumatech/secp256k1-js@1.0.0/src/secp256k1.js" type="text/javascript"></script>
<script src="https://unpkg.com/@trustedkey/secp256r1-js@1.0.0/src/secp256r1.js" type="text/javascript"></script>
```

## Development
Expand All @@ -25,6 +25,7 @@ Open `test/test.html` to run the same tests in the browser.

# The MIT License
Copyright 2018 Enuma Technologies Limited.
Copyright 2019 Trusted Key Solutions Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
14 changes: 7 additions & 7 deletions bin/ecverify
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env node
const Secp256k1 = require('../src/secp256k1')
const Secp256r1 = require('../src/secp256r1')

if (process.argv.length < 7) {
console.log(`Usage: ecverify PUBKEY_X PUBKEY_Y SIG_R SIG_S HASH`)
return
}

const pubX = Secp256k1.uint256(process.argv[2], 16)
const pubY = Secp256k1.uint256(process.argv[3], 16)
const r = Secp256k1.uint256(process.argv[4], 16)
const s = Secp256k1.uint256(process.argv[5], 16)
const z = Secp256k1.uint256(process.argv[6], 16)
const pubX = Secp256r1.uint256(process.argv[2], 16)
const pubY = Secp256r1.uint256(process.argv[3], 16)
const r = Secp256r1.uint256(process.argv[4], 16)
const s = Secp256r1.uint256(process.argv[5], 16)
const z = Secp256r1.uint256(process.argv[6], 16)

const result = Secp256k1.ecverify(pubX, pubY, r, s, z)
const result = Secp256r1.ecverify(pubX, pubY, r, s, z)
console.log(result)
219 changes: 2 additions & 217 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"name": "@enumatech/secp256k1-js",
"version": "1.0.0",
"description": "Pure JS implementation of secp256k1 signing, verification, recovery ECDSA.",
"main": "src/secp256k1.js",
"name": "@trustedkey/secp256r1-js",
"version": "1.0.1",
"description": "Pure JS implementation of secp256r1 signing, verification, recovery ECDSA.",
"main": "src/secp256r1.js",
"scripts": {
"test": "mocha test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/enumatech/secp256k1-js.git"
"url": "git+https://github.com/trustedkey/secp256r1-js.git"
},
"keywords": [],
"author": "Lionello Lunesu",
"license": "MIT",
"bugs": {
"url": "https://github.com/enumatech/secp256k1-js/issues"
"url": "https://github.com/trustedkey/secp256r1-js/issues"
},
"homepage": "https://github.com/enumatech/secp256k1-js#readme",
"homepage": "https://github.com/trustedkey/secp256r1-js#readme",
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^5.1.1",
"secp256k1": "^3.5.0"
"mocha": "^5.1.1"
},
"dependencies": {
"bn.js": "^4.11.8"
Expand Down
Loading