From 0757898d61f4d535b43a33af20e676fe7183b1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Tue, 13 Oct 2026 13:31:34 +0200 Subject: [PATCH] perf: share links use scrypt 2^15, about 40 ms each way Keys keeping to share.keyRules are random and long, so age's 2^18 (a third of a second to share and to open) bought little. Co-Authored-By: Claude Opus 5.5 (1M context) --- internal/share/share.go | 10 ++++++---- internal/ui/app/sharefiles_test.go | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/share/share.go b/internal/share/share.go index e9a4d22..9dac614 100644 --- a/internal/share/share.go +++ b/internal/share/share.go @@ -51,10 +51,12 @@ const ( maxFiles = 1 << 20 ) -// workFactor is age's scrypt work factor for sealing (its default); -// maxWorkFactor is the most opening accepts, so a link can't make it -// work for minutes. -var workFactor, maxWorkFactor = 18, 20 +// workFactor is the scrypt work factor for sealing: 2^15, about 40 ms +// each way, instead of age's 2^18 (a third of a second). scrypt makes +// guessing a weak passphrase slow; a key keeping to the rules is random +// and long enough not to need that. maxWorkFactor is the most opening +// accepts, so a link can't make it work for minutes. +var workFactor, maxWorkFactor = 15, 20 // File is a shared file. type File struct { diff --git a/internal/ui/app/sharefiles_test.go b/internal/ui/app/sharefiles_test.go index 5917cee..ee3d061 100644 --- a/internal/ui/app/sharefiles_test.go +++ b/internal/ui/app/sharefiles_test.go @@ -17,8 +17,8 @@ import ( "git.kebcloud.no/keb/lazysecrets/internal/share" ) -// scryptWait is how long the driver waits for encrypting and decrypting, -// which take about a second on purpose. +// scryptWait is how long the driver waits for encrypting and decrypting: +// tens of milliseconds, more than its usual wait, and more under load. const scryptWait = 20 * time.Second // demoRules take the demo key, made up to be remembered.