commit 419e8a18143bc8adb994476383df50971216bbbe
parent 37654da007344554c8054b46b7fa348ba063286f
Author: srfsh <dev@srf.sh>
Date: Mon, 20 Jun 2022 16:43:50 +0300
zencode: move to its dedicated directory
The rationale behind this is that zencodes are not part of the
source code, thus they can't be in src/ or test/.
Diffstat:
6 files changed, 94 insertions(+), 55 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -89,6 +89,7 @@
!/zencode/
/zencode/*
!/zencode/*.zen
+!/zencode/test.sh
# docs
!/docs/
diff --git a/test/zencode/run.sh b/test/zencode/run.sh
@@ -1,55 +0,0 @@
-#!/usr/bin/env bash
-
-conf="rngseed=hex:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
-
-which zenroom > /dev/null
-if [ $? != 0 ]; then
- echo "Error: zenroom interpreter not found in PATH"
- exit 1
-fi
-if ! [ -r src/zencode ]; then
- echo "Error: run from base dir: ./test/zencode/run.sh"
- exit 1
-fi
-
-results=`mktemp`
-echo > $results
-echo "Zenflows tests of zencode scripts" >> $results
-date >> $results
-echo >> $results
-
-function testzen() {
- script="src/zencode/${1}.zen"
- expect="$2"
- input="$3"
- if [ "$input" != "" ]; then
- tmpin=`mktemp`
- echo "$input" > $tmpin
- result=`cat $script | zenroom -z -c $conf -a $tmpin`
- rm -f $tmpin
- else
- result=`cat $script | zenroom -z -c $conf`
- fi
- if [ $? != 0 ]; then
- echo "[!] Parse error in $script" >> $results
- else
- if [ "$result" != "$expect" ]; then
- echo "[!] Error in $script" >> $results
- echo "$result"
- else
- echo " . Success: $script" >> $results
- fi
- fi
-}
-
-testzen keygen '{"bitcoin_address":"bc1qlsqa5rgnrma4agtjar4q5jv9pe4pxze7vsyvp7","ethereum_address":"05a94ba6d94f9056e79351a8fd1dc186b737993f","keyring":{"bitcoin":"L1ipn47zzKEDFhbHgJ3ef4Hwpf3ACu4CHEzDGXdJ4Wh6DtjV1woo","ecdh":"B4rYTWx6UMbc2YPWRNpl4w2M6gY9jqSa637n8Kr2pPc=","ethereum":"d6fe79ff70b4a8663d1ecf495a983ba6effd0392c636923dff08a0482f5e5d5f","reflow":"abYTJShT0ZBKU+ZwJlEIPNinT6TFU+unaKMEZ+u3kbs=","schnorr":"DR92VSF2l3Az1K1+LyWO13Jk1eBPmuhhPT2NbpxGgsk="},"pubkeys":{"ecdh_public_key":"BHdrWMNBRclVO1I1/iEaYjfEi5C0eEvG2GZgsCNq87qy8feZ74JEvnKK9FC07ThhJ8s4ON2ZQcLJ+8HpWMfKPww=","reflow_public_key":"FwWLOfRBAoZKfykEvq26iNn2D64gvwgCfinWWZnG4HotCuomB6EB9qJ0sinpV5LNB6GdkrKU3wvYMUU+fBMX8mtR77E3x/ljbqpwwpcmjB9YtONG1peywJvRhXqhIBJSALFTXAB2Y1XtM63Uw5/CBex8zH3wXyYU6sv/ctKi5bUZ2Zzqua9Q8LMqtgLsrrB9GDKbmPT1einkXVMLX0kuJV/AOTnA57q91HKXMCvlvlKs/sr5mJ70FchdEZl0UHIV","schnorr_public_key":"EZH/DtDoGvjabyqiHwROQpt5suHlD3JiMZ7Cqv8yAWZpewOm8i5TlOq6L6eBbc/J"}}'
-
-testzen passgen_pbkdf2 '{"key_derivation":"hUWpLrhAYoeWA/0uNjn32a/YNwQc8S1mAI0IpWgPMLU="}' '{"salt":"c24463f5e352da20cb79a43f97436cce57344911e1d0ec0008cbedb5fabcca33","password":"my secret pass"}'
-
-testzen passverify_pbkdf2 '{"output":["1"]}' '{"hash":"hUWpLrhAYoeWA/0uNjn32a/YNwQc8S1mAI0IpWgPMLU=","salt":"c24463f5e352da20cb79a43f97436cce57344911e1d0ec0008cbedb5fabcca33","password": "my secret pass"}'
-
-echo >> $results
-cat $results
-rm -f $results
-
-
diff --git a/zencode/keygen.zen b/zencode/keygen.zen
@@ -0,0 +1,27 @@
+Scenario ecdh : 'keygen'
+Scenario ethereum: 'keygen'
+Scenario schnorr: 'keygen'
+Scenario reflow: 'keygen'
+
+Given nothing
+When I create the ecdh key
+When I create the reflow key
+When I create the schnorr key
+When I create the ethereum key
+When I create the bitcoin key
+
+When I create the 'base64 dictionary' named 'pubkeys'
+When I create the ecdh public key
+and I move 'ecdh public key' in 'pubkeys'
+When I create the reflow public key
+and I move 'reflow public key' in 'pubkeys'
+When I create the schnorr public key
+and I move 'schnorr public key' in 'pubkeys'
+
+When I create the ethereum address
+When I create the bitcoin address
+
+Then print the 'keyring'
+and print the 'pubkeys'
+and print the 'ethereum address'
+and print the 'bitcoin address'
diff --git a/zencode/passgen_pbkdf2.zen b/zencode/passgen_pbkdf2.zen
@@ -0,0 +1,4 @@
+Given I have a 'hex' named 'salt'
+and I have a 'string' named 'password'
+When I create the key derivation of 'password' with password 'salt'
+Then print the 'key derivation' as 'base64'
diff --git a/zencode/passverify_pbkdf2.zen b/zencode/passverify_pbkdf2.zen
@@ -0,0 +1,7 @@
+Given I have a 'hex' named 'salt'
+and I have a 'base64' named 'hash'
+and I have a 'string' named 'password'
+When I create the key derivation of 'password' with password 'salt'
+and I verify 'key_derivation' is equal to 'hash'
+Then print the string '1'
+# when false zenroom returns error
diff --git a/zencode/test.sh b/zencode/test.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+
+conf="rngseed=hex:00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
+
+which zenroom > /dev/null
+if [ $? != 0 ]; then
+ echo "Error: zenroom interpreter not found in PATH"
+ exit 1
+fi
+if ! ls ./*.zen >/dev/null 2>&1 ; then
+ echo "Error: there is no zencode scripts in PWD to run"
+ exit 1
+fi
+
+results=`mktemp`
+echo > $results
+echo "Zenflows tests of zencode scripts" >> $results
+date >> $results
+echo >> $results
+
+function testzen() {
+ script="${1}.zen"
+ expect="$2"
+ input="$3"
+ if [ "$input" != "" ]; then
+ tmpin=`mktemp`
+ echo "$input" > $tmpin
+ result=`cat $script | zenroom -z -c $conf -a $tmpin`
+ rm -f $tmpin
+ else
+ result=`cat $script | zenroom -z -c $conf`
+ fi
+ if [ $? != 0 ]; then
+ echo "[!] Parse error in $script" >> $results
+ else
+ if [ "$result" != "$expect" ]; then
+ echo "[!] Error in $script" >> $results
+ echo "$result"
+ else
+ echo " . Success: $script" >> $results
+ fi
+ fi
+}
+
+testzen keygen '{"bitcoin_address":"bc1qlsqa5rgnrma4agtjar4q5jv9pe4pxze7vsyvp7","ethereum_address":"05a94ba6d94f9056e79351a8fd1dc186b737993f","keyring":{"bitcoin":"L1ipn47zzKEDFhbHgJ3ef4Hwpf3ACu4CHEzDGXdJ4Wh6DtjV1woo","ecdh":"B4rYTWx6UMbc2YPWRNpl4w2M6gY9jqSa637n8Kr2pPc=","ethereum":"d6fe79ff70b4a8663d1ecf495a983ba6effd0392c636923dff08a0482f5e5d5f","reflow":"abYTJShT0ZBKU+ZwJlEIPNinT6TFU+unaKMEZ+u3kbs=","schnorr":"DR92VSF2l3Az1K1+LyWO13Jk1eBPmuhhPT2NbpxGgsk="},"pubkeys":{"ecdh_public_key":"BHdrWMNBRclVO1I1/iEaYjfEi5C0eEvG2GZgsCNq87qy8feZ74JEvnKK9FC07ThhJ8s4ON2ZQcLJ+8HpWMfKPww=","reflow_public_key":"FwWLOfRBAoZKfykEvq26iNn2D64gvwgCfinWWZnG4HotCuomB6EB9qJ0sinpV5LNB6GdkrKU3wvYMUU+fBMX8mtR77E3x/ljbqpwwpcmjB9YtONG1peywJvRhXqhIBJSALFTXAB2Y1XtM63Uw5/CBex8zH3wXyYU6sv/ctKi5bUZ2Zzqua9Q8LMqtgLsrrB9GDKbmPT1einkXVMLX0kuJV/AOTnA57q91HKXMCvlvlKs/sr5mJ70FchdEZl0UHIV","schnorr_public_key":"EZH/DtDoGvjabyqiHwROQpt5suHlD3JiMZ7Cqv8yAWZpewOm8i5TlOq6L6eBbc/J"}}'
+
+testzen passgen_pbkdf2 '{"key_derivation":"hUWpLrhAYoeWA/0uNjn32a/YNwQc8S1mAI0IpWgPMLU="}' '{"salt":"c24463f5e352da20cb79a43f97436cce57344911e1d0ec0008cbedb5fabcca33","password":"my secret pass"}'
+
+testzen passverify_pbkdf2 '{"output":["1"]}' '{"hash":"hUWpLrhAYoeWA/0uNjn32a/YNwQc8S1mAI0IpWgPMLU=","salt":"c24463f5e352da20cb79a43f97436cce57344911e1d0ec0008cbedb5fabcca33","password": "my secret pass"}'
+
+echo >> $results
+cat $results
+rm -f $results
+
+