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

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.0.2 to 0.0.3

elliptic-secp256k1.js

10

keccak.js
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var keccakPure = __importStar(require("./pure/keccak"));
var keccakModule;

@@ -17,3 +9,3 @@ try {

catch (_a) {
keccakModule = keccakPure;
keccakModule = require("./pure/keccak");
}

@@ -20,0 +12,0 @@ exports.keccak224 = keccakModule.keccak224;

{
"name": "ethereum-cryptography",
"version": "0.0.2",
"version": "0.0.3",
"description": "All the cryptographic primitives used in Ethereum",

@@ -26,3 +26,4 @@ "author": "Patricio Palladino <patricio@nomiclabs.io>",

"browser": {
"./keccak.js": "./pure/keccak.js"
"./keccak.js": "./pure/keccak.js",
"./scrypt.js": "./pure/scrypt.js"
},

@@ -32,7 +33,17 @@ "sideEffects": false,

"prepare": "npm run build",
"build": "tsc --project tsconfig.prod.json",
"build": "npm-run-all elliptic-build build:tsc elliptic-copy",
"build:tsc": "tsc --project tsconfig.prod.json",
"test": "mocha",
"clean": "rimraf pure '*.js' '*.js.map' '*.d.ts' '*.d.ts.map'",
"clean": "rimraf test-builds pure '*.js' '*.js.map' '*.d.ts' '*.d.ts.map'",
"lint": "tslint --project tsconfig.json",
"lint:fix": "tslint --fix --project tsconfig.json"
"lint:fix": "tslint --fix --project tsconfig.json",
"browser-tests": "npm-run-all browser-tests:build browser-tests:test",
"browser-tests:build": "bash -x ../../scripts/build-browser-tests.sh",
"browser-tests:test": "npm-run-all browser-tests:test-parcel browser-tests:test-browserify browser-tests:test-webpack browser-tests:test-rollup",
"browser-tests:test-parcel": "karma start --single-run --browsers ChromeHeadless test/karma.parcel.conf.js",
"browser-tests:test-browserify": "karma start --single-run --browsers ChromeHeadless test/karma.browserify.conf.js",
"browser-tests:test-webpack": "karma start --single-run --browsers ChromeHeadless test/karma.webpack.conf.js",
"browser-tests:test-rollup": "karma start --single-run --browsers ChromeHeadless test/karma.rollup.conf.js",
"elliptic-build": "rollup -c elliptic-secp256k1-config/rollup.config.js",
"elliptic-copy": "cp src/elliptic-secp256k1.js ./"
},

@@ -43,6 +54,20 @@ "devDependencies": {

"@types/node": "^8.10.52",
"browserify": "^16.5.0",
"chai": "^4.2.0",
"karma": "^4.3.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^6.2.0",
"npm-run-all": "^4.1.5",
"parcel-bundler": "^1.12.3",
"prettier": "1.18.2",
"rimraf": "^3.0.0",
"rollup": "^1.20.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"ts-node": "^8.3.0",

@@ -52,7 +77,17 @@ "tslint": "^5.19.0",

"tslint-plugin-prettier": "^2.0.1",
"typescript": "~3.6.2"
"typescript": "~3.6.2",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.8"
},
"dependencies": {
"js-sha3": "^0.8.0"
"@types/secp256k1": "^3.5.0",
"bip66": "^1.1.5",
"bn.js": "^4.11.8",
"create-hash": "^1.2.0",
"elliptic": "^6.4.1",
"hash.js": "^1.1.7",
"js-sha3": "^0.8.0",
"safe-buffer": "^5.1.2",
"scrypt-js": "^2.0.4"
}
}

@@ -13,2 +13,6 @@ # ethereum-cryptography

* `keccak`
* `scrypt`
* `sha256`
* `ripemd160`
* `secp256k1`

@@ -33,6 +37,6 @@ ## Installation

No `index.js` is provided, as that would lead to huge bundles when using this
package for the web.
No `index.js`/`main` is provided, as that would lead to huge bundles when using
this package for the web.
### keccak
### keccak submodule

@@ -43,2 +47,14 @@ The `keccack` submodule has four functions that receive a `Buffer` with the

#### Function types
```ts
function keccak224(msg: Buffer): Buffer;
function keccak256(msg: Buffer): Buffer;
function keccak384(msg: Buffer): Buffer;
function keccak512(msg: Buffer): Buffer;
```
#### Example usage

@@ -52,7 +68,116 @@

### scrypt submodule
The `scrypt` submodule has two functions implementing the `scrypt` hash
algorithm in synchronous and asynchronous ways. This algorithm is very slow,
and using the synchronous version in the browser is not recommended, as it will
block its main thread and hang your ui.
#### Password encoding
Encoding passwords is a frequent source of errors. Please read
[these notes](https://github.com/ricmoo/scrypt-js/tree/0eb70873ddf3d24e34b53e0d9a99a0cef06a79c0#encoding-notes)
before using this submodule.
#### Function types
```ts
function scrypt(password: Buffer, salt: Buffer, n: number, p: number, r: number, dklen: number): Buffer;
function scryptAsync(password: Buffer, salt: Buffer, n: number, p: number, r: number, dklen: number): Promise<Buffer>;
```
#### Example usage
```js
const { scrypt } = require("ethereum-cryptography/scrypt");
console.log(
scrypt(
Buffer.from("ascii password", "ascii"),
Buffer.from("AAAA", "hex"),
16,
1,
1,
64
).toString("hex")
);
```
### sha256 submodule
The `sha256` submodule contains a single functions implementing the `sha256`
hash algorithm.
#### Function types
```ts
function sha256(msg: Buffer): Buffer;
```
#### Example usage
```js
const { sha256 } = require("ethereum-cryptography/sha256");
console.log(sha256(Buffer.from("message", "ascii")).toString("hex"));
```
### ripemd160 submodule
The `ripemd160` submodule contains a single functions implementing the
`ripemd160` hash algorithm.
#### Function types
```ts
function ripemd160(msg: Buffer): Buffer;
```
#### Example usage
```js
const { ripemd160 } = require("ethereum-cryptography/ripemd160");
console.log(ripemd160(Buffer.from("message", "ascii")).toString("hex"));
```
### secp256k1 submodule
The `secp256k1` submodule has the same API than the native module
[`secp256k1` from cryptocoinjs](https://github.com/cryptocoinjs/secp256k1-node)
version `3.x`, but it's backed by [`elliptic`](https://www.npmjs.com/package/elliptic).
#### Function types
Consult [`secp256k1`'s documentation](https://github.com/cryptocoinjs/secp256k1-node).
#### Example usage
```js
const { sign } = require("ethereum-cryptography/secp256k1");
const msgHash = Buffer.from(
"82ff40c0a986c6a5cfad4ddf4c3aa6996f1a7837f9c398e17e5de5cbd5a12b28",
"hex"
);
const privateKey = Buffer.from(
"3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1",
"hex"
);
console.log(sign(msgHash, privateKey).toString("hex"));
```
## Browser usage
This package works out of the box with all the major Javascript bundlers (e.g.
`webpack`, `Rollup`, `Parcel`, `Browserify`).
This package works with all the major Javascript bundlers. It is
tested with `webpack`, `Rollup`, `Parcel`, and `Browserify`.
For using it with `Rollup` you need to use these plugins:
[`rollup-plugin-node-builtins`](https://www.npmjs.com/package/rollup-plugin-node-builtins),
[`rollup-plugin-node-globals`](https://www.npmjs.com/package/rollup-plugin-node-globals),
and [`rollup-plugin-json`](https://www.npmjs.com/package/rollup-plugin-json).
## Opt-in native implementations (Node.js only)

@@ -72,3 +197,6 @@

## License
`ethereum-cryptography` is released under [the MIT License](./LICENSE).
[1]: https://img.shields.io/npm/v/ethereum-cryptography.svg

@@ -79,2 +207,2 @@ [2]: https://www.npmjs.com/package/ethereum-cryptography

[5]: https://img.shields.io/npm/l/ethereum-cryptography
[6]: https://github.com/alcuadrado/ethereum-cryptography/blob/master/LICENSE
[6]: https://github.com/alcuadrado/ethereum-cryptography/blob/master/packages/ethereum-cryptography/LICENSE

@@ -9,3 +9,3 @@ import * as keccakPure from "./pure/keccak";

} catch {
keccakModule = keccakPure;
keccakModule = require("./pure/keccak");
}

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

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