From 5534ada1be75c3bca356dddc0c1195418026fabd Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Wed, 1 Jun 2022 14:44:58 -0700 Subject: [PATCH] Fix robot PGP keys created in a future time --- api/logics.py | 3 ++- frontend/src/utils/pgp.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/logics.py b/api/logics.py index ed0550e5..3115a37a 100644 --- a/api/logics.py +++ b/api/logics.py @@ -103,11 +103,12 @@ class Logics: import_pub_result = gpg.import_keys(pub_key) pub_key = gpg.export_keys(import_pub_result.fingerprints[0]) except Exception as e: + e = "Your system time might be in the future " if str(e)=="list index out of range" else str(e) return ( False, { "bad_request": - f"Your PGP public key does not seem valid. Exception: {str(e)}" + f"Your PGP public key does not seem valid. Error: {str(e)}" }, None, None) diff --git a/frontend/src/utils/pgp.js b/frontend/src/utils/pgp.js index 81623cf9..486548ac 100644 --- a/frontend/src/utils/pgp.js +++ b/frontend/src/utils/pgp.js @@ -12,13 +12,14 @@ import { sha256 } from 'js-sha256'; // Generate KeyPair. Private Key is encrypted with the highEntropyToken export async function genKey(highEntropyToken) { - + var d = new Date(); const keyPair = await generateKey({ type: 'ecc', // Type of the key, defaults to ECC curve: 'curve25519', // ECC curve name, defaults to curve25519 userIDs: [{name: 'RoboSats ID '+ sha256(sha256(highEntropyToken))}], //Ideally it would be the avatar nickname, but the nickname is generated only after submission. The second SHA256 can be converted into the Nickname using nick_generator package. passphrase: highEntropyToken, - format: 'armored' + format: 'armored', + date: d.setDate(d.getDate()-1) // One day of offset. Helps reducing errors due to client's system time being in the future. }) return {publicKeyArmored: keyPair.publicKey, encryptedPrivateKeyArmored: keyPair.privateKey}