Skip to content

Commit

Permalink
fix: crs hex::decode | NPG-000 (#629)
Browse files Browse the repository at this point in the history
In proof systems, provers and the verifiers rely on a common set of
parameters, sometimes referred to as the common reference string (CRS).

we are using the the DigestOf<Blake2b256, VotePlan>; as the CRS

align with on the fly load tester updates
  • Loading branch information
cong-or authored Nov 20, 2023
1 parent 1a15c2a commit 9ccc415
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 15 deletions.
136 changes: 136 additions & 0 deletions Cargo.lock

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

7 changes: 2 additions & 5 deletions src/sign/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ serde_json = "1.0"
serde_yaml = "0.8.17"
rand = "0.8.3"
bech32 = "0.8"


rand_core = { version = "0.5.1", default-features = false }


ed25519-dalek = "1.0.1"
ed25519-dalek = "1.0.1"
reqwest = { version = "*", features = ["blocking","json"] }
7 changes: 4 additions & 3 deletions src/sign/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Fragment generator and signer:
# **Vote** Fragment generator and signer:
Generates vote fragments and signs them accordingly

## Specifications
[*see here for format.abnf*](../chain-libs/chain-impl-mockchain/doc/format.abnf)

[*see here for format.md*](../chain-libs/chain-impl-mockchain/doc/format.md)

## Ingredients for generating a fragment
## Ingredients for generating a **vote** fragment

- Election public key
- Alice public key
Expand All @@ -21,7 +22,7 @@
cargo build --release -p sign
```

*Generate raw fragment in byte representation*
*Generate raw vote fragment in byte representation*

```bash

Expand Down
6 changes: 3 additions & 3 deletions src/sign/src/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mod tests {
use jormungandr_lib::interfaces::AccountIdentifier;

#[test]
fn test_fragment_generation() {
fn fragment_generation() {
let mut csprng = OsRng;

// User key for signing witness
Expand All @@ -206,7 +206,7 @@ mod tests {
// vote
let vote = chain_vote::Vote::new(2, 1 as usize).unwrap();

let crs = chain_vote::Crs::from_hash(vote_plan_id.as_bytes());
let crs = chain_vote::Crs::from_hash(&hex::decode(vote_plan_id.as_bytes()).unwrap());

let (ciphertexts, proof) = ek.encrypt_and_prove_vote(&mut rng, &crs, vote);
let (proof, encrypted_vote) =
Expand Down Expand Up @@ -289,7 +289,7 @@ mod tests {
}

#[test]
fn test_encrypted_vote_generation() {
fn encrypted_vote_generation() {
let mut rng = ChaCha20Rng::from_seed([0u8; 32]);

// vote plan id
Expand Down
8 changes: 4 additions & 4 deletions src/sign/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use std::error::Error;

use crate::fragment::{compose_encrypted_vote_part, generate_vote_fragment};

mod fragment;
pub mod fragment;
pub mod network;

///
/// Args defines and declares CLI behaviour within the context of clap
Expand Down Expand Up @@ -65,10 +66,9 @@ fn main() -> Result<(), Box<dyn Error>> {
// join sk+pk together, api requirement
sk.extend(pk.clone());
let keypair: Keypair = Keypair::from_bytes(&sk)?;

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

// parse ek key
let ek = ElectionPublicKey::from_bytes(&election_pk)
Expand Down
Loading

0 comments on commit 9ccc415

Please sign in to comment.