From d91c0245572755792fd6f2acc5b6ab90bbf5e166 Mon Sep 17 00:00:00 2001 From: zo-el Date: Mon, 30 Oct 2023 11:09:18 -0500 Subject: [PATCH 1/2] manage passphrase in-memory --- package.json | 2 +- src/lib/helpers/generate-keys.ts | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 0c73919..ff7316b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "type": "module", "dependencies": { - "hcSeedBundle": "git+https://github.com/holochain/hcSeedBundle#semver:^0.0.3", + "hcSeedBundle": "file:///home/zo-el/Documents/git_repo/holo/hcSeedBundle", "clsx": "^2.0.0", "svelte": "^4.0.5", "tailwindcss": "^3.3.3", diff --git a/src/lib/helpers/generate-keys.ts b/src/lib/helpers/generate-keys.ts index c194c09..978aee2 100644 --- a/src/lib/helpers/generate-keys.ts +++ b/src/lib/helpers/generate-keys.ts @@ -4,8 +4,6 @@ import * as hcSeedBundle from 'hcSeedBundle'; export async function generateKeys(passphrase: string) { await hcSeedBundle.seedBundleReady; - const pw = new TextEncoder().encode(passphrase); - const master = hcSeedBundle.UnlockedSeedBundle.newRandom({ bundle_type: 'master' }); @@ -13,14 +11,21 @@ export async function generateKeys(passphrase: string) { generate_by: 'keymanager-v1.0' }); const encodedMasterBytes = master.lock([ - new hcSeedBundle.SeedCipherPwHash(hcSeedBundle.parseSecret(pw), 'minimum') + new hcSeedBundle.SeedCipherPwHash( + hcSeedBundle.parseSecret(new TextEncoder().encode(passphrase)), + 'minimum' + ) ]); const revocationDerivationPath = 0; - const encodedRevocationBytes = await derive(revocationDerivationPath, 'revocationRoot', pw); + const encodedRevocationBytes = await derive( + revocationDerivationPath, + 'revocationRoot', + passphrase + ); const deviceNumber = 1; - const encodedDeviceBytes = await derive(deviceNumber, 'deviceRoot', pw); + const encodedDeviceBytes = await derive(deviceNumber, 'deviceRoot', passphrase); master.zero(); @@ -39,7 +44,10 @@ export async function generateKeys(passphrase: string) { generate_by: 'keymanager-v1.0' }); const encodedBytes = root.lock([ - new hcSeedBundle.SeedCipherPwHash(hcSeedBundle.parseSecret(passphrase), 'minimum') + new hcSeedBundle.SeedCipherPwHash( + hcSeedBundle.parseSecret(new TextEncoder().encode(passphrase)), + 'minimum' + ) ]); return encodedBytes; } From 0f4ab4a2fad98a5b09a0f8688c10f78f5d967f01 Mon Sep 17 00:00:00 2001 From: zo-el Date: Mon, 30 Oct 2023 11:09:53 -0500 Subject: [PATCH 2/2] clean up --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff7316b..0c73919 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "type": "module", "dependencies": { - "hcSeedBundle": "file:///home/zo-el/Documents/git_repo/holo/hcSeedBundle", + "hcSeedBundle": "git+https://github.com/holochain/hcSeedBundle#semver:^0.0.3", "clsx": "^2.0.0", "svelte": "^4.0.5", "tailwindcss": "^3.3.3",