Comparing version 3.2.0 to 4.0.0
# eos-ecc changelog | ||
# 3.2.0 | ||
# 4.0.0 | ||
## Major | ||
- Minium support node 16 | ||
- Updates to the recover public key, now recovers PUB_K1 by default inplace of legacy key. | ||
- Added new keys function to return `K1` keys. | ||
## Patch | ||
- Depen updated | ||
- Fixed generate public key bug, diff between legacy key and new PUB_K1 | ||
# 3.2.0 | ||
## Minor | ||
- Added support for `PUB_K1` and `PVT_K1` Antelope & EOSIO keys. | ||
@@ -8,0 +21,0 @@ |
@@ -7,4 +7,5 @@ 'use strict' | ||
exports.new_eos_keys = require('./new_eos_keys.js') | ||
exports.new_keys = require('./new_keys.js') | ||
exports.validate_private_key = require('./validate_private_key.js') | ||
exports.validate_public_key = require('./validate_public_key.js') | ||
exports.recover_public_key_from_signature = require('./recover_public_key_from_signature.js') |
@@ -9,7 +9,7 @@ 'use strict' | ||
/** | ||
* An EOS wallet import formatted (WIF) public & private key pair. | ||
* An Antelope/EOSIO wallet import formatted (WIF) public & private key pair. | ||
* @kind typedef | ||
* @name KeyPair | ||
* @prop {string} public_key EOS WIF public key. | ||
* @prop {string} private_key EOS WIF private key. | ||
* @prop {string} public_key WIF public key. | ||
* @prop {string} private_key WIF private key. | ||
*/ | ||
@@ -22,3 +22,2 @@ | ||
* @param {Uint8Array} [seed] A 32 byte array to seed a private key (seed < curve order n). | ||
* @param {boolean} [legacy] Indicates if you want legacy keys. | ||
* @returns {KeyPair} Key pair. | ||
@@ -39,3 +38,3 @@ * @example <caption>Ways to `import`.</caption> | ||
*/ | ||
async function new_eos_keys(seed, legacy) { | ||
async function new_eos_keys(seed) { | ||
const private_key = seed ? seed : await random_bytes() | ||
@@ -45,4 +44,4 @@ const public_key = await get_public_key(private_key) | ||
return { | ||
public_key: await public_key_to_wif(public_key, legacy), | ||
private_key: await private_key_to_wif(private_key, legacy) | ||
public_key: await public_key_to_wif(public_key), | ||
private_key: await private_key_to_wif(private_key) | ||
} | ||
@@ -49,0 +48,0 @@ } |
{ | ||
"name": "eos-ecc", | ||
"version": "3.2.0", | ||
"description": "An universal JavaScript (Node.js and browsers) EOSIO based digital signature package with public & private key utilities.", | ||
"version": "4.0.0", | ||
"description": "An universal JavaScript (Node.js and browsers) EOSIO and Antelope based digital signature package with public & private key utilities.", | ||
"main": "public/index.js", | ||
"engines": { | ||
"node": ">=15" | ||
"node": ">=16" | ||
}, | ||
@@ -14,2 +14,3 @@ "exports": { | ||
"./new_eos_keys.js": "./new_eos_keys.js", | ||
"./new_keys.js": "./new_keys.js", | ||
"./public_key_from_private.js": "./public_key_from_private.js", | ||
@@ -25,2 +26,3 @@ "./sign_txn.js": "./sign_txn.js", | ||
"new_eos_keys.js", | ||
"new_keys.js", | ||
"public_key_from_private.js", | ||
@@ -27,0 +29,0 @@ "recover_public_key_from_signature.js", |
@@ -16,4 +16,4 @@ 'use strict' | ||
*/ | ||
async function private_key_to_wif(private_key, legacy) { | ||
if (legacy) { | ||
async function private_key_to_wif(private_key, legacy = true) { | ||
if (!legacy) { | ||
const checksum = await ripemd160(Uint8Array.from([...private_key, 75, 49])) | ||
@@ -20,0 +20,0 @@ return ( |
@@ -16,4 +16,4 @@ 'use strict' | ||
async function wif_to_private_key(wif_private_key) { | ||
const non_legacy = wif_private_key.startsWith('PVT_K1_') | ||
const priv_key = base58_to_binary(wif_private_key.replace('PVT_K1_', '')) | ||
const non_legacy = wif_private_key?.startsWith('PVT_K1_') | ||
const priv_key = base58_to_binary(wif_private_key?.replace('PVT_K1_', '')) | ||
const raw_priv_key = priv_key.slice(0, non_legacy ? 32 : 33) | ||
@@ -20,0 +20,0 @@ const checksum = priv_key.slice(-4) |
@@ -26,3 +26,3 @@ ![eos ecc logo](https://raw.githubusercontent.com/pur3miish/eos-ecc/main/static/eos-ecc.svg) | ||
- Node.js `>= 15` | ||
- Node.js `>= 16` | ||
- Browser `defaults, no IE 11` | ||
@@ -33,2 +33,3 @@ | ||
- [function new_eos_keys](#function-new_eos_keys) | ||
- [function new_keys](#function-new_keys) | ||
- [function public_key_from_private](#function-public_key_from_private) | ||
@@ -50,3 +51,2 @@ - [function recover_public_key](#function-recover_public_key) | ||
| `seed` | Uint8Array? | A 32 byte array to seed a private key (seed < curve order n). | | ||
| `legacy` | boolean? | Indicates if you want legacy keys. | | ||
@@ -79,2 +79,36 @@ **Returns:** [KeyPair](#type-keypair) — Key pair. | ||
## function new_keys | ||
Generate a new pair of crypto keys for an antelope or EOSIO based blockchain. | ||
| Parameter | Type | Description | | ||
| :-- | :-- | :-- | | ||
| `seed` | Uint8Array? | A 32 byte array to seed a private key (seed < curve order n). | | ||
**Returns:** [KeyPair](#type-keypair) — Key pair. | ||
### Examples | ||
_Ways to `import`._ | ||
> ```js | ||
> import { new_keys } from 'eos-ecc' | ||
> ``` | ||
_Ways to `require`._ | ||
> ```js | ||
> const { new_keys } = require('eos-ecc') | ||
> ``` | ||
_Usage `new_eos_keys`._ | ||
> ```js | ||
> new_keys().then(console.log) | ||
> ``` | ||
> | ||
> The logged output will be an object containing PUB_K1 and PVT_K1 wif keys. | ||
--- | ||
## function public_key_from_private | ||
@@ -125,2 +159,3 @@ | ||
| `Arg.hex` | string | Hex data that was used to create signature. | | ||
| `Arg.legacy` | bool? | Returns the key in the legacy format. | | ||
@@ -266,8 +301,8 @@ **Returns:** string — WIF Public key. | ||
An EOS wallet import formatted (WIF) public & private key pair. | ||
An Antelope/EOSIO wallet import formatted (WIF) public & private key pair. | ||
| Property | Type | Description | | ||
| :------------ | :----- | :------------------- | | ||
| `public_key` | string | EOS WIF public key. | | ||
| `private_key` | string | EOS WIF private key. | | ||
| Property | Type | Description | | ||
| :------------ | :----- | :--------------- | | ||
| `public_key` | string | WIF public key. | | ||
| `private_key` | string | WIF private key. | | ||
@@ -274,0 +309,0 @@ --- |
@@ -14,2 +14,3 @@ 'use strict' | ||
* @param {string} Arg.hex Hex data that was used to create signature. | ||
* @param {bool} [Arg.legacy] Returns the key in the legacy format. | ||
* @returns {string} WIF Public key. | ||
@@ -33,3 +34,3 @@ * @example <caption>Ways to `import`.</caption> | ||
*/ | ||
async function recover_EOS_public_key({ signature, hex }) { | ||
async function recover_public_key({ signature, hex, legacy = false }) { | ||
let hex_array | ||
@@ -42,3 +43,3 @@ if (typeof hex == 'string') | ||
if (!signature.startsWith('SIG_K1_')) | ||
if (!signature?.startsWith('SIG_K1_')) | ||
throw new TypeError('Invalid EOS signature, must start with “SIG_K1_”') | ||
@@ -63,6 +64,7 @@ | ||
} | ||
}) | ||
}), | ||
legacy | ||
) | ||
} | ||
module.exports = recover_EOS_public_key | ||
module.exports = recover_public_key |
29439
18
501
313