Skip to content

Commit

Permalink
perf: remove argon bench on boot, use sane defaults across the board
Browse files Browse the repository at this point in the history
  • Loading branch information
woodenfurniture committed Nov 21, 2023
1 parent 5e315b9 commit 5b3e66f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 232 deletions.
57 changes: 0 additions & 57 deletions packages/hdwallet-native-vault/src/argonBenchmark.test.ts

This file was deleted.

168 changes: 0 additions & 168 deletions packages/hdwallet-native-vault/src/argonBenchmark.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/hdwallet-native-vault/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createMnemonic, crypto, entropyToMnemonic, GENERATE_MNEMONIC } from "./util";
import { Vault } from "./vault";

export { argonBenchmark } from "./argonBenchmark";
export type { ISealableVaultFactory, IVault, IVaultFactory } from "./types";
export { GENERATE_MNEMONIC } from "./util";
export { Vault } from "./vault";
Expand Down
11 changes: 5 additions & 6 deletions packages/hdwallet-native-vault/src/rawVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as jose from "jose";
import * as ta from "type-assertions";
import * as uuid from "uuid";

import { argonBenchmark } from "./argonBenchmark";
import { ArgonParams, IVaultBackedBy, IVaultFactory, VaultPrepareParams } from "./types";
import { crypto, encoder, keyStoreUUID, Revocable, revocable, setCrypto, setPerformance, vaultStoreUUID } from "./util";

Expand Down Expand Up @@ -69,16 +68,16 @@ export class RawVault extends Revocable(Object.freeze(class {})) implements IVau
(await idb.get<ArgonParams>("defaultArgonParams", await RawVault.#keyStore)) ?? {
then: (onfulfilled, onrejected) => {
return (async () => {
// For more details on parameter selection, see:
// https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-argon2-04#section-4
const out: ArgonParams = {
parallelism: 1,
memorySize: 32 * 1024,
iterations: 26,
iterations: 16,
};
const argonBenchmarkResults = await argonBenchmark(out.memorySize, 1000, { measureError: true });
console.debug("argonBenchmarkResults:", argonBenchmarkResults);
await idb.set("argonBenchmarkResults", argonBenchmarkResults, await RawVault.#keyStore);
out.iterations = argonBenchmarkResults.iterations;

await idb.set("defaultArgonParams", out, await RawVault.#keyStore);

return out;
})().then(onfulfilled, onrejected);
},
Expand Down

0 comments on commit 5b3e66f

Please sign in to comment.