ethereumjs-util
Advanced tools
Comparing version 7.0.2 to 7.0.3
@@ -9,2 +9,24 @@ # Changelog | ||
## [7.0.3] - 2020-07-07 | ||
This release replaces the `keccak` and `secp256k1` dependencies | ||
(PR [#257](https://github.com/ethereumjs/ethereumjs-util/pull/257)) | ||
and instead uses the | ||
[ethereum-cryptography](https://github.com/ethereum/js-ethereum-cryptography) | ||
package that uses native JS implementations for cryptographic primitives | ||
and makes use of modern and forward-compatible N-API implementations in Node | ||
wherever possible. | ||
This is part of a larger initiative led by Nomic Labs to improve the developer | ||
experience within the Ethereum developer ecosystem, | ||
see https://github.com/ethereum/js-organization/issues/18 for context. | ||
**Other Changes:** | ||
- Added `TypeScript` definitions for `ethjs-util` methods, | ||
PR [#248](https://github.com/ethereumjs/ethereumjs-util/pull/248) and | ||
PR [#260](https://github.com/ethereumjs/ethereumjs-util/pull/260) | ||
[7.0.3]: https://github.com/ethereumjs/ethereumjs-util/compare/v7.0.2...v7.0.3 | ||
## [7.0.2] - 2020-05-25 | ||
@@ -11,0 +33,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ethjsUtil = require('ethjs-util'); | ||
var ethjsUtil = require("ethjs-util"); | ||
var _a = require('ethereum-cryptography/secp256k1'), privateKeyVerify = _a.privateKeyVerify, publicKeyCreate = _a.publicKeyCreate, publicKeyVerify = _a.publicKeyVerify, publicKeyConvert = _a.publicKeyConvert; | ||
var assert = require("assert"); | ||
var secp256k1 = require("secp256k1"); | ||
var BN = require("bn.js"); | ||
@@ -103,3 +103,3 @@ var bytes_1 = require("./bytes"); | ||
exports.isValidPrivate = function (privateKey) { | ||
return secp256k1.privateKeyVerify(privateKey); | ||
return privateKeyVerify(privateKey); | ||
}; | ||
@@ -117,3 +117,3 @@ /** | ||
// Convert to SEC1 for secp256k1 | ||
return secp256k1.publicKeyVerify(Buffer.concat([Buffer.from([4]), publicKey])); | ||
return publicKeyVerify(Buffer.concat([Buffer.from([4]), publicKey])); | ||
} | ||
@@ -123,3 +123,3 @@ if (!sanitize) { | ||
} | ||
return secp256k1.publicKeyVerify(publicKey); | ||
return publicKeyVerify(publicKey); | ||
}; | ||
@@ -136,3 +136,3 @@ /** | ||
if (sanitize && pubKey.length !== 64) { | ||
pubKey = bytes_1.toBuffer(secp256k1.publicKeyConvert(pubKey, false).slice(1)); | ||
pubKey = Buffer.from(publicKeyConvert(pubKey, false).slice(1)); | ||
} | ||
@@ -158,3 +158,3 @@ assert(pubKey.length === 64); | ||
// skip the type flag and use the X, Y points | ||
return bytes_1.toBuffer(secp256k1.publicKeyCreate(privateKey, false).slice(1)); | ||
return Buffer.from(publicKeyCreate(privateKey, false)).slice(1); | ||
}; | ||
@@ -167,3 +167,3 @@ /** | ||
if (publicKey.length !== 64) { | ||
publicKey = bytes_1.toBuffer(secp256k1.publicKeyConvert(publicKey, false).slice(1)); | ||
publicKey = Buffer.from(publicKeyConvert(publicKey, false).slice(1)); | ||
} | ||
@@ -170,0 +170,0 @@ return publicKey; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ethjsUtil = require('ethjs-util'); | ||
var ethjsUtil = require("ethjs-util"); | ||
var BN = require("bn.js"); | ||
@@ -5,0 +5,0 @@ var helpers_1 = require("./helpers"); |
/** | ||
* Re-exports commonly used modules: | ||
* * Adds [`ethjs-util`](https://github.com/ethjs/ethjs-util) methods. | ||
* * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp). | ||
@@ -5,0 +4,0 @@ * @packageDocumentation |
"use strict"; | ||
/** | ||
* Re-exports commonly used modules: | ||
* * Adds [`ethjs-util`](https://github.com/ethjs/ethjs-util) methods. | ||
* * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp). | ||
@@ -9,3 +8,2 @@ * @packageDocumentation | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ethjsUtil = require('ethjs-util'); | ||
var BN = require("bn.js"); | ||
@@ -15,6 +13,2 @@ exports.BN = BN; | ||
exports.rlp = rlp; | ||
/** | ||
* [`ethjsUtil`](https://github.com/ethjs/ethjs-util) | ||
*/ | ||
Object.assign(exports, ethjsUtil); | ||
//# sourceMappingURL=externals.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var createKeccakHash = require('keccak'); | ||
var _a = require('ethereum-cryptography/keccak'), keccak224 = _a.keccak224, keccak384 = _a.keccak384, k256 = _a.keccak256, keccak512 = _a.keccak512; | ||
var createHash = require('create-hash'); | ||
var ethjsUtil = require('ethjs-util'); | ||
var rlp = require("rlp"); | ||
@@ -17,5 +16,19 @@ var bytes_1 = require("./bytes"); | ||
helpers_1.assertIsBuffer(a); | ||
return createKeccakHash("keccak" + bits) | ||
.update(a) | ||
.digest(); | ||
switch (bits) { | ||
case 224: { | ||
return keccak224(a); | ||
} | ||
case 256: { | ||
return k256(a); | ||
} | ||
case 384: { | ||
return keccak384(a); | ||
} | ||
case 512: { | ||
return keccak512(a); | ||
} | ||
default: { | ||
throw new Error("Invald algorithm: keccak" + bits); | ||
} | ||
} | ||
}; | ||
@@ -22,0 +35,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ethjsUtil = require('ethjs-util'); | ||
var ethjsUtil = require("ethjs-util"); | ||
/** | ||
@@ -5,0 +5,0 @@ * Throws if a string is not hex prefixed |
@@ -0,1 +1,2 @@ | ||
/// <reference path="@types/ethjs-util/index.d.ts" /> | ||
/** | ||
@@ -26,4 +27,8 @@ * Constants | ||
/** | ||
* External exports (ethjsUtil, BN, rlp, secp256k1) | ||
* External exports (BN, rlp, secp256k1) | ||
*/ | ||
export * from './externals'; | ||
/** | ||
* Export ethjs-util methods | ||
*/ | ||
export * from 'ethjs-util'; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/// <reference path="./@types/ethjs-util/index.ts"/> | ||
/** | ||
@@ -32,5 +33,9 @@ * Constants | ||
/** | ||
* External exports (ethjsUtil, BN, rlp, secp256k1) | ||
* External exports (BN, rlp, secp256k1) | ||
*/ | ||
__export(require("./externals")); | ||
/** | ||
* Export ethjs-util methods | ||
*/ | ||
__export(require("ethjs-util")); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ethjsUtil = require('ethjs-util'); | ||
var ethjsUtil = require("ethjs-util"); | ||
var assert = require("assert"); | ||
@@ -5,0 +5,0 @@ var rlp = require("rlp"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var secp256k1 = require("secp256k1"); | ||
var _a = require('ethereum-cryptography/secp256k1'), ecdsaSign = _a.ecdsaSign, ecdsaRecover = _a.ecdsaRecover, publicKeyConvert = _a.publicKeyConvert; | ||
var BN = require("bn.js"); | ||
@@ -12,7 +12,7 @@ var bytes_1 = require("./bytes"); | ||
exports.ecsign = function (msgHash, privateKey, chainId) { | ||
var sig = secp256k1.ecdsaSign(msgHash, privateKey); | ||
var sig = ecdsaSign(msgHash, privateKey); | ||
var recovery = sig.recid; | ||
var ret = { | ||
r: bytes_1.toBuffer(sig.signature.slice(0, 32)), | ||
s: bytes_1.toBuffer(sig.signature.slice(32, 64)), | ||
r: Buffer.from(sig.signature.slice(0, 32)), | ||
s: Buffer.from(sig.signature.slice(32, 64)), | ||
v: chainId ? recovery + (chainId * 2 + 35) : recovery + 27, | ||
@@ -32,4 +32,4 @@ }; | ||
} | ||
var senderPubKey = secp256k1.ecdsaRecover(signature, recovery, msgHash); | ||
return bytes_1.toBuffer(secp256k1.publicKeyConvert(senderPubKey, false).slice(1)); | ||
var senderPubKey = ecdsaRecover(signature, recovery, msgHash); | ||
return Buffer.from(publicKeyConvert(senderPubKey, false).slice(1)); | ||
}; | ||
@@ -36,0 +36,0 @@ /** |
{ | ||
"name": "ethereumjs-util", | ||
"version": "7.0.2", | ||
"version": "7.0.3", | ||
"description": "a collection of utility functions for Ethereum", | ||
@@ -95,6 +95,5 @@ "main": "dist/index.js", | ||
"create-hash": "^1.1.2", | ||
"ethereum-cryptography": "^0.1.3", | ||
"ethjs-util": "0.1.6", | ||
"keccak": "^3.0.0", | ||
"rlp": "^2.2.4", | ||
"secp256k1": "^4.0.1" | ||
"rlp": "^2.2.4" | ||
}, | ||
@@ -101,0 +100,0 @@ "devDependencies": { |
@@ -18,3 +18,3 @@ # SYNOPSIS | ||
import assert from 'assert' | ||
import { isValidChecksumAddress, unpad, BN } from 'ethereumjs-util' | ||
import { isValidChecksumAddress, unpadBuffer, BN } from 'ethereumjs-util' | ||
@@ -24,3 +24,3 @@ const address = '0x2F015C60E0be116B1f0CD534704Db9c92118FB6A' | ||
assert.equal(unpad('0000000006600'), '6600') | ||
assert.equal(unpadBuffer(Buffer.from('000000006600', 'hex')), Buffer.from('6600', 'hex')) | ||
@@ -71,2 +71,8 @@ assert.equal(new BN('dead', 16).add(new BN('101010', 2)), 57047) | ||
Import can be done directly by function name analogous to the build-in function import: | ||
```js | ||
import { intToHex, stripHexPrefix } from 'ethereumjs-util' | ||
``` | ||
### Re-Exports | ||
@@ -73,0 +79,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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101394
6
34
1285
91
+ Addedethereum-cryptography@^0.1.3
+ Added@types/pbkdf2@3.1.2(transitive)
+ Added@types/secp256k1@4.0.6(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedblakejs@1.2.1(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbs58@4.0.1(transitive)
+ Addedbs58check@2.1.2(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addedethereum-cryptography@0.1.3(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedscrypt-js@3.0.1(transitive)
+ Addedsetimmediate@1.0.5(transitive)
- Removedkeccak@^3.0.0
- Removedsecp256k1@^4.0.1