Skip to content

Commit

Permalink
Tidying up and variable renames
Browse files Browse the repository at this point in the history
  • Loading branch information
asn-d6 committed Aug 23, 2024
1 parent a406698 commit 0140a6a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/eip7594/eip7594.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,15 @@ static C_KZG_RET compute_r_powers_for_verify_cell_kzg_proof_batch(
/**
* Compute the sum of the commitments weighted by the powers of r.
*
* @param[out] final_g1_sum The resulting G1 sum of the commitments
* @param[in] unique_commitments Array of unique commitments
* @param[in] commitment_indices Indices mapping cells to unique commitments
* @param[in] r_powers Array of powers of r used for weighting
* @param[in] num_commitments The number of unique commitments
* @param[in] num_cells The number of cells
*
* @return C_KZG_OK on success, otherwise error code
* @param[out] sum_of_commitments_out The resulting G1 sum of the commitments
* @param[in] unique_commitments Array of unique commitments
* @param[in] commitment_indices Indices mapping to unique commitments
* @param[in] r_powers Array of powers of r used for weighting
* @param[in] num_commitments The number of unique commitments
* @param[in] num_cells The number of cells
*/
static C_KZG_RET compute_commitment_sum(
g1_t *final_g1_sum,
g1_t *sum_of_commitments_out,
const Bytes48 *unique_commitments,
const uint64_t *commitment_indices,
const fr_t *r_powers,
Expand Down Expand Up @@ -502,7 +500,7 @@ static C_KZG_RET compute_commitment_sum(
}

/* Compute commitment sum */
ret = g1_lincomb_fast(final_g1_sum, commitments_g1, commitment_weights, num_commitments);
ret = g1_lincomb_fast(sum_of_commitments_out, commitments_g1, commitment_weights, num_commitments);
if (ret != C_KZG_OK) goto out;

out:
Expand Down Expand Up @@ -736,7 +734,7 @@ C_KZG_RET verify_cell_kzg_proof_batch(
g1_t interpolation_poly_commit;
g1_t final_g1_sum;
g1_t proof_lincomb;
g1_t weighted_proof_lincomb;
g1_t weighted_sum_of_proofs;
g2_t power_of_s = s->g2_values_monomial[FIELD_ELEMENTS_PER_CELL];
size_t num_commitments;

Expand Down Expand Up @@ -791,7 +789,7 @@ C_KZG_RET verify_cell_kzg_proof_batch(
if (ret != C_KZG_OK) goto out;

////////////////////////////////////////////////////////////////////////////////////////////////
// Compute random linear combination of the proofs
// Compute powers of r, and extract KZG proofs out of input bytes
////////////////////////////////////////////////////////////////////////////////////////////////

/*
Expand All @@ -816,6 +814,10 @@ C_KZG_RET verify_cell_kzg_proof_batch(
if (ret != C_KZG_OK) goto out;
}

////////////////////////////////////////////////////////////////////////////////////////////////
// Compute random linear combination of the proofs
////////////////////////////////////////////////////////////////////////////////////////////////

/* Do the linear combination */
ret = g1_lincomb_fast(&proof_lincomb, proofs_g1, r_powers, num_cells);
if (ret != C_KZG_OK) goto out;
Expand Down Expand Up @@ -846,15 +848,15 @@ C_KZG_RET verify_cell_kzg_proof_batch(
// Compute sum of the proofs scaled by the coset factors
////////////////////////////////////////////////////////////////////////////////////////////////

ret = computed_weighted_sum_of_proofs(&weighted_proof_lincomb,
ret = computed_weighted_sum_of_proofs(&weighted_sum_of_proofs,
proofs_g1,
r_powers,
cell_indices,
num_cells,
s);
if (ret != C_KZG_OK) goto out;

blst_p1_add(&final_g1_sum, &final_g1_sum, &weighted_proof_lincomb);
blst_p1_add(&final_g1_sum, &final_g1_sum, &weighted_sum_of_proofs);

////////////////////////////////////////////////////////////////////////////////////////////////
// Do the final pairing check
Expand Down

0 comments on commit 0140a6a

Please sign in to comment.