From fe1a6a28fe8ebf05b1c2fa3d03415f84eaf54510 Mon Sep 17 00:00:00 2001 From: qo-op Date: Fri, 20 Mar 2020 04:06:36 +0100 Subject: [PATCH] rewriting --- command_received.sh | 2 +- iptubes | 2 +- zen/diceware.sh | 17 -- zen/functions.sh | 12 +- zen/ipfs_PUBLISH.sh | 31 ---- zen/ipfs_TASK.sh | 38 ---- zen/{ => tools}/diceware-wordlist.txt | 0 zen/tools/diceware.sh | 33 ++++ zen/{ => tools}/duniter_getnode.sh | 22 +-- zen/{ => tools}/dunitey2secret.sh | 0 zen/{ => tools}/natools.py | 0 zen/{ => tools}/secret2dunikey.sh | 18 +- zen/{ => tools}/timeout.sh | 0 zen/zen_G1TXtoZenTag.sh | 7 +- zen/zen_MAKE.sh | 257 +++++++++++++------------- 15 files changed, 200 insertions(+), 239 deletions(-) delete mode 100755 zen/diceware.sh mode change 100644 => 100755 zen/functions.sh delete mode 100755 zen/ipfs_PUBLISH.sh delete mode 100755 zen/ipfs_TASK.sh rename zen/{ => tools}/diceware-wordlist.txt (100%) create mode 100755 zen/tools/diceware.sh rename zen/{ => tools}/duniter_getnode.sh (79%) rename zen/{ => tools}/dunitey2secret.sh (100%) rename zen/{ => tools}/natools.py (100%) rename zen/{ => tools}/secret2dunikey.sh (65%) rename zen/{ => tools}/timeout.sh (100%) diff --git a/command_received.sh b/command_received.sh index b560e61..09fcb66 100755 --- a/command_received.sh +++ b/command_received.sh @@ -2,7 +2,7 @@ ######################################################################## # Author: Fred (support@qo-op.com) # Version: 0.3 -# License: GPL (http://www.google.com/search?q=GPL) +# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## # ASTROPORT COMMAND RECEIVER & DISPACHER # Rise Up by unid@chan && Run corresponding command.sh diff --git a/iptubes b/iptubes index 028b6e1..2d1a73c 160000 --- a/iptubes +++ b/iptubes @@ -1 +1 @@ -Subproject commit 028b6e139da0ce455415622c2595540690e4ce9a +Subproject commit 2d1a73c225ef577d6716adaf56e7f714c702198e diff --git a/zen/diceware.sh b/zen/diceware.sh deleted file mode 100755 index 91d74c7..0000000 --- a/zen/diceware.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -MOTS=$(echo "$1" | grep -E "^\-?[0-9]+$") -# Default to 6 words passphrase -if [[ "$MOTS" == "" ]]; then MOTS=6; fi -WORDCOUNT=${1-$MOTS} -# Download the wordlist -# wget -nc -O ~/.diceware-wordlist http://world.std.com/%7Ereinhold/diceware.wordlist.asc 2> /dev/null -# print a list of the diceware words -cat ./diceware-wordlist.txt | -awk '/[1-6][1-6][1-6][1-6][1-6]/{ print $2 }' | -# randomize the list order -shuf --random-source=/dev/urandom | -# pick the first n words -head -n ${WORDCOUNT} | -# pretty print -tr '\n' ' ' -echo diff --git a/zen/functions.sh b/zen/functions.sh old mode 100644 new mode 100755 index 72b4517..82e1b1a --- a/zen/functions.sh +++ b/zen/functions.sh @@ -1,11 +1,19 @@ #!/bin/bash ######################################################################## # Author: Fred (support@qo-op.com) -# Version: 0.3 -# License: GPL (http://www.google.com/search?q=GPL) +# Version: 2020.03.18 +# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +######################################################################## +# \\/// +# qo-op +############# +########################## +####################################### +#################################################### +######################################################################## ######################################################################## # check /tmp/cmd_received_$SOURCEH and /tmp/cmd_SPAM_$SOURCEH within 1mn diff --git a/zen/ipfs_PUBLISH.sh b/zen/ipfs_PUBLISH.sh deleted file mode 100755 index df6141d..0000000 --- a/zen/ipfs_PUBLISH.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -################################################################################ -# Author: Fred (support@qo-op.com) -# Version: 1.0 -# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) -########################################################################################### -# ipfs_TASK.sh SYNC SWARM PEERS AND RUN TASKS -me=`basename "$0"` -IPFSNODEID=$(ipfs id -f='\n') - -######################################################################## -### IPFS ADD ~/.zen/wallets -IWALLETS=$(ipfs add -rHq '~/.zen/wallets' | tail -n 1) - -# CHAIN STATE FOR $IPFSNODEID -if [[ -f ~/.zen/wallets/.$IPFSNODEID.chain ]]; then - cat ~/.zen/wallets/.$IPFSNODEID.chain > ~/.zen/wallets/.$IPFSNODEID.chain.prev - INC=$(cat ~/.zen/wallets/.$IPFSNODEID.n) - ((INC++)) - echo $INC > ~/.zen/wallets/.$IPFSNODEID.n -else - echo "" > ~/.zen/wallets/.$IPFSNODEID.chain.prev - echo "0" > ~/.zen/wallets/.$IPFSNODEID.n -fi -### IPFS ADD ~/.zen/wallets -echo $IWALLETS > ~/.zen/wallets/.$IPFSNODEID.chain - -IWALLETS=$(ipfs add -rHq '~/.zen/wallets' | tail -n 1) -# PUBLISH IPNS NODE WALLETS -NODEWALLETS=$(ipfs name publish --quieter /ipfs/$IWALLETS) -echo $IWALLETS diff --git a/zen/ipfs_TASK.sh b/zen/ipfs_TASK.sh deleted file mode 100755 index a772538..0000000 --- a/zen/ipfs_TASK.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -################################################################################ -# Author: Fred (support@qo-op.com) -# Version: 1.0 -# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) -########################################################################################### -# ipfs_TASK.sh SYNC SWARM PEERS AND RUN TASKS -IPFSNODEID=$(ipfs id -f='\n') - -######################################################################## -### SYNC IPFS SWARM PEERS -count=0 -for id in $(ipfs swarm peers | awk -F '/' '{print $7}'); -do - count=$((count+1)) - id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1) - echo "REFRESH ~/.zen/wallets_swarm/.$id ..." - rm -Rf ~/.zen/wallets_swarm/.$id - ./timeout.sh -t 10 ipfs get --output=~/.zen/wallets_swarm/ /ipns/$id > /dev/null 2>&1 -done -echo "~/.zen/wallets_swarm/ RENEW from $count peers .........FINISH!!!" - -######################################################################## -# MAKE LOCAL ~/.zen/wallets/.$IPFSNODEID/TASK/ directory -[[ ! -d ~/.zen/wallets/.$IPFSNODEID/TASK/ ]] && mkdir -p ~/.zen/wallets/.$IPFSNODEID/TASK/ -### SEARCH FOR RECEIVED TASK .todo FROM SWARM -for todo in $(ls ~/.zen/wallets_swarm/.$IPFSNODEID/TASK/*.todo 2>/dev/null); -do - - TODO=$(cat $todo) - CMD=$(echo $TODO | cut -d ':' -f 1) - SUB=$(echo $TODO | cut -d ':' -f 2) - ACTION=$(echo $TODO | cut -d ':' -f 3) - - -done - -# ./ipfs_PUBLISH.sh diff --git a/zen/diceware-wordlist.txt b/zen/tools/diceware-wordlist.txt similarity index 100% rename from zen/diceware-wordlist.txt rename to zen/tools/diceware-wordlist.txt diff --git a/zen/tools/diceware.sh b/zen/tools/diceware.sh new file mode 100755 index 0000000..f28320e --- /dev/null +++ b/zen/tools/diceware.sh @@ -0,0 +1,33 @@ +#!/bin/bash +######################################################################## +# Author: Fred (support@qo-op.com) +# Version: 2020.03.18 +# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) +######################################################################## +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +######################################################################## +# \\/// +# qo-op +############# +########################## +####################################### +#################################################### +######################################################################## + +MOTS=$(echo "$1" | grep -E "^\-?[0-9]+$") +# Default is 6 words passphrase +if [[ "$MOTS" == "" ]]; then MOTS=6; fi +WORDCOUNT=${1-$MOTS} +# Download the wordlist +# wget -nc -O ~/.diceware-wordlist http://world.std.com/%7Ereinhold/diceware.wordlist.asc 2> /dev/null +# print a list of the diceware words +cat $MY_PATH/diceware-wordlist.txt | +awk '/[1-6][1-6][1-6][1-6][1-6]/{ print $2 }' | +# randomize the list order +shuf --random-source=/dev/urandom | +# pick the first n words +head -n ${WORDCOUNT} | +# pretty print +tr '\n' ' ' +echo diff --git a/zen/duniter_getnode.sh b/zen/tools/duniter_getnode.sh similarity index 79% rename from zen/duniter_getnode.sh rename to zen/tools/duniter_getnode.sh index 29ff6f9..34fc78e 100755 --- a/zen/duniter_getnode.sh +++ b/zen/tools/duniter_getnode.sh @@ -5,7 +5,7 @@ # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ -# Checks the current block number of /tmp/zen/duniter_nodes.txt (is run in parallel) +# Checks the current block number of $DIR/duniter_nodes.txt (is run in parallel) # and output random (from last synchronized) node checkonenode() @@ -55,18 +55,18 @@ DIR=/tmp/zen/gnodewatch export DIR mkdir -p $DIR/chains -### /tmp/zen/duniter_nodes.txt REFRESH -find /tmp/zen/ -cmin +20 -type f -name "duniter_*" -exec rm -f '{}' \; -if [[ ! -f /tmp/zen/duniter_nodes.txt ]]; then - [[ -f /tmp/zen/good.nodes.txt ]] && DUNITER=$(shuf -n 1 /tmp/zen/good.nodes.txt) || DUNITER="g1.duniter.org:443" - # echo "___ REFRESH /tmp/zen/duniter_nodes.txt from $DUNITER ___" - curl -s https://$DUNITER/network/peers | jq '.peers[] | .endpoints' | grep BMAS | awk '{print $2,$3}' | sed s/\"//g | sed s/\,//g | sed s/\ /:/g > /tmp/zen/duniter_nodes.txt +##### $DIR/duniter_nodes.txt REFRESH after 20 minutes ##### +find $DIR/ -cmin +20 -type f -name "duniter_*" -exec rm -f '{}' \; +if [[ ! -f $DIR/duniter_nodes.txt ]]; then + # Get New BMAS known Nodes list from shuffle one $DIR/good.nodes.txt + [[ -f $DIR/good.nodes.txt ]] && DUNITER=$(shuf -n 1 $DIR/good.nodes.txt) || DUNITER="duniter-g1.p2p.legal:443" + curl -s https://$DUNITER/network/peers | jq '.peers[] | .endpoints' | grep BMAS | awk '{print $2,$3}' | sed s/\"//g | sed s/\,//g | sed s/\ /:/g > $DIR/duniter_nodes.txt fi # Grab the nodes we are actively watching - they will be in bold in the final output -watched=`grep -v "#" /tmp/zen/duniter_nodes.txt|egrep "\!$"|awk '{print "#" $1 "#"}'` +watched=`grep -v "#" $DIR/duniter_nodes.txt|egrep "\!$"|awk '{print "#" $1 "#"}'` # All nodes we are watching -nodes=`grep -v "#" /tmp/zen/duniter_nodes.txt|awk '{print $1}'` +nodes=`grep -v "#" $DIR/duniter_nodes.txt|awk '{print $1}'` # The index to generate separate file names index=0 # Wipe out the output directory @@ -101,6 +101,6 @@ do done longchain=$(ls -S $DIR/chains/ | head -n 1) -cp $DIR/chains/$longchain /tmp/zen/good.nodes.txt +cp $DIR/chains/$longchain $DIR/good.nodes.txt # WRITE OUT shuffle Duniter Node Sync with longest chain -echo $(shuf -n 1 /tmp/zen/good.nodes.txt) +echo $(shuf -n 1 $DIR/good.nodes.txt) diff --git a/zen/dunitey2secret.sh b/zen/tools/dunitey2secret.sh similarity index 100% rename from zen/dunitey2secret.sh rename to zen/tools/dunitey2secret.sh diff --git a/zen/natools.py b/zen/tools/natools.py similarity index 100% rename from zen/natools.py rename to zen/tools/natools.py diff --git a/zen/secret2dunikey.sh b/zen/tools/secret2dunikey.sh similarity index 65% rename from zen/secret2dunikey.sh rename to zen/tools/secret2dunikey.sh index 1c26b1c..2fb7a49 100755 --- a/zen/secret2dunikey.sh +++ b/zen/tools/secret2dunikey.sh @@ -4,11 +4,15 @@ # Version: 1.0 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## -# This script creates ~/.ssb/secret.dunikey from your scuttlebutt secret -# You can use it https://cesium.app / https://silkaj.duniter.org/ -# Python API https://pypi.org/project/duniterpy/ +# This script creates ~/.ssb/secret.dunikey from SSB secret ######################################################################## -[[ ! -f ~/.ssb/secret ]] && echo "Your SSB secret is missing... EXIT" && exit 1 +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +######################################################################## +# \\/// +# qo-op +############# +[[ ! -f ~/.ssb/secret ]] && echo "ERROR Your SSB secret is missing... EXIT" && exit 1 rm -f ~/.ssb/secret.dunikey ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g) ssbpriv=$(cat ~/.ssb/secret | grep private\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g) @@ -20,8 +24,4 @@ Version: 1 pub: $g1pub sec: $g1priv EOF -echo "Your G1 Wallet PubKey is : -$g1pub - -Your KEY is located in ~/.ssb/secret.dunikey -Use it with https://cesium.app " +echo "$g1pub" diff --git a/zen/timeout.sh b/zen/tools/timeout.sh similarity index 100% rename from zen/timeout.sh rename to zen/tools/timeout.sh diff --git a/zen/zen_G1TXtoZenTag.sh b/zen/zen_G1TXtoZenTag.sh index 18c1292..5d40013 100755 --- a/zen/zen_G1TXtoZenTag.sh +++ b/zen/zen_G1TXtoZenTag.sh @@ -19,7 +19,12 @@ #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # [ASTROPORT](https://astroport.com) ######################################################################## -me=`basename "$0"` +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +######################################################################## +# \\/// +# qo-op +############# if [[ ! $(which silkaj) ]]; then echo "$USER please Install SILKAJ !!" && exit 1 diff --git a/zen/zen_MAKE.sh b/zen/zen_MAKE.sh index 5de94cd..cab2ceb 100755 --- a/zen/zen_MAKE.sh +++ b/zen/zen_MAKE.sh @@ -1,137 +1,138 @@ #!/bin/bash -########################################################################################### -# Script appelé depuis zen_G1TXIN pour créer des QRCode IPNS + Clef associé à un ZenTag -# rempli des centimes de June reçues.# -########################################################################################### -########################################################################################### -# ZenTag Draft Format -# fred@ONELOVE:~/workspace/ZEN$ ipfs ls /ipns/QmZxwgScLyLjitE1mrUFqpTw27gk6tMdfKQ7QTEo28dE2u -# QmVkur97Pqpgt7cy71FCNacPd5Z1eD9QVfw5tu4LdXHavk 47 _chain -# QmUQcSjQx2bg4cSe2rUZyQi6F8QtJFJb74fWL7D784UWf9 2 _chain.n -# QmRPdapkSVeYeRcC6X7freVo8vrGYjKcGsa96V5GsMg36p 20 _chain.nanodate -# Qmc5m94Gu7z62RC8waSKkZUrCCBJPyHbkpmGzEePxy2oXJ 1 _chain.prev -# Qmb8gYFmno4QeEpaPTi969qQNyVJK9VyfBbsXtyMA3PMow 45 _g1.creator -# QmQo6ghBGdkGCnGoB22cYmraR76q44K1mjVXqQQ3UVn2T1 45 _g1.issuer -# QmfUFk27ZvHaGfEwBeqResw2qQ9SCu4tsY69SkVuCdWAxB 65 _g1.txhash -# QmaKa7FGwmMshE7RACrWAFCsWETu1HcHnV1eak7HcUk6Cs 47 _ipfs.creator -# QmfCL14hnVnm3mrYT7fRjveMRTEoSp2axqCVp3JYoxXXgn 1300 _ipfs.publishkey.B.gpg -# QmUQ7WsACNYYWAw4QW8hKTCq8MM8oYGV7HJuxW7QTGj9qS 1243 _ipfs.publishkey.crypt -# QmdvRknZWSZUyS9SfmFWcvySv1tgi2PTF711rsGPN6ftL1 65 _tag.B.sha -# QmXA1zSxA3dh1dxFtkKaH5iomN3BsKMSAo2qhruA58AU81 34 _tag.uid -# QmPrumas2N5DuwcqUz9mayAU6oDL2bLjhpkVZ8hCRq9rpx 5 _tag.zen -########################################################################################### -# Symetric Encrypt and Decrypt -# openssl aes-256-cbc -k "$BB" -salt -in file -out file.aes -# openssl aes-256-cbc -k "$BB" -d -salt -in file.aes -out file -# tar zip and encrypt a whole directory +######################################################################## +# Author: Fred (support@qo-op.com) +# Version: 2020.03.18 +# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) +######################################################################## +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +######################################################################## +# \\/// +# qo-op +############# +########################## +######################################################################## +# ./zen_MAKE.sh $ZEN $TXHASH +# Create ~/.zen/tag/... & IPNS key publish +######################################################################## +######################################################################## +# ZenTag is an IPFS/IPNS datastructure put into IPFS, publish +# ~~~ Draft ~~~~ +# _chain # ZenTag IPFS Hash +# _chain.n # Sequence Number +# _chain.nanodate # Current nanodate +# _chain.prev # Previous IPFS Hash +# _g1.node.creator # G1SSB wallet pubkey +# _g1.issuer # G1TX ISSUER pubkey +# _g1.txhash # G1TX HASH +# _ipfs.node.creator # NODE IPFS ID +# _ipfs.publishkey.B.gpg # B cyphered IPNS publish key +# _ipfs.publishkey.crypt # G1SSB cyphered IPNS publish key +# _tag.B.sha # B sha256sum +# _tag.uid # ZenTag UID +# _tag.zen # ZentTag balance +# TODO: Could be converted into yaml or json if you like +######################################################################## +######################################################################## +# Clean IPFS repo # ipfs pin ls -q --type recursive | xargs ipfs pin rm +######################################################################## +ZEN="$1" # Zen amount +TXHASH="$2" # G1 TX HASH +PASSENGER="$3" # /path/file.ext to include into ZenTag (add to IPFS datastructure) + +# G1TX HASH CONTROL +[[ ! -f ~/.zen/scan/zen.$TXHASH ]] && echo "ERROR# UNKNOWN TX $TXHASH !!" && exit 1 +# G1TX ISSUER CONTROL +ISSUER=$(cat ~/.zen/scan/zen.$TXHASH) +[[ $ISSUER == "" ]] && echo "ERROR# NO ISSUER FOUND FOR TX $TXHASH !!" && exit 1 + +# IPFSNODEID +######################################################################## +IPFSNODEID=$(ipfs id -f='\n') +######################################################################## + +# ~/.ssb/secret.dunikey => NODE_G1PUBKEY +######################################################################## +[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh +NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) +######################################################################## + +# CREATE ZEN TAG : name AA + key BB +######################################################################## +AA=$($MY_PATH/tools/diceware.sh 6 | xargs); # ZenTag Name = Diceware 6 words +AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1) # ZenTag Name SHA256 + +RR=$(echo ${AA} | sed s/\ //g ); # Name without space = IPNS key name + +# TODO CHECK UNIQUE AA +# Create Unique Zentag in all IPFS SWARM! +# $(grep -Rwl "$AAH" ./wallets_swarm/.*/_zentag.list) +# AA=$(./diceware.sh 6 | xargs); +# AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1) +# RR=$(echo ${AA} | sed s/\ //g ); +# PR=$(echo ${AA} | cut -d ' ' -f 1 ); +#done + +# PASSWORD FOR HUMAN ACTION +BB=$($MY_PATH/tools/diceware.sh 4 | xargs); +BBH=$(echo -n "$BB" | sha256sum | cut -d ' ' -f 1) +################################################################################## +# CREATE ZENTAG FILES DATA STRUCTURE +mkdir -p ~/.zen/tag/${AAH} +echo "CREATING ZenTag, Value = $ZEN Zen (ls -al ~/.zen/tag/${AAH})" +echo "Name: $AA | Key: $BB" + +# ZenTag Create files +echo "$AA" > ~/.zen/tag/${AAH}/_tag.uid # Nom du ZenTAG +echo "$ZEN" > ~/.zen/tag/${AAH}/_tag.zen # Tag ZEN amount +echo "${IPFSNODEID}" > ~/.zen/tag/${AAH}/_ipfs.node.creator # NODE IPFS ID +echo "$TXHASH" > ~/.zen/tag/${AAH}/_g1.txhash # HASH G1 TX/IN +echo "$NODE_G1PUBKEY" > ~/.zen/tag/${AAH}/_g1.node.creator # CREATOR IPFS NODE G1PUBKEY +echo "$ISSUER" > ~/.zen/tag/${AAH}/_g1.issuer # TX ISSUER G1PUBKEY + +#################################################### +# ${RR} IPNS publishkey CYPHER *BB & **NODE_G1PUBKEY +[[ ! -f ~/.ipfs/keystore/${RR} ]] && J=$(ipfs key gen -t rsa -s 2048 ${RR}) +# WRITE BBH for QRCode BB verification +echo "$BBH" > ~/.zen/tag/${AAH}/_tag.B.sha +# BB pgp symetric publishkey +echo "${BB}" | gpg -q --output ~/.zen/tag/${AAH}/_ipfs.publishkey.B.gpg --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 ~/.ipfs/keystore/${RR} +# GIVE IPFS CREATOR NODE ACCESS TO ZEN TAG +$MY_PATH/tools/natools.py encrypt -p $NODE_G1PUBKEY -i ~/.ipfs/keystore/${RR} -o ~/.zen/tag/${AAH}/_ipfs.publishkey.crypt +####################################################################### +# TODO Symetric Encrypt and Decrypt with openssl +# openssl aes-256-cbc -k "$BB" -salt -in file -out file.aes # Encrypt +# openssl aes-256-cbc -k "$BB" -d -salt -in file.aes -out file # Decrypt +# tar zip and encrypt a whole directory # # tar -zcf - directory | openssl aes-128-cbc -salt -out directory.tar.gz.aes # Encrypt # openssl aes-128-cbc -d -salt -in directory.tar.gz.aes | tar -xz -f - # Decrypt -########################################################################################### -# To clean your IPFS repo: -# ipfs pin ls -q --type recursive | xargs ipfs pin rm -########################################################################################### -me=`basename "$0"` # Script name -ZEN="$1" # Initial Zen amount -TXhash="$2" # Contains G1 TX HASH -File="$3" # Contains G1 TX HASH +####################################################################### +[[ -f $PASSENGER ]] && openssl aes-256-cbc -k "$BB" -salt -in $PASSENGER -out ~/.zen/tag/${AAH}/passenger.aes +[[ -d $PASSENGER ]] && tar -zcf - $PASSENGER | openssl aes-128-cbc -k "$BB" -salt -out ~/.zen/tag/${AAH}/passenger.tar.gz.aes -[[ ! -f ~/.zen/scan/zen.$TXhash ]] && echo "ERROR Unknown TX... EXIT" && exit 1 -ISSUER=$(cat ~/.zen/scan/zen.$TXhash) # Get G1 wallet issuer pubkey -[[ $ISSUER == "" ]] && echo "# NO SCANNED TX.... PLEASE USE ./zen_G1TXtoZenTag.sh" && exit 1 +########################################################### +# TAG IPFS STORAGE & G1Tag IPNS PUBLISHING +########################################################### +NANODATE=$(date -u +%s%N) +echo "0" > ~/.zen/tag/${AAH}/_chain.n # Tag modification number (0 first) +echo "$NANODATE" > ~/.zen/tag/${AAH}/_chain.nanodate # Nanodate notification -######################################################################################################### -IPFSNODEID=$(ipfs id -f='\n') -######################################################################################################### - -######################################################################################################### -if [[ -f ~/.ssb/secret.dunikey ]]; then - NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) -else - echo "MISSING your G1 KEY ~/.ssb/secret.dunikey ... Please run ./secret2dunikey.sh ... Ciao" - exit 1 -fi -######################################################################################################### - -######################################################################################################### -# CREATE ZEN TAG - # ZenTag NAMES - AA=$(./diceware.sh 6 | xargs); # ZenTag Name = Diceware 6 words - SHAA=$(echo -n $AA | sha256sum | cut -d ' ' -f 1) # ZenTag Name SHA256 - RR=$(echo ${AA} | sed s/\ //g ); # Name without space - PR=$(echo ${AA} | cut -d ' ' -f 1 ); # ZenTag short name - - # Create Unique Zentag in all IPFS SWARM! TODO CHANGE METHOD - while [[ -f ~/.zen/tag/${SHAA} ]]; do - AA=$(./diceware.sh 6 | xargs); - SHAA=$(echo -n $AA | sha256sum | cut -d ' ' -f 1) - RR=$(echo ${AA} | sed s/\ //g ); - PR=$(echo ${AA} | cut -d ' ' -f 1 ); - done +# Activate ZenTag CHAIN +I=$(ipfs add -qr ~/.zen/tag/${AAH} | tail -n 1) +echo "${I}" > ~/.zen/tag/${AAH}/_chain +cp -f ~/.zen/tag/${AAH}/_chain ~/.zen/tag/${AAH}/_chain.prev - # PASSWORD FOR HUMAN ACTION - BB=$(./diceware.sh 4 | xargs); - SHABB=$(echo -n "$BB" | sha256sum | cut -d ' ' -f 1) - ################################################################################## - # CREATE ZENTAG FILES DATA STRUCTURE (TODO: Convert into yaml or json if you like) - mkdir -p ~/.zen/tag/${SHAA} - echo "CREATING ZenTag, Value = $ZEN Zen (ls -al ~/.zen/tag/${SHAA})" - echo "Name: $AA | Key: $BB" - # ZenTag Create files - echo "$AA" > ~/.zen/tag/${SHAA}/_tag.uid # Nom du ZenTAG - echo "$ZEN" > ~/.zen/tag/${SHAA}/_tag.zen # Tag ZEN amount - echo "${IPFSNODEID}" > ~/.zen/tag/${SHAA}/_ipfs.node.creator # NODE IPFS ID - echo "$TXhash" > ~/.zen/tag/${SHAA}/_g1.txhash # HASH G1 TX/IN - echo "$NODE_G1PUBKEY" > ~/.zen/tag/${SHAA}/_g1.node.creator # CREATOR IPFS NODE G1PUBKEY - echo "$ISSUER" > ~/.zen/tag/${SHAA}/_g1.issuer # TX ISSUER G1PUBKEY - - #################################################### - # ${RR} IPNS publishkey CYPHER *BB & **NODE_G1PUBKEY - [[ ! -f ~/.ipfs/keystore/_${RR} ]] && J=$(ipfs key gen -t rsa -s 2048 _${RR}) - # WRITE SHABB for QRCode BB verification - echo "$SHABB" > ~/.zen/tag/${SHAA}/_tag.B.sha - # BB pgp symetric publishkey - echo "${BB}" | gpg -q --output ~/.zen/tag/${SHAA}/_ipfs.publishkey.B.gpg --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 ~/.ipfs/keystore/_${RR} - # GIVE IPFS CREATOR NODE ACCESS TO ZEN TAG - ./natools.py encrypt -p $NODE_G1PUBKEY -i ~/.ipfs/keystore/_${RR} -o ~/.zen/tag/${SHAA}/_ipfs.publishkey.crypt +# IPFS Hash for Immutable G1tag data +J=$(ipfs name publish -k ${RR} --quieter /ipfs/${I}) +echo "${J}" > ~/.zen/tag/${AAH}/_ipns - ########################################################### - # TAG IPFS STORAGE & G1Tag IPNS PUBLISHING - ########################################################### - # TAG CHAIN DATA - echo "0" > ~/.zen/tag/${SHAA}/_chain.n # Tag modification number (0 first) - NANODATE=$(date -u +%s%N) - echo "$NANODATE" > ~/.zen/tag/${SHAA}/_chain.nanodate # Nanodate notification +echo "ZenTag Done check it with :: ipfs ls /ipns/${J}" - echo "" > ~/.zen/tag/${SHAA}/_chain.prev - I=$(ipfs add -qr ~/.zen/tag/${SHAA} | tail -n 1) - # MEMORIZE FOR CHAINING FUTURE CHANGES - echo "${I}" > ~/.zen/tag/${SHAA}/_chain - # Activate chain - I=$(ipfs add -qr ~/.zen/tag/${SHAA} | tail -n 1) - - # IPFS Hash for Immutable G1tag data - J=$(ipfs name publish -k _${RR} --quieter /ipfs/${I}) - echo "${J}" > ~/.zen/tag/${SHAA}/_ipns - -echo "ZENTAG MADE: ipfs ls /ipns/${J}" -ipfs ls /ipns/${J} -#################################################################################### ### G1TAG PRINT TYPE:DATA:IPNS - # QR CODE LECTURE - qrencode -s 5 -o ~/.zen/tag/${SHAA}/.QRCODE.pub.png "RJ:${SHAA}#${J}" - # QR CODE ECRITURE + ISSUER CYPHER (TODO : SHABB ou BB?) - qrencode -s 5 -o ~/.zen/tag/${SHAA}/.QRCODE.priv.png "BJ:${BB}#${J}" - - ############################################################################## - # TODO: PRINT LOCAL OR SEND "PRINT TASK" TO DAB MACHINE $ISSUER PREFERING ... - # DESTNODE=$(grep -Rwl "$ISSUER" ~/.zen/wallets_swarm/*/_pub) - # [[ $DESTNODE != "" ]] && DESNODEIPFSFILE=$(echo $DESTNODE | cut -d '_' -f 1)_ipfsid || exit - # DESTIPFS=$(cat $DESNODEIPFSFILE) - # ./natools.py encrypt -p $DESTIPFS -i ~/.zen/tag/${SHAA}/.QRCODE.priv.png -o ~/.zen/tag/${SHAA}/.QRCODE.crypt.png && rm ~/.zen/tag/${SHAA}/.QRCODE.priv.png - - # CREATE TASK - # mkdir -p ~/.zen/wallets/.$DESTIPFS/TASK/ - # echo "PRINT:ZENTAG:${J}" > ~/.zen/wallets/.$DESTIPFS/TASK/$NANODATE.$IPFSNODEID.todo - # ./ipfs_PUBLISH.sh - -### +#################################################################################### +# READ QRCODE +qrencode -s 5 -o ~/.zen/tag/${AAH}/_QRCODE.read.png "RJ:${AAH}#${J}" +# WRITE QRCODE +qrencode -s 5 -o ~/.zen/tag/${AAH}/_QRCODE.write.png "BJ:${BB}#${J}" + +exit 0