Make verify_*() functions pessimistic by default (#184)

This commit is contained in:
George Kadianakis 2023-03-08 19:00:12 +02:00 committed by GitHub
parent db2fa8dcdb
commit 02b7855eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -932,7 +932,7 @@ static C_KZG_RET verify_kzg_proof_impl(
/**
* Verify a KZG proof claiming that `p(z) == y`.
*
* @param[out] out `true` if the proof is valid, `false` if not
* @param[out] ok `true` if the proof is valid, `false` if not
* @param[in] commitment The KZG commitment corresponding to polynomial
* p(x)
* @param[in] z The evaluation point
@ -942,7 +942,7 @@ static C_KZG_RET verify_kzg_proof_impl(
* verification key (i.e. trusted setup)
*/
C_KZG_RET verify_kzg_proof(
bool *out,
bool *ok,
const Bytes48 *commitment_bytes,
const Bytes32 *z_bytes,
const Bytes32 *y_bytes,
@ -953,6 +953,8 @@ C_KZG_RET verify_kzg_proof(
fr_t z_fr, y_fr;
g1_t commitment_g1, proof_g1;
*ok = false;
ret = bytes_to_kzg_commitment(&commitment_g1, commitment_bytes);
if (ret != C_KZG_OK) return ret;
ret = bytes_to_bls_field(&z_fr, z_bytes);
@ -963,7 +965,7 @@ C_KZG_RET verify_kzg_proof(
if (ret != C_KZG_OK) return ret;
return verify_kzg_proof_impl(
out, &commitment_g1, &z_fr, &y_fr, &proof_g1, s
ok, &commitment_g1, &z_fr, &y_fr, &proof_g1, s
);
}
@ -1202,6 +1204,8 @@ C_KZG_RET verify_blob_kzg_proof(
fr_t evaluation_challenge_fr, y_fr;
g1_t commitment_g1, proof_g1;
*ok = false;
ret = bytes_to_kzg_commitment(&commitment_g1, commitment_bytes);
if (ret != C_KZG_OK) return ret;
@ -1334,6 +1338,8 @@ static C_KZG_RET verify_kzg_proof_batch(
assert(n > 0);
*ok = false;
/* First let's allocate our arrays */
ret = new_fr_array(&r_powers, n);
if (ret != C_KZG_OK) goto out;