Skip to content

Commit 5008c59

Browse files
authored
feat: Tally script improvement | NPG-000 (#666)
# Description Add a small improvement to the tally script, fetching the vote plan id straight from the active plans file Fixes # (issue) _if applicable_ ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Test A - [ ] Test B **Test Configuration**: _if applicable_ - Firmware version: - Hardware: - Toolchain: - SDK: **List of new dependencies**: _if applicable_ Provide a list of newly added dependencies in this PR, with the description of what are they doing and why do we need them. - Crate A: description - Crate B: description ## Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
1 parent 7cf94df commit 5008c59

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/tally/private_offline.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
set -exuo pipefail
33

44
if [ "$#" -ne 1 ]; then
5-
echo "Script is expecting voteplan id "
6-
echo "./private.sh 9a278b6f788278e5cd8dfd6de8b8b8699a7f6b4847c680843de6c02d5b3169b2"
5+
echo "Script is expecting voteplan index "
6+
echo "./private.sh 0"
77
exit -1
88
fi
99

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

1516
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
1617
jcli "votes" "tally" "merge-shares" $VOTE_PLAN_ID"_decryption_share.json" > "$VOTE_PLAN_ID"_shares.json
17-
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
18+
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 commit comments

Comments
 (0)