EOS-ECC
A universal JavaScript ECDSA package for the EOSIO blockchain.
Setup
npm i eos-ecc
Support
We support all browsers that can handle WebAssembly.
- Node.js
^12.20.1 || >= 13.2
- Browser
defaults, no IE 11
NB For testing purposes you will need webcrypto a Node.js v15 feature.
API
function new_eos_keys
Generate a new cryptographically random EOS key pair.
Parameter | Type | Description |
---|
seed | Uint8Array? | A 32 byte array to seed a private key (seed < curve order n). |
Returns: KeyPair — Key pair.
Examples
Ways to import
.
import { new_eos_keys } from 'eos-ecc'
Ways to require
.
const { new_eos_keys } = require('eos-ecc')
Usage new_eos_keys
.
new_eos_keys().then(console.log)
The logged output will be an object containing EOS wif public & private keys.
function public_key_from_private
Convert an EOS WIF private key to a WIF public key.
Parameter | Type | Description |
---|
wif_private_key | string | EOS wallet import format key. |
Returns: string — EOS wallet import format public key.
Examples
Ways to import
.
import { public_key_from_private } from 'eos-ecc'
Ways to require
.
const { public_key_from_private } = require('eos-ecc')
Usage public_key_from_private
.
public_key_from_private(
'5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
).then(console.log)
The logged output will be EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV.
function recover_public_key
Recovers EOS Wallet import format (WIF) public key from signature.
Parameter | Type | Description |
---|
Arg | obeject | Argument |
Arg.signature | string | EOS signature. |
Arg.hex | string | Hex data that was used to create signature. |
Returns: string — WIF Public key.
Examples
Ways to import
.
import { recover_public_key } from 'eos-ecc'
Ways to require
.
const { recover_public_key } = require('eos-ecc')
Usage public_key_from_private
.
recover_public_key({
signature: 'SIG_K1_…',
data: 'ff'
}).then(console.log)
The logged output will be EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV.
function sign_txn
Generate an EOS encoded signature.
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. |
Returns: string — EOS encoded signature.
Examples
Ways to import
.
import { sign_txn } from 'eos-ecc'
Ways to require
.
const { sign_txn } = require('eos-ecc')
Usage of sign_hash
.
import crypto from 'crypto'
sign_txn({
hex: FDFDFDFD,
wif_private_key: '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
}).then(console.log)
The logged output will be SIG_K1_….
function validate_private_key
Validate an EOS private key.
Parameter | Type | Description |
---|
wif_private_key | string | base58 private key |
Returns: validation_obj — validation message.
function validate_public_key
Validate EOS public key.
Parameter | Type | Description |
---|
wif_public_key | string | wallet import format EOS public key. |
Returns: validation_obj — validation object
type KeyPair
An EOS 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. |
type validation_obj
Validates an EOS private key.
Property | Type | Description |
---|
valid | bool | Determins if the private key |
message | string? | Description of invalidation. |