Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new protocol for zk discrete log with El-Gamal commitment #4

Open
wants to merge 1 commit into
base: m
Choose a base branch
from

Conversation

jfdreis
Copy link
Collaborator

@jfdreis jfdreis commented Nov 25, 2024

No description provided.

@jfdreis jfdreis requested a review from manel1874 November 25, 2024 17:06
//!
//! //! ## Description
//!
//! A party P has `L = g * lambda`, `M = (g * y) (X * lambda)`, and `Y = h * y`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! A party P has `L = g * lambda`, `M = (g * y) (X * lambda)`, and `Y = h * y`,
//! A party P has `L = g ^ lambda`, `M = (g ^ y) * (X ^ lambda)`, and `Y = h ^ y`,

Comment on lines +7 to +8
//! with g being a generator of curve `E`, h is a point of the curve
//! and X is a public key (and a point of the curve).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! with g being a generator of curve `E`, h is a point of the curve
//! and X is a public key (and a point of the curve).
//! with g being a generator of curve `E`, h is a point on the curve
//! and X is a public key (and a point on the curve).

//!
//! Given:
//! - Curve `E`
//! - `X` - public key, point of the curve
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! - `X` - public key, point of the curve
//! - `X` - public key, point on the curve

//! Given:
//! - Curve `E`
//! - `X` - public key, point of the curve
//! - `L = g * lambda`, `M = (g * y) (X * lambda)`, and `Y = h * y` - data to obtain proof about
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! - `L = g * lambda`, `M = (g * y) (X * lambda)`, and `Y = h * y` - data to obtain proof about
//! - `L = g * lambda`, `M = (g ^ y) * (X ^ lambda)`, and `Y = h ^ y` - data to obtain proof about

//! - `L = g * lambda`, `M = (g * y) (X * lambda)`, and `Y = h * y` - data to obtain proof about
//!
//! Prove:
//! - `logarithm base h of Y= lambda`
Copy link
Member

@manel1874 manel1874 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! - `logarithm base h of Y= lambda`
//! - `logarithm base h of Y= y`

Right?

//!
//! // 1. Setup: prover prepares the public key X
//!
//! // X in paper is a point of the Curve E
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! // X in paper is a point of the Curve E
//! // X in paper is a point on the Curve E

//! // X in paper is a point of the Curve E
//! let x = Point::<E>::generator() * Scalar::random(&mut rng);
//!
//! // h in paper is a point of the Curve E
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! // h in paper is a point of the Curve E
//! // h in paper is a point on the Curve E

Comment on lines +60 to +72
//! // y in paper
//! let y = Integer::from_rng_pm(&security.q,&mut rng);
//! // lambda in paper
//! let lambda = Integer::from_rng_pm(&security.q,&mut rng);
//!
//! // 3. Setup: prover encrypts everything on correct keys
//!
//! // L in paper
//! let l = Point::<C>::generator() * lambda.to_scalar();
//! // M in paper
//! let m = Point::<C>::generator() * y.to_scalar() + x * lambda.to_scalar();
//! // Y in paper
//! let h_to_y = h * y.to_scalar();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! // y in paper
//! let y = Integer::from_rng_pm(&security.q,&mut rng);
//! // lambda in paper
//! let lambda = Integer::from_rng_pm(&security.q,&mut rng);
//!
//! // 3. Setup: prover encrypts everything on correct keys
//!
//! // L in paper
//! let l = Point::<C>::generator() * lambda.to_scalar();
//! // M in paper
//! let m = Point::<C>::generator() * y.to_scalar() + x * lambda.to_scalar();
//! // Y in paper
//! let h_to_y = h * y.to_scalar();
//! // y in paper
//! let plaintext_y = Integer::from_rng_pm(&security.q,&mut rng);
//! // lambda in paper
//! let plaintext_lambda = Integer::from_rng_pm(&security.q,&mut rng);
//!
//! // 3. Setup: prover encrypts everything on correct keys
//!
//! // L in paper
//! let ciphertext_l = Point::<C>::generator() * plaintext_lambda.to_scalar();
//! // M in paper
//! let ciphertext_m = Point::<C>::generator() * plaintext_y.to_scalar() + x * plaintext_lambda.to_scalar();
//! // Y in paper
//! let ciphertext_h_to_y = h * plaintext_y.to_scalar();

//! // and lambda are the same
//!
//! let data = p::Data {
//! key0: &key0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! key0: &key0,

I don't believe we are using a key0.

Comment on lines +79 to +82
//! l: &l,
//! m: &m,
//! x: &x,
//! h_to_y: &h_to_y,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! l: &l,
//! m: &m,
//! x: &x,
//! h_to_y: &h_to_y,
//! l: &ciphertext_l,
//! m: &ciphertext_m,
//! x: &x,
//! h_to_y: &ciphertext_h_to_y,

Comment on lines +86 to +87
//! y: &y,
//! lambda: &lambda,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! y: &y,
//! lambda: &lambda,
//! y: &plaintext_y,
//! lambda: &plaintext_lambda,

pub lambda: &'a Integer,
}

// As described in cggmp21 at page 35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// As described in cggmp21 at page 35
// As described in cggmp24 at page 57

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(bound = ""))]
pub struct Commitment<C: Curve> {
pub a: Point<C>,
pub cap_n: Point<C>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cap_n stands for capital n? Why are the others (a, b) not following the same naming?

let alpha = Integer::gen_invertible(&Integer::curve_order::<C>(), &mut rng);
let m = Integer::gen_invertible(&Integer::curve_order::<C>(), &mut rng);


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change



let a= Point::<C>::generator() * alpha.to_scalar();
let enne= Point::<C>::generator() * m.to_scalar() + data.x * alpha.to_scalar();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not cap_n?

challenge: &Challenge,
proof: &Proof,
) -> Result<(), InvalidProof> {
// Three equality checks and two range checks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Three equality checks and two range checks
// Three equality checks

let security = super::SecurityParams {
q: (Integer::ONE << 128_u32).into(),
};
let y = Integer::from_rng_pm(&security.q,&mut rng);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let y = Integer::from_rng_pm(&security.q,&mut rng);
let y = Integer::from_rng_pm(&security.q,&mut rng);

let security = super::SecurityParams {
q: (Integer::ONE << 128_u32).into(),
};
let y = Integer::from_rng_pm(&security.q,&mut rng);
Copy link
Member

@manel1874 manel1874 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let y = Integer::from_rng_pm(&security.q,&mut rng);
let y = Integer::from_rng_pm(&security.q, &mut rng);

Comment on lines +417 to +418
let lambda = Integer::from_rng_pm(&security.q,&mut rng);
let false_lambda = Integer::from_rng_pm(&security.q,&mut rng);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let lambda = Integer::from_rng_pm(&security.q,&mut rng);
let false_lambda = Integer::from_rng_pm(&security.q,&mut rng);
let lambda = Integer::from_rng_pm(&security.q, &mut rng);
let false_lambda = Integer::from_rng_pm(&security.q, &mut rng);

Comment on lines +451 to +453
let y = Integer::from_rng_pm(&security.q,&mut rng);
let lambda = Integer::from_rng_pm(&security.q,&mut rng);
let false_y = Integer::from_rng_pm(&security.q,&mut rng);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let y = Integer::from_rng_pm(&security.q,&mut rng);
let lambda = Integer::from_rng_pm(&security.q,&mut rng);
let false_y = Integer::from_rng_pm(&security.q,&mut rng);
let y = Integer::from_rng_pm(&security.q, &mut rng);
let lambda = Integer::from_rng_pm(&security.q, &mut rng);
let false_y = Integer::from_rng_pm(&security.q, &mut rng);

Copy link
Member

@manel1874 manel1874 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run cargo fmt?

It seems good to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants