From a719820ccb71767a69f3dfe7c4d2a2f7501d0513 Mon Sep 17 00:00:00 2001 From: qo-op Date: Wed, 11 Nov 2020 18:54:49 +0100 Subject: [PATCH] create_ipfsnodeid_from_tmp_secret.dunikey.py --- .../__pycache__/crypto_pb2.cpython-36.pyc | Bin 0 -> 2974 bytes ...ate_ipfsnodeid_from_tmp_secret.dunikey.py} | 22 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 zen/tools/__pycache__/crypto_pb2.cpython-36.pyc rename zen/tools/{key_create_dunikey_and_ipfs.py => create_ipfsnodeid_from_tmp_secret.dunikey.py} (81%) diff --git a/zen/tools/__pycache__/crypto_pb2.cpython-36.pyc b/zen/tools/__pycache__/crypto_pb2.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b86094b061253dbb476d60b73b356afb2893c8a3 GIT binary patch literal 2974 zcmbtWNpIUm6eg*SqP2U8oJDqQC$XGZs+~A!&>(1HJ4KK-HEcI+=0cE~kwTdwi6NC( zLT>KWx1y(Bd+2{D&^v*ideWsopg@7XH?$U~F3_eL@Xa@G-a7MUMt8GW?dM;A)E~`A z(r?nlZyxZc@cBO|l0+pc+Y*tO)Rw6g(k2k3P>gGSSL>6GHRsk zL?=m70;_;kk`_1(SR+#cYk)H(D@!cf&Yegk&rA=^?~5;mAwrdfg3=xuuEv_LAt`#PAh3sBt}+2rpi`FGV3Fmg^|pfkXb_+%wE4u&m&uFl^;RoFHTprZ>%&7;i zYy0&E?|Ff%d*)`%>xJq=+vu3oc$7dF@JT!g;_jTTr8 zHO`tgYXp|-z$owcI;Lyu)CdgI@L4|-rBw5{8@T=SaAcCC;B5BqkhPW-yzZK{hTEyz zmg#MJ^_IIHq4kE#+1awxJ+uF(cFtgFY;frlExp$@ZL9H|^-7Cc{16f-%ZtitZnIPy z`K`e$&Xh7*d;tsd9%!kd*_0OBKX_b_N>f^Dmu_xtZ9FK* zrL2}dU=43`>;BP3K`EuR#P0SEh{c}#r}V3dFzy%~7N($rj$r-6q~CJ_<2Wq&j9Z3n z^%>P&4>!Xn*$JL!hQkp1#lI~^h%r|aJO||vCM<`t<1h(DU^32&$ctk&gu{deSoYyK zqX8CS7^O7$9`N87Ak}naFWv0gwl2a}o0iQ4iX#e>Zw$N3{4n2eAq&f~oR+A&$Z26B zem^jH5auR0%%S0U!~4_Yq()T`iW=ybFPN%f4Gb{ffePelwIG7!6&P@Ms3bm%WDW>X z8=fb^3KOZ}y=Y}M6c0MAt^yonGB{Z0^e4QN!%<*BL;6WNf z-EX*X+Hl4BB9Ks2=*974?G7>^G)SYQG`NEJC6IHeEC55;5}w0k(_%LDLv7^KCmDzN z0hA4Hu}`#7tiA|@WQW00!?YPMfI(6isq5TuTA-G69p*NDzKs4>fP@q0sXsHZ1EW*c zpTCGJHs&9uM9$xU@xgb(L!^(lWmO5ao!x`&{bzfJU+#yRu6JD8wVAG0?}RbG=ZBd$ zjN@|ameX{JqMM}La^05AqMOO=Hfxp>Fzy&O#}y^{_og{suw)AMeRvP@Dded7*C_~-r*Is0#+E-u#oR6&!7-Cem)Vx>$lG=1-@C!ast z26vF;-u|HBx zl`C>)*kWoTE-RuXs?o}nyQ58+mKt{CqNL!BdRiPc1qh5s`?P&`9 aKq9gbA@%?0#xNT#YDx~G)?(VQkNpLN=pXn1 literal 0 HcmV?d00001 diff --git a/zen/tools/key_create_dunikey_and_ipfs.py b/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py similarity index 81% rename from zen/tools/key_create_dunikey_and_ipfs.py rename to zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py index 558cdd3..4c20343 100644 --- a/zen/tools/key_create_dunikey_and_ipfs.py +++ b/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py @@ -1,14 +1,13 @@ #!/usr/bin/env python3 -# This Python script gets Duniter creddentials as arguments, and writes a PubSec file that should be compatible with Cesium and Silkaj(DuniterPy) clients. -# It also create ipfs Identity +# This Python script gets /tmp/secret.dunikey produce with key_create_dunikey.py or from https://Cesium.app +# It create ED25519 ipfs (currently 0.7.0) Identity ######################################################################### # sudo apt install protobuf-compiler # pip3 install base58 google protobuf duniterpy # wget https://github.com/libp2p/go-libp2p-core/raw/master/crypto/pb/crypto.proto # protoc --python_out=. crypto.proto ######################################################################### -# launch with : -# python3 key_create_dnuikey_and_ipfs.py + import os import base58 import base64 @@ -16,16 +15,8 @@ import cryptography.hazmat.primitives.asymmetric.ed25519 as ed25519 from cryptography.hazmat.primitives import serialization import crypto_pb2 from sys import argv -from duniterpy.key import SigningKey -# path to save to -path = "/tmp/secret.dunikey" - -key = SigningKey.from_credentials(argv[1], argv[2], None) -key.save_pubsec_file(path) -print( - key.pubkey, -) +# 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() @@ -45,6 +36,7 @@ ipfs_secure_bytes = ipfs_secure.private_bytes(encoding=serialization.Encoding.Ra # Formulating PeerID ipfs_pid = base58.b58encode(b'\x00$\x08\x01\x12 ' + ipfs_shared_bytes) +PeerID = ipfs_pid.decode('ascii') print('Peer ID: {}'.format(ipfs_pid.decode('ascii'))) @@ -52,4 +44,8 @@ print('Peer ID: {}'.format(ipfs_pid.decode('ascii'))) pkey = crypto_pb2.PrivateKey() pkey.Type = crypto_pb2.KeyType.Ed25519 pkey.Data = ipfs_secure_bytes + ipfs_shared_bytes +PrivKey = base64.b64encode(pkey.SerializeToString()).decode('ascii') print('Private key: {}'.format(base64.b64encode(pkey.SerializeToString()).decode('ascii'))) + +# jq '.Identity.PeerID="$PeerID"' ~/.ipfs/config +# jq '.Identity.PrivKey="$PeerID"' ~/.ipfs/config