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 - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

6

changelog.md
# eos-ecc changelog
# 4.1.0
## Major
- Support for (PUB_K1 & PVT_K1) key validation.
# 4.0.0

@@ -4,0 +10,0 @@

2

package.json
{
"name": "eos-ecc",
"version": "4.0.0",
"version": "4.1.0",
"description": "An universal JavaScript (Node.js and browsers) EOSIO and Antelope based digital signature package with public & private key utilities.",

@@ -5,0 +5,0 @@ "main": "public/index.js",

'use strict'
const { base58_to_binary } = require('base58-js')
const ripemd160 = require('ripemd160-js')
const sha256 = require('universal-sha256-js')

@@ -22,6 +23,18 @@

async function validate_private_key(wif_private_key) {
if (wif_private_key[0] != '5')
const legacy = !wif_private_key.startsWith('PVT_K1_')
if (legacy) {
if (wif_private_key[0] != '5')
return {
valid: false,
message: 'Private key must start with 5.'
}
if (wif_private_key.length != 51)
return {
valid: false,
message: 'Legacy private keys need to be 51 characters long.'
}
} else if (wif_private_key.length != 56)
return {
valid: false,
message: 'Private key must start with 5.'
message: 'Private keys need to be 56 characters long.'
}

@@ -37,11 +50,9 @@

if (wif_private_key.length != 51)
return {
valid: false,
message: 'EOS private keys need to be 51 characters long.'
}
const base58_str = base58_to_binary(wif_private_key?.replace('PVT_K1_', ''))
const checksum_check = base58_str.slice(-4)
const base58_str = base58_to_binary(wif_private_key)
const checksum_check = base58_str.slice(-4)
const checksum = await sha256(await sha256(base58_str.slice(0, -4)))
const checksum = legacy
? await sha256(await sha256(base58_str.slice(0, -4)))
: await ripemd160(Uint8Array.from([...base58_str.slice(0, -4), 75, 49]))
let invalid_checksum

@@ -48,0 +59,0 @@

@@ -14,20 +14,32 @@ 'use strict'

async function validate_public_key(wif_public_key) {
if (!wif_public_key.startsWith('EOS'))
const legacy = wif_public_key.startsWith('EOS')
if (
!wif_public_key.startsWith('EOS') &&
!wif_public_key.startsWith('PUB_K1_')
)
return {
valid: false,
message: 'Public key need to start with EOS.'
message: 'Public keys need to start with PUB_K1 or for legacy keys EOS'
}
let public_key = wif_public_key.slice(3)
if (public_key.slice(3).match(/[0IOl]+/gmu))
if (legacy && wif_public_key.length != 53)
return {
valid: false,
message: 'Invalid base58 character.'
message: 'Legacy public keys need to be 53 characters long.'
}
if (public_key.length != 50)
if (!legacy && wif_public_key.startsWith('PUB_K1_'))
if (wif_public_key.length != 57)
return {
valid: false,
message: 'Public key needs to be 57 characters long.'
}
let public_key = wif_public_key?.replace('EOS', '').replace('PUB_K1_', '')
if (public_key.match(/[0IOl]+/gmu))
return {
valid: false,
message: 'Public key should be 53 characters long.'
message: 'Invalid base58 character.'
}

@@ -37,4 +49,7 @@

const checksum_check = base58_str.slice(-4)
const checksum = await ripemd160(base58_str.slice(0, -4))
const checksum = legacy
? await ripemd160(base58_str.slice(0, -4))
: await ripemd160(Uint8Array.from([...base58_str.slice(0, -4), 75, 49]))
let invalid_checksum

@@ -41,0 +56,0 @@

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