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

Inverse dlog statement is built by the verifier, not by the prover #24

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 6 additions & 11 deletions src/add_party_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ pub struct JoinMessage {
pub(crate) ek: EncryptionKey,
pub(crate) dk_correctness_proof: NICorrectKeyProof,
pub(crate) party_index: Option<usize>,
pub(crate) dlog_statement_base_h1: DLogStatement,
pub(crate) dlog_statement_base_h2: DLogStatement,
pub(crate) dlog_statement: DLogStatement,
pub(crate) composite_dlog_proof_base_h1: CompositeDLogProof,
pub(crate) composite_dlog_proof_base_h2: CompositeDLogProof,
}
Expand All @@ -61,9 +60,8 @@ fn generate_h1_h2_n_tilde() -> (BigInt, BigInt, BigInt, BigInt, BigInt) {
(ek_tilde.n, h1, h2, xhi, xhi_inv)
}

/// Generates the DlogStatements and CompositeProofs using the parameters generated by [generate_h1_h2_n_tilde]
/// Generates the DlogStatement and CompositeProofs using the parameters generated by [generate_h1_h2_n_tilde]
fn generate_dlog_statement_proofs() -> (
DLogStatement,
DLogStatement,
CompositeDLogProof,
CompositeDLogProof,
Expand All @@ -87,7 +85,6 @@ fn generate_dlog_statement_proofs() -> (

(
dlog_statement_base_h1,
dlog_statement_base_h2,
composite_dlog_proof_base_h1,
composite_dlog_proof_base_h2,
)
Expand All @@ -100,8 +97,7 @@ impl JoinMessage {
pub fn distribute() -> (Self, Keys) {
let pailier_key_pair = Keys::create(0);
let (
dlog_statement_base_h1,
dlog_statement_base_h2,
dlog_statement,
composite_dlog_proof_base_h1,
composite_dlog_proof_base_h2,
) = generate_dlog_statement_proofs();
Expand All @@ -110,8 +106,7 @@ impl JoinMessage {
// in a join message, we only care about the ek and the correctness proof
ek: pailier_key_pair.ek.clone(),
dk_correctness_proof: NICorrectKeyProof::proof(&pailier_key_pair.dk, None),
dlog_statement_base_h1,
dlog_statement_base_h2,
dlog_statement,
composite_dlog_proof_base_h1,
composite_dlog_proof_base_h2,
party_index: None,
Expand Down Expand Up @@ -207,11 +202,11 @@ impl JoinMessage {
let available_h1_h2_ntilde_vec: HashMap<usize, &DLogStatement> = refresh_messages
.iter()
.map(|msg| (msg.party_index, &msg.dlog_statement))
.chain(std::iter::once((party_index, &self.dlog_statement_base_h1)))
.chain(std::iter::once((party_index, &self.dlog_statement)))
.chain(join_messages.iter().map(|join_message| {
(
join_message.party_index.unwrap(),
&join_message.dlog_statement_base_h1,
&join_message.dlog_statement,
)
}))
.collect();
Expand Down
12 changes: 9 additions & 3 deletions src/refresh_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl<P> RefreshMessage<P> {
for join_message in new_parties.iter() {
let party_index = join_message.get_party_index()?;
key.paillier_key_vec[party_index - 1] = join_message.ek.clone();
key.h1_h2_n_tilde_vec[party_index - 1] = join_message.dlog_statement_base_h1.clone();
key.h1_h2_n_tilde_vec[party_index - 1] = join_message.dlog_statement.clone();
}

Ok(RefreshMessage::distribute(key))
Expand Down Expand Up @@ -281,13 +281,19 @@ impl<P> RefreshMessage<P> {
return Err(FsDkrError::PaillierVerificationError { party_index });
}

// creating an inverse dlog statement
let dlog_statement_base_h2 = DLogStatement {
N: join_message.dlog_statement.N.clone(),
g: join_message.dlog_statement.ni.clone(),
ni: join_message.dlog_statement.g.clone(),
};
if join_message
.composite_dlog_proof_base_h1
.verify(&join_message.dlog_statement_base_h1)
.verify(&join_message.dlog_statement)
.is_err()
|| join_message
.composite_dlog_proof_base_h2
.verify(&join_message.dlog_statement_base_h2)
.verify(&dlog_statement_base_h2)
.is_err()
{
return Err(FsDkrError::DLogProofValidation { party_index });
Expand Down