mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 10:31:35 +00:00
Fix robot PGP keys created in a future time
This commit is contained in:
parent
585b768a17
commit
5534ada1be
@ -103,11 +103,12 @@ class Logics:
|
|||||||
import_pub_result = gpg.import_keys(pub_key)
|
import_pub_result = gpg.import_keys(pub_key)
|
||||||
pub_key = gpg.export_keys(import_pub_result.fingerprints[0])
|
pub_key = gpg.export_keys(import_pub_result.fingerprints[0])
|
||||||
except Exception as e:
|
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 (
|
return (
|
||||||
False,
|
False,
|
||||||
{
|
{
|
||||||
"bad_request":
|
"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,
|
||||||
None)
|
None)
|
||||||
|
@ -12,13 +12,14 @@ import { sha256 } from 'js-sha256';
|
|||||||
|
|
||||||
// Generate KeyPair. Private Key is encrypted with the highEntropyToken
|
// Generate KeyPair. Private Key is encrypted with the highEntropyToken
|
||||||
export async function genKey(highEntropyToken) {
|
export async function genKey(highEntropyToken) {
|
||||||
|
var d = new Date();
|
||||||
const keyPair = await generateKey({
|
const keyPair = await generateKey({
|
||||||
type: 'ecc', // Type of the key, defaults to ECC
|
type: 'ecc', // Type of the key, defaults to ECC
|
||||||
curve: 'curve25519', // ECC curve name, defaults to curve25519
|
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.
|
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,
|
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}
|
return {publicKeyArmored: keyPair.publicKey, encryptedPrivateKeyArmored: keyPair.privateKey}
|
||||||
|
Loading…
Reference in New Issue
Block a user