From 71c9337ab72749a747f19708a41997ad7d22b1e8 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 27 Sep 2019 18:04:49 -0500 Subject: [PATCH] board now uses sha256 --- docs/usage/firststeps.md | 4 ++-- onionr/onionrcommands/onionrstatistics.py | 2 +- onionr/onionrstorage/setdata.py | 3 ++- onionr/runtests/uicheck.py | 2 +- static-data/www/board/board.js | 4 +++- static-data/www/shared/useridenticons.js | 9 +++++++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/usage/firststeps.md b/docs/usage/firststeps.md index 8733565d..a3d7faaf 100644 --- a/docs/usage/firststeps.md +++ b/docs/usage/firststeps.md @@ -3,5 +3,5 @@ After installing Onionr, there are several things to do: 1. Setup a [deterministic address](usage/deterministic.md) (optional) -2. Add friends' ids -3. Publish your id \ No newline at end of file +2. Start your node `/path/to/onionr.sh start` +3. Copy your ID and share it with friends \ No newline at end of file diff --git a/onionr/onionrcommands/onionrstatistics.py b/onionr/onionrcommands/onionrstatistics.py index a63db177..303aa8f8 100755 --- a/onionr/onionrcommands/onionrstatistics.py +++ b/onionr/onionrcommands/onionrstatistics.py @@ -89,7 +89,7 @@ def show_details(): details = { 'Node Address' : gethostname.get_hostname(), 'Web Password' : config.get('client.webpassword'), - 'Public Key' : onionrcrypto.pub_key, + 'Public Key' : onionrcrypto.pub_key.replace('=', ''), 'Human-readable Public Key' : mnemonickeys.get_human_readable_ID() } diff --git a/onionr/onionrstorage/setdata.py b/onionr/onionrstorage/setdata.py index 474916b0..0ac5d21b 100644 --- a/onionr/onionrstorage/setdata.py +++ b/onionr/onionrstorage/setdata.py @@ -39,4 +39,5 @@ def set_data(data)->str: else: raise onionrexceptions.DataExists("Data is already set for " + dataHash) - return dataHash \ No newline at end of file + print(dataHash, nonce_hash) + return dataHash diff --git a/onionr/runtests/uicheck.py b/onionr/runtests/uicheck.py index 530d1519..57f27cae 100644 --- a/onionr/runtests/uicheck.py +++ b/onionr/runtests/uicheck.py @@ -6,4 +6,4 @@ def check_ui(test_manager): if not result: raise ValueError result = result.lower() if not 'onionr' in result and not 'Onionr' in result: - raise ValueError \ No newline at end of file + raise ValueError diff --git a/static-data/www/board/board.js b/static-data/www/board/board.js index f5fa4bf1..c445e2fa 100755 --- a/static-data/www/board/board.js +++ b/static-data/www/board/board.js @@ -97,7 +97,9 @@ function appendMessages(msg, blockHash, beforeHash){ div[3].textContent = msg['meta']['signer'].substr(0, 5) setHumanReadableIDOnPost(div[3], msg['meta']['signer']) div[3].title = msg['meta']['signer'] - identicon[0].src = "data:image/svg+xml;base64," + userIcon(msg['meta']['signer']) + userIcon(msg['meta']['signer']).then(function(data){ + identicon[0].src = "data:image/svg+xml;base64," + data + }) } else{ identicon[0].remove() diff --git a/static-data/www/shared/useridenticons.js b/static-data/www/shared/useridenticons.js index 2c562578..72c4fe97 100644 --- a/static-data/www/shared/useridenticons.js +++ b/static-data/www/shared/useridenticons.js @@ -7,8 +7,13 @@ function toHexString(byteArray) { return s; } -function userIcon(pubkey, imgSize=64){ - pubkey = toHexString(base32.decode.asBytes(pubkey)) + async function sha256(str) { + const buf = await crypto.subtle.digest("SHA-256", new TextEncoder("utf-8").encode(str)); + return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join(''); + } + +async function userIcon(pubkey, imgSize=64){ + pubkey = await sha256(base32.decode.asBytes(pubkey)) let options = { //foreground: [0,0,0,1], // rgba black background: [255, 255, 255, 255], // rgba white