c-kzg-4844/bindings/csharp/kzg_tests.c
Justin Traglia 69f6155d75
Bytes-only interface (#62)
* Convert argument types to bytes

* Update java bindings

* Update python bindings

* Update node.js bindings

* Update c# bindings

* Fix java binding compile issues

* Fix incorrect memcpy in nodejs bindings

* Fix bug (called the wrong func)

* Fix issues with java bindings

* Fix issues with node.js bindings

* Remove unnecessary wrapped funcs for c#

* Rename struct member to bytes

* Use goto out for callocs

* Fix nit

* Make un-exported funcs static

* Fix python bindings

* Check commitment length in python bindings

* Update python error message

* Steal good ideas from #37

* Fix tests.py which didn't get copied over

* Convert remaining a[] to *a

* Add missing Py_DECREF

* Bytes only rust (#1)

* Make interface bytes only
* Fix benches
* Avoid newtypes for kzg types
* Fix benches again
* Make fields private
* tidy
* Address review comments

* Fix one small thing in rust bindings

* Use ckzg types where possible

* Remove null terminator from domain bytes in rust

* Update rust binding docs

* Use BYTES_PER_* where applicable

* Add extra check for calloc

Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
2023-01-16 20:05:23 +00:00

45 lines
1.1 KiB
C

// RUN: make run-test
#include "ckzg.h"
#include <stdio.h>
void calculate_proof_and_commitment(char * trusted_setup_path){
KZGSettings *s = load_trusted_setup_wrap(trusted_setup_path);
size_t n = 1;
uint8_t *commitment = (uint8_t *)calloc(48, 1);
uint8_t *proof = (uint8_t *)calloc(48, 1);
uint8_t *blob = (uint8_t *)calloc(4096, 32);
uint8_t *blobHash = (uint8_t *)calloc(32, 1);
n = 0;
for(int i = 0; i < 5875; i++){
if((n + 1) % 32 == 0)n++;
blob[n] = i % 250;
n++;
}
int res0 = compute_aggregate_kzg_proof(proof, blob, 1, s);
int res1 = blob_to_kzg_commitment(commitment, blob, s);
FILE *f = fopen("output.txt", "wt");
// commitment
for(int i = 0; i < 48; i++){
fprintf(f, "%02x", commitment[i]);
}
fprintf(f, "\n");
// proof
for(int i = 0; i < 48; i++){
fprintf(f, "%02x", proof[i]);
}
fprintf(f, "\n");
fclose(f);
free(blob);
free(commitment);
free(proof);
free_trusted_setup_wrap(s);
}
int main() {
calculate_proof_and_commitment("../../src/trusted_setup.txt");
return 0;
}