mirror of
https://github.com/status-im/c-kzg-4844.git
synced 2025-02-08 08:14:50 +00:00
Change on compute_[blob_]kzg_proof function signatures (#174)
This commit is contained in:
parent
088b062d36
commit
ccf1a4fdf0
@ -65,13 +65,19 @@ static PyObject* compute_kzg_proof_wrap(PyObject *self, PyObject *args) {
|
||||
if (PyBytes_Size(z) != BYTES_PER_FIELD_ELEMENT)
|
||||
return PyErr_Format(PyExc_ValueError, "expected blobs to be BYTES_PER_FIELD_ELEMENT bytes");
|
||||
|
||||
PyObject *out = PyBytes_FromStringAndSize(NULL, BYTES_PER_PROOF);
|
||||
PyObject *py_y = PyBytes_FromStringAndSize(NULL, BYTES_PER_FIELD_ELEMENT);
|
||||
if (py_y == NULL) return PyErr_NoMemory();
|
||||
PyObject *py_proof = PyBytes_FromStringAndSize(NULL, BYTES_PER_PROOF);
|
||||
if (py_proof == NULL) return PyErr_NoMemory();
|
||||
|
||||
PyObject *out = PyTuple_Pack(2, py_proof, py_y);
|
||||
if (out == NULL) return PyErr_NoMemory();
|
||||
|
||||
Blob *blob = (Blob *)PyBytes_AsString(b);
|
||||
Bytes32 *z_bytes = (Bytes32 *)PyBytes_AsString(z);
|
||||
KZGProof *proof = (KZGProof *)PyBytes_AsString(out);
|
||||
if (compute_kzg_proof(proof, blob, z_bytes, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
||||
KZGProof *proof = (KZGProof *)PyBytes_AsString(py_proof);
|
||||
Bytes32 *y_bytes = (Bytes32 *)PyBytes_AsString(py_y);
|
||||
if (compute_kzg_proof(proof, y_bytes, blob, z_bytes, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
||||
Py_DECREF(out);
|
||||
return PyErr_Format(PyExc_RuntimeError, "compute_kzg_proof failed");
|
||||
}
|
||||
@ -80,22 +86,26 @@ static PyObject* compute_kzg_proof_wrap(PyObject *self, PyObject *args) {
|
||||
}
|
||||
|
||||
static PyObject* compute_blob_kzg_proof_wrap(PyObject *self, PyObject *args) {
|
||||
PyObject *b, *s;
|
||||
PyObject *b, *c, *s;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "compute_kzg_proof_wrap", 2, 2, &b, &s) ||
|
||||
if (!PyArg_UnpackTuple(args, "compute_blob_kzg_proof_wrap", 3, 3, &b, &c, &s) ||
|
||||
!PyBytes_Check(b) ||
|
||||
!PyBytes_Check(c) ||
|
||||
!PyCapsule_IsValid(s, "KZGSettings"))
|
||||
return PyErr_Format(PyExc_ValueError, "expected bytes, trusted setup");
|
||||
return PyErr_Format(PyExc_ValueError, "expected bytes, bytes, trusted setup");
|
||||
|
||||
if (PyBytes_Size(b) != BYTES_PER_BLOB)
|
||||
return PyErr_Format(PyExc_ValueError, "expected blobs to be BYTES_PER_BLOB bytes");
|
||||
if (PyBytes_Size(c) != BYTES_PER_COMMITMENT)
|
||||
return PyErr_Format(PyExc_ValueError, "expected commitment to be BYTES_PER_COMMITMENT bytes");
|
||||
|
||||
PyObject *out = PyBytes_FromStringAndSize(NULL, BYTES_PER_PROOF);
|
||||
if (out == NULL) return PyErr_NoMemory();
|
||||
|
||||
Blob *blob = (Blob *)PyBytes_AsString(b);
|
||||
Bytes48 *commitment_bytes = (Bytes48 *)PyBytes_AsString(c);
|
||||
KZGProof *proof = (KZGProof *)PyBytes_AsString(out);
|
||||
if (compute_blob_kzg_proof(proof, blob, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
||||
if (compute_blob_kzg_proof(proof, blob, commitment_bytes, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
||||
Py_DECREF(out);
|
||||
return PyErr_Format(PyExc_RuntimeError, "compute_blob_kzg_proof failed");
|
||||
}
|
||||
|
@ -51,14 +51,17 @@ def test_compute_kzg_proof(ts):
|
||||
z = bytes_from_hex(test["input"]["z"])
|
||||
|
||||
try:
|
||||
proof = ckzg.compute_kzg_proof(blob, z, ts)
|
||||
proof, y = ckzg.compute_kzg_proof(blob, z, ts)
|
||||
except:
|
||||
assert test["output"] is None
|
||||
continue
|
||||
|
||||
expected_proof = bytes_from_hex(test["output"])
|
||||
expected_proof = bytes_from_hex(test["output"][0])
|
||||
assert proof == expected_proof, f"{test_file}\n{proof.hex()=}\n{expected_proof.hex()=}"
|
||||
|
||||
expected_y = bytes_from_hex(test["output"][1])
|
||||
assert y == expected_y, f"{test_file}\n{y.hex()=}\n{expected_y.hex()=}"
|
||||
|
||||
|
||||
def test_compute_blob_kzg_proof(ts):
|
||||
for test_file in glob.glob(COMPUTE_BLOB_KZG_PROOF_TESTS):
|
||||
@ -66,9 +69,10 @@ def test_compute_blob_kzg_proof(ts):
|
||||
test = yaml.safe_load(f)
|
||||
|
||||
blob = bytes_from_hex(test["input"]["blob"])
|
||||
commitment = bytes_from_hex(test["input"]["commitment"])
|
||||
|
||||
try:
|
||||
proof = ckzg.compute_blob_kzg_proof(blob, ts)
|
||||
proof = ckzg.compute_blob_kzg_proof(blob, commitment, ts)
|
||||
except:
|
||||
assert test["output"] is None
|
||||
continue
|
||||
|
@ -1007,7 +1007,8 @@ static C_KZG_RET verify_kzg_proof_impl(
|
||||
|
||||
/* Forward function declaration */
|
||||
static C_KZG_RET compute_kzg_proof_impl(
|
||||
KZGProof *out,
|
||||
KZGProof *proof_out,
|
||||
fr_t *y_out,
|
||||
const Polynomial *polynomial,
|
||||
const fr_t *z,
|
||||
const KZGSettings *s
|
||||
@ -1016,28 +1017,32 @@ static C_KZG_RET compute_kzg_proof_impl(
|
||||
/**
|
||||
* Compute KZG proof for polynomial in Lagrange form at position z.
|
||||
*
|
||||
* @param[out] out The combined proof as a single G1 element
|
||||
* @param[in] blob The blob (polynomial) to generate a proof for
|
||||
* @param[in] z The generator z-value for the evaluation points
|
||||
* @param[in] s The settings containing the secrets, previously
|
||||
* initialised with #new_kzg_settings
|
||||
* @param[out] proof_out The combined proof as a single G1 element
|
||||
* @param[out] y_out The evaluation of the polynomial at the evaluation
|
||||
* point z
|
||||
* @param[in] blob The blob (polynomial) to generate a proof for
|
||||
* @param[in] z The generator z-value for the evaluation points
|
||||
* @param[in] s The settings containing the secrets, previously
|
||||
* initialised with #new_kzg_settings
|
||||
*/
|
||||
C_KZG_RET compute_kzg_proof(
|
||||
KZGProof *out,
|
||||
KZGProof *proof_out,
|
||||
Bytes32 *y_out,
|
||||
const Blob *blob,
|
||||
const Bytes32 *z_bytes,
|
||||
const KZGSettings *s
|
||||
) {
|
||||
C_KZG_RET ret;
|
||||
Polynomial polynomial;
|
||||
fr_t frz;
|
||||
fr_t frz, fry;
|
||||
|
||||
ret = blob_to_polynomial(&polynomial, blob);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
ret = bytes_to_bls_field(&frz, z_bytes);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
ret = compute_kzg_proof_impl(out, &polynomial, &frz, s);
|
||||
ret = compute_kzg_proof_impl(proof_out, &fry, &polynomial, &frz, s);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
bytes_from_bls_field(y_out, &fry);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
@ -1045,26 +1050,28 @@ out:
|
||||
|
||||
/**
|
||||
* Helper function for compute_kzg_proof() and
|
||||
* compute_aggregate_kzg_proof().
|
||||
* compute_blob_kzg_proof().
|
||||
*
|
||||
* @param[out] out The combined proof as a single G1 element
|
||||
* @param[out] proof_out The combined proof as a single G1 element
|
||||
* @param[out] y_out The evaluation of the polynomial at the evaluation
|
||||
* point z
|
||||
* @param[in] polynomial The polynomial in Lagrange form
|
||||
* @param[in] z The evaluation point
|
||||
* @param[in] s The settings containing the secrets, previously
|
||||
* initialised with #new_kzg_settings
|
||||
*/
|
||||
static C_KZG_RET compute_kzg_proof_impl(
|
||||
KZGProof *out,
|
||||
KZGProof *proof_out,
|
||||
fr_t *y_out,
|
||||
const Polynomial *polynomial,
|
||||
const fr_t *z,
|
||||
const KZGSettings *s
|
||||
) {
|
||||
C_KZG_RET ret;
|
||||
fr_t y;
|
||||
fr_t *inverses_in = NULL;
|
||||
fr_t *inverses = NULL;
|
||||
|
||||
ret = evaluate_polynomial_in_evaluation_form(&y, polynomial, z, s);
|
||||
ret = evaluate_polynomial_in_evaluation_form(y_out, polynomial, z, s);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
|
||||
fr_t tmp;
|
||||
@ -1085,7 +1092,7 @@ static C_KZG_RET compute_kzg_proof_impl(
|
||||
continue;
|
||||
}
|
||||
// (p_i - y) / (ω_i - z)
|
||||
blst_fr_sub(&q.evals[i], &polynomial->evals[i], &y);
|
||||
blst_fr_sub(&q.evals[i], &polynomial->evals[i], y_out);
|
||||
blst_fr_sub(&inverses_in[i], &roots_of_unity[i], z);
|
||||
}
|
||||
|
||||
@ -1111,7 +1118,7 @@ static C_KZG_RET compute_kzg_proof_impl(
|
||||
for (i = 0; i < FIELD_ELEMENTS_PER_BLOB; i++) {
|
||||
if (i == m) continue;
|
||||
/* Build numerator: ω_i * (p_i - y) */
|
||||
blst_fr_sub(&tmp, &polynomial->evals[i], &y);
|
||||
blst_fr_sub(&tmp, &polynomial->evals[i], y_out);
|
||||
blst_fr_mul(&tmp, &tmp, &roots_of_unity[i]);
|
||||
/* Do the division: (p_i - y) * ω_i / (z * (z - ω_i)) */
|
||||
blst_fr_mul(&tmp, &tmp, &inverses[i]);
|
||||
@ -1125,7 +1132,7 @@ static C_KZG_RET compute_kzg_proof_impl(
|
||||
);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
|
||||
bytes_from_g1(out, &out_g1);
|
||||
bytes_from_g1(proof_out, &out_g1);
|
||||
|
||||
out:
|
||||
free(inverses_in);
|
||||
@ -1134,30 +1141,38 @@ out:
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a blob, return the KZG proof that is used to verify it against the
|
||||
* commitment.
|
||||
* Given a blob and a commitment, return the KZG proof that is used to verify
|
||||
* it against the commitment. This function does not verify that the commitment
|
||||
* is correct with respect to the blob.
|
||||
*
|
||||
* @param[out] out The resulting proof
|
||||
* @param[in] blob A blob
|
||||
* @param[in] s The trusted setup
|
||||
* @param[out] out The resulting proof
|
||||
* @param[in] blob A blob
|
||||
* @param[in] commitment_bytes Commitment to verify
|
||||
* @param[in] s The trusted setup
|
||||
*/
|
||||
C_KZG_RET compute_blob_kzg_proof(
|
||||
KZGProof *out, const Blob *blob, const KZGSettings *s
|
||||
KZGProof *out,
|
||||
const Blob *blob,
|
||||
const Bytes48 *commitment_bytes,
|
||||
const KZGSettings *s
|
||||
) {
|
||||
C_KZG_RET ret;
|
||||
Polynomial polynomial;
|
||||
g1_t commitment_g1;
|
||||
fr_t evaluation_challenge_fr;
|
||||
fr_t y;
|
||||
|
||||
ret = bytes_to_kzg_commitment(&commitment_g1, commitment_bytes);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
|
||||
ret = blob_to_polynomial(&polynomial, blob);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
|
||||
ret = poly_to_kzg_commitment(&commitment_g1, &polynomial, s);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
|
||||
compute_challenge(&evaluation_challenge_fr, blob, &commitment_g1);
|
||||
|
||||
ret = compute_kzg_proof_impl(out, &polynomial, &evaluation_challenge_fr, s);
|
||||
ret = compute_kzg_proof_impl(
|
||||
out, &y, &polynomial, &evaluation_challenge_fr, s
|
||||
);
|
||||
if (ret != C_KZG_OK) goto out;
|
||||
|
||||
out:
|
||||
|
@ -149,14 +149,18 @@ C_KZG_RET blob_to_kzg_commitment(
|
||||
);
|
||||
|
||||
C_KZG_RET compute_kzg_proof(
|
||||
KZGProof *out,
|
||||
KZGProof *proof_out,
|
||||
Bytes32 *y_out,
|
||||
const Blob *blob,
|
||||
const Bytes32 *z_bytes,
|
||||
const KZGSettings *s
|
||||
);
|
||||
|
||||
C_KZG_RET compute_blob_kzg_proof(
|
||||
KZGProof *out, const Blob *blob, const KZGSettings *s
|
||||
KZGProof *out,
|
||||
const Blob *blob,
|
||||
const Bytes48 *commitment_bytes,
|
||||
const KZGSettings *s
|
||||
);
|
||||
|
||||
C_KZG_RET verify_kzg_proof(
|
||||
|
@ -1032,7 +1032,9 @@ static void test_is_power_of_two__fails_not_powers_of_two(void) {
|
||||
static void test_compute_kzg_proof__succeeds_expected_proof(void) {
|
||||
C_KZG_RET ret;
|
||||
Blob blob;
|
||||
Bytes32 input_value, field_element;
|
||||
Polynomial poly;
|
||||
fr_t y_fr, z_fr;
|
||||
Bytes32 input_value, output_value, field_element, expected_output_value;
|
||||
Bytes48 proof, expected_proof;
|
||||
int diff;
|
||||
|
||||
@ -1050,7 +1052,7 @@ static void test_compute_kzg_proof__succeeds_expected_proof(void) {
|
||||
memcpy(blob.bytes, field_element.bytes, BYTES_PER_FIELD_ELEMENT);
|
||||
|
||||
/* Compute the KZG proof for the given blob & z */
|
||||
ret = compute_kzg_proof(&proof, &blob, &input_value, &s);
|
||||
ret = compute_kzg_proof(&proof, &output_value, &blob, &input_value, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
bytes48_from_hex(
|
||||
@ -1062,17 +1064,36 @@ static void test_compute_kzg_proof__succeeds_expected_proof(void) {
|
||||
/* Compare the computed proof to the expected proof */
|
||||
diff = memcmp(proof.bytes, expected_proof.bytes, sizeof(Bytes48));
|
||||
ASSERT_EQUALS(diff, 0);
|
||||
|
||||
/* Get the expected y by evaluating the polynomial at input_value */
|
||||
ret = blob_to_polynomial(&poly, &blob);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
ret = bytes_to_bls_field(&z_fr, &input_value);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
ret = evaluate_polynomial_in_evaluation_form(&y_fr, &poly, &z_fr, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
bytes_from_bls_field(&expected_output_value, &y_fr);
|
||||
|
||||
/* Compare the computed y to the expected y */
|
||||
diff = memcmp(
|
||||
output_value.bytes, expected_output_value.bytes, sizeof(Bytes32)
|
||||
);
|
||||
ASSERT_EQUALS(diff, 0);
|
||||
}
|
||||
|
||||
static void test_compute_and_verify_kzg_proof__succeeds_round_trip(void) {
|
||||
C_KZG_RET ret;
|
||||
Bytes48 proof;
|
||||
Bytes32 z, y;
|
||||
Bytes32 z, y, computed_y;
|
||||
KZGCommitment c;
|
||||
Blob blob;
|
||||
Polynomial poly;
|
||||
fr_t y_fr, z_fr;
|
||||
bool ok;
|
||||
int diff;
|
||||
|
||||
get_rand_field_element(&z);
|
||||
get_rand_blob(&blob);
|
||||
@ -1082,7 +1103,7 @@ static void test_compute_and_verify_kzg_proof__succeeds_round_trip(void) {
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/* Compute the proof */
|
||||
ret = compute_kzg_proof(&proof, &blob, &z, &s);
|
||||
ret = compute_kzg_proof(&proof, &computed_y, &blob, &z, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/*
|
||||
@ -1103,6 +1124,10 @@ static void test_compute_and_verify_kzg_proof__succeeds_round_trip(void) {
|
||||
/* Now also get `y` in bytes */
|
||||
bytes_from_bls_field(&y, &y_fr);
|
||||
|
||||
/* Compare the recently evaluated y to the computed y */
|
||||
diff = memcmp(y.bytes, computed_y.bytes, sizeof(Bytes32));
|
||||
ASSERT_EQUALS(diff, 0);
|
||||
|
||||
/* Finally verify the proof */
|
||||
ret = verify_kzg_proof(&ok, &c, &z, &y, &proof, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
@ -1116,9 +1141,10 @@ static void test_compute_and_verify_kzg_proof__succeeds_within_domain(void) {
|
||||
KZGCommitment c;
|
||||
Polynomial poly;
|
||||
Bytes48 proof;
|
||||
Bytes32 z, y;
|
||||
Bytes32 z, y, computed_y;
|
||||
fr_t y_fr, z_fr;
|
||||
bool ok;
|
||||
int diff;
|
||||
|
||||
get_rand_blob(&blob);
|
||||
|
||||
@ -1134,7 +1160,7 @@ static void test_compute_and_verify_kzg_proof__succeeds_within_domain(void) {
|
||||
bytes_from_bls_field(&z, &z_fr);
|
||||
|
||||
/* Compute the proof */
|
||||
ret = compute_kzg_proof(&proof, &blob, &z, &s);
|
||||
ret = compute_kzg_proof(&proof, &computed_y, &blob, &z, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/* Now evaluate the poly at `z` to learn `y` */
|
||||
@ -1144,6 +1170,10 @@ static void test_compute_and_verify_kzg_proof__succeeds_within_domain(void) {
|
||||
/* Now also get `y` in bytes */
|
||||
bytes_from_bls_field(&y, &y_fr);
|
||||
|
||||
/* Compare the recently evaluated y to the computed y */
|
||||
diff = memcmp(y.bytes, computed_y.bytes, sizeof(Bytes32));
|
||||
ASSERT_EQUALS(diff, 0);
|
||||
|
||||
/* Finally verify the proof */
|
||||
ret = verify_kzg_proof(&ok, &c, &z, &y, &proof, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
@ -1155,7 +1185,7 @@ static void test_compute_and_verify_kzg_proof__fails_incorrect_proof(void) {
|
||||
C_KZG_RET ret;
|
||||
Bytes48 proof;
|
||||
g1_t proof_g1;
|
||||
Bytes32 z, y;
|
||||
Bytes32 z, y, computed_y;
|
||||
KZGCommitment c;
|
||||
Blob blob;
|
||||
Polynomial poly;
|
||||
@ -1170,7 +1200,7 @@ static void test_compute_and_verify_kzg_proof__fails_incorrect_proof(void) {
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/* Compute the proof */
|
||||
ret = compute_kzg_proof(&proof, &blob, &z, &s);
|
||||
ret = compute_kzg_proof(&proof, &computed_y, &blob, &z, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/*
|
||||
@ -1300,7 +1330,7 @@ static void test_compute_and_verify_blob_kzg_proof__succeeds_round_trip(void) {
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/* Compute the proof */
|
||||
ret = compute_blob_kzg_proof(&proof, &blob, &s);
|
||||
ret = compute_blob_kzg_proof(&proof, &blob, &c, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/* Finally verify the proof */
|
||||
@ -1324,7 +1354,7 @@ static void test_compute_and_verify_blob_kzg_proof__fails_incorrect_proof(void
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/* Compute the proof */
|
||||
ret = compute_blob_kzg_proof(&proof, &blob, &s);
|
||||
ret = compute_blob_kzg_proof(&proof, &blob, &c, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
|
||||
/* Change the proof so it should not verify */
|
||||
@ -1361,8 +1391,29 @@ static void test_compute_and_verify_blob_kzg_proof__fails_proof_not_in_g1(void
|
||||
ASSERT_EQUALS(ret, C_KZG_BADARGS);
|
||||
}
|
||||
|
||||
static void test_compute_and_verify_blob_kzg_proof__fails_commitment_not_in_g1(
|
||||
void
|
||||
static void
|
||||
test_compute_and_verify_blob_kzg_proof__fails_compute_commitment_not_in_g1(void
|
||||
) {
|
||||
C_KZG_RET ret;
|
||||
Bytes48 proof;
|
||||
KZGCommitment c;
|
||||
Blob blob;
|
||||
|
||||
/* Some preparation */
|
||||
get_rand_blob(&blob);
|
||||
bytes48_from_hex(
|
||||
&c,
|
||||
"8123456789abcdef0123456789abcdef0123456789abcdef"
|
||||
"0123456789abcdef0123456789abcdef0123456789abcdef"
|
||||
);
|
||||
|
||||
/* Finally compute the proof */
|
||||
ret = compute_blob_kzg_proof(&proof, &blob, &c, &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_BADARGS);
|
||||
}
|
||||
|
||||
static void
|
||||
test_compute_and_verify_blob_kzg_proof__fails_verify_commitment_not_in_g1(void
|
||||
) {
|
||||
C_KZG_RET ret;
|
||||
Bytes48 proof;
|
||||
@ -1423,7 +1474,9 @@ static void test_verify_kzg_proof_batch__succeeds_round_trip(void) {
|
||||
get_rand_blob(&blobs[i]);
|
||||
ret = blob_to_kzg_commitment(&commitments[i], &blobs[i], &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
ret = compute_blob_kzg_proof(&proofs[i], &blobs[i], &s);
|
||||
ret = compute_blob_kzg_proof(
|
||||
&proofs[i], &blobs[i], &commitments[i], &s
|
||||
);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
}
|
||||
|
||||
@ -1451,7 +1504,9 @@ static void test_verify_kzg_proof_batch__fails_with_incorrect_proof(void) {
|
||||
get_rand_blob(&blobs[i]);
|
||||
ret = blob_to_kzg_commitment(&commitments[i], &blobs[i], &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
ret = compute_blob_kzg_proof(&proofs[i], &blobs[i], &s);
|
||||
ret = compute_blob_kzg_proof(
|
||||
&proofs[i], &blobs[i], &commitments[i], &s
|
||||
);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
}
|
||||
|
||||
@ -1478,7 +1533,9 @@ static void test_verify_kzg_proof_batch__fails_proof_not_in_g1(void) {
|
||||
get_rand_blob(&blobs[i]);
|
||||
ret = blob_to_kzg_commitment(&commitments[i], &blobs[i], &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
ret = compute_blob_kzg_proof(&proofs[i], &blobs[i], &s);
|
||||
ret = compute_blob_kzg_proof(
|
||||
&proofs[i], &blobs[i], &commitments[i], &s
|
||||
);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
}
|
||||
|
||||
@ -1508,7 +1565,9 @@ static void test_verify_kzg_proof_batch__fails_commitment_not_in_g1(void) {
|
||||
get_rand_blob(&blobs[i]);
|
||||
ret = blob_to_kzg_commitment(&commitments[i], &blobs[i], &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
ret = compute_blob_kzg_proof(&proofs[i], &blobs[i], &s);
|
||||
ret = compute_blob_kzg_proof(
|
||||
&proofs[i], &blobs[i], &commitments[i], &s
|
||||
);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
}
|
||||
|
||||
@ -1539,7 +1598,9 @@ static void test_verify_kzg_proof_batch__fails_invalid_blob(void) {
|
||||
get_rand_blob(&blobs[i]);
|
||||
ret = blob_to_kzg_commitment(&commitments[i], &blobs[i], &s);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
ret = compute_blob_kzg_proof(&proofs[i], &blobs[i], &s);
|
||||
ret = compute_blob_kzg_proof(
|
||||
&proofs[i], &blobs[i], &commitments[i], &s
|
||||
);
|
||||
ASSERT_EQUALS(ret, C_KZG_OK);
|
||||
}
|
||||
|
||||
@ -1688,7 +1749,7 @@ static void profile_verify_aggregate_kzg_proof(void) {
|
||||
|
||||
static void profile_compute_kzg_proof(void) {
|
||||
Blob blob;
|
||||
Bytes32 z;
|
||||
Bytes32 z, y;
|
||||
KZGProof out;
|
||||
|
||||
get_rand_blob(&blob);
|
||||
@ -1696,7 +1757,7 @@ static void profile_compute_kzg_proof(void) {
|
||||
|
||||
ProfilerStart("compute_kzg_proof.prof");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
compute_kzg_proof(&out, &blob, &z, &s);
|
||||
compute_kzg_proof(&out, &y, &blob, &z, &s);
|
||||
}
|
||||
ProfilerStop();
|
||||
}
|
||||
@ -1810,7 +1871,10 @@ int main(void) {
|
||||
RUN(test_compute_and_verify_blob_kzg_proof__succeeds_round_trip);
|
||||
RUN(test_compute_and_verify_blob_kzg_proof__fails_incorrect_proof);
|
||||
RUN(test_compute_and_verify_blob_kzg_proof__fails_proof_not_in_g1);
|
||||
RUN(test_compute_and_verify_blob_kzg_proof__fails_commitment_not_in_g1);
|
||||
RUN(test_compute_and_verify_blob_kzg_proof__fails_compute_commitment_not_in_g1
|
||||
);
|
||||
RUN(test_compute_and_verify_blob_kzg_proof__fails_verify_commitment_not_in_g1
|
||||
);
|
||||
RUN(test_compute_and_verify_blob_kzg_proof__fails_invalid_blob);
|
||||
RUN(test_verify_kzg_proof_batch__succeeds_round_trip);
|
||||
RUN(test_verify_kzg_proof_batch__fails_with_incorrect_proof);
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
input: {commitment: '0x8123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
|
||||
z: '0x623ce31cf9759a5c8daf3a357992f9f3dd7f9339d8998bc8e68373e54f00b75e', y: '0x0200000000000000000000000000000000000000000000000000000000000000',
|
||||
z: '0x623ce31cf9759a5c8daf3a357992f9f3dd7f9339d8998bc8e68373e54f00b75e', y: '0x00000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73',
|
||||
proof: '0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'}
|
||||
output: null
|
||||
|
@ -1,4 +1,4 @@
|
||||
input: {commitment: '0x8123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde0',
|
||||
z: '0x00000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73', y: '0x623ce31cf9759a5c8daf3a357992f9f3dd7f9339d8998bc8e68373e54f00b75e',
|
||||
z: '0x00000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73', y: '0xfcffffff0300000004900600f46f09b1ea9f78d9df9f1833df0a8a59b3624930',
|
||||
proof: '0xa69fc1abb7125e6ae566a95cacd832cca426b8c8ecd7397b19a8f003103bc11a508fc6dceab3a2a16cc83782d295c08f'}
|
||||
output: null
|
||||
|
@ -1,4 +1,4 @@
|
||||
input: {commitment: '0xb7f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb',
|
||||
z: '0x01000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73', y: '0x623ce31cf9759a5c8daf3a357992f9f3dd7f9339d8998bc8e68373e54f00b75e',
|
||||
z: '0x01000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73', y: '0x00000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73',
|
||||
proof: '0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'}
|
||||
output: null
|
||||
|
@ -1,4 +1,4 @@
|
||||
input: {commitment: '0xb7f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb',
|
||||
z: '0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff', y: '0x623ce31cf9759a5c8daf3a357992f9f3dd7f9339d8998bc8e68373e54f00b75e',
|
||||
z: '0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff', y: '0x00000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73',
|
||||
proof: '0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'}
|
||||
output: null
|
||||
|
@ -1,4 +1,4 @@
|
||||
input: {commitment: '0xb7f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb',
|
||||
z: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', y: '0x623ce31cf9759a5c8daf3a357992f9f3dd7f9339d8998bc8e68373e54f00b75e',
|
||||
z: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', y: '0x00000000fffffffffe5bfeff02a4bd5305d8a10908d83933487d9d2953a7ed73',
|
||||
proof: '0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'}
|
||||
output: null
|
||||
|
Loading…
x
Reference in New Issue
Block a user