Skip to content

Commit

Permalink
Use func prefix macros in all public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
asn-d6 committed Jun 6, 2023
1 parent 2c58b2a commit 6253751
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 83 deletions.
100 changes: 58 additions & 42 deletions src/c_kzg_4844.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,10 @@ static C_KZG_RET poly_to_kzg_commitment(
* @param[in] blob The blob representing the polynomial to be committed to
* @param[in] s The trusted setup
*/
C_KZG_RET blob_to_kzg_commitment(
KZGCommitment *out, const Blob *blob, const KZGSettings *s
PUB_FUNC_IMPL(
C_KZG_RET,
blob_to_kzg_commitment,
(KZGCommitment * out, const Blob *blob, const KZGSettings *s)
) {
C_KZG_RET ret;
Polynomial p;
Expand Down Expand Up @@ -922,13 +924,15 @@ static C_KZG_RET verify_kzg_proof_impl(
* @param[in] kzg_proof The KZG proof
* @param[in] s The trusted setup
*/
C_KZG_RET verify_kzg_proof(
bool *ok,
const Bytes48 *commitment_bytes,
const Bytes32 *z_bytes,
const Bytes32 *y_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s
PUB_FUNC_IMPL(
C_KZG_RET,
verify_kzg_proof,
(bool *ok,
const Bytes48 *commitment_bytes,
const Bytes32 *z_bytes,
const Bytes32 *y_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s)
) {
C_KZG_RET ret;
fr_t z_fr, y_fr;
Expand Down Expand Up @@ -1011,12 +1015,14 @@ static C_KZG_RET compute_kzg_proof_impl(
* @param[in] z The generator z-value for the evaluation points
* @param[in] s The trusted setup
*/
C_KZG_RET compute_kzg_proof(
KZGProof *proof_out,
Bytes32 *y_out,
const Blob *blob,
const Bytes32 *z_bytes,
const KZGSettings *s
PUB_FUNC_IMPL(
C_KZG_RET,
compute_kzg_proof,
(KZGProof * proof_out,
Bytes32 *y_out,
const Blob *blob,
const Bytes32 *z_bytes,
const KZGSettings *s)
) {
C_KZG_RET ret;
Polynomial polynomial;
Expand Down Expand Up @@ -1137,11 +1143,13 @@ static C_KZG_RET compute_kzg_proof_impl(
* @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 Bytes48 *commitment_bytes,
const KZGSettings *s
PUB_FUNC_IMPL(
C_KZG_RET,
compute_blob_kzg_proof,
(KZGProof * out,
const Blob *blob,
const Bytes48 *commitment_bytes,
const KZGSettings *s)
) {
C_KZG_RET ret;
Polynomial polynomial;
Expand Down Expand Up @@ -1178,12 +1186,14 @@ C_KZG_RET compute_blob_kzg_proof(
* @param[in] proof_bytes Proof used for verification
* @param[in] s The trusted setup
*/
C_KZG_RET verify_blob_kzg_proof(
bool *ok,
const Blob *blob,
const Bytes48 *commitment_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s
PUB_FUNC_IMPL(
C_KZG_RET,
verify_blob_kzg_proof,
(bool *ok,
const Blob *blob,
const Bytes48 *commitment_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s)
) {
C_KZG_RET ret;
Polynomial polynomial;
Expand Down Expand Up @@ -1391,14 +1401,16 @@ static C_KZG_RET verify_kzg_proof_batch(
* @param[in] n The number of blobs/commitments/proofs
* @param[in] s The trusted setup
*/
C_KZG_RET verify_blob_kzg_proof_batch(
bool *ok,
const Blob *blobs,
const Bytes48 *commitments_bytes,
const Bytes48 *proofs_bytes,
size_t n,
const KZGSettings *s
) {
PUB_FUNC_IMPL(
C_KZG_RET,
verify_blob_kzg_proof_batch,
(bool *ok,
const Blob *blobs,
const Bytes48 *commitments_bytes,
const Bytes48 *proofs_bytes,
size_t n,
const KZGSettings *s)
) {
C_KZG_RET ret;
g1_t *commitments_g1 = NULL;
g1_t *proofs_g1 = NULL;
Expand Down Expand Up @@ -1648,7 +1660,7 @@ static C_KZG_RET compute_roots_of_unity(
*
* @param[in] s The trusted setup to free
*/
void free_trusted_setup(KZGSettings *s) {
PUB_FUNC_IMPL(void, free_trusted_setup, (KZGSettings * s)) {
if (s == NULL) return;
s->max_width = 0;
c_kzg_free(s->roots_of_unity);
Expand All @@ -1667,12 +1679,14 @@ void free_trusted_setup(KZGSettings *s) {
* @param[in] g2_bytes Array of G2 points in monomial form
* @param[in] n2 Number of `g2` points in g2_bytes
*/
C_KZG_RET load_trusted_setup(
KZGSettings *out,
const uint8_t *g1_bytes,
size_t n1,
const uint8_t *g2_bytes,
size_t n2
PUB_FUNC_IMPL(
C_KZG_RET,
load_trusted_setup,
(KZGSettings * out,
const uint8_t *g1_bytes,
size_t n1,
const uint8_t *g2_bytes,
size_t n2)
) {
C_KZG_RET ret;

Expand Down Expand Up @@ -1759,7 +1773,9 @@ C_KZG_RET load_trusted_setup(
* @param[out] out Pointer to the loaded trusted setup data
* @param[in] in File handle for input
*/
C_KZG_RET load_trusted_setup_file(KZGSettings *out, FILE *in) {
PUB_FUNC_IMPL(
C_KZG_RET, load_trusted_setup_file, (KZGSettings * out, FILE *in)
) {
int num_matches;
uint64_t i;
uint8_t g1_bytes[TRUSTED_SETUP_NUM_G1_POINTS * BYTES_PER_G1];
Expand Down
98 changes: 57 additions & 41 deletions src/c_kzg_4844.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,61 +176,77 @@ typedef struct {
// Interface functions
///////////////////////////////////////////////////////////////////////////////

C_KZG_RET load_trusted_setup(
KZGSettings *out,
const uint8_t *g1_bytes, /* n1 * 48 bytes */
size_t n1,
const uint8_t *g2_bytes, /* n2 * 96 bytes */
size_t n2
PUB_FUNC_DECL(
C_KZG_RET,
load_trusted_setup,
(KZGSettings * out,
const uint8_t *g1_bytes, /* n1 * 48 bytes */
size_t n1,
const uint8_t *g2_bytes, /* n2 * 96 bytes */
size_t n2)
);

C_KZG_RET load_trusted_setup_file(KZGSettings *out, FILE *in);
PUB_FUNC_DECL(
C_KZG_RET, load_trusted_setup_file, (KZGSettings * out, FILE *in)
);

void free_trusted_setup(KZGSettings *s);
PUB_FUNC_DECL(void, free_trusted_setup, (KZGSettings * s));

C_KZG_RET blob_to_kzg_commitment(
KZGCommitment *out, const Blob *blob, const KZGSettings *s
PUB_FUNC_DECL(
C_KZG_RET,
blob_to_kzg_commitment,
(KZGCommitment * out, const Blob *blob, const KZGSettings *s)
);

C_KZG_RET compute_kzg_proof(
KZGProof *proof_out,
Bytes32 *y_out,
const Blob *blob,
const Bytes32 *z_bytes,
const KZGSettings *s
PUB_FUNC_DECL(
C_KZG_RET,
compute_kzg_proof,
(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 Bytes48 *commitment_bytes,
const KZGSettings *s
PUB_FUNC_DECL(
C_KZG_RET,
compute_blob_kzg_proof,
(KZGProof * out,
const Blob *blob,
const Bytes48 *commitment_bytes,
const KZGSettings *s)
);

C_KZG_RET verify_kzg_proof(
bool *ok,
const Bytes48 *commitment_bytes,
const Bytes32 *z_bytes,
const Bytes32 *y_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s
PUB_FUNC_DECL(
C_KZG_RET,
verify_kzg_proof,
(bool *ok,
const Bytes48 *commitment_bytes,
const Bytes32 *z_bytes,
const Bytes32 *y_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s)
);

C_KZG_RET verify_blob_kzg_proof(
bool *ok,
const Blob *blob,
const Bytes48 *commitment_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s
PUB_FUNC_DECL(
C_KZG_RET,
verify_blob_kzg_proof,
(bool *ok,
const Blob *blob,
const Bytes48 *commitment_bytes,
const Bytes48 *proof_bytes,
const KZGSettings *s)
);

C_KZG_RET verify_blob_kzg_proof_batch(
bool *ok,
const Blob *blobs,
const Bytes48 *commitments_bytes,
const Bytes48 *proofs_bytes,
size_t n,
const KZGSettings *s
PUB_FUNC_DECL(
C_KZG_RET,
verify_blob_kzg_proof_batch,
(bool *ok,
const Blob *blobs,
const Bytes48 *commitments_bytes,
const Bytes48 *proofs_bytes,
size_t n,
const KZGSettings *s)
);

#ifdef __cplusplus
Expand Down

0 comments on commit 6253751

Please sign in to comment.