Fix robot PGP keys created in a future time

This commit is contained in:
Reckless_Satoshi 2022-06-01 14:44:58 -07:00
parent 585b768a17
commit 5534ada1be
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 5 additions and 3 deletions

View File

@ -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)

View File

@ -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}