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

cardano-crypto.js

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cardano-crypto.js - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

81

index.js
var Module = require('./lib.js')
var bip39 = require('bip39')
var crypto = require('crypto')

@@ -21,2 +20,8 @@ function validateDerivationMode(input) {

function validateArray(input) {
if (typeof(input) !== typeof([])) {
throw new Error('not an array!')
}
}
function validateDerivationIndex(input) {

@@ -72,3 +77,3 @@ if (!Number.isInteger(input)) {

Module._sign(walletSecretArrPtr, msgArrPtr, msgLen, sigPtr)
Module._emscripten_sign(walletSecretArrPtr, msgArrPtr, msgLen, sigPtr)
Module._free(msgArrPtr)

@@ -98,3 +103,3 @@ Module._free(walletSecretArrPtr)

var result = Module._verify(msgArrPtr, msgLen, publicKeyArrPtr, sigPtr) === 0
var result = Module._emscripten_verify(msgArrPtr, msgLen, publicKeyArrPtr, sigPtr) === 0

@@ -122,3 +127,3 @@ Module._free(msgArrPtr)

const returnCode = Module._wallet_secret_from_seed(seedArrPtr, chainCodeArrPtr, walletSecretArrPtr)
const returnCode = Module._emscripten_wallet_secret_from_seed(seedArrPtr, chainCodeArrPtr, walletSecretArrPtr)

@@ -157,9 +162,6 @@ Module._free(seedArrPtr)

try {
var hmac = crypto.createHmac('sha512', hashSeed)
hmac.update(`Root Seed Chain ${i}`)
var digest = hmac_sha512(hashSeed, [Buffer.from(`Root Seed Chain ${i}`, 'ascii')])
var seed = digest.slice(0, 32)
var chainCode = digest.slice(32, 64)
var digest = hmac.digest('hex')
var seed = Buffer.from(digest.substr(0, 64), 'hex')
var chainCode = Buffer.from(digest.substr(64, 64), 'hex')
result = walletSecretFromSeed(seed, chainCode)

@@ -194,6 +196,9 @@

var childKeyArr = new Uint8Array(Module.HEAPU8.buffer, childKeyArrPtr, 128)
parentKeyArr.set(parentKey)
Module._derive_private(parentKeyArrPtr, index, childKeyArrPtr, derivationMode)
Module._emscripten_derive_private(parentKeyArrPtr, index, childKeyArrPtr, derivationMode)
Module._free(parentKeyArrPtr)
Module._free(childKeyArrPtr)
return new Buffer(childKeyArr)

@@ -223,3 +228,3 @@ }

Module._derive_public(parentPubKeyArrPtr, parentChainCodeArrPtr, index, childPubKeyArrPtr, childChainCodeArrPtr, derivationMode)
Module._emscripten_derive_public(parentPubKeyArrPtr, parentChainCodeArrPtr, index, childPubKeyArrPtr, childChainCodeArrPtr, derivationMode)

@@ -245,3 +250,3 @@ Module._free(parentPubKeyArrPtr)

Module._blake2b_emscripten(inputArrPtr, inputLen, outputArrPtr, outputLen)
Module._emscripten_blake2b(inputArrPtr, inputLen, outputArrPtr, outputLen)

@@ -266,3 +271,3 @@ Module._free(inputArrPtr)

Module._sha3_256(inputArrPtr, inputLen, outputArrPtr)
Module._emscripten_sha3_256(inputArrPtr, inputLen, outputArrPtr)

@@ -275,2 +280,44 @@ Module._free(inputArrPtr)

function hmac_sha512(initKey, inputs) {
validateBuffer(initKey)
validateArray(inputs)
inputs.map(validateBuffer)
var ctxLen = Module._emscripten_size_of_hmac_sha512_ctx()
var ctxArrPtr = Module._malloc(ctxLen)
var ctxArr = new Uint8Array(Module.HEAPU8.buffer, ctxArrPtr, ctxLen)
var initKeyLen = initKey.length
var initKeyArrPtr = Module._malloc(ctxLen)
var initKeyArr = new Uint8Array(Module.HEAPU8.buffer, initKeyArrPtr, initKeyLen)
initKeyArr.set(initKey)
Module._emscripten_hmac_sha512_init(ctxArrPtr, initKeyArrPtr, initKeyLen)
for (var i = 0; i < inputs.length; i++) {
var inputLen = inputs[i].length
var inputArrPtr = Module._malloc(inputLen)
var inputArr = new Uint8Array(Module.HEAPU8.buffer, inputArrPtr, inputLen)
inputArr.set(inputs[i])
Module._emscripten_hmac_sha512_update(ctxArrPtr, inputArrPtr, inputLen)
Module._free(inputArrPtr)
}
var outputLen = 64
var outputArrPtr = Module._malloc(outputLen)
var outputArr = new Uint8Array(Module.HEAPU8.buffer, outputArrPtr, outputLen)
Module._emscripten_hmac_sha512_final(ctxArrPtr, outputArrPtr)
Module._free(initKeyArrPtr)
Module._free(ctxArrPtr)
Module._free(outputArrPtr)
return Buffer.from(outputArr)
}
function cardanoMemoryCombine(input, password) {

@@ -299,3 +346,3 @@ validateString(password)

Module._cardano_memory_combine(transformedPasswordArrPtr, transformedPasswordLen, inputArrPtr, outputArrPtr, inputLen)
Module._emscripten_cardano_memory_combine(transformedPasswordArrPtr, transformedPasswordLen, inputArrPtr, outputArrPtr, inputLen)

@@ -335,3 +382,3 @@ Module._free(inputArrPtr)

var resultCode = Module._chacha20poly1305_enc(keyArrPtr, nonceArrPtr, inputArrPtr, inputLen, outputArrPtr, outputArrPtr + inputLen, tagLen, 1)
var resultCode = Module._emscripten_chacha20poly1305_enc(keyArrPtr, nonceArrPtr, inputArrPtr, inputLen, outputArrPtr, outputArrPtr + inputLen, tagLen, 1)

@@ -384,3 +431,3 @@ Module._free(inputArrPtr)

var resultCode = Module._chacha20poly1305_enc(keyArrPtr, nonceArrPtr, inputArrPtr, inputLen, outputArrPtr, tagArrPtr, tagLen, 0)
var resultCode = Module._emscripten_chacha20poly1305_enc(keyArrPtr, nonceArrPtr, inputArrPtr, inputLen, outputArrPtr, tagArrPtr, tagLen, 0)

@@ -387,0 +434,0 @@ Module._free(inputArrPtr)

{
"name": "cardano-crypto.js",
"version": "3.0.0",
"version": "3.1.0",
"description": "input-output-hk/cardano-crypto compiled to pure javascript using Emscripten",

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

Sorry, the diff of this file is too big to display

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