Skip to content

Commit

Permalink
Merge pull request #1 from webb-tools/uy
Browse files Browse the repository at this point in the history
gg20 like t of n key gen change from x and pubx to u and y
  • Loading branch information
akileshtangella authored Sep 25, 2022
2 parents e207a68 + d4f0315 commit 9ecf9f5
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/party_i.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub struct Parameters {

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Keys<E: Curve = Secp256k1> {
pub x_i: Scalar<E>,
pub pub_X_i: Point<E>,
pub u_i: Scalar<E>,
pub pub_y_i: Point<E>,
// Paillier keys
pub dk: DecryptionKey,
pub ek: EncryptionKey,
Expand Down Expand Up @@ -167,14 +167,14 @@ pub fn generate_s_t_N_tilde() -> (BigInt, BigInt, BigInt) {

impl Keys {
pub fn create(index: usize) -> Self {
let x = Scalar::<Secp256k1>::random();
let pub_X = Point::generator() * &x;
let u = Scalar::<Secp256k1>::random();
let y = Point::generator() * &u;
let (ek, dk) = Paillier::keypair().keys();
let rid = rand::thread_rng().gen::<[u8; SECURITY / 8]>();
let (N_tilde, s, t) = generate_s_t_N_tilde();
Self {
x_i: x,
pub_X_i: pub_X,
u_i: u,
pub_y_i: y,
dk,
ek,
party_index: index,
Expand All @@ -187,15 +187,15 @@ impl Keys {

// we recommend using safe primes if the code is used in production
pub fn create_safe_prime(rid: [u8; SECURITY / 8], index: usize) -> Self {
let x = Scalar::<Secp256k1>::random();
let pub_X = Point::generator() * &x;
let u = Scalar::<Secp256k1>::random();
let pub_y = Point::generator() * &u;

let (ek, dk) = Paillier::keypair_safe_primes().keys();
let (N_tilde, s, t) = generate_s_t_N_tilde();

Self {
x_i: x,
pub_X_i: pub_X,
u_i: u,
pub_y_i: pub_y,
dk,
ek,
party_index: index,
Expand All @@ -205,14 +205,14 @@ impl Keys {
t,
}
}
pub fn create_from(x: Scalar<Secp256k1>, rid: [u8; SECURITY / 8], index: usize) -> Self {
let pub_X = Point::generator() * &x;
pub fn create_from(u: Scalar<Secp256k1>, rid: [u8; SECURITY / 8], index: usize) -> Self {
let pub_y = Point::generator() * &u;
let (ek, dk) = Paillier::keypair().keys();
let (N_tilde, s, t) = generate_s_t_N_tilde();

Self {
x_i: x,
pub_X_i: pub_X,
u_i: u,
pub_y_i: pub_y,
dk,
ek,
party_index: index,
Expand Down

0 comments on commit 9ecf9f5

Please sign in to comment.