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

@polkadot/wasm-crypto

Package Overview
Dependencies
Maintainers
1
Versions
565
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot/wasm-crypto - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0-beta.0

12

index.d.ts

@@ -10,2 +10,14 @@ // Copyright 2019 @polkadot/wasm-crypto authors & contributors

export function bip39Validate (phrase: string): boolean;
export function ed25519KeypairFromSeed (seed: Uint8Array): Uint8Array;
export function ed25519Sign (publicKey: Uint8Array, secretKey: Uint8Array, message: Uint8Array): Uint8Array;
export function ed25519Verify (signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
export function sr25519DeriveKeypairHard (pair: Uint8Array, chainCode: Uint8Array): Uint8Array;
export function sr25519DeriveKeypairSoft (pair: Uint8Array, chainCode: Uint8Array): Uint8Array;
export function sr25519DerivePublicSoft (publicKey: Uint8Array, chainCode: Uint8Array): Uint8Array;
export function sr25519KeypairFromSeed (seed: Uint8Array): Uint8Array;
export function sr25519Sign (publicKey: Uint8Array, secretKey: Uint8Array, message: Uint8Array): Uint8Array;
export function sr25519Verify (signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
export function blake2b (data: Uint8Array, key: Uint8Array, byteSize: number): Uint8Array;

@@ -12,0 +24,0 @@ export function keccak256 (data: Uint8Array): Uint8Array;

44

index.js

@@ -5,18 +5,38 @@ // Copyright 2019 @polkadot/wasm-crypto authors & contributors

const { assert } = require('@polkadot/util');
const stubbed = require('./wasm');
module.exports.bip39Generate = stubbed.ext_bip39_generate;
module.exports.bip39ToEntropy = stubbed.ext_bip39_to_entropy;
module.exports.bip39ToMiniSecret = stubbed.ext_bip39_to_mini_secret;
module.exports.bip39ToSeed = stubbed.ext_bip39_to_seed;
module.exports.bip39Validate = stubbed.ext_bip39_validate
module.exports.blake2b = stubbed.ext_blake2b;
module.exports.keccak256 = stubbed.ext_keccak256;
module.exports.pbkdf2 = stubbed.ext_pbkdf2;
// module.exports.secp256k1IsRecoverable = stubbed.ext_secp256k1_is_recoverable;
// module.exports.secp256k1Recover = stubbed.ext_secp256k1_recover;
module.exports.sha512 = stubbed.ext_sha512;
module.exports.twox = stubbed.ext_twox;
const wrapReady = (fn) =>
(...params) => {
assert(stubbed.isReady(), 'ERROR: @polkadot/wasm-crypto has not been initialized');
return fn(...params);
};
module.exports.bip39Generate = wrapReady(stubbed.ext_bip39_generate);
module.exports.bip39ToEntropy = wrapReady(stubbed.ext_bip39_to_entropy);
module.exports.bip39ToMiniSecret = wrapReady(stubbed.ext_bip39_to_mini_secret);
module.exports.bip39ToSeed = wrapReady(stubbed.ext_bip39_to_seed);
module.exports.bip39Validate = wrapReady(stubbed.ext_bip39_validate);
module.exports.ed25519KeypairFromSeed = wrapReady(stubbed.ext_ed_from_seed);
module.exports.ed25519Sign = wrapReady(stubbed.ext_ed_sign);
module.exports.ed25519Verify = wrapReady(stubbed.ext_ed_verify);
module.exports.sr25519DeriveKeypairHard = wrapReady(stubbed.ext_sr_derive_keypair_hard);
module.exports.sr25519DeriveKeypairSoft = wrapReady(stubbed.ext_sr_derive_keypair_soft);
module.exports.sr25519DerivePublicSoft = wrapReady(stubbed.ext_sr_derive_public_soft);
module.exports.sr25519KeypairFromSeed = wrapReady(stubbed.ext_sr_from_seed);
module.exports.sr25519Sign = wrapReady(stubbed.ext_sr_sign);
module.exports.sr25519Verify = wrapReady(stubbed.ext_sr_verify);
module.exports.blake2b = wrapReady(stubbed.ext_blake2b);
module.exports.keccak256 = wrapReady(stubbed.ext_keccak256);
module.exports.pbkdf2 = wrapReady(stubbed.ext_pbkdf2);
// module.exports.secp256k1IsRecoverable = wrapReady(stubbed.ext_secp256k1_is_recoverable);
// module.exports.secp256k1Recover = wrapReady(stubbed.ext_secp256k1_recover);
module.exports.sha512 = wrapReady(stubbed.ext_sha512);
module.exports.twox = wrapReady(stubbed.ext_twox);
module.exports.isReady = stubbed.isReady;
module.exports.waitReady = stubbed.waitReady;
{
"name": "@polkadot/wasm-crypto",
"version": "0.7.1",
"version": "0.8.0-beta.0",
"author": "Jaco Greeff <jacogr@gmail.com>",

@@ -5,0 +5,0 @@ "files": [

/* tslint:disable */
/**
* Generate a bip39 phrase
* Perform a derivation on a secret
*
* words: number of words, either 12, 15, 18 21 or 24
* * secret: UIntArray with 64 bytes
* * cc: UIntArray with 32 bytes
*
* Returns the bip 39 phrase
* @param {number} arg0
* @returns {string}
* returned vector the derived keypair as a array of 96 bytes
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @returns {Uint8Array}
*/
export function ext_bip39_generate(arg0: number): string;
export function ext_sr_derive_keypair_hard(arg0: Uint8Array, arg1: Uint8Array): Uint8Array;
/**
* Create entropy from a bip39 phrase
* Perform a derivation on a secret
*
* * phrase: mnemonic phrase
* * secret: UIntArray with 64 bytes
* * cc: UIntArray with 32 bytes
*
* Returns the entropy
* @param {string} arg0
* returned vector the derived keypair as a array of 96 bytes
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @returns {Uint8Array}
*/
export function ext_bip39_to_entropy(arg0: string): Uint8Array;
export function ext_sr_derive_keypair_soft(arg0: Uint8Array, arg1: Uint8Array): Uint8Array;
/**
* Create a mini-secret from a bip39 phrase
* Perform a derivation on a publicKey
*
* * phrase: mnemonic phrase
* * pubkey: UIntArray with 32 bytes
* * cc: UIntArray with 32 bytes
*
* Returns the 32-byte mini-secret via entropy
* @param {string} arg0
* @param {string} arg1
* returned vector is the derived publicKey as a array of 32 bytes
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @returns {Uint8Array}
*/
export function ext_bip39_to_mini_secret(arg0: string, arg1: string): Uint8Array;
export function ext_sr_derive_public_soft(arg0: Uint8Array, arg1: Uint8Array): Uint8Array;
/**
* Creates a see from a bip-39 phrase
* Generate a key pair.
*
* @phrase: mnemonic phrase
* * seed: UIntArray with 32 element
*
* Returns a 32-byte seed
* @param {string} arg0
* @param {string} arg1
* returned vector is the concatenation of first the private key (64 bytes)
* followed by the public key (32) bytes.
* @param {Uint8Array} arg0
* @returns {Uint8Array}
*/
export function ext_bip39_to_seed(arg0: string, arg1: string): Uint8Array;
export function ext_sr_from_seed(arg0: Uint8Array): Uint8Array;
/**
* Validates a bip39 phrase
* Sign a message
*
* * phrase: mnemonic phrase
* The combination of both public and private key must be provided.
* This is effectively equivalent to a keypair.
*
* Returns the true/false
* @param {string} arg0
* * public: UIntArray with 32 element
* * private: UIntArray with 64 element
* * message: Arbitrary length UIntArray
*
* * returned vector is the signature consisting of 64 bytes.
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {Uint8Array}
*/
export function ext_sr_sign(arg0: Uint8Array, arg1: Uint8Array, arg2: Uint8Array): Uint8Array;
/**
* Verify a message and its corresponding against a public key;
*
* * signature: UIntArray with 64 element
* * message: Arbitrary length UIntArray
* * pubkey: UIntArray with 32 element
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {boolean}
*/
export function ext_bip39_validate(arg0: string): boolean;
export function ext_sr_verify(arg0: Uint8Array, arg1: Uint8Array, arg2: Uint8Array): boolean;
/**

@@ -113,2 +137,94 @@ * blake2b hash for the specified input

export function ext_twox(arg0: Uint8Array, arg1: number): Uint8Array;
/**
* Generate a bip39 phrase
*
* words: number of words, either 12, 15, 18 21 or 24
*
* Returns the bip 39 phrase
* @param {number} arg0
* @returns {string}
*/
export function ext_bip39_generate(arg0: number): string;
/**
* Create entropy from a bip39 phrase
*
* * phrase: mnemonic phrase
*
* Returns the entropy
* @param {string} arg0
* @returns {Uint8Array}
*/
export function ext_bip39_to_entropy(arg0: string): Uint8Array;
/**
* Create a mini-secret from a bip39 phrase
*
* * phrase: mnemonic phrase
*
* Returns the 32-byte mini-secret via entropy
* @param {string} arg0
* @param {string} arg1
* @returns {Uint8Array}
*/
export function ext_bip39_to_mini_secret(arg0: string, arg1: string): Uint8Array;
/**
* Creates a see from a bip-39 phrase
*
* @phrase: mnemonic phrase
*
* Returns a 32-byte seed
* @param {string} arg0
* @param {string} arg1
* @returns {Uint8Array}
*/
export function ext_bip39_to_seed(arg0: string, arg1: string): Uint8Array;
/**
* Validates a bip39 phrase
*
* * phrase: mnemonic phrase
*
* Returns the true/false
* @param {string} arg0
* @returns {boolean}
*/
export function ext_bip39_validate(arg0: string): boolean;
/**
* Generate a key pair.
*
* * seed: UIntArray with 32 element
*
* returned vector is the concatenation of first the private key (64 bytes)
* followed by the public key (32) bytes.
* @param {Uint8Array} arg0
* @returns {Uint8Array}
*/
export function ext_ed_from_seed(arg0: Uint8Array): Uint8Array;
/**
* Sign a message
*
* The combination of both public and private key must be provided.
* This is effectively equivalent to a keypair.
*
* * public: UIntArray with 32 element
* * private: UIntArray with 64 element
* * message: Arbitrary length UIntArray
*
* * returned vector is the signature consisting of 64 bytes.
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {Uint8Array}
*/
export function ext_ed_sign(arg0: Uint8Array, arg1: Uint8Array, arg2: Uint8Array): Uint8Array;
/**
* Verify a message and its corresponding against a public key;
*
* * signature: UIntArray with 64 element
* * message: Arbitrary length UIntArray
* * pubkey: UIntArray with 32 element
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {boolean}
*/
export function ext_ed_verify(arg0: Uint8Array, arg1: Uint8Array, arg2: Uint8Array): boolean;

@@ -115,0 +231,0 @@ export function isReady(): boolean;

const crypto = require('crypto'); let wasm; const requires = { crypto };
const { u8aToString } = require('@polkadot/util');
// let cachedTextDecoder = new TextDecoder('utf-8');
let cachegetUint8Memory = null;

@@ -15,6 +11,15 @@ function getUint8Memory() {

function getStringFromWasm(ptr, len) {
return u8aToString(getUint8Memory().subarray(ptr, ptr + len));
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm(arg) {
const ptr = wasm.__wbindgen_malloc(arg.length * 1);
getUint8Memory().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
function getArrayU8FromWasm(ptr, len) {
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
}
let cachedGlobalArgumentPtr = null;

@@ -36,79 +41,92 @@ function globalArgumentPtr() {

/**
* Generate a bip39 phrase
* Perform a derivation on a secret
*
* words: number of words, either 12, 15, 18 21 or 24
* * secret: UIntArray with 64 bytes
* * cc: UIntArray with 32 bytes
*
* Returns the bip 39 phrase
* @param {number} arg0
* @returns {string}
* returned vector the derived keypair as a array of 96 bytes
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @returns {Uint8Array}
*/
module.exports.ext_bip39_generate = function(arg0) {
module.exports.ext_sr_derive_keypair_hard = function(arg0, arg1) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
wasm.ext_bip39_generate(retptr, arg0);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
try {
wasm.ext_sr_derive_keypair_hard(retptr, ptr0, len0, ptr1, len1);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getStringFromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);
}
};
const { stringToU8a } = require('@polkadot/util');
/**
* Perform a derivation on a secret
*
* * secret: UIntArray with 64 bytes
* * cc: UIntArray with 32 bytes
*
* returned vector the derived keypair as a array of 96 bytes
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @returns {Uint8Array}
*/
module.exports.ext_sr_derive_keypair_soft = function(arg0, arg1) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_sr_derive_keypair_soft(retptr, ptr0, len0, ptr1, len1);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
// let cachedTextEncoder = new TextEncoder('utf-8');
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
let WASM_VECTOR_LEN = 0;
let passStringToWasm;
if (typeof stringToU8aInto === 'function') {
passStringToWasm = function(arg) {
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);
let size = arg.length;
let ptr = wasm.__wbindgen_malloc(size);
let writeOffset = 0;
while (true) {
const view = getUint8Memory().subarray(ptr + writeOffset, ptr + size);
const { read, written } = stringToU8aInto(arg, view);
arg = arg.substring(read);
writeOffset += written;
if (arg.length === 0) {
break;
}
ptr = wasm.__wbindgen_realloc(ptr, size, size * 2);
size *= 2;
}
WASM_VECTOR_LEN = writeOffset;
return ptr;
};
} else {
passStringToWasm = function(arg) {
}
const buf = stringToU8a(arg);
const ptr = wasm.__wbindgen_malloc(buf.length);
getUint8Memory().set(buf, ptr);
WASM_VECTOR_LEN = buf.length;
return ptr;
};
}
};
function getArrayU8FromWasm(ptr, len) {
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
}
/**
* Create entropy from a bip39 phrase
* Perform a derivation on a publicKey
*
* * phrase: mnemonic phrase
* * pubkey: UIntArray with 32 bytes
* * cc: UIntArray with 32 bytes
*
* Returns the entropy
* @param {string} arg0
* returned vector is the derived publicKey as a array of 32 bytes
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @returns {Uint8Array}
*/
module.exports.ext_bip39_to_entropy = function(arg0) {
const ptr0 = passStringToWasm(arg0);
module.exports.ext_sr_derive_public_soft = function(arg0, arg1) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_bip39_to_entropy(retptr, ptr0, len0);
wasm.ext_sr_derive_public_soft(retptr, ptr0, len0, ptr1, len1);
const mem = getUint32Memory();

@@ -125,2 +143,3 @@ const rustptr = mem[retptr / 4];

wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);

@@ -132,19 +151,17 @@ }

/**
* Create a mini-secret from a bip39 phrase
* Generate a key pair.
*
* * phrase: mnemonic phrase
* * seed: UIntArray with 32 element
*
* Returns the 32-byte mini-secret via entropy
* @param {string} arg0
* @param {string} arg1
* returned vector is the concatenation of first the private key (64 bytes)
* followed by the public key (32) bytes.
* @param {Uint8Array} arg0
* @returns {Uint8Array}
*/
module.exports.ext_bip39_to_mini_secret = function(arg0, arg1) {
const ptr0 = passStringToWasm(arg0);
module.exports.ext_sr_from_seed = function(arg0) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_bip39_to_mini_secret(retptr, ptr0, len0, ptr1, len1);
wasm.ext_sr_from_seed(retptr, ptr0, len0);
const mem = getUint32Memory();

@@ -161,3 +178,2 @@ const rustptr = mem[retptr / 4];

wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);

@@ -169,19 +185,27 @@ }

/**
* Creates a see from a bip-39 phrase
* Sign a message
*
* @phrase: mnemonic phrase
* The combination of both public and private key must be provided.
* This is effectively equivalent to a keypair.
*
* Returns a 32-byte seed
* @param {string} arg0
* @param {string} arg1
* * public: UIntArray with 32 element
* * private: UIntArray with 64 element
* * message: Arbitrary length UIntArray
*
* * returned vector is the signature consisting of 64 bytes.
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {Uint8Array}
*/
module.exports.ext_bip39_to_seed = function(arg0, arg1) {
const ptr0 = passStringToWasm(arg0);
module.exports.ext_sr_sign = function(arg0, arg1, arg2) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm(arg1);
const ptr1 = passArray8ToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm(arg2);
const len2 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_bip39_to_seed(retptr, ptr0, len0, ptr1, len1);
wasm.ext_sr_sign(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
const mem = getUint32Memory();

@@ -199,2 +223,3 @@ const rustptr = mem[retptr / 4];

wasm.__wbindgen_free(ptr1, len1 * 1);
wasm.__wbindgen_free(ptr2, len2 * 1);

@@ -206,18 +231,26 @@ }

/**
* Validates a bip39 phrase
* Verify a message and its corresponding against a public key;
*
* * phrase: mnemonic phrase
*
* Returns the true/false
* @param {string} arg0
* * signature: UIntArray with 64 element
* * message: Arbitrary length UIntArray
* * pubkey: UIntArray with 32 element
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {boolean}
*/
module.exports.ext_bip39_validate = function(arg0) {
const ptr0 = passStringToWasm(arg0);
module.exports.ext_sr_verify = function(arg0, arg1, arg2) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm(arg2);
const len2 = WASM_VECTOR_LEN;
try {
return (wasm.ext_bip39_validate(ptr0, len0)) !== 0;
return (wasm.ext_sr_verify(ptr0, len0, ptr1, len1, ptr2, len2)) !== 0;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);
wasm.__wbindgen_free(ptr2, len2 * 1);

@@ -228,8 +261,2 @@ }

function passArray8ToWasm(arg) {
const ptr = wasm.__wbindgen_malloc(arg.length * 1);
getUint8Memory().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
/**

@@ -405,2 +432,295 @@ * blake2b hash for the specified input

const { u8aToString } = require('@polkadot/util');
// let cachedTextDecoder = new TextDecoder('utf-8');
function getStringFromWasm(ptr, len) {
return u8aToString(getUint8Memory().subarray(ptr, ptr + len));
}
/**
* Generate a bip39 phrase
*
* words: number of words, either 12, 15, 18 21 or 24
*
* Returns the bip 39 phrase
* @param {number} arg0
* @returns {string}
*/
module.exports.ext_bip39_generate = function(arg0) {
const retptr = globalArgumentPtr();
wasm.ext_bip39_generate(retptr, arg0);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getStringFromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
};
const { stringToU8a } = require('@polkadot/util');
// let cachedTextEncoder = new TextEncoder('utf-8');
let passStringToWasm;
if (typeof stringToU8aInto === 'function') {
passStringToWasm = function(arg) {
let size = arg.length;
let ptr = wasm.__wbindgen_malloc(size);
let writeOffset = 0;
while (true) {
const view = getUint8Memory().subarray(ptr + writeOffset, ptr + size);
const { read, written } = stringToU8aInto(arg, view);
arg = arg.substring(read);
writeOffset += written;
if (arg.length === 0) {
break;
}
ptr = wasm.__wbindgen_realloc(ptr, size, size * 2);
size *= 2;
}
WASM_VECTOR_LEN = writeOffset;
return ptr;
};
} else {
passStringToWasm = function(arg) {
const buf = stringToU8a(arg);
const ptr = wasm.__wbindgen_malloc(buf.length);
getUint8Memory().set(buf, ptr);
WASM_VECTOR_LEN = buf.length;
return ptr;
};
}
/**
* Create entropy from a bip39 phrase
*
* * phrase: mnemonic phrase
*
* Returns the entropy
* @param {string} arg0
* @returns {Uint8Array}
*/
module.exports.ext_bip39_to_entropy = function(arg0) {
const ptr0 = passStringToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_bip39_to_entropy(retptr, ptr0, len0);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
}
};
/**
* Create a mini-secret from a bip39 phrase
*
* * phrase: mnemonic phrase
*
* Returns the 32-byte mini-secret via entropy
* @param {string} arg0
* @param {string} arg1
* @returns {Uint8Array}
*/
module.exports.ext_bip39_to_mini_secret = function(arg0, arg1) {
const ptr0 = passStringToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_bip39_to_mini_secret(retptr, ptr0, len0, ptr1, len1);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);
}
};
/**
* Creates a see from a bip-39 phrase
*
* @phrase: mnemonic phrase
*
* Returns a 32-byte seed
* @param {string} arg0
* @param {string} arg1
* @returns {Uint8Array}
*/
module.exports.ext_bip39_to_seed = function(arg0, arg1) {
const ptr0 = passStringToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_bip39_to_seed(retptr, ptr0, len0, ptr1, len1);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);
}
};
/**
* Validates a bip39 phrase
*
* * phrase: mnemonic phrase
*
* Returns the true/false
* @param {string} arg0
* @returns {boolean}
*/
module.exports.ext_bip39_validate = function(arg0) {
const ptr0 = passStringToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
try {
return (wasm.ext_bip39_validate(ptr0, len0)) !== 0;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
}
};
/**
* Generate a key pair.
*
* * seed: UIntArray with 32 element
*
* returned vector is the concatenation of first the private key (64 bytes)
* followed by the public key (32) bytes.
* @param {Uint8Array} arg0
* @returns {Uint8Array}
*/
module.exports.ext_ed_from_seed = function(arg0) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_ed_from_seed(retptr, ptr0, len0);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
}
};
/**
* Sign a message
*
* The combination of both public and private key must be provided.
* This is effectively equivalent to a keypair.
*
* * public: UIntArray with 32 element
* * private: UIntArray with 64 element
* * message: Arbitrary length UIntArray
*
* * returned vector is the signature consisting of 64 bytes.
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {Uint8Array}
*/
module.exports.ext_ed_sign = function(arg0, arg1, arg2) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm(arg2);
const len2 = WASM_VECTOR_LEN;
const retptr = globalArgumentPtr();
try {
wasm.ext_ed_sign(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
const mem = getUint32Memory();
const rustptr = mem[retptr / 4];
const rustlen = mem[retptr / 4 + 1];
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
wasm.__wbindgen_free(rustptr, rustlen * 1);
return realRet;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);
wasm.__wbindgen_free(ptr2, len2 * 1);
}
};
/**
* Verify a message and its corresponding against a public key;
*
* * signature: UIntArray with 64 element
* * message: Arbitrary length UIntArray
* * pubkey: UIntArray with 32 element
* @param {Uint8Array} arg0
* @param {Uint8Array} arg1
* @param {Uint8Array} arg2
* @returns {boolean}
*/
module.exports.ext_ed_verify = function(arg0, arg1, arg2) {
const ptr0 = passArray8ToWasm(arg0);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArray8ToWasm(arg1);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passArray8ToWasm(arg2);
const len2 = WASM_VECTOR_LEN;
try {
return (wasm.ext_ed_verify(ptr0, len0, ptr1, len1, ptr2, len2)) !== 0;
} finally {
wasm.__wbindgen_free(ptr0, len0 * 1);
wasm.__wbindgen_free(ptr1, len1 * 1);
wasm.__wbindgen_free(ptr2, len2 * 1);
}
};
const heap = new Array(32);

@@ -407,0 +727,0 @@

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