diff --git a/api/views.py b/api/views.py index e6420193..45795f8b 100644 --- a/api/views.py +++ b/api/views.py @@ -666,8 +666,8 @@ class UserView(APIView): except: pass - # Hash the token_sha256, only 1 iteration. (this is the second SHA256 of the user token) - hash = hashlib.sha256(str.encode(token_sha256)).hexdigest() + # Hash the token_sha256, only 1 iteration. (this is the second SHA256 of the user token, aka RoboSats ID) + hash = hashlib.sha256(token_sha256.encode('utf-8')).hexdigest() # Generate nickname deterministically nickname = self.NickGen.short_from_SHA256(hash, max_length=18)[0] diff --git a/frontend/src/components/UserGenPage.js b/frontend/src/components/UserGenPage.js index 883cc243..41edc745 100644 --- a/frontend/src/components/UserGenPage.js +++ b/frontend/src/components/UserGenPage.js @@ -221,12 +221,14 @@ class UserGenPage extends Component { InputProps={{ startAdornment:
- + + saveAsJson(this.state.nickname+'.json', this.createJsonFile())}> + diff --git a/frontend/src/utils/pgp.js b/frontend/src/utils/pgp.js index 32947778..81623cf9 100644 --- a/frontend/src/utils/pgp.js +++ b/frontend/src/utils/pgp.js @@ -8,6 +8,7 @@ import { createMessage, readMessage } from 'openpgp/lightweight'; +import { sha256 } from 'js-sha256'; // Generate KeyPair. Private Key is encrypted with the highEntropyToken export async function genKey(highEntropyToken) { @@ -15,7 +16,7 @@ export async function genKey(highEntropyToken) { const keyPair = await generateKey({ type: 'ecc', // Type of the key, defaults to ECC curve: 'curve25519', // ECC curve name, defaults to curve25519 - userIDs: [{name: 'RoboSats Avatar ID'+ parseInt(Math.random() * 1000000)}], //Just for identification. Ideally it would be the avatar nickname, but the nickname is generated only after submission + 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' })