Skip to content

Commit

Permalink
feat: (yay or nay): add choice to current jorm crypto config feat | N…
Browse files Browse the repository at this point in the history
…PG-000 (#652)

add choice flag to vote signer, tied to current jorm config where 0 is
NO and 1 is YES in the context of position in array.
  • Loading branch information
cong-or authored Jan 8, 2024
1 parent 2ce952c commit 024bb07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 138 deletions.
135 changes: 0 additions & 135 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/sign/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ rand = "0.8.3"
bech32 = "0.8"
rand_core = { version = "0.5.1", default-features = false }
ed25519-dalek = "1.0.1"
reqwest = { version = "*", features = ["blocking","json"] }
reqwest = { version = "*", default_features = false, features = [ "blocking","json", "rustls-tls" ] }
3 changes: 2 additions & 1 deletion src/sign/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ PROPOSAL=5
VOTE_PLAN_ID=36ad42885189a0ac3438cdb57bc8ac7f6542e05a59d1f2e4d1d38194c9d4ac7b
EPOCH=0
SLOT=0
CHOICE=1

./target/release/sign --election-pub-key $ELECTION_PUB_KEY --private-key $ALICE_SK --public-key $ALICE_PK --proposal $PROPOSAL --vote-plan-id $VOTE_PLAN_ID --epoch $EPOCH --slot $SLOT
./target/release/sign --election-pub-key $ELECTION_PUB_KEY --private-key $ALICE_SK --public-key $ALICE_PK --proposal $PROPOSAL --vote-plan-id $VOTE_PLAN_ID --epoch $EPOCH --slot $SLOT --choice $CHOICE

```
8 changes: 7 additions & 1 deletion src/sign/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub struct Args {
/// vote plan hash
#[clap(short, long)]
vote_plan_id: String,
/// vote yay or nay
#[clap(short, long)]
choice: u8,
}

fn main() -> Result<(), Box<dyn Error>> {
Expand All @@ -66,7 +69,10 @@ fn main() -> Result<(), Box<dyn Error>> {
// join sk+pk together, api requirement
sk.extend(pk.clone());
let keypair: Keypair = Keypair::from_bytes(&sk)?;
let vote = chain_vote::Vote::new(2, 1_usize)?;

let choice = args.choice;

let vote = chain_vote::Vote::new(2, choice.into())?;
// common reference string
let crs = chain_vote::Crs::from_hash(&hex::decode(args.vote_plan_id.clone())?);

Expand Down

0 comments on commit 024bb07

Please sign in to comment.