SHA256 PHONE compatibility & SWARMKEY GPG CYPHER

This commit is contained in:
qo-op 2019-12-26 17:44:26 +01:00
parent 9600127295
commit c57cc485fc
9 changed files with 77 additions and 42 deletions

2
_chain
View File

@ -1 +1 @@
QmbVfLJ9UsnyV3Si9UgZVS4srCnL1c2Gqt7XissCV4iC83
QmWEyZDyn7XMM3pDFCBkDqC6XPAraTSLHbVD3h7geunNWy

View File

@ -178,3 +178,6 @@ OK
2019-12-20: NOW
2019-12-21: Various
2019-12-24:
2019-12-26: SWARMKEY
2019-12-26: ipfs p2p listen /x/$YOU /ip4/127.0.0.1/tcp/80
2019-12-26: ./wallets/sha256sum(PHONE)

View File

@ -1 +1 @@
1577203467543924569
1577378596986046001

Binary file not shown.

View File

@ -9,12 +9,16 @@ MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
cd $GPATH
su $YOU -c ipfs p2p close --all
su $YOU -c ipfs p2p listen /x/ssh /ip4/127.0.0.1/tcp/22
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
# UIDNA NODE
[[ -f ./wallets/.$IPFSNODEID/$IPFSNODEID.uidna ]] && UIDNA=$(cat ./wallets/.$IPFSNODEID/$IPFSNODEID.uidna) || UIDNA="ssh"
su $YOU -c "ipfs p2p close --all"
su $YOU -c "ipfs p2p listen /x/$UIDNA /ip4/127.0.0.1/tcp/22"
su $YOU -c "ipfs p2p listen /x/$IPFSNODEID /ip4/127.0.0.1/tcp/80"
echo $(su $YOU -c "ipfs p2p ls")

View File

@ -309,6 +309,11 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
UNKNOWN=0
# TODO Optimize GLOBAL/local variables use, use more function array output ?!
# Initiate PHONE settings files and values
# ALL CHANNEL INTO ./wallets/sha256sum(ID)
HASHLINK=$(echo $PHONE | sha256sum | cut -d ' ' -f 1)
# ALL CHANNEL INTO ./wallets/sha256sum(ID)
IPFSNODEIDFILE="./wallets/$PHONE/MASTERPHONE.ipfsid" # Contains G1sms+ NODE IPFS id
SMSNODE="./wallets/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
PINFILE="./wallets/$PHONE/$PHONE.pin" # Contains phone wallet diceware password
@ -341,7 +346,11 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
#######################
# Create Account Files
#######################
mkdir -p "./wallets/$PHONE/"
[[ ! $GPATH ]] && GPATH="."
[[ -d $GPATH/wallets/$PHONE ]] && mv $GPATH/wallets/$PHONE $GPATH/wallets/$HASHLINK && ln -s $GPATH/wallets/$HASHLINK $GPATH/wallets/$PHONE
[[ ! -d $GPATH/wallets/$HASHLINK ]] && mkdir -p $GPATH/wallets/$HASHLINK && ln -s $GPATH/wallets/$HASHLINK $GPATH/wallets/$PHONE
# LINKS ARE NOT REPLICATED INTO IPFS ;)
PIN=$(./shell/diceware.sh | xargs)
PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$PHONE" -password="$PIN")
@ -377,10 +386,11 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
################
echo "$PIN" > "$PINFILE"
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE"
echo "${SWARMKEY}" | gpg -q --output "$GPGPINFILE.swarm" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE"
PIN=$(cat "$PINFILE" | xargs)
echo "" > "$PINFILE"
echo "114" > "$G1COUNTFILE"
echo "314" > "$G1COUNTFILE"
echo "$PUBKEY" > "$PUBKEYFILE"
echo "$COIN" > "$UNITFILE"
echo "$MASTERPHONE" > "$SMSNODE"
@ -397,39 +407,46 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
######################################################################
if [[ ! -f "$GPGPINFILE" ]]
then
HASH=$(echo $PHONE | sha256sum | cut -d ' ' -f 1)
# ------------8<------------------
# WALLET MIGRATION -> CRYPT PIN (For Old G1sms clear PIN WALLETs...)
# ADD NEW PARAMS TO WALLET
#######################
# 4 derniers chiffres du numéro de téléphone
echo "$MASTERPHONE" > "$SMSNODE"
TAIL=${PHONE:8:4}
# No UIDNA yet. Create new
UIDNA=$(./shell/diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets
while [[ $(grep -Rwl $UIDNA$TAIL ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done
echo "$UIDNA$TAIL" > "$UIDNAFILE"
if [[ ! -s "$UIDNAFILE" ]]; then
# ADD NEW PARAMS TO WALLET
#######################
# 4 derniers chiffres du numéro de téléphone
TAIL=${PHONE:8:4}
# No UIDNA yet. Create new
UIDNA=$(./shell/diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets
while [[ $(grep -Rwl $UIDNA$TAIL ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done
echo "$UIDNA$TAIL" > "$UIDNAFILE"
fi
echo "$MASTERPHONE" > "$SMSNODE"
PIN=$(cat "$PINFILE" | xargs)
log "__SUB:sms_INIT_ACCOUNT: Old G1sms wallet ;) SECURITY HOLE... Chiffrage PGP du PIN !!!"
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE";
echo "${SWARMKEY}" | gpg -q --output "$GPGPINFILE.swarm" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE";
else
# ------------>8------------------
log "__SUB:sms_INIT_ACCOUNT: Déchiffrage PGP PIN..."
# GPG decypher PIN
# TODO make decypher less stress on filesystem, use /tmp and ramdisk
echo "${GPGPASS}" | gpg -d -q --output "$PINFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGPINFILE"
[[ ! -f $PINFILE ]] && echo "${SWARMKEY}" | gpg -d -q --output "$PINFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGPINFILE.swarm"
PIN=$(cat "$PINFILE" | xargs)
echo "" > "$PINFILE";
fi
# CYPHER EMAIL FILE
if [[ ! -f "$GPGMAILFILE" ]]; then
if [[ ! -f "$GPGMAILFILE.swarm" ]]; then
# ------------8<------------------
# NO .gpg file, CREATING it (OLD G1sms accounts)
if [ -f "$MAILFILE" ]; then
MAIL=$(cat "$MAILFILE");
echo "${GPGPASS}" | gpg -q --output "$GPGMAILFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$MAILFILE";
echo "${SWARMKEY}" | gpg -q --output "$GPGMAILFILE.swarm" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$MAILFILE";
else
MAIL="";
fi
@ -437,6 +454,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
else
# Already existing gpg DECODING IT
echo "${GPGPASS}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
[[ -f "$GPGMAILFILE.swarm" ]] && echo "${SWARMKEY}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE.swarm"
MAIL=$(cat "$MAILFILE");
echo "" > "$MAILFILE";
fi

View File

@ -21,6 +21,10 @@ YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/\"//g)
if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS EMPTY"; exit; fi
# GET SWARM KEY G1sms+ .ipfs/swarm.key
export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key" | tail -n 1)
if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi
##################################################################
# G1sms+ Swarm KEYS
##################################################################
@ -31,8 +35,8 @@ if [[ -f "${GPATH}/g1sms.pub.key" && -f "${GPATH}/g1sms.priv.key" ]]; then
export NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.pub.key")
export NODE_G1PRIVKEYFILE="${GPATH}/g1sms.priv.key"
else
echo "ATTENTION!! Vous devez posséder la clef du G1 Wallet utilisé par le SWARM G1sms!!"
./shell/parle.sh "Les clefs du portefeuille essaim G1 SMS sont absente. Au revoir."
echo "ATTENTION!! Vous devez installer une clef de G1 Wallet!!"
./shell/parle.sh "Il manque les Clefs du portefeuille G1 de votre noeud. Au revoir."
echo "Fichiers manquants:"
echo "${GPATH}/g1sms.pub.key"
echo "${GPATH}/g1sms.priv.key"

View File

@ -10,21 +10,21 @@ log "X sms_AIDE.sh ($1=phone)"
sms_INIT_ACCOUNT "$1" "NOSMS"
MESS="[Aide]
N Pseudo (membre ou nom de portefeuille) : Création portefeuille
MESS="N Pseudo : Création Portefeuille rattaché à Pseudo
S : Synchro Solde
P 06nnnnnnnn 300 : Payer 300 à 06nnnnnnnn
U G1/DU/LOVE : Unité
S : Solde
P 06nnnnnnnn 300 : Payer 300 à 06nnnnnnnn"
"
# Send response SMS
sms_SEND "$1" "$MESS"
MESS="EMAIL moi@email : Indiquer son email
VIR 50 Pseudo : Virer 50 à Pseudo (membre ou Portefeuille SMS)"
MESS="EMAIL moi@email : Email pour commande G1Billets
BILL n : Recevoir 6 G1Billets remplis de n LOVE"
sms_SEND "$1" "$MESS"
MESS="REC 50 Dest S 4 : Virer 50 à Dest pendant 4 Semaines (J/S/M/A)
BILL n : Recevoir 6 G1Billets remplis de n LOVE par email!
https://g1sms.fr - $ADMINPSEUDO ($ADMINPHONE)"
MESS="VIR 50 Pseudo : Virer 50 à Pseudo (membre ou Portefeuille SMS)
REC 50 Dest S 4 : Virer 50 à Dest, 4 Semaines (J/S/M/A)
Contact : $ADMINPSEUDO ($ADMINPHONE) - https://g1sms.fr"
sms_SEND "$1" "$MESS"
log "END sms_AIDE.sh"

View File

@ -17,6 +17,8 @@ pin=$PIN
if [[ $UNKNOWN == "unknown" ]]; then
sms_ERROR "$phone" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
exit
else
log "PIN: $pin"
fi
###########################################################
@ -40,8 +42,10 @@ if [[ -f "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub" ]]
then
PUBKEYDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub")
UNITDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.unit")
log "__SUB:sms_PAY.sh: PUBKEYDEST found in swarn... $PUBKEYDEST"
else
# NO, then create NEW Wallet
log "__SUB:sms_PAY.sh: Creating Account for... $PHONEDEST"
sms_INIT_ACCOUNT "$PHONEDEST"
# Refreshed new values
PUBKEYDEST="$PUBKEY"
@ -49,11 +53,13 @@ else
fi
# Payement
PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY $AMOUNT $UNIT" -y)
log "./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST""
PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY $AMOUNT $UNIT" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
new=$(./shell/checknodes.sh "BAN")
sms_ERROR "$phone" "Problème de payement avec silkaj (changement de serveur $new): $PAY";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $PAY"
sms_ERROR "$phone" "PIN : $PAY ? Voyez vous votre code secret: $pin?
NON, Reinitaliser Compte. Envoyer: RAZ
OUI, Bourage Blockchain. Envoyer: S";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj : $PAY"
exit
else
# OK: Sync g1cents TODO check move_g1cents function and generalize on all silkaj transactions
@ -64,11 +70,11 @@ fi
sleep 2
# + G1SMS Commission
COM=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Commission" -y)
if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
new=$(./shell/checknodes.sh "BAN")
sms_ERROR "$phone" "Problème de payement avec silkaj (changement de serveur $new): $COM";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $COM"
log "./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY""
COM=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY" --comment="[G1sms+] P Commission" -y)
if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$COM" == "" ]]; then
sms_ERROR "$phone" "Problème de bourrage blockchain : $COM";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj : $COM"
exit
else
# OK: Sync g1cents