Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ members = [
"src/vit-servicing-station-f10/vit-servicing-station-lib-f10",
"src/vit-servicing-station-f10/vit-servicing-station-server-f10",
"src/vit-servicing-station-f10/vit-servicing-station-tests-f10",
"src/sign",
]

[workspace.dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ pub(super) struct TransactionStruct {
/// Verify the structure of the transaction and return all the offsets
fn get_spine<P: Payload>(slice: &[u8]) -> Result<TransactionStruct, TransactionStructError> {
let sz = slice.len();

let mut codec = Codec::new(slice);

// read payload
Expand Down
23 changes: 23 additions & 0 deletions src/chain-libs/chain-vote/src/cryptography/zkps/unit_vector/zkp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ impl Zkp {
self.ibas.iter()
}

/// Return announcement commitments group elements
pub fn announcments_group_elements(&self) -> Vec<GroupElement> {
let mut announcements = Vec::new();
for g in self.ibas.clone() {
announcements.push(g.i);
announcements.push(g.b);
announcements.push(g.a)
}
announcements
}

/// Return an iterator of the encryptions of the polynomial coefficients
pub fn ds(&self) -> impl Iterator<Item = &Ciphertext> {
self.ds.iter()
Expand All @@ -303,6 +314,18 @@ impl Zkp {
self.zwvs.iter()
}

/// Return an iterator of the response related to the randomness
pub fn response_randomness_group_elements(&self) -> Vec<Scalar> {
let mut response = Vec::new();
for z in self.zwvs.iter().clone() {
response.push(z.z.clone());
response.push(z.w.clone());
response.push(z.v.clone());
}

response
}

/// Return R
pub fn r(&self) -> &Scalar {
&self.r
Expand Down
1 change: 1 addition & 0 deletions src/chain-libs/chain-vote/src/encrypted_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ mod tests {
#[test]
fn unit_vector() {
let uv = UnitVector::new(5, 0).unwrap();

assert_eq!(
&uv.iter().collect::<Vec<_>>()[..],
[true, false, false, false, false]
Expand Down
40 changes: 40 additions & 0 deletions src/sign/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "sign"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chain-crypto = { path = "../chain-libs/chain-crypto" }
chain-vote = { path = "../chain-libs/chain-vote" }
jormungandr-lib = { path = "../jormungandr/jormungandr-lib" }
chain-addr = { path = "../chain-libs/chain-addr" }
chain-core = { path = "../chain-libs/chain-core" }
chain-impl-mockchain = { path = "../chain-libs/chain-impl-mockchain" ,features= ["audit"]}
chain-ser = { path = "../chain-libs/chain-ser" }
chain-storage = { path = "../chain-libs/chain-storage" }


hex = "0.4"
cryptoxide = "0.4.2"
rand_chacha = "0.3"

clap = { version = "4", features = ["derive", "cargo"] }
clap_complete_command = { version = "0.5" }

color-eyre = "0.6"
thiserror = "1.0.40"
csv = "1.1"

serde = "1.0"
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"
34 changes: 34 additions & 0 deletions src/sign/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Fragment generator and signer:

## 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

- Election public key
- Alice public key
- Alice private key
- proposal to vote on
- vote plan id (hash of voteplan)

*Example usage:*

```
cargo build --release -p sign
```

*Generate raw fragment in byte representation*

```bash

ELECTION_PUB_KEY=ristretto255_votepk1ppxnuxrqa4728evnp2ues000uvwvwtxmtf77ejc29lknjuqqu44s4cfmja
ALICE_SK=56e367979579e2ce27fbd305892b0706b7dede999a534a864a7430a5c6aefd3c
ALICE_PK=ea084d2d80ed0ab681333d934efc56df3868d13d46a2de3b7f27f40b62e5344d
PROPOSAL=5
VOTE_PLAN_ID=36ad42885189a0ac3438cdb57bc8ac7f6542e05a59d1f2e4d1d38194c9d4ac7b

./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

```
Loading