mirror of
https://github.com/status-im/c-kzg-4844.git
synced 2025-01-11 02:35:53 +00:00
Update interface for verify_kzg_proof
This commit is contained in:
parent
9611bfde9a
commit
bcc138560a
@ -63,15 +63,12 @@ C_KZG_RET compute_aggregate_kzg_proof_wrap(uint8_t out[48], const Blob blobs[],
|
||||
int verify_kzg_proof_wrap(const uint8_t c[48], const uint8_t x[32], const uint8_t y[32], const uint8_t p[48], KZGSettings *s) {
|
||||
KZGCommitment commitment;
|
||||
KZGProof proof;
|
||||
BLSFieldElement fx, fy;
|
||||
bool out;
|
||||
|
||||
bytes_to_bls_field(&fx, x);
|
||||
bytes_to_bls_field(&fy, y);
|
||||
if (bytes_to_g1(&commitment, c) != C_KZG_OK) return -1;
|
||||
if (bytes_to_g1(&proof, p) != C_KZG_OK) return -1;
|
||||
|
||||
if (verify_kzg_proof(&out, &commitment, &fx, &fy, &proof, s) != C_KZG_OK)
|
||||
if (verify_kzg_proof(&out, &commitment, x, y, &proof, s) != C_KZG_OK)
|
||||
return -2;
|
||||
|
||||
return out ? 0 : 1;
|
||||
|
@ -306,10 +306,6 @@ Napi::Value VerifyKzgProof(const Napi::CallbackInfo& info) {
|
||||
|
||||
auto kzg_settings = info[4].As<Napi::External<KZGSettings>>().Data();
|
||||
|
||||
BLSFieldElement fz, fy;
|
||||
bytes_to_bls_field(&fz, z);
|
||||
bytes_to_bls_field(&fy, y);
|
||||
|
||||
KZGCommitment commitment;
|
||||
auto ret = bytes_to_g1(&commitment, polynomial_kzg);
|
||||
if (ret != C_KZG_OK) {
|
||||
@ -327,7 +323,7 @@ Napi::Value VerifyKzgProof(const Napi::CallbackInfo& info) {
|
||||
}
|
||||
|
||||
bool out;
|
||||
if (verify_kzg_proof(&out, &commitment, &fz, &fy, &proof, kzg_settings) != C_KZG_OK) {
|
||||
if (verify_kzg_proof(&out, &commitment, z, y, &proof, kzg_settings) != C_KZG_OK) {
|
||||
Napi::TypeError::New(env, "Failed to verify KZG proof").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
@ -934,7 +934,7 @@ void blob_to_kzg_commitment(KZGCommitment *out, const Blob blob, const KZGSettin
|
||||
* @param[in] ks The settings containing the secrets, previously initialised with #new_kzg_settings
|
||||
* @retval C_CZK_OK All is well
|
||||
*/
|
||||
C_KZG_RET verify_kzg_proof(bool *out, const g1_t *commitment, const fr_t *x, const fr_t *y,
|
||||
static C_KZG_RET verify_kzg_proof_impl(bool *out, const g1_t *commitment, const fr_t *x, const fr_t *y,
|
||||
const g1_t *proof, const KZGSettings *ks) {
|
||||
g2_t x_g2, s_minus_x;
|
||||
g1_t y_g1, commitment_minus_y;
|
||||
@ -948,6 +948,18 @@ C_KZG_RET verify_kzg_proof(bool *out, const g1_t *commitment, const fr_t *x, con
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
||||
C_KZG_RET verify_kzg_proof(bool *out,
|
||||
const KZGCommitment *commitment,
|
||||
const uint8_t z[BYTES_PER_FIELD_ELEMENT],
|
||||
const uint8_t y[BYTES_PER_FIELD_ELEMENT],
|
||||
const KZGProof *kzg_proof,
|
||||
const KZGSettings *s) {
|
||||
BLSFieldElement frz, fry;
|
||||
bytes_to_bls_field(&frz, z);
|
||||
bytes_to_bls_field(&fry, y);
|
||||
return verify_kzg_proof_impl(out, commitment, &frz, &fry, kzg_proof, s);
|
||||
}
|
||||
|
||||
static C_KZG_RET evaluate_polynomial_in_evaluation_form(BLSFieldElement *out, const Polynomial p, const BLSFieldElement *x, const KZGSettings *s) {
|
||||
fr_t tmp, *inverses_in, *inverses;
|
||||
uint64_t i;
|
||||
@ -1190,5 +1202,5 @@ C_KZG_RET verify_aggregate_kzg_proof(bool *out,
|
||||
BLSFieldElement y;
|
||||
TRY(evaluate_polynomial_in_evaluation_form(&y, aggregated_poly, &evaluation_challenge, s));
|
||||
|
||||
return verify_kzg_proof(out, &aggregated_poly_commitment, &evaluation_challenge, &y, kzg_aggregated_proof, s);
|
||||
return verify_kzg_proof_impl(out, &aggregated_poly_commitment, &evaluation_challenge, &y, kzg_aggregated_proof, s);
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ void blob_to_kzg_commitment(KZGCommitment *out,
|
||||
|
||||
C_KZG_RET verify_kzg_proof(bool *out,
|
||||
const KZGCommitment *polynomial_kzg,
|
||||
const BLSFieldElement *z,
|
||||
const BLSFieldElement *y,
|
||||
const uint8_t z[BYTES_PER_FIELD_ELEMENT],
|
||||
const uint8_t y[BYTES_PER_FIELD_ELEMENT],
|
||||
const KZGProof *kzg_proof,
|
||||
const KZGSettings *s);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user