adding the needed interface
This commit is contained in:
parent
accc70c6cd
commit
2ad9433a2b
|
@ -1 +1,2 @@
|
|||
generated/
|
||||
generated/
|
||||
*.cxx
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "../../src/c_kzg_4844.h"
|
||||
#include "c_kzg_4844.h"
|
||||
#include "exception.hpp"
|
||||
|
||||
class Fr
|
||||
|
@ -48,14 +48,14 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
static G1 from_compressed(uint8_t arr[48]) throw(KZGException)
|
||||
static G1 from_bytes(uint8_t arr[48]) throw(KZGException)
|
||||
{
|
||||
return G1(arr);
|
||||
}
|
||||
|
||||
G1() {}
|
||||
|
||||
void to_compressed(uint8_t out[48])
|
||||
void to_bytes(uint8_t out[48])
|
||||
{
|
||||
bytes_from_g1(out, &g1);
|
||||
}
|
||||
|
@ -77,14 +77,14 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
static G2 from_compressed(const signed char arr[96]) throw(KZGException)
|
||||
static G2 from_bytes(const signed char arr[96]) throw(KZGException)
|
||||
{
|
||||
return new G2((byte *)arr);
|
||||
}
|
||||
|
||||
G2() {}
|
||||
|
||||
void to_compressed(signed char out[96])
|
||||
void to_bytes(signed char out[96])
|
||||
{
|
||||
blst_p2_compress((byte *)out, &g2);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "setup.hpp"
|
||||
#include "exception.hpp"
|
||||
|
||||
// TODO: make it work
|
||||
|
||||
KZGSetup load_trusted_setup_wrap(const char *file)
|
||||
{
|
||||
KZGSettings *out = malloc(sizeof(KZGSettings));
|
||||
|
@ -25,4 +27,52 @@ void free_trusted_setup_wrap(KZGSetup *s)
|
|||
CKZG_TRY(free_trusted_setup(s_))
|
||||
}
|
||||
|
||||
G1 compute_aggregate_kzg_proof_wrap(const Blob blobs[], size_t n, const KZGSetup *s)
|
||||
{
|
||||
uint8_t out[48];
|
||||
KZGProof f;
|
||||
KZGSettings s_;
|
||||
CKZG_TRY(compute_aggregate_kzg_proof(&f, blobs, n, s_))
|
||||
bytes_from_g1(out, &f);
|
||||
return G1::from_bytes(out)
|
||||
}
|
||||
|
||||
bool verify_aggregate_kzg_proof_wrap(const Blob blobs[],
|
||||
const G1 expected_kzg_commitments[],
|
||||
size_t n,
|
||||
const G1 *kzg_aggregated_proof,
|
||||
const KZGSetup *s)
|
||||
{
|
||||
KZGCommitment expected_kzg_commitments_[];
|
||||
KZGProof kzg_aggregated_proof_;
|
||||
KZGSettings s_;
|
||||
bool out;
|
||||
CKZG_TRY(verify_aggregate_kzg_proof(&out, blobs, expected_kzg_commitments_, n, kzg_aggregated_proof, s_))
|
||||
return out;
|
||||
}
|
||||
|
||||
G1 blob_to_kzg_commitment_wrap(const Blob blob, const KZGSetup *s)
|
||||
{
|
||||
KZGSettings s_;
|
||||
uint8_t out[48];
|
||||
KZGCommitment c;
|
||||
blob_to_kzg_commitment(&c, blob, s_);
|
||||
bytes_from_g1(out, &c);
|
||||
return G1::from_bytes(out)
|
||||
}
|
||||
|
||||
bool verify_kzg_proof_wrap(const G1 *polynomial_kzg,
|
||||
const uint8_t z[BYTES_PER_FIELD_ELEMENT],
|
||||
const uint8_t y[BYTES_PER_FIELD_ELEMENT],
|
||||
const G1 *kzg_proof,
|
||||
const KZGSetup *s)
|
||||
{
|
||||
KZGCommitment commitment;
|
||||
KZGProof proof;
|
||||
KZGSettings s_;
|
||||
bool out;
|
||||
CKZG_TRY(verify_kzg_proof(&out, &commitment, z, y, &proof, s_))
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue