chore_: LoginAccount simplifications (#6338)

* fix(LoginAccount)_: ensure Mnemonic key uid matches the given account

* fix(LoginAccount)_: get KDF Iterations number from multiaccounts db
This commit is contained in:
Igor Sirotin 2025-02-12 17:21:26 +03:00 committed by GitHub
parent 45adccdcf9
commit 3e435221ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -590,6 +590,10 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
return errors.Wrap(err, "failed to generate account info")
}
if info.KeyUID != request.KeyUID {
return errors.New("mnemonic does not match this account")
}
derivedAddresses, err := b.getDerivedAddresses(info.ID)
if err != nil {
return errors.Wrap(err, "failed to get derived addresses")
@ -605,7 +609,11 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
}
if acc.KDFIterations == 0 {
acc.KDFIterations = dbsetup.ReducedKDFIterationsNumber
var err error
acc.KDFIterations, err = b.multiaccountsDB.GetAccountKDFIterationsNumber(acc.KeyUID)
if err != nil {
return errors.Wrap(err, "failed to get account kdf iterations number")
}
}
err := b.ensureDBsOpened(acc, request.Password)

View File

@ -17,7 +17,9 @@ type Login struct {
Password string `json:"password"`
KeyUID string `json:"keyUid"`
KdfIterations int `json:"kdfIterations"` // FIXME: KdfIterations should be loaded from multiaccounts db.
// Deprecated: KdfIterations will be automatically fetched from the multiaccounts db.
// For now the automation is done when KdfIterations is 0. In future this field will be completely ignored.
KdfIterations int `json:"kdfIterations"`
RuntimeLogLevel string `json:"runtimeLogLevel"`
WakuV2Nameserver string `json:"wakuV2Nameserver"`
BandwidthStatsEnabled bool `json:"bandwidthStatsEnabled"`
@ -31,6 +33,7 @@ type Login struct {
// When non-empty, mnemonic is used to generate required keypairs and:
// - Password is ignored and replaced with encryption public key
// - KeycardWhisperPrivateKey is ignored and replaced with chat private key
// - KeyUID is ignored and replaced with hash of the master public key
Mnemonic string `json:"mnemonic"`
WalletSecretsConfig