Reuse cosmjsSalt from wallet.ts

This commit is contained in:
Simon Warta 2020-07-23 13:44:47 +02:00
parent 0ea2babd74
commit e949d92097
3 changed files with 9 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import {
xchacha20NonceLength,
Xchacha20poly1305Ietf,
} from "@cosmjs/crypto";
import { fromBase64, fromHex, fromUtf8, toAscii, toBase64, toHex, toUtf8 } from "@cosmjs/encoding";
import { fromBase64, fromHex, fromUtf8, toBase64, toHex, toUtf8 } from "@cosmjs/encoding";
import { assert, isNonNullObject } from "@cosmjs/utils";
import { rawSecp256k1PubkeyToAddress } from "./address";
@ -21,6 +21,7 @@ import { StdSignature } from "./types";
import {
AccountData,
Algo,
cosmjsSalt,
executeKdf,
KdfConfiguration,
makeCosmoshubPath,
@ -31,13 +32,6 @@ import {
const serializationTypeV1 = "secp256k1wallet-v1";
/**
* A fixed salt is chosen to archive a deterministic password to key derivation.
* This reduces the scope of a potential rainbow attack to all CosmJS users.
* Must be 16 bytes due to implementation limitations.
*/
const cosmjsSalt = toAscii("The CosmJS salt.");
/**
* A KDF configuration that is not very strong but can be used on the main thread.
* It takes about 1 second in Node.js 12.15 and should have similar runtimes in other modern Wasm hosts.

View File

@ -59,7 +59,7 @@ export function makeCosmoshubPath(a: number): readonly Slip10RawIndex[] {
* This reduces the scope of a potential rainbow attack to all CosmJS users.
* Must be 16 bytes due to implementation limitations.
*/
const cosmjsSalt = toAscii("The CosmJS salt.");
export const cosmjsSalt = toAscii("The CosmJS salt.");
export interface KdfConfiguration {
/**

View File

@ -23,6 +23,12 @@ export declare function prehash(bytes: Uint8Array, type: PrehashType): Uint8Arra
* with 0-based account index `a`.
*/
export declare function makeCosmoshubPath(a: number): readonly Slip10RawIndex[];
/**
* A fixed salt is chosen to archive a deterministic password to key derivation.
* This reduces the scope of a potential rainbow attack to all CosmJS users.
* Must be 16 bytes due to implementation limitations.
*/
export declare const cosmjsSalt: Uint8Array;
export interface KdfConfiguration {
/**
* An algorithm identifier, such as "argon2id" or "scrypt".