Skip to content

Commit

Permalink
test(benchmark): 🧪 update ethereum benchmark with new statements
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino committed Aug 4, 2023
1 parent fe0964e commit 802ce10
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
5 changes: 2 additions & 3 deletions test/benchmark/eth/lua_for/batch_verification.zen.bench
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Scenario 'ethereum': batch verification

Given I have a 'ethereum address array' named 'ethereum addresses'
and I have a 'ethereum signature array' named 'ethereum signatures'
Given I have a 'ethereum address signature pair array' named 'address_signature_pair'
and I have a 'string' named 'message'

When I verify the 'message' has an array of ethereum signatures in 'ethereum signatures' by 'ethereum addresses'
When I verify the ethereum address signature pair array 'address_signature_pair' of 'message'

Then print the string 'OK'
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Scenario ethereum: verify sig
Given I have a 'ethereum address array' named 'ethereum addresses'
and I have a 'ethereum signature array' named 'ethereum signatures'
Given I have a 'ethereum address signature pair array' named 'address_signature_pair'
and I have a 'string' named 'message'

When I create the verification result verifying the 'message' has an array of ethereum signatures in 'ethereum signatures' by 'ethereum addresses'
When I use the ethereum address signature pair array 'address_signature_pair' to create the result array of 'message'

Then print the 'verification result'
Then print the 'result array'
17 changes: 6 additions & 11 deletions test/benchmark/eth/lua_for/benchmark_sign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ msg='"message": "I love the Beatles, all but 3",'

echo
echo Signing $n_signatures times...
echo '"ethereum_addresses": [' >addresses.txt
echo '"ethereum_signatures": [' >signatures.txt
echo '"address_signature_pair": [' >addresses_signatures.txt
time for ((i=1; i<=$n_signatures; i++)); do
zenroom -a key_add_sign_gen.keys.bench -z key_add_sign_gen_manual.zen.bench >res_1.json 2>execution_data_1.txt
if [ "$?" != "0" ]; then
Expand All @@ -22,20 +21,16 @@ time for ((i=1; i<=$n_signatures; i++)); do
exit 1
fi
if [ "$i" != "$n_signatures" ]; then
cat res_1.json | cut -d, -f1 | cut -d: -f2 | sed 's/$/,/' >> addresses.txt
cat res_1.json | cut -d, -f2 | cut -d: -f2 | cut -d\} -f1 | sed 's/$/,/' >> signatures.txt
cat res_1.json | cut -d: -f2- | cut -d\} -f1-2 | sed 's/$/,/' >> addresses_signatures.txt
else
cat res_1.json | cut -d, -f1 | cut -d: -f2 >> addresses.txt
cat res_1.json | cut -d, -f2 | cut -d: -f2 | cut -d\} -f1 >> signatures.txt
cat res_1.json | cut -d: -f2- | cut -d\} -f1-2 >> addresses_signatures.txt
fi
done
echo '],' >>addresses.txt
echo ']' >>signatures.txt
echo ']' >>addresses_signatures.txt
echo "{$msg" > add_and_sign.json
cat addresses.txt >> add_and_sign.json
cat signatures.txt >> add_and_sign.json
cat addresses_signatures.txt >> add_and_sign.json
echo "}" >> add_and_sign.json
rm res_1.json execution_data_1.txt addresses.txt signatures.txt
rm res_1.json execution_data_1.txt addresses_signatures.txt

echo
echo Verifying $n_signatures signatures...
Expand Down
7 changes: 5 additions & 2 deletions test/benchmark/eth/lua_for/key_add_sign_gen_manual.zen.bench
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ When I create the ethereum key
and I create the ethereum address
and I create the ethereum signature of 'message'

Then print the 'ethereum address'
and print the 'ethereum signature'
When I create the 'ethereum_address_signature_pair' named 'signature'
and I move the 'ethereum_address' to 'address' in 'signature'
and I move the 'ethereum_signature' to 'signature' in 'signature'

Then print the 'signature'

0 comments on commit 802ce10

Please sign in to comment.