diff --git a/bindings/csharp/Ckzg.Bindings/Ckzg.cs b/bindings/csharp/Ckzg.Bindings/Ckzg.cs index 142a452..25bce2e 100644 --- a/bindings/csharp/Ckzg.Bindings/Ckzg.cs +++ b/bindings/csharp/Ckzg.Bindings/Ckzg.cs @@ -26,8 +26,9 @@ public class Ckzg /// Prealocated buffer of bytes to receive the commitment /// Flatten array of blob elements /// Trusted setup settings + /// Returns error code or 0 if successful [DllImport("ckzg", EntryPoint = "blob_to_kzg_commitment_wrap", CallingConvention = CallingConvention.Cdecl)] - public unsafe static extern void BlobToKzgCommitment(byte* commitment, byte* blob, IntPtr ts); + public unsafe static extern int BlobToKzgCommitment(byte* commitment, byte* blob, IntPtr ts); /// @@ -37,7 +38,7 @@ public class Ckzg /// Blobs as a flatten byte array /// Blobs count /// Trusted setup settings - /// Returns error code or 0 if succeed + /// Returns error code or 0 if successful [DllImport("ckzg", EntryPoint = "compute_aggregate_kzg_proof_wrap", CallingConvention = CallingConvention.Cdecl)] // returns 0 on success public unsafe static extern int ComputeAggregatedKzgProof(byte* proof, byte* blobs, int count, IntPtr ts); diff --git a/bindings/csharp/ckzg.c b/bindings/csharp/ckzg.c index 429f9bb..1eafbe2 100644 --- a/bindings/csharp/ckzg.c +++ b/bindings/csharp/ckzg.c @@ -24,10 +24,13 @@ void free_trusted_setup_wrap(KZGSettings *s) { free(s); } -void blob_to_kzg_commitment_wrap(uint8_t out[48], const Blob blob, const KZGSettings *s) { +C_KZG_RET blob_to_kzg_commitment_wrap(uint8_t out[48], const Blob blob, const KZGSettings *s) { KZGCommitment c; - blob_to_kzg_commitment(&c, blob, s); + C_KZG_RET ret; + ret = blob_to_kzg_commitment(&c, blob, s); + if (ret != C_KZG_OK) return ret; bytes_from_g1(out, &c); + return C_KZG_OK; } int verify_aggregate_kzg_proof_wrap(const Blob blobs[], const uint8_t commitments[], size_t n, const uint8_t proof[48], const KZGSettings *s) { @@ -56,7 +59,7 @@ C_KZG_RET compute_aggregate_kzg_proof_wrap(uint8_t out[48], const Blob blobs[], KZGProof f; C_KZG_RET ret; ret = compute_aggregate_kzg_proof(&f, blobs, n, s); - if (ret != C_KZG_OK) return -1; + if (ret != C_KZG_OK) return ret; bytes_from_g1(out, &f); return C_KZG_OK; } diff --git a/bindings/csharp/ckzg.h b/bindings/csharp/ckzg.h index 835acd2..80e0c65 100644 --- a/bindings/csharp/ckzg.h +++ b/bindings/csharp/ckzg.h @@ -13,7 +13,7 @@ DLLEXPORT KZGSettings* load_trusted_setup_wrap(const char* file); DLLEXPORT void free_trusted_setup_wrap(KZGSettings *s); -DLLEXPORT void blob_to_kzg_commitment_wrap(uint8_t out[48], const Blob blob, const KZGSettings *s); +DLLEXPORT C_KZG_RET blob_to_kzg_commitment_wrap(uint8_t out[48], const Blob blob, const KZGSettings *s); DLLEXPORT int verify_aggregate_kzg_proof_wrap(const Blob blobs[], const uint8_t commitments[], size_t n, const uint8_t proof[48], const KZGSettings *s); diff --git a/bindings/csharp/kzg_tests.c b/bindings/csharp/kzg_tests.c index c37398a..cfaf8f5 100644 --- a/bindings/csharp/kzg_tests.c +++ b/bindings/csharp/kzg_tests.c @@ -16,7 +16,7 @@ void calculate_proof_and_commitment(char * trusted_setup_path){ n++; } int res0 = compute_aggregate_kzg_proof_wrap(proof, blob, 1, s); - blob_to_kzg_commitment_wrap(commitment, blob, s); + int res1 = blob_to_kzg_commitment_wrap(commitment, blob, s); FILE *f = fopen("output.txt", "wt"); // commitment @@ -34,7 +34,7 @@ void calculate_proof_and_commitment(char * trusted_setup_path){ fclose(f); free(blob); free(commitment); - free(proof); + free(proof); free_trusted_setup_wrap(s); }