Skip to content

Commit

Permalink
feat: processing voteplanid with jq
Browse files Browse the repository at this point in the history
  • Loading branch information
kukkok3 committed Feb 5, 2024
1 parent 7cf94df commit 642eb76
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/tally/private_offline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
set -exuo pipefail

if [ "$#" -ne 1 ]; then
echo "Script is expecting voteplan id "
echo "./private.sh 9a278b6f788278e5cd8dfd6de8b8b8699a7f6b4847c680843de6c02d5b3169b2"
echo "Script is expecting voteplan index "
echo "./private.sh 0"
exit -1
fi

VOTE_PLAN_ID=$1
VOTE_PLAN_INDEX=$1
VOTE_PLAN_ID=$(jq -r --arg VOTE_PLAN_INDEX "$VOTE_PLAN_INDEX" '.[$VOTE_PLAN_INDEX|tonumber].id' active_plans.json)
COMMITTEE_KEY=committee_1
COMMITTEE_PK=$(jcli key to-public < "$COMMITTEE_KEY")
MEMBER_SECRET_KEY=$(printf "./%s_committees/%s/member_secret_key.sk" $VOTE_PLAN_ID $COMMITTEE_PK)

jcli "votes" "tally" "decryption-shares" "--vote-plan" "active_plans.json" "--vote-plan-id" "$VOTE_PLAN_ID" "--key" "$MEMBER_SECRET_KEY" > "$VOTE_PLAN_ID"_decryption_share.json
jcli "votes" "tally" "merge-shares" $VOTE_PLAN_ID"_decryption_share.json" > "$VOTE_PLAN_ID"_shares.json
jcli "votes" "tally" "decrypt-results" "--vote-plan" "active_plans.json" "--vote-plan-id" "$VOTE_PLAN_ID" "--shares" $VOTE_PLAN_ID"_shares.json" "--threshold" "1" "--output-format" "json" > "$VOTE_PLAN_ID"_result.json
jcli "votes" "tally" "decrypt-results" "--vote-plan" "active_plans.json" "--vote-plan-id" "$VOTE_PLAN_ID" "--shares" $VOTE_PLAN_ID"_shares.json" "--threshold" "1" "--output-format" "json" > results"$VOTE_PLAN_INDEX".json

0 comments on commit 642eb76

Please sign in to comment.