Skip to content

Implementation of the Elgamal encryption scheme over elliptic curves using the BLS12-381 curve (G1).

License

Notifications You must be signed in to change notification settings

AlvinHon/bls-elgamal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elgamal Encryption

This crate provides an implementation of the Elgamal encryption scheme over elliptic curves using the BLS12-381 curve (G1).

Note: this repository has not been thoroughly audited. Please take your own risk if you use it in production environment.

Example

use ark_std::UniformRand;
use bls_elgamal::{Fr, SecretKey, G1Affine};
use rand::prelude::StdRng;
use rand_core::SeedableRng;
    
let mut rng = StdRng::from_entropy();
let x = Fr::rand(&mut rng);
let g1 = G1Affine::rand(&mut rng);

// Create a secret key and a public key
let sk = SecretKey::new(g1, x);
let pk = sk.public_key();

// Define a message and randomness
let m = G1Affine::rand(&mut rng);
let r = Fr::rand(&mut rng);

// Encrypt and decrypt the message
let ciphertext = pk.encrypt(m, r);
let decrypted_m = sk.decrypt(ciphertext);

assert_eq!(m, decrypted_m);

About

Implementation of the Elgamal encryption scheme over elliptic curves using the BLS12-381 curve (G1).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages