mirror of
https://github.com/status-im/status-go.git
synced 2025-02-23 12:18:38 +00:00
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:
parent
45adccdcf9
commit
3e435221ce
@ -590,6 +590,10 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
|
|||||||
return errors.Wrap(err, "failed to generate account info")
|
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)
|
derivedAddresses, err := b.getDerivedAddresses(info.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to get derived addresses")
|
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 {
|
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)
|
err := b.ensureDBsOpened(acc, request.Password)
|
||||||
|
@ -17,7 +17,9 @@ type Login struct {
|
|||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
KeyUID string `json:"keyUid"`
|
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"`
|
RuntimeLogLevel string `json:"runtimeLogLevel"`
|
||||||
WakuV2Nameserver string `json:"wakuV2Nameserver"`
|
WakuV2Nameserver string `json:"wakuV2Nameserver"`
|
||||||
BandwidthStatsEnabled bool `json:"bandwidthStatsEnabled"`
|
BandwidthStatsEnabled bool `json:"bandwidthStatsEnabled"`
|
||||||
@ -31,6 +33,7 @@ type Login struct {
|
|||||||
// When non-empty, mnemonic is used to generate required keypairs and:
|
// When non-empty, mnemonic is used to generate required keypairs and:
|
||||||
// - Password is ignored and replaced with encryption public key
|
// - Password is ignored and replaced with encryption public key
|
||||||
// - KeycardWhisperPrivateKey is ignored and replaced with chat private 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"`
|
Mnemonic string `json:"mnemonic"`
|
||||||
|
|
||||||
WalletSecretsConfig
|
WalletSecretsConfig
|
||||||
|
Loading…
x
Reference in New Issue
Block a user