@iov/crypto
Advanced tools
Comparing version 1.2.0 to 2.0.0-alpha.0
"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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
@@ -35,6 +35,6 @@ "use strict"; | ||
} | ||
exports.EnglishMnemonic = EnglishMnemonic; | ||
EnglishMnemonic.wordlist = bip39.wordlists.english; | ||
// list of space separated lower case words (1 or more) | ||
EnglishMnemonic.mnemonicMatcher = /^[a-z]+( [a-z]+)*$/; | ||
exports.EnglishMnemonic = EnglishMnemonic; | ||
//# sourceMappingURL=englishmnemonic.js.map |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./bip39")); | ||
var bip39_1 = require("./bip39"); | ||
exports.Bip39 = bip39_1.Bip39; | ||
var englishmnemonic_1 = require("./englishmnemonic"); | ||
exports.EnglishMnemonic = englishmnemonic_1.EnglishMnemonic; | ||
__export(require("./hmac")); | ||
__export(require("./keccak")); | ||
__export(require("./libsodium")); | ||
var hmac_1 = require("./hmac"); | ||
exports.Hmac = hmac_1.Hmac; | ||
var keccak_1 = require("./keccak"); | ||
exports.Keccak256 = keccak_1.Keccak256; | ||
var libsodium_1 = require("./libsodium"); | ||
exports.Xchacha20poly1305Ietf = libsodium_1.Xchacha20poly1305Ietf; | ||
exports.Argon2id = libsodium_1.Argon2id; | ||
exports.Ed25519 = libsodium_1.Ed25519; | ||
exports.Ed25519Keypair = libsodium_1.Ed25519Keypair; | ||
var random_1 = require("./random"); | ||
exports.Random = random_1.Random; | ||
__export(require("./secp256k1")); | ||
var ripemd_1 = require("./ripemd"); | ||
exports.Ripemd160 = ripemd_1.Ripemd160; | ||
var secp256k1_1 = require("./secp256k1"); | ||
exports.Secp256k1 = secp256k1_1.Secp256k1; | ||
var secp256k1signature_1 = require("./secp256k1signature"); | ||
exports.ExtendedSecp256k1Signature = secp256k1signature_1.ExtendedSecp256k1Signature; | ||
exports.Secp256k1Signature = secp256k1signature_1.Secp256k1Signature; | ||
__export(require("./sha")); | ||
__export(require("./slip10")); | ||
var sha_1 = require("./sha"); | ||
exports.Sha1 = sha_1.Sha1; | ||
exports.Sha256 = sha_1.Sha256; | ||
exports.Sha512 = sha_1.Sha512; | ||
var slip10_1 = require("./slip10"); | ||
exports.Slip10 = slip10_1.Slip10; | ||
exports.Slip10Curve = slip10_1.Slip10Curve; | ||
exports.Slip10RawIndex = slip10_1.Slip10RawIndex; | ||
exports.slip10CurveFromString = slip10_1.slip10CurveFromString; | ||
//# sourceMappingURL=index.js.map |
@@ -7,6 +7,7 @@ "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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -31,2 +32,6 @@ }); | ||
class Ed25519Keypair { | ||
constructor(privkey, pubkey) { | ||
this.privkey = privkey; | ||
this.pubkey = pubkey; | ||
} | ||
// a libsodium privkey has the format `<ed25519 privkey> + <ed25519 pubkey>` | ||
@@ -39,6 +44,2 @@ static fromLibsodiumPrivkey(libsodiumPrivkey) { | ||
} | ||
constructor(privkey, pubkey) { | ||
this.privkey = privkey; | ||
this.pubkey = pubkey; | ||
} | ||
toLibsodiumPrivkey() { | ||
@@ -45,0 +46,0 @@ return new Uint8Array([...this.privkey, ...this.pubkey]); |
"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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -103,4 +104,24 @@ }); | ||
} | ||
static compressPubkey(pubkey) { | ||
switch (pubkey.length) { | ||
case 33: | ||
return pubkey; | ||
case 65: | ||
return Uint8Array.from(secp256k1.keyFromPublic(pubkey).pub.encodeCompressed()); | ||
default: | ||
throw new Error("Invalid pubkey length"); | ||
} | ||
} | ||
static trimRecoveryByte(signature) { | ||
switch (signature.length) { | ||
case 64: | ||
return signature; | ||
case 65: | ||
return signature.slice(0, 64); | ||
default: | ||
throw new Error("Invalid signature length"); | ||
} | ||
} | ||
} | ||
exports.Secp256k1 = Secp256k1; | ||
//# sourceMappingURL=secp256k1.js.map |
@@ -17,2 +17,14 @@ "use strict"; | ||
class Secp256k1Signature { | ||
constructor(r, s) { | ||
if (r.length > 32 || r.length === 0 || r[0] === 0x00) { | ||
throw new Error("Unsigned integer r must be encoded as unpadded big endian."); | ||
} | ||
if (s.length > 32 || s.length === 0 || s[0] === 0x00) { | ||
throw new Error("Unsigned integer s must be encoded as unpadded big endian."); | ||
} | ||
this.data = { | ||
r: r, | ||
s: s, | ||
}; | ||
} | ||
static fromDer(data) { | ||
@@ -53,14 +65,2 @@ let pos = 0; | ||
} | ||
constructor(r, s) { | ||
if (r.length > 32 || r.length === 0 || r[0] === 0x00) { | ||
throw new Error("Unsigned integer r must be encoded as unpadded big endian."); | ||
} | ||
if (s.length > 32 || s.length === 0 || s[0] === 0x00) { | ||
throw new Error("Unsigned integer s must be encoded as unpadded big endian."); | ||
} | ||
this.data = { | ||
r: r, | ||
s: s, | ||
}; | ||
} | ||
r(length) { | ||
@@ -108,12 +108,2 @@ if (length === undefined) { | ||
class ExtendedSecp256k1Signature extends Secp256k1Signature { | ||
/** | ||
* Decode extended signature from the simple fixed length encoding | ||
* described in toFixedLength(). | ||
*/ | ||
static fromFixedLength(data) { | ||
if (data.length !== 65) { | ||
throw new Error(`Got invalid data length ${data.length}. Expected 32 + 32 + 1`); | ||
} | ||
return new ExtendedSecp256k1Signature(trimLeadingNullBytes(data.slice(0, 32)), trimLeadingNullBytes(data.slice(32, 64)), data[64]); | ||
} | ||
constructor(r, s, recovery) { | ||
@@ -130,2 +120,12 @@ super(r, s); | ||
/** | ||
* Decode extended signature from the simple fixed length encoding | ||
* described in toFixedLength(). | ||
*/ | ||
static fromFixedLength(data) { | ||
if (data.length !== 65) { | ||
throw new Error(`Got invalid data length ${data.length}. Expected 32 + 32 + 1`); | ||
} | ||
return new ExtendedSecp256k1Signature(trimLeadingNullBytes(data.slice(0, 32)), trimLeadingNullBytes(data.slice(32, 64)), data[64]); | ||
} | ||
/** | ||
* A simple custom encoding that encodes the extended signature as | ||
@@ -132,0 +132,0 @@ * r (32 bytes) | s (32 bytes) | recovery param (1 byte) |
{ | ||
"name": "@iov/crypto", | ||
"version": "1.2.0", | ||
"version": "2.0.0-alpha.0", | ||
"description": "Cryptography resources for IOV projects", | ||
@@ -34,3 +34,3 @@ "author": "IOV SAS <admin@iov.one>", | ||
"test": "yarn build-or-skip && yarn test-node", | ||
"move-types": "shx rm -r ./types/* && shx mv build/types/* ./types && shx rm ./types/*.spec.d.ts", | ||
"move-types": "shx rm -r ./types/* && shx mv build/types/* ./types && rm -rf ./types/testdata && shx rm ./types/*.spec.d.ts", | ||
"format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"", | ||
@@ -42,3 +42,3 @@ "build": "shx rm -rf ./build && tsc && yarn move-types && yarn format-types", | ||
"dependencies": { | ||
"@iov/encoding": "^1.2.0", | ||
"@iov/encoding": "^2.0.0-alpha.0", | ||
"bip39": "^3.0.2", | ||
@@ -50,2 +50,3 @@ "bn.js": "^4.11.8", | ||
"pbkdf2": "^3.0.16", | ||
"ripemd160": "^2.0.2", | ||
"sha.js": "^2.4.11", | ||
@@ -58,3 +59,3 @@ "type-tagger": "^1.0.0", | ||
}, | ||
"gitHead": "3d3c018043d6d438ed9222bef413ecc52fbda1a7" | ||
"gitHead": "6a8923c2ee67f4190fba61952ca4e198e1e50d59" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { HashFunction } from "./sha"; | ||
import { HashFunction } from "./hash"; | ||
export declare class Hmac<H extends HashFunction> implements HashFunction { | ||
@@ -3,0 +3,0 @@ readonly blockSize: number; |
@@ -1,10 +0,22 @@ | ||
export * from "./bip39"; | ||
export { Bip39 } from "./bip39"; | ||
export { EnglishMnemonic } from "./englishmnemonic"; | ||
export * from "./hmac"; | ||
export * from "./keccak"; | ||
export * from "./libsodium"; | ||
export { HashFunction } from "./hash"; | ||
export { Hmac } from "./hmac"; | ||
export { Keccak256 } from "./keccak"; | ||
export { | ||
Xchacha20poly1305Ietf, | ||
Xchacha20poly1305IetfCiphertext, | ||
Xchacha20poly1305IetfKey, | ||
Xchacha20poly1305IetfMessage, | ||
Xchacha20poly1305IetfNonce, | ||
Argon2id, | ||
Argon2idOptions, | ||
Ed25519, | ||
Ed25519Keypair, | ||
} from "./libsodium"; | ||
export { Random } from "./random"; | ||
export * from "./secp256k1"; | ||
export { Ripemd160 } from "./ripemd"; | ||
export { Secp256k1, Secp256k1Keypair } from "./secp256k1"; | ||
export { ExtendedSecp256k1Signature, Secp256k1Signature } from "./secp256k1signature"; | ||
export * from "./sha"; | ||
export * from "./slip10"; | ||
export { Sha1, Sha256, Sha512 } from "./sha"; | ||
export { Slip10, Slip10Curve, Slip10RawIndex, Slip10Result, slip10CurveFromString } from "./slip10"; |
@@ -1,2 +0,2 @@ | ||
import { HashFunction } from "./sha"; | ||
import { HashFunction } from "./hash"; | ||
export declare class Keccak256 implements HashFunction { | ||
@@ -3,0 +3,0 @@ readonly blockSize: number; |
@@ -17,3 +17,5 @@ import { As } from "type-tagger"; | ||
static recoverPubkey(signature: ExtendedSecp256k1Signature, messageHash: Uint8Array): Uint8Array; | ||
static compressPubkey(pubkey: Uint8Array): Uint8Array; | ||
static trimRecoveryByte(signature: Uint8Array): Uint8Array; | ||
} | ||
export {}; |
@@ -1,6 +0,2 @@ | ||
export interface HashFunction { | ||
readonly blockSize: number; | ||
readonly update: (_: Uint8Array) => HashFunction; | ||
readonly digest: () => Uint8Array; | ||
} | ||
import { HashFunction } from "./hash"; | ||
export declare class Sha1 implements HashFunction { | ||
@@ -7,0 +3,0 @@ readonly blockSize: number; |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
77316
42
1033
11
2
+ Addedripemd160@^2.0.2
+ Added@cosmjs/encoding@0.20.1(transitive)
+ Added@cosmjs/math@0.20.1(transitive)
+ Added@cosmjs/utils@0.20.1(transitive)
+ Added@iov/encoding@2.5.0(transitive)
- Removed@iov/encoding@1.2.0(transitive)
Updated@iov/encoding@^2.0.0-alpha.0