Add a program to generate outputs for a basic test
This commit is contained in:
parent
3fdc6d37f5
commit
9fa293effc
|
@ -40,7 +40,7 @@ ckzg:
|
|||
# E2e tests as an executable
|
||||
test:
|
||||
@make .blst
|
||||
$(CLANG_EXECUTABLE) -O -w -Wall $(CLANG_FLAGS) ${addprefix -I,${INCLUDE_DIRS}} -o $(TESTS_EXECUTABLE) tests.c $(TARGETS)
|
||||
$(CLANG_EXECUTABLE) -O -w -Wall $(CLANG_FLAGS) ${addprefix -I,${INCLUDE_DIRS}} -o $(TESTS_EXECUTABLE) kzg_tests.c $(TARGETS)
|
||||
|
||||
# E2e tests are built and run
|
||||
run-test:
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
// RUN: make run-test
|
||||
#include "ckzg.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void TestProofs(char * path){
|
||||
KZGSettings *s = load_trusted_setup_wrap(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_wrap(proof, blob, 1, s);
|
||||
blob_to_kzg_commitment_wrap(commitment, blob, s);
|
||||
|
||||
// commitment
|
||||
FILE *f = fopen("output.txt", "wt");
|
||||
for(int i = 0; i< 4096*32; i++){
|
||||
fprintf(f, "%02x", blob[i]);
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
|
||||
for(int i = 0; i< 48; i++){
|
||||
fprintf(f, "%02x", commitment[i]);
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
|
||||
// hash
|
||||
hash(blobHash, commitment, 48);
|
||||
blobHash[0] = 1;
|
||||
for(int i = 0; i< 32; i++){
|
||||
fprintf(f, "%02x", blobHash[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() {
|
||||
TestProofs("devnetv2-geth.txt");
|
||||
return 0;
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1065,7 +1065,7 @@ void sha256_init(SHA256_CTX *ctx);
|
|||
void sha256_update(SHA256_CTX *ctx, const void *_inp, size_t len);
|
||||
void sha256_final(unsigned char md[32], SHA256_CTX *ctx);
|
||||
|
||||
static void hash(uint8_t md[32], uint8_t input[], size_t n) {
|
||||
void hash(uint8_t md[32], uint8_t input[], size_t n) {
|
||||
SHA256_CTX ctx;
|
||||
sha256_init(&ctx);
|
||||
sha256_update(&ctx, input, n);
|
||||
|
|
|
@ -121,6 +121,8 @@ C_KZG_RET verify_kzg_proof(bool *out,
|
|||
const KZGProof *kzg_proof,
|
||||
const KZGSettings *s);
|
||||
|
||||
void hash(uint8_t md[32], uint8_t input[], size_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue