From 304017ac7e7a5e1f6ffbbb71a726c51ea1ad497b Mon Sep 17 00:00:00 2001 From: marukai67 Date: Wed, 28 Jan 2026 21:40:18 +0100 Subject: [PATCH] Update main.go --- cmd/clef/main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/clef/main.go b/cmd/clef/main.go index dde4ae853f..df5286b21d 100644 --- a/cmd/clef/main.go +++ b/cmd/clef/main.go @@ -387,7 +387,7 @@ func attestFile(ctx *cli.Context) error { utils.Fatalf(err.Error()) } configDir := ctx.String(configdirFlag.Name) - vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10])) + vaultLocation := vaultPath(configDir, stretchedKey) confKey := crypto.Keccak256([]byte("config"), stretchedKey) // Initialize the encrypted storages @@ -434,7 +434,7 @@ func setCredential(ctx *cli.Context) error { utils.Fatalf(err.Error()) } configDir := ctx.String(configdirFlag.Name) - vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10])) + vaultLocation := vaultPath(configDir, stretchedKey) pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey) pwStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey) @@ -462,7 +462,7 @@ func removeCredential(ctx *cli.Context) error { utils.Fatalf(err.Error()) } configDir := ctx.String(configdirFlag.Name) - vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10])) + vaultLocation := vaultPath(configDir, stretchedKey) pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey) pwStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey) @@ -498,6 +498,10 @@ func initialize(c *cli.Context) error { return nil } +func vaultPath(configDir string, stretchedKey []byte) string { + return filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10])) +} + func newAccount(c *cli.Context) error { internalApi, _, err := initInternalApi(c) if err != nil { @@ -657,7 +661,7 @@ func signer(c *cli.Context) error { if stretchedKey, err := readMasterKey(c, ui); err != nil { log.Warn("Failed to open master, rules disabled", "err", err) } else { - vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10])) + vaultLocation := vaultPath(configDir, stretchedKey) // Generate domain specific keys pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey)