Comparing version 0.0.1-rc to 1.0.0-rc
# eos-ecc changelog | ||
## 1.0.0 | ||
## Next | ||
### Major | ||
- Added `universal-ecdsa` package | ||
- Removed signature validation | ||
- Fix for invalid signature | ||
### Minor | ||
- `new eos keys` function now contains a seed argument. | ||
- Removed `hard-coverage` | ||
- Removed `isomorphic-secp256k1` | ||
### Patch | ||
Updated dependencies. | ||
## 0.0.0-rc | ||
Initial Release. |
{ | ||
"name": "eos-ecc", | ||
"version": "0.0.1-rc", | ||
"version": "1.0.0-rc", | ||
"description": "A universal JavaScript package for elliptic curve cryptography on the EOSIO blockchain.", | ||
@@ -31,3 +31,3 @@ "main": "public/index.js", | ||
"test": "npm run test:eslint && npm run test:prettier && npm run test:api", | ||
"test:api": "coverage-node -r hard-rejection/register test/index.test.mjs", | ||
"test:api": "coverage-node test/index.test.mjs", | ||
"test:eslint": "eslint .", | ||
@@ -57,4 +57,2 @@ "test:prettier": "prettier -c .", | ||
"secp256k1", | ||
"verify", | ||
"libsec256k1", | ||
"WASM", | ||
@@ -67,21 +65,20 @@ "Javascript", | ||
"devDependencies": { | ||
"coverage-node": "^4.0.0", | ||
"eslint": "^7.18.0", | ||
"eslint-config-env": "^17.0.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"coverage-node": "^5.0.1", | ||
"eslint": "^7.16.0", | ||
"eslint-config-env": "^21.0.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-compat": "^3.9.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsdoc": "^31.0.8", | ||
"eslint-plugin-jsdoc": "^35.4.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.3.0", | ||
"hard-rejection": "^2.1.0", | ||
"jsdoc-md": "^9.0.0", | ||
"jsdoc-md": "^11.0.0", | ||
"prettier": "^2.2.1", | ||
"test-director": "^5.0.0" | ||
"test-director": "^6.0.0" | ||
}, | ||
"dependencies": { | ||
"base58-js": "^1.0.0", | ||
"isomorphic-secp256k1": "^1.0.0-rc", | ||
"ripemd160-js": "^1.1.1" | ||
"ripemd160-js": "^1.1.1", | ||
"universal-ecdsa": "^1.0.0" | ||
} | ||
} |
'use strict' | ||
const binary_to_base58 = require('base58-js/public/binary_to_base58') | ||
const sha256 = require('./sha256') | ||
const { sha256 } = require('universal-ecdsa') | ||
@@ -6,0 +6,0 @@ /** |
'use strict' | ||
const base58_to_binary = require('base58-js/public/base58_to_binary') | ||
const sha256 = require('./sha256') | ||
const { sha256 } = require('universal-ecdsa') | ||
@@ -19,4 +19,6 @@ /** | ||
const checksum_hash = await sha256(await sha256(raw_priv_key)) | ||
if (checksum_hash.slice(0, 4).filter((x, i) => x != checksum[i]).length) | ||
throw new Error('Invalid wif private key - checksum mismatch') | ||
return raw_priv_key.slice(1, 33) | ||
@@ -23,0 +25,0 @@ } |
'use strict' | ||
exports.generate_eos_signature = require('./generate_eos_signature.js') | ||
exports.sign_txn = require('./sign_txn.js') | ||
exports.public_key_from_private = require('./public_key_from_private.js') | ||
exports.new_eos_keys = require('./new_eos_keys.js') | ||
exports.verify_eos_signature = require('./verify_eos_signature.js') |
'use strict' | ||
const generate_key_pair = require('isomorphic-secp256k1/public/generate_key_pair') | ||
const { get_public_key } = require('universal-ecdsa') | ||
const private_key_to_wif = require('../private/private_key_to_wif') | ||
const public_key_to_wif = require('../private/public_key_to_wif') | ||
const random_bytes = require('../private/random_bytes') | ||
@@ -19,2 +19,3 @@ /** | ||
* @name new_eos_keys | ||
* @param {Uint8Array} [seed] A 32 byte array to seed a private key (seed < curve order n). | ||
* @returns {KeyPair} Key pair. | ||
@@ -41,4 +42,6 @@ * @example <caption>Ways to `import`.</caption> | ||
*/ | ||
async function new_eos_keys() { | ||
const { private_key, public_key } = await generate_key_pair() | ||
async function new_eos_keys(seed) { | ||
const private_key = seed ? seed : await random_bytes() | ||
const public_key = await get_public_key(private_key) | ||
return { | ||
@@ -45,0 +48,0 @@ public_key: await public_key_to_wif(public_key), |
'use strict' | ||
const get_public_key = require('isomorphic-secp256k1/public/get_public_key') | ||
const { get_public_key } = require('universal-ecdsa') | ||
const public_key_to_wif = require('../private/public_key_to_wif') | ||
@@ -29,3 +29,5 @@ const wif_to_private_key = require('../private/wif_to_private_key') | ||
* ```js | ||
* public_key_from_private("5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3").then(console.log) | ||
* public_key_from_private( | ||
* '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' | ||
* ).then(console.log) | ||
* ``` | ||
@@ -36,5 +38,5 @@ * The logged output will be EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV. | ||
const private_key = await wif_to_private_key(wif_private_key) | ||
return public_key_to_wif(await get_public_key({ private_key })) | ||
return public_key_to_wif(await get_public_key(private_key)) | ||
} | ||
module.exports = public_key_from_private |
@@ -28,8 +28,5 @@ ![eos ecc logo](https://raw.githubusercontent.com/pur3miish/eos-ecc/main/static/eos-ecc.svg) | ||
## Table of contents | ||
- [function generate_eos_signature](#function-generate_eos_signature) | ||
- [function new_eos_keys](#function-new_eos_keys) | ||
- [function public_key_from_private](#function-public_key_from_private) | ||
- [function verify_eos_signature](#function-verify_eos_signature) | ||
- [type KeyPair](#type-keypair) | ||
@@ -41,6 +38,6 @@ | ||
| Parameter | Type | Description | | ||
| :-------------------- | :----- | :--------------------------------------- | | ||
| `arg` | object | Argument. | | ||
| `arg.hex` | string | Message digest sha256 to sign. | | ||
| Parameter | Type | Description | | ||
| :-- | :-- | :-- | | ||
| `arg` | object | Argument. | | ||
| `arg.hex` | string \| Uint8Array | Data to sign. | | ||
| `arg.wif_private_key` | string | An EOS wallet import format private key. | | ||
@@ -57,6 +54,2 @@ | ||
> ``` | ||
> | ||
> ```js | ||
> import generate_eos_signature from 'eos-ecc/public/generate_eos_signature.js' | ||
> ``` | ||
@@ -68,6 +61,2 @@ _Ways to `require`._ | ||
> ``` | ||
> | ||
> ```js | ||
> const generate_eos_signature = require('eos-ecc/public/generate_eos_signature.js') | ||
> ``` | ||
@@ -79,8 +68,4 @@ _Usage of `generate_eos_signature`._ | ||
> | ||
> const message = 'hello' | ||
> const hex = new Uint8Array( | ||
> crypto.createHash('sha256').update(message).digest() | ||
> ) | ||
> generate_eos_signature({ | ||
> hex, | ||
> data: hello, | ||
> wif_private_key: '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' | ||
@@ -98,2 +83,6 @@ > }).then(console.log) | ||
| Parameter | Type | Description | | ||
| :-- | :-- | :-- | | ||
| `seed` | Uint8Array? | A 32 byte array to seed a private key (seed < curve order n). | | ||
**Returns:** [KeyPair](#type-keypair) — Key pair. | ||
@@ -177,53 +166,2 @@ | ||
## function verify_eos_signature | ||
Validates and EOS signature from the message digest and public key. | ||
| Parameter | Type | Description | | ||
| :------------------- | :----- | :--------------------------- | | ||
| `arg` | object | Argument. | | ||
| `arg.wif_public_key` | string | EOS public key. | | ||
| `arg.signature` | string | EOS encoded signature. | | ||
| `arg.hash` | string | The `sha256` message digest. | | ||
**Returns:** boolena — Will be `true` & `false` for valid & invalid signatures respectively. | ||
### Examples | ||
_Ways to `import`._ | ||
> ```js | ||
> import { verify_eos_signature } from 'eos-ecc' | ||
> ``` | ||
> | ||
> ```js | ||
> import verify_eos_signature from 'eos-ecc/public/verify_eos_signature.js' | ||
> ``` | ||
_Ways to `require`._ | ||
> ```js | ||
> const { verify_eos_signature } = require('eos-ecc') | ||
> ``` | ||
> | ||
> ```js | ||
> const verify_eos_signature = require('eos-ecc/public/verify_eos_signature.js') | ||
> ``` | ||
_Usage `verify_eos_signature`._ | ||
> ```js | ||
> const signature = 'SIG_K1_JxMNpqjt…yNJ' | ||
> const wif_public_key = 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV' | ||
> const hash = new Uint8Array( | ||
> crypto.createHash('sha256').update('hello').digest() | ||
> ) | ||
> | ||
> verify_eos_signature({ wif_public_key, signature, hash }) | ||
> ``` | ||
> | ||
> The logged output will return `true`. | ||
--- | ||
## type KeyPair | ||
@@ -230,0 +168,0 @@ |
Sorry, the diff of this file is not supported yet
12
16680
14
243
168
+ Addeduniversal-ecdsa@^1.0.0
+ Addeduniversal-ecdsa@1.1.4(transitive)
- Removedisomorphic-secp256k1@^1.0.0-rc