@iov/crypto
Advanced tools
Comparing version 0.15.0 to 0.16.0-alpha.0
@@ -18,6 +18,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const encoding_1 = require("@iov/encoding"); | ||
const bip39 = __importStar(require("bip39")); | ||
const pbkdf2_1 = require("pbkdf2"); | ||
const unorm = __importStar(require("unorm")); | ||
const encoding_1 = require("@iov/encoding"); | ||
const englishmnemonic_1 = require("./englishmnemonic"); | ||
@@ -24,0 +24,0 @@ class Bip39 { |
@@ -14,12 +14,13 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// use require instead of import because of this bug | ||
// https://github.com/jedisct1/libsodium.js/issues/148 | ||
const sodium = require("libsodium-wrappers"); | ||
const libsodium_wrappers_1 = __importDefault(require("libsodium-wrappers")); | ||
class Argon2id { | ||
static execute(password, salt, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sodium.ready; | ||
return sodium.crypto_pwhash(options.outputLength, password, salt, // libsodium only supports 16 byte salts and will throw when you don't respect that | ||
options.opsLimit, options.memLimitKib * 1024, sodium.crypto_pwhash_ALG_ARGON2ID13); | ||
yield libsodium_wrappers_1.default.ready; | ||
return libsodium_wrappers_1.default.crypto_pwhash(options.outputLength, password, salt, // libsodium only supports 16 byte salts and will throw when you don't respect that | ||
options.opsLimit, options.memLimitKib * 1024, libsodium_wrappers_1.default.crypto_pwhash_ALG_ARGON2ID13); | ||
}); | ||
@@ -33,4 +34,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sodium.ready; | ||
return sodium.randombytes_buf(count); | ||
yield libsodium_wrappers_1.default.ready; | ||
return libsodium_wrappers_1.default.randombytes_buf(count); | ||
}); | ||
@@ -68,4 +69,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sodium.ready; | ||
const keypair = sodium.crypto_sign_seed_keypair(seed); | ||
yield libsodium_wrappers_1.default.ready; | ||
const keypair = libsodium_wrappers_1.default.crypto_sign_seed_keypair(seed); | ||
return Ed25519Keypair.fromLibsodiumPrivkey(keypair.privateKey); | ||
@@ -76,4 +77,4 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sodium.ready; | ||
return sodium.crypto_sign_detached(message, keyPair.toLibsodiumPrivkey()); | ||
yield libsodium_wrappers_1.default.ready; | ||
return libsodium_wrappers_1.default.crypto_sign_detached(message, keyPair.toLibsodiumPrivkey()); | ||
}); | ||
@@ -83,4 +84,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sodium.ready; | ||
return sodium.crypto_sign_verify_detached(signature, message, pubkey); | ||
yield libsodium_wrappers_1.default.ready; | ||
return libsodium_wrappers_1.default.crypto_sign_verify_detached(signature, message, pubkey); | ||
}); | ||
@@ -93,5 +94,5 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sodium.ready; | ||
yield libsodium_wrappers_1.default.ready; | ||
const additionalData = undefined; | ||
return sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(message, additionalData, null, // secret nonce: unused and should be null (https://download.libsodium.org/doc/secret-key_cryptography/aead/chacha20-poly1305/xchacha20-poly1305_construction) | ||
return libsodium_wrappers_1.default.crypto_aead_xchacha20poly1305_ietf_encrypt(message, additionalData, null, // secret nonce: unused and should be null (https://download.libsodium.org/doc/secret-key_cryptography/aead/chacha20-poly1305/xchacha20-poly1305_construction) | ||
nonce, key); | ||
@@ -102,5 +103,5 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sodium.ready; | ||
yield libsodium_wrappers_1.default.ready; | ||
const additionalData = undefined; | ||
return sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(null, // secret nonce: unused and should be null (https://download.libsodium.org/doc/secret-key_cryptography/aead/chacha20-poly1305/xchacha20-poly1305_construction) | ||
return libsodium_wrappers_1.default.crypto_aead_xchacha20poly1305_ietf_decrypt(null, // secret nonce: unused and should be null (https://download.libsodium.org/doc/secret-key_cryptography/aead/chacha20-poly1305/xchacha20-poly1305_construction) | ||
ciphertext, additionalData, nonce, key); | ||
@@ -107,0 +108,0 @@ }); |
@@ -10,9 +10,12 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const BN = require("bn.js"); | ||
const elliptic = require("elliptic"); | ||
const encoding_1 = require("@iov/encoding"); | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const elliptic_1 = __importDefault(require("elliptic")); | ||
const secp256k1signature_1 = require("./secp256k1signature"); | ||
const secp256k1 = new elliptic.ec("secp256k1"); | ||
const secp256k1N = new BN("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", "hex"); | ||
const secp256k1 = new elliptic_1.default.ec("secp256k1"); | ||
const secp256k1N = new bn_js_1.default("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", "hex"); | ||
class Secp256k1 { | ||
@@ -31,3 +34,3 @@ static makeKeypair(privkey) { | ||
// range test that is not part of the elliptic implementation | ||
const privkeyAsBigInteger = new BN(privkey); | ||
const privkeyAsBigInteger = new bn_js_1.default(privkey); | ||
if (privkeyAsBigInteger.gte(secp256k1N)) { | ||
@@ -34,0 +37,0 @@ // not strictly smaller than N |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const BN = require("bn.js"); | ||
const elliptic = require("elliptic"); | ||
const encoding_1 = require("@iov/encoding"); | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const elliptic_1 = __importDefault(require("elliptic")); | ||
const hmac_1 = require("./hmac"); | ||
@@ -44,3 +47,3 @@ const sha_1 = require("./sha"); | ||
exports.Slip10RawIndex = Slip10RawIndex; | ||
const secp256k1 = new elliptic.ec("secp256k1"); | ||
const secp256k1 = new elliptic_1.default.ec("secp256k1"); | ||
// Universal private key derivation accoring to | ||
@@ -83,3 +86,3 @@ // https://github.com/satoshilabs/slips/blob/master/slip-0010.md | ||
const data = new Uint8Array([ | ||
...Slip10.serializedPoint(curve, new BN(parentPrivkey)), | ||
...Slip10.serializedPoint(curve, new bn_js_1.default(parentPrivkey)), | ||
...rawIndex.toBytesBigEndian(), | ||
@@ -120,3 +123,3 @@ ]); | ||
const n = this.n(curve); | ||
const returnChildKeyAsNumber = new BN(il).add(new BN(parentPrivkey)).mod(n); | ||
const returnChildKeyAsNumber = new bn_js_1.default(il).add(new bn_js_1.default(parentPrivkey)).mod(n); | ||
const returnChildKey = returnChildKeyAsNumber.toArrayLike(Uint8Array, "be", 32); | ||
@@ -140,3 +143,3 @@ // step 6 | ||
static isGteN(curve, privkey) { | ||
const keyAsNumber = new BN(privkey); | ||
const keyAsNumber = new bn_js_1.default(privkey); | ||
return keyAsNumber.gte(this.n(curve)); | ||
@@ -147,3 +150,3 @@ } | ||
case Slip10Curve.Secp256k1: | ||
return new BN("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", 16); | ||
return new bn_js_1.default("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", 16); | ||
default: | ||
@@ -150,0 +153,0 @@ throw new Error("curve not supported"); |
{ | ||
"name": "@iov/crypto", | ||
"version": "0.15.0", | ||
"version": "0.16.0-alpha.0", | ||
"description": "Cryptography resources for IOV projects", | ||
@@ -33,3 +33,3 @@ "author": "IOV SAS <admin@iov.one>", | ||
"dependencies": { | ||
"@iov/encoding": "^0.15.0", | ||
"@iov/encoding": "^0.16.0-alpha.0", | ||
"bip39": "^2.5.0", | ||
@@ -39,3 +39,3 @@ "bn.js": "^4.11.8", | ||
"js-sha3": "^0.8.0", | ||
"libsodium-wrappers": "^0.7.4", | ||
"libsodium-wrappers": "^0.7.5", | ||
"pbkdf2": "^3.0.16", | ||
@@ -47,5 +47,5 @@ "sha.js": "^2.4.11", | ||
"devDependencies": { | ||
"@types/libsodium-wrappers": "^0.7.3" | ||
"@types/libsodium-wrappers": "^0.7.5" | ||
}, | ||
"gitHead": "6705df135a4d75a8d9198a38c99399411aaab8bf" | ||
"gitHead": "98661476c470a6fc35f9edc8e3dd03ed5637273e" | ||
} |
@@ -9,3 +9,3 @@ # @iov/crypto | ||
checks, and a simple API to these libraries. This can also be freely imported | ||
outside of @iov/core based applications. | ||
outside of IOV-Core based applications. | ||
@@ -12,0 +12,0 @@ ## API Documentation |
@@ -5,3 +5,2 @@ import { Encoding } from "@iov/encoding"; | ||
import { EnglishMnemonic } from "./englishmnemonic"; | ||
import bip39Vectors from "./testdata/bip39.json"; | ||
@@ -8,0 +7,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { Encoding } from "@iov/encoding"; | ||
import * as bip39 from "bip39"; | ||
@@ -5,4 +6,2 @@ import { pbkdf2 } from "pbkdf2"; | ||
import { Encoding } from "@iov/encoding"; | ||
import { EnglishMnemonic } from "./englishmnemonic"; | ||
@@ -9,0 +8,0 @@ |
import jssha3 from "js-sha3"; | ||
import { HashFunction } from "./sha"; | ||
@@ -3,0 +4,0 @@ |
@@ -6,5 +6,3 @@ // Keep all classes requiring libsodium-js in one file as having multiple | ||
// use require instead of import because of this bug | ||
// https://github.com/jedisct1/libsodium.js/issues/148 | ||
import sodium = require("libsodium-wrappers"); | ||
import sodium from "libsodium-wrappers"; | ||
import { As } from "type-tagger"; | ||
@@ -11,0 +9,0 @@ |
@@ -1,7 +0,6 @@ | ||
import BN = require("bn.js"); | ||
import elliptic = require("elliptic"); | ||
import { Encoding } from "@iov/encoding"; | ||
import BN from "bn.js"; | ||
import elliptic from "elliptic"; | ||
import { As } from "type-tagger"; | ||
import { Encoding } from "@iov/encoding"; | ||
import { ExtendedSecp256k1Signature, Secp256k1Signature } from "./secp256k1signature"; | ||
@@ -8,0 +7,0 @@ |
@@ -1,5 +0,4 @@ | ||
import BN = require("bn.js"); | ||
import elliptic = require("elliptic"); | ||
import { Encoding, Uint32 } from "@iov/encoding"; | ||
import BN from "bn.js"; | ||
import elliptic from "elliptic"; | ||
@@ -6,0 +5,0 @@ import { Hmac } from "./hmac"; |
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 too big to display
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 too big to display
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
980292
12702
+ Added@iov/encoding@0.16.3(transitive)
- Removed@iov/encoding@0.15.0(transitive)
Updatedlibsodium-wrappers@^0.7.5