mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-18 16:53:16 +00:00
PGP ID is second hash of token
This commit is contained in:
@ -666,8 +666,8 @@ class UserView(APIView):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Hash the token_sha256, only 1 iteration. (this is the second SHA256 of the user token)
|
# Hash the token_sha256, only 1 iteration. (this is the second SHA256 of the user token, aka RoboSats ID)
|
||||||
hash = hashlib.sha256(str.encode(token_sha256)).hexdigest()
|
hash = hashlib.sha256(token_sha256.encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
# Generate nickname deterministically
|
# Generate nickname deterministically
|
||||||
nickname = self.NickGen.short_from_SHA256(hash, max_length=18)[0]
|
nickname = self.NickGen.short_from_SHA256(hash, max_length=18)[0]
|
||||||
|
@ -221,12 +221,14 @@ class UserGenPage extends Component {
|
|||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment:
|
startAdornment:
|
||||||
<div style={{width:50, minWidth:50, position:'relative',left:-6}}>
|
<div style={{width:50, minWidth:50, position:'relative',left:-6}}>
|
||||||
<Grid container xs={12}>
|
<Grid container>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
<Tooltip enterTouchDelay={250} title={t("Save token and PGP credentials to file")}>
|
<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())}>
|
<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}}/>
|
<DownloadIcon sx={{width:22, height:22}}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
createMessage,
|
createMessage,
|
||||||
readMessage
|
readMessage
|
||||||
} from 'openpgp/lightweight';
|
} from 'openpgp/lightweight';
|
||||||
|
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) {
|
||||||
@ -15,7 +16,7 @@ export async function genKey(highEntropyToken) {
|
|||||||
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 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,
|
passphrase: highEntropyToken,
|
||||||
format: 'armored'
|
format: 'armored'
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user