MCPcopy Create free account
hub / github.com/DeepNotesApp/DeepNotes / derivePasswordValues

Function derivePasswordValues

apps/client/src/code/crypto.ts:17–44  ·  view source on GitHub ↗
(input: {
  password: string | Uint8Array;
  salt: Uint8Array;
})

Source from the content-addressed store, hash-verified

15const moduleLogger = mainLogger.sub('crypto.client.ts');
16
17export async function derivePasswordValues(input: {
18 password: string | Uint8Array;
19 salt: Uint8Array;
20}) {
21 moduleLogger.info('Started key derivation');
22
23 const derivedKey = (
24 await (globalThis as any).argon2.hash({
25 pass: input.password,
26 salt: input.salt,
27
28 hashLen: 32 + 64,
29
30 time: 8,
31 mem: 32 * 1024,
32 parallelism: 1,
33
34 type: (globalThis as any).argon2.ArgonType.Argon2id,
35 })
36 ).hash as Uint8Array;
37
38 moduleLogger.info('Finished key derivation');
39
40 return {
41 key: wrapSymmetricKey(derivedKey.slice(0, 32)),
42 hash: derivedKey.slice(32),
43 };
44}
45
46export async function deriveUserValues(input: {
47 email: string;

Callers 2

deriveUserValuesFunction · 0.70

Calls 1

wrapSymmetricKeyFunction · 0.90

Tested by

no test coverage detected