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

eos-ecc

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eos-ecc

An universal JavaScript (Node.js and browsers) EOSIO and Antelope based digital signature package with public & private key utilities.

  • 4.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by350%
Maintainers
1
Weekly downloads
 
Created
Source

eos ecc logo

EOS-ECC

NPM Package CI status License: MIT

A lightweight (~6 KB) universal JavaScript Antelope and EOSIO digital signature and cryptokey utilty package.

Antelope/EOSIO Features

  • Public & private key creation
  • Digital signatures
  • Signature verification
  • Legacy support

Setup

npm i eos-ecc

Support

We support all browsers that can handle WebAssembly.

  • Node.js >= 16
  • Browser defaults, no IE 11

API

function new_eos_keys

Generate a new cryptographically random EOS key pair.

ParameterTypeDescription
seedUint8Array?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 new_keys

Generate a new pair of crypto keys for an antelope or EOSIO based blockchain.

ParameterTypeDescription
seedUint8Array?A 32 byte array to seed a private key (seed < curve order n).

Returns: KeyPair — Key pair.

Examples

Ways to import.

import { new_keys } from 'eos-ecc'

Ways to require.

const { new_keys } = require('eos-ecc')

Usage new_eos_keys.

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

Convert an EOS WIF private key to a WIF public key.

ParameterTypeDescription
wif_private_keystringEOS 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.

ParameterTypeDescription
ArgobejectArgument
Arg.signaturestringEOS signature.
Arg.hexstringHex data that was used to create signature.
Arg.legacybool?Returns the key in the legacy format.

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_packed_txn

Generate an EOSIO signature for a packed transaction object.

ParameterTypeDescription
PackedTxnobjectPacked EOSIO transaction object.
PackedTxn.chain_idstringID specifiying what chain we are operating on.
PackedTxn.transaction_headerstringSerialised transaction header.
PackedTxn.transaction_bodystringSerialised transaction body.
PackedTxn.wif_private_keystringEOSIO private key (wallet import format).

Returns: string — Signature

Examples

Ways to import.

import { sign_packed_txn } from 'eos-ecc'

Ways to require.

const { sign_packed_txn } = require('eos-ecc')

Usage sign_packed_txn.

sign_packed_txn({
  chain_id: '2a02a0053…',
  transaction_header: 'fa123232…',
  transaction_body: 'fa45ffa2…',
  wif_private_key: '5f…'
})

The logged output was SIG_K1_….


function sign_txn

Generate an EOS encoded signature.

ParameterTypeDescription
argobjectArgument.
arg.hexstring | Uint8ArrayData to sign.
arg.wif_private_keystringAn 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.

ParameterTypeDescription
wif_private_keystringbase58 private key

Returns: validation_obj — validation message.


function validate_public_key

Validate EOS public key.

ParameterTypeDescription
wif_public_keystringwallet import format EOS public key.

Returns: validation_obj — validation object


type KeyPair

An Antelope/EOSIO wallet import formatted (WIF) public & private key pair.

PropertyTypeDescription
public_keystringWIF public key.
private_keystringWIF private key.

type validation_obj

Validates an EOS private key.

PropertyTypeDescription
validbooleanDetermins if the private key
messagestring?Description of invalidation.

Keywords

FAQs

Package last updated on 23 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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