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

fix: inverse dlog statement is built by the verifier, and not by the prover #5

Merged
merged 2 commits into from
Oct 19, 2022
Merged
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
28 changes: 8 additions & 20 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<u16>,
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,13 +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]
fn generate_dlog_statement_proofs() -> (
DLogStatement,
DLogStatement,
CompositeDLogProof,
CompositeDLogProof,
) {
/// Generates the DlogStatement and CompositeProofs using the parameters generated by [generate_h1_h2_n_tilde]
fn generate_dlog_statement_proofs() -> (DLogStatement, CompositeDLogProof, CompositeDLogProof) {
let (n_tilde, h1, h2, xhi, xhi_inv) = generate_h1_h2_n_tilde();

let dlog_statement_base_h1 = DLogStatement {
Expand All @@ -87,7 +81,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 @@ -102,19 +95,14 @@ impl JoinMessage {
/// [Keys] that are going to be used when generating the [LocalKey].
pub fn distribute() -> (Self, Keys) {
let paillier_key_pair = Keys::create(0);
let (
dlog_statement_base_h1,
dlog_statement_base_h2,
composite_dlog_proof_base_h1,
composite_dlog_proof_base_h2,
) = generate_dlog_statement_proofs();
let (dlog_statement, composite_dlog_proof_base_h1, composite_dlog_proof_base_h2) =
generate_dlog_statement_proofs();

let join_message = JoinMessage {
// in a join message, we only care about the ek and the correctness proof
ek: paillier_key_pair.ek.clone(),
dk_correctness_proof: NiCorrectKeyProof::proof(&paillier_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 @@ -211,11 +199,11 @@ impl JoinMessage {
let available_h1_h2_ntilde_vec: HashMap<u16, &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
14 changes: 10 additions & 4 deletions src/refresh_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ impl<E: Curve, H: Digest + Clone> RefreshMessage<E, H> {
key.h1_h2_n_tilde_vec.remove((party_index - 1) as usize);
key.h1_h2_n_tilde_vec.insert(
(party_index - 1) as usize,
join_message.dlog_statement_base_h1.clone(),
join_message.dlog_statement.clone(),
);
} else {
key.paillier_key_vec
.insert((party_index - 1) as usize, join_message.ek.clone());
key.h1_h2_n_tilde_vec.insert(
(party_index - 1) as usize,
join_message.dlog_statement_base_h1.clone(),
join_message.dlog_statement.clone(),
);
}
}
Expand Down Expand Up @@ -324,13 +324,19 @@ impl<E: Curve, H: Digest + Clone> RefreshMessage<E, H> {
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