PGP ID is second hash of token

This commit is contained in:
Reckless_Satoshi
2022-05-26 14:16:02 -07:00
parent 30d65ee852
commit 4da6a43a59
3 changed files with 7 additions and 4 deletions

View File

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

View File

@ -221,12 +221,14 @@ class UserGenPage extends Component {
InputProps={{
startAdornment:
<div style={{width:50, minWidth:50, position:'relative',left:-6}}>
<Grid container xs={12}>
<Grid container>
<Grid item xs={6}>
<Tooltip enterTouchDelay={250} title={t("Save token and PGP credentials to file")}>
<span>
<IconButton color="primary" disabled={getCookie('robot_token')==null || !this.props.avatarLoaded} onClick= {()=> saveAsJson(this.state.nickname+'.json', this.createJsonFile())}>
<DownloadIcon sx={{width:22, height:22}}/>
</IconButton>
</span>
</Tooltip>
</Grid>
<Grid item xs={6}>

View File

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