From 6d139db765595b636a4f1d7ae8503bdd79c040f6 Mon Sep 17 00:00:00 2001 From: vba2000 Date: Tue, 24 Sep 2019 18:51:59 +0300 Subject: [PATCH] DEXW-2177: check password --- .../migrate/controllers/MigrateCtrl.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/modules/migrate/controllers/MigrateCtrl.js b/src/modules/migrate/controllers/MigrateCtrl.js index 45d4f92098..17d04785ea 100644 --- a/src/modules/migrate/controllers/MigrateCtrl.js +++ b/src/modules/migrate/controllers/MigrateCtrl.js @@ -119,11 +119,20 @@ } } + checkSeed(seed, publicKey) { + return publicKey === libs.crypto.publicKey(seed); + } + + checkPK(privateKey, publicKey) { + return libs.crypto.publicKey({ privateKey }) === publicKey; + } + onSubmit() { try { this._hidePasswordError(); - const { userType, id, publicKey, address } = this.userToMigrate; + const { id, publicKey, address } = this.userToMigrate; + const userType = userType || 'seed'; const networkByte = base58Decode(address)[1]; const seed = userType === 'seed' ? ds.Seed.decryptSeedPhrase( @@ -138,6 +147,14 @@ ) : undefined; + if (seed && !this.checkSeed(seed, publicKey)) { + throw new Error('Incorrect seed'); + } + + if (privateKey && !this.checkPK(privateKey, publicKey)) { + throw new Error('Incorrect private key'); + } + this.migrateUser({ userType, networkByte,