#voting #secure #electronic #signature #ring #systems

passring

Secret remote electronic voting based on ring signatures

5 releases

new 0.1.6 Oct 25, 2024
0.1.5 Oct 25, 2024
0.1.3 Oct 25, 2024
0.1.2 Oct 17, 2024
0.1.1 Oct 17, 2024

#807 in Cryptography

Download history 202/week @ 2024-10-12 225/week @ 2024-10-19

433 downloads per month

AGPL-3.0-only

45KB
470 lines

Passring


lib.rs:

Passring

Cryptographic library for secure voting systems.

Passring is a cryptographic library for secure voting systems. It provides a set of cryptographic primitives for secure voting systems, including key generation, encryption, decryption, and signature generation.

For more information, see the Passring whitepaper.

Features

  • Secure: Passring uses the latest cryptographic algorithms to ensure the security of the voting system.
  • Fast: Passring is optimized for performance and can handle large volumes of data.
  • Easy to use: Passring provides a simple and easy-to-use API for developers.

Algorithms

Passring uses the following cryptographic algorithms:

  • ChaCha20-Poly1305: For encryption and decryption of payloads.
  • Curve25519 and Ristretto: For key generation.
  • bLSAG: For signature generation. bLSAG is a ring signature scheme described in the Chapter 3 of Zero to Monero 2.0 (Z2M2).

Usage

To use Passring in your project, add it as dependency using Cargo:

cargo add passring

NOTE: If you want to serialize and deserialize keys/signatures, you need to enable the serde feature:

cargo add passring --features=serde

Here is an example of how to use Passring to create a new voting system:

use chacha20poly1305::{ChaCha20Poly1305, KeyInit};
use passring::{Passring, PrivateKey, PublicKey};
use passring::payload::ClearPayload;
use passring::traits::Random;
use rand_core::OsRng;
use passring::choices::{BasicVotingChoice, VotingChoice};

// Generate a new voting ID
let voting_id = uuid::Uuid::new_v4();

// Generate a new private key and public key
let private_key = PrivateKey::random(&mut OsRng);
let public_key = PublicKey::from(private_key);

// Ring must be retrieved from the Verifier
let ring: Vec<PublicKey> = (0..9).map(|_| PublicKey::random(&mut OsRng)).chain(std::iter::once(public_key)).collect();

// Create a new Passring instance
let passring = Passring::new(voting_id, ring);

// Create a new clear payload

let choice = VotingChoice::Basic { choice: BasicVotingChoice::For }; // The choice of the voter
let clear_payload = ClearPayload::new_random(voting_id, choice, &mut OsRng);

// Encrypt the clear payload
let key = ChaCha20Poly1305::generate_key(&mut OsRng); // Generate a new key
let payload = clear_payload.encrypt(&key, &mut OsRng).expect("Failed to encrypt payload");

// Issue a new signature
let full_signature = passring.issue::<OsRng>(payload, private_key).expect("Failed to issue signature");

// Verify the signature
passring.verify(&full_signature).expect("Failed to verify signature");

// validate the signature (when the key is known)
passring.validate(&full_signature, &key).expect("Failed to validate signature");

println!("Signature is valid");

Dependencies

~4–5.5MB
~96K SLoC