mirror of
https://github.com/status-im/c-kzg-4844.git
synced 2025-01-12 03:04:11 +00:00
Change evaluate_polynomial_in_evaluation_form interface
This commit is contained in:
parent
dd242cd93c
commit
5c90a4e5a0
@ -90,28 +90,14 @@ KZGSettings* load_trusted_setup_wrap(const char* file) {
|
||||
return out;
|
||||
}
|
||||
|
||||
int evaluate_polynomial_wrap(uint8_t out[32], const uint8_t pvals[], size_t n, const uint8_t point[32], const KZGSettings *s) {
|
||||
PolynomialEvalForm p;
|
||||
BLSFieldElement* evaluate_polynomial_wrap(const PolynomialEvalForm* p, const BLSFieldElement* z, const KZGSettings *s) {
|
||||
BLSFieldElement *out = (BLSFieldElement*)malloc(sizeof(BLSFieldElement));
|
||||
if (out == NULL) return NULL;
|
||||
|
||||
if (alloc_polynomial(&p, n) != C_KZG_OK)
|
||||
return -1;
|
||||
if (evaluate_polynomial_in_evaluation_form(out, p, z, s) != C_KZG_OK)
|
||||
return NULL;
|
||||
|
||||
for (size_t i = 0; i < n; i++)
|
||||
bytes_to_bls_field(&p.values[i], &pvals[i * 32]);
|
||||
|
||||
BLSFieldElement z;
|
||||
bytes_to_bls_field(&z, point);
|
||||
|
||||
BLSFieldElement r;
|
||||
|
||||
if (evaluate_polynomial_in_evaluation_form(&r, &p, &z, s) != C_KZG_OK) {
|
||||
free_polynomial(&p);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bytes_from_bls_field(out, &r);
|
||||
|
||||
return 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
void free_trusted_setup_wrap(KZGSettings* s) {
|
||||
|
@ -21,8 +21,8 @@ class ckzg
|
||||
[DllImport("ckzg.dll", EntryPoint = "verify_kzg_proof_wrap")]
|
||||
public static extern bool verify_kzg_proof(byte[] c, byte[] x, byte[] y, byte[] p, IntPtr ts);
|
||||
|
||||
[DllImport("ckzg.dll", EntryPoint = "evaluate_polynomial_wrap")]
|
||||
public static extern bool evaluate_polynomial_in_evaluation_form(byte[] result, byte[] p, UInt64 n, byte[] z, IntPtr ts);
|
||||
[DllImport("ckzg.dll", EntryPoint = "evaluate_polynomial_wrap")] // free result with free()
|
||||
public static extern IntPtr evaluate_polynomial_in_evaluation_form(IntPtr p, IntPtr z, IntPtr ts);
|
||||
|
||||
[DllImport("ckzg.dll", EntryPoint = "load_trusted_setup_wrap")] // free result with free_trusted_setup()
|
||||
public static extern IntPtr load_trusted_setup(string filename);
|
||||
@ -40,7 +40,7 @@ class ckzg
|
||||
class tests
|
||||
{
|
||||
IntPtr ts = ckzg.load_trusted_setup("../../src/trusted_setup.txt");
|
||||
|
||||
|
||||
byte[] ssz_of(params object[] anything)
|
||||
{
|
||||
return new byte[1]; //mock
|
||||
@ -103,7 +103,7 @@ class tests
|
||||
ssz_of("PolynomialAndCommitment", aggregated_poly, aggregated_poly_commitment)
|
||||
);
|
||||
// Evaluate aggregated polynomial at `x` (evaluation function checks for div-by-zero)
|
||||
var y = ckzg.evaluate_polynomial_in_evaluation_form(aggregated_poly, x, "need to clarify", "need to clarify", ts);
|
||||
var y = ckzg.evaluate_polynomial_in_evaluation_form(aggregated_poly, x, ts);
|
||||
|
||||
// Verify aggregated proof
|
||||
if (!ckzg.verify_kzg_proof(aggregated_poly_commitment, x, y, "need to clarify", ts))
|
||||
|
Loading…
x
Reference in New Issue
Block a user