Socket
Socket
Sign inDemoInstall

ethereum-cryptography

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-cryptography - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

src/vendor/bip39-without-wordlists.js

14

bip39/index.d.ts

@@ -1,8 +0,8 @@

import * as bip39Pure from "../pure/bip39";
export declare const generateMnemonic: typeof bip39Pure.generateMnemonic;
export declare const mnemonicToEntropy: typeof bip39Pure.mnemonicToEntropy;
export declare const entropyToMnemonic: typeof bip39Pure.entropyToMnemonic;
export declare const validateMnemonic: typeof bip39Pure.validateMnemonic;
export declare const mnemonicToSeed: typeof bip39Pure.mnemonicToSeed;
export declare const mnemonicToSeedSync: typeof bip39Pure.mnemonicToSeedSync;
/// <reference types="node" />
export declare function generateMnemonic(wordlist: string[], strength?: number): string;
export declare function mnemonicToEntropy(mnemonic: string, wordlist: string[]): Buffer;
export declare function entropyToMnemonic(entropy: Buffer, wordlist: string[]): string;
export declare function validateMnemonic(mnemonic: string, wordlist: string[]): boolean;
export declare function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Buffer>;
export declare function mnemonicToSeedSync(mnemonic: string, passphrase?: string): Buffer;
//# sourceMappingURL=index.d.ts.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var bip39Module;
try {
// tslint:disable-next-line no-implicit-dependencies
bip39Module = require("ethereum-cryptography-native/bip39");
var bip39 = require("../vendor/bip39-without-wordlists");
function generateMnemonic(wordlist, strength) {
if (strength === void 0) { strength = 128; }
return bip39.generateMnemonic(strength, undefined, wordlist);
}
catch (_a) {
bip39Module = require("../pure/bip39");
exports.generateMnemonic = generateMnemonic;
function mnemonicToEntropy(mnemonic, wordlist) {
return bip39.mnemonicToEntropy(mnemonic, wordlist);
}
exports.generateMnemonic = bip39Module.generateMnemonic;
exports.mnemonicToEntropy = bip39Module.mnemonicToEntropy;
exports.entropyToMnemonic = bip39Module.entropyToMnemonic;
exports.validateMnemonic = bip39Module.validateMnemonic;
exports.mnemonicToSeed = bip39Module.mnemonicToSeed;
exports.mnemonicToSeedSync = bip39Module.mnemonicToSeedSync;
exports.mnemonicToEntropy = mnemonicToEntropy;
function entropyToMnemonic(entropy, wordlist) {
return bip39.entropyToMnemonic(entropy, wordlist);
}
exports.entropyToMnemonic = entropyToMnemonic;
function validateMnemonic(mnemonic, wordlist) {
return bip39.validateMnemonic(mnemonic, wordlist);
}
exports.validateMnemonic = validateMnemonic;
function mnemonicToSeed(mnemonic, passphrase) {
if (passphrase === void 0) { passphrase = ""; }
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, bip39.mnemonicToSeed(mnemonic, passphrase)];
});
});
}
exports.mnemonicToSeed = mnemonicToSeed;
function mnemonicToSeedSync(mnemonic, passphrase) {
if (passphrase === void 0) { passphrase = ""; }
return bip39.mnemonicToSeedSync(mnemonic, passphrase);
}
exports.mnemonicToSeedSync = mnemonicToSeedSync;
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import * as blake2bPure from "./pure/blake2b";
export declare const blake2b: typeof blake2bPure.blake2b;
/// <reference types="node" />
export declare function blake2b(input: Buffer, outputLength?: number): Buffer;
//# sourceMappingURL=blake2b.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var blake2bModule;
try {
// tslint:disable-next-line no-implicit-dependencies
blake2bModule = require("ethereum-cryptography-native/blake2b");
var blake2bJs = require("blakejs");
function blake2b(input, outputLength) {
if (outputLength === void 0) { outputLength = 64; }
if (outputLength <= 0 || outputLength > 64) {
throw Error("Invalid outputLength");
}
return Buffer.from(blake2bJs.blake2b(input, undefined, outputLength));
}
catch (_a) {
blake2bModule = require("./pure/blake2b");
}
exports.blake2b = blake2bModule.blake2b;
exports.blake2b = blake2b;
//# sourceMappingURL=blake2b.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var hdkey;
try {
// tslint:disable-next-line no-implicit-dependencies
hdkey = require("ethereum-cryptography-native/hdkey").HDKey;
}
catch (_a) {
// This module is slightly more complicated, as we don't want to use the
// 100% pure version of hdkey if the native one isn't installed.
// We require this local version of hdkey-without-crypto because it uses
// the built-in crypto module
hdkey = require("./vendor/hdkey-without-crypto");
}
var hdkey = require("./vendor/hdkey-without-crypto");
exports.HDKey = hdkey;
//# sourceMappingURL=hdkey.js.map
{
"name": "ethereum-cryptography",
"version": "0.1.0",
"version": "0.1.2",
"description": "All the cryptographic primitives used in Ethereum",

@@ -52,7 +52,5 @@ "contributors": [

"browser": {
"./hdkey.js": "./pure/hdkey.js",
"./ripemd160.js": "./pure/ripemd160.js",
"./sha256.js": "./pure/sha256.js",
"./hdkey.js": "./pure/hdkey.js",
"./blake2b.js": "./pure/blake2b.js",
"./bip39/index.js": "./pure/bip39/index.js"
"./sha256.js": "./pure/sha256.js"
},

@@ -79,3 +77,3 @@ "sideEffects": false,

"bip39-without-wordlists:build": "bash -x scripts/build-bip39-without-wordlists.sh",
"bip39-without-wordlists:copy": "mkdir -p pure/vendor && cp src/pure/vendor/bip39-without-wordlists.js ./pure/vendor"
"bip39-without-wordlists:copy": "mkdir -p vendor && cp src/vendor/bip39-without-wordlists.js ./vendor"
},

@@ -82,0 +80,0 @@ "devDependencies": {

@@ -8,4 +8,4 @@ /// <reference types="node" />

static HARDENED_OFFSET: number;
static fromMasterSeed(seed: Buffer, versions: Versions): HDKeyT;
static fromExtendedKey(base58key: string, versions: Versions): HDKeyT;
static fromMasterSeed(seed: Buffer, versions?: Versions): HDKeyT;
static fromExtendedKey(base58key: string, versions?: Versions): HDKeyT;
static fromJSON(json: {

@@ -12,0 +12,0 @@ xpriv: string;

@@ -297,3 +297,3 @@ # ethereum-cryptography

### IV reusing
### How to use the IV parameter

@@ -372,3 +372,3 @@ The `iv` parameter of the `encrypt` function must be unique, or the security

```js
const { sign, createPrivateKeySync } = require("ethereum-cryptography/secp256k1");
const { createPrivateKeySync, ecdsaSign } = require("ethereum-cryptography/secp256k1");

@@ -382,3 +382,3 @@ const msgHash = Buffer.from(

console.log(Buffer.from(sign(msgHash, privateKey)).signature.toString("hex"));
console.log(Buffer.from(ecdsaSign(msgHash, privateKey).signature).toString("hex"));
```

@@ -385,0 +385,0 @@

@@ -1,17 +0,40 @@

import * as bip39Pure from "../pure/bip39";
const bip39 = require("../vendor/bip39-without-wordlists");
let bip39Module: typeof bip39Pure;
export function generateMnemonic(
wordlist: string[],
strength: number = 128
): string {
return bip39.generateMnemonic(strength, undefined, wordlist);
}
try {
// tslint:disable-next-line no-implicit-dependencies
bip39Module = require("ethereum-cryptography-native/bip39");
} catch {
bip39Module = require("../pure/bip39");
export function mnemonicToEntropy(
mnemonic: string,
wordlist: string[]
): Buffer {
return bip39.mnemonicToEntropy(mnemonic, wordlist);
}
export const generateMnemonic = bip39Module.generateMnemonic;
export const mnemonicToEntropy = bip39Module.mnemonicToEntropy;
export const entropyToMnemonic = bip39Module.entropyToMnemonic;
export const validateMnemonic = bip39Module.validateMnemonic;
export const mnemonicToSeed = bip39Module.mnemonicToSeed;
export const mnemonicToSeedSync = bip39Module.mnemonicToSeedSync;
export function entropyToMnemonic(entropy: Buffer, wordlist: string[]): string {
return bip39.entropyToMnemonic(entropy, wordlist);
}
export function validateMnemonic(
mnemonic: string,
wordlist: string[]
): boolean {
return bip39.validateMnemonic(mnemonic, wordlist);
}
export async function mnemonicToSeed(
mnemonic: string,
passphrase: string = ""
): Promise<Buffer> {
return bip39.mnemonicToSeed(mnemonic, passphrase);
}
export function mnemonicToSeedSync(
mnemonic: string,
passphrase: string = ""
): Buffer {
return bip39.mnemonicToSeedSync(mnemonic, passphrase);
}

@@ -1,12 +0,9 @@

import * as blake2bPure from "./pure/blake2b";
const blake2bJs = require("blakejs");
let blake2bModule: typeof blake2bPure;
export function blake2b(input: Buffer, outputLength = 64): Buffer {
if (outputLength <= 0 || outputLength > 64) {
throw Error("Invalid outputLength");
}
try {
// tslint:disable-next-line no-implicit-dependencies
blake2bModule = require("ethereum-cryptography-native/blake2b");
} catch {
blake2bModule = require("./pure/blake2b");
return Buffer.from(blake2bJs.blake2b(input, undefined, outputLength));
}
export const blake2b = blake2bModule.blake2b;
import * as hdkeyPure from "./pure/hdkey";
let hdkey: typeof hdkeyPure.HDKey;
const hdkey: typeof hdkeyPure.HDKey = require("./vendor/hdkey-without-crypto");
try {
// tslint:disable-next-line no-implicit-dependencies
hdkey = require("ethereum-cryptography-native/hdkey").HDKey;
} catch {
// This module is slightly more complicated, as we don't want to use the
// 100% pure version of hdkey if the native one isn't installed.
// We require this local version of hdkey-without-crypto because it uses
// the built-in crypto module
hdkey = require("./vendor/hdkey-without-crypto");
}
export const HDKey = hdkey;

@@ -8,4 +8,4 @@ export interface Versions {

public static HARDENED_OFFSET: number;
public static fromMasterSeed(seed: Buffer, versions: Versions): HDKeyT;
public static fromExtendedKey(base58key: string, versions: Versions): HDKeyT;
public static fromMasterSeed(seed: Buffer, versions?: Versions): HDKeyT;
public static fromExtendedKey(base58key: string, versions?: Versions): HDKeyT;
public static fromJSON(json: { xpriv: string }): HDKeyT;

@@ -12,0 +12,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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