In internal/secret/keychainunlocker.go, the getLongTermPrivateKey() function hardcodes derivation index 0 when deriving the long-term key from a mnemonic:
This ignores the vault's actual DerivationIndex stored in vault-metadata.json. For any vault with a derivation index other than 0 (i.e., the second or subsequent vault created from the same mnemonic), this will derive the wrong long-term key, causing:
Keychain unlocker creation to encrypt the wrong key
Silent data corruption where the unlocker stores a key that doesn't match the vault
Expected Behavior
The function should read the vault's metadata to get the correct DerivationIndex and use it for key derivation.
Affected Code
internal/secret/keychainunlocker.go line ~330 in getLongTermPrivateKey()
## Bug
In `internal/secret/keychainunlocker.go`, the `getLongTermPrivateKey()` function hardcodes derivation index `0` when deriving the long-term key from a mnemonic:
```go
ltIdentity, err := agehd.DeriveIdentity(envMnemonic, 0)
```
This ignores the vault's actual `DerivationIndex` stored in `vault-metadata.json`. For any vault with a derivation index other than 0 (i.e., the second or subsequent vault created from the same mnemonic), this will derive the **wrong long-term key**, causing:
- Keychain unlocker creation to encrypt the wrong key
- Silent data corruption where the unlocker stores a key that doesn't match the vault
## Expected Behavior
The function should read the vault's metadata to get the correct `DerivationIndex` and use it for key derivation.
## Affected Code
`internal/secret/keychainunlocker.go` line ~330 in `getLongTermPrivateKey()`
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Bug
In
internal/secret/keychainunlocker.go, thegetLongTermPrivateKey()function hardcodes derivation index0when deriving the long-term key from a mnemonic:This ignores the vault's actual
DerivationIndexstored invault-metadata.json. For any vault with a derivation index other than 0 (i.e., the second or subsequent vault created from the same mnemonic), this will derive the wrong long-term key, causing:Expected Behavior
The function should read the vault's metadata to get the correct
DerivationIndexand use it for key derivation.Affected Code
internal/secret/keychainunlocker.goline ~330 ingetLongTermPrivateKey()