From 042e66a0918a4543f4167108123f9b2a28c056a4 Mon Sep 17 00:00:00 2001 From: poka Date: Tue, 8 Dec 2020 17:05:04 +0100 Subject: [PATCH 1/3] Use python only, no bash anymore ... --- zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py b/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py index 86ded7c..167b691 100755 --- a/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py +++ b/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py @@ -8,19 +8,19 @@ # protoc --python_out=. crypto.proto ######################################################################### -import os -import base58 -import base64 +import re, base58, base64, crypto_pb2 import cryptography.hazmat.primitives.asymmetric.ed25519 as ed25519 from cryptography.hazmat.primitives import serialization -import crypto_pb2 -from sys import argv # TODO controls # Capturing keys (from /tmp/secret.dunikey) -shared_key = os.popen('cat /tmp/secret.dunikey | grep pub | cut -d " " -f 2').read() -secure_key = os.popen('cat /tmp/secret.dunikey | grep sec | cut -d " " -f 2').read() +dunikey = "/tmp/secret.dunikey" +for line in open(dunikey, "r"): + if re.search("pub", line): + shared_key = line.replace('\n','').split(': ')[1] + elif re.search("sec", line): + secure_key = line.replace('\n','').split(': ')[1] # Decoding keys decoded_shared = base58.b58decode(shared_key) @@ -46,7 +46,7 @@ pkey = crypto_pb2.PrivateKey() pkey.Type = 1 pkey.Data = ipfs_secure_bytes + ipfs_shared_bytes PrivKey = base64.b64encode(pkey.SerializeToString()).decode('ascii') -print('PrivKEY={}'.format(base64.b64encode(pkey.SerializeToString()).decode('ascii'))) +print('PrivKEY=' + base64.b64encode(pkey.SerializeToString()).decode('ascii')) # jq '.Identity.PeerID="$PeerID"' ~/.ipfs/config # jq '.Identity.PrivKey="$PrivKey"' ~/.ipfs/config From 5c65c8fb55a92928db09d9887acb296bc65d2b49 Mon Sep 17 00:00:00 2001 From: poka Date: Tue, 8 Dec 2020 18:01:42 +0100 Subject: [PATCH 2/3] Add tool to convert ipfs ID to pubkey --- zen/tools/ipfs_to_g1.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 zen/tools/ipfs_to_g1.py diff --git a/zen/tools/ipfs_to_g1.py b/zen/tools/ipfs_to_g1.py new file mode 100755 index 0000000..f34b750 --- /dev/null +++ b/zen/tools/ipfs_to_g1.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +import sys, base58 + +ID = sys.argv[1] +hexFmt = base58.b58decode(ID) +noTag = hexFmt[6:] +b58Key = base58.b58encode(noTag).decode() + +print(b58Key) From 913ae5a16d5c3d01f3e4caadd81090f1da695b16 Mon Sep 17 00:00:00 2001 From: poka Date: Tue, 8 Dec 2020 18:36:48 +0100 Subject: [PATCH 3/3] remove zen/tools/__pycache__/ -> .gitignore --- .gitignore | 1 + zen/tools/__pycache__/crypto_pb2.cpython-36.pyc | Bin 3040 -> 0 bytes 2 files changed, 1 insertion(+) delete mode 100644 zen/tools/__pycache__/crypto_pb2.cpython-36.pyc diff --git a/.gitignore b/.gitignore index 7cb3b64..c31e826 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ www/LOVELand/jukebox/prefs www/LOVELand/jukebox/albumart www/LOVELand/g1barre/img/qrcodes zen/tools/scraping/transiscope/transiscope.json +zen/tools/__pycache__ diff --git a/zen/tools/__pycache__/crypto_pb2.cpython-36.pyc b/zen/tools/__pycache__/crypto_pb2.cpython-36.pyc deleted file mode 100644 index ba72c329458995fb1ecdc5beef84a296f951dffa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3040 zcmbtWNpIUm6eg*iS}og(oOqF!EOKlqcIp&CgP@7+6hYcVu-&wo3qff{3T28UhIC>J zxv8fDz7_osz4dPtD9}5vy;QfJ3l!*kLv2o7piMR4<2P^KI`7R;chhP0=Wl<~ew&u0 zU!{p(5%8z*xIZeAL?tSl5|NnHmZ>x+QRP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