2022-11-16 15:51:26 +00:00
|
|
|
// RUN: make run-test
|
|
|
|
#include "ckzg.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2022-11-22 07:44:34 +00:00
|
|
|
void calculate_proof_and_commitment(char * trusted_setup_path){
|
|
|
|
KZGSettings *s = load_trusted_setup_wrap(trusted_setup_path);
|
2022-11-16 15:51:26 +00:00
|
|
|
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++;
|
|
|
|
}
|
2023-01-16 20:05:23 +00:00
|
|
|
int res0 = compute_aggregate_kzg_proof(proof, blob, 1, s);
|
|
|
|
int res1 = blob_to_kzg_commitment(commitment, blob, s);
|
2022-11-16 15:51:26 +00:00
|
|
|
|
|
|
|
FILE *f = fopen("output.txt", "wt");
|
2022-11-16 16:43:36 +00:00
|
|
|
// commitment
|
2023-01-16 20:05:23 +00:00
|
|
|
for(int i = 0; i < 48; i++){
|
2022-11-16 15:51:26 +00:00
|
|
|
fprintf(f, "%02x", commitment[i]);
|
|
|
|
}
|
|
|
|
fprintf(f, "\n");
|
|
|
|
|
|
|
|
// proof
|
2023-01-16 20:05:23 +00:00
|
|
|
for(int i = 0; i < 48; i++){
|
2022-11-16 15:51:26 +00:00
|
|
|
fprintf(f, "%02x", proof[i]);
|
|
|
|
}
|
|
|
|
fprintf(f, "\n");
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
free(blob);
|
|
|
|
free(commitment);
|
2023-01-09 21:22:13 +00:00
|
|
|
free(proof);
|
2022-11-16 15:51:26 +00:00
|
|
|
free_trusted_setup_wrap(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
2022-11-22 07:44:34 +00:00
|
|
|
calculate_proof_and_commitment("../../src/trusted_setup.txt");
|
2022-11-16 15:51:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|