2022-11-03 13:08:17 +00:00
|
|
|
|
|
|
|
#include "ckzg.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
void TestE2e(char * path){
|
|
|
|
KZGSettings *s = load_trusted_setup_wrap(path);
|
|
|
|
size_t n = 1;
|
|
|
|
uint8_t *commitments = (uint8_t *)calloc(48, 1);
|
|
|
|
uint8_t *proof = (uint8_t *)calloc(48, 1);
|
|
|
|
uint8_t blobs[] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0xf0,0x08,0x03,0x00,0x00,0x00,0x09,0x8b,0x00,0x19,0xa0,0x00,0x00,0x00,0x04,0x67,0x41,0x4d,0x41,0x00,0x00,0xb1,0x8f,0x0b,0xfc,0x61,0x05,0x00,0x00,0x00,0x01,0x73,0x52,0x47,0x42,0x00,0xae,0xce,0x1c,0xe9,0x00,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0d,0xd7,0x00,0x00,0x0d,0xd7,0x01,0x42,0x28,0x9b,0x78,0x00,0x00,0x02,0xac,0x50,0x4c,0x54,0x45,0x47,0x70,0x00,0x4c,0x62,0x7e,0xea,0x62,0x7e,0xea,0x61,0x7e,0xea,0x62,0x7e,0xea,0x63,0x7d,0xe9,0x62,0x7e,0xea,0x5d,0x5d,0xff,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x00,0x66,0x7c,0xeb,0x5e,0x72,0xff,0x62,0x7e,0xea,0x80,0x80,0xff,0x62,0x7e,0xea,0x00,0x00,0xff,0x62,0x7e,0xea,0x60,0x80,0xdf,0x62,0x7e,0xea,0x62,0x7f,0xea,0x6d,0x00,0x6d,0xdb,0x62,0x7e,0xea,0x62,0x7e,0xea,0x61,0x7d,0xea,0x62,0x7e,0xeb,0x61,0x7f,0xe9,0x62,0x7e,0xea,0x55,0x71,0xe3,0x63,0x7f,0xeb,0x62,0x7e,0xea,0x62,0x7d,0x00,0xe9,0x61,0x7e,0xeb,0x62,0x7e,0xea,0x62,0x7e,0xea,0x61,0x7f,0xe9,0x61,0x7e,0xea,0x62,0x7e,0xea,0x63,0x7e,0xea,0x5d,0x74,0xe8,0x62,0x7f,0xea,0x64,0x7d,0xeb,0x00,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7f,0xe9,0x62,0x7e,0xeb,0x66,0x80,0xe6,0x62,0x7e,0xea,0x61,0x7f,0xea,0x61,0x7d,0xea,0x62,0x7e,0xea,0x64,0x00,0x7d,0xe7,0x62,0x7e,0xea,0x62,0x7d,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xeb,0x62,0x7e,0xea,0x62,0x7f,0xe9,0x62,0x7d,0xea,0x61,0x7d,0x00,0xed,0x64,0x80,0xe8,0x62,0x7e,0xea,0x62,0x7e,0xeb,0x61,0x7f,0xea,0x62,0x7d,0xeb,0x62,0x7e,0xea,0x63,0x7e,0xeb,0x62,0x7d,0xeb,0x62,0x7d,0xe7,0x62,0x7e,0xe9,0x00,0x62,0x7e,0xeb,0x62,0x7d,0xeb,0x63,0x7d,0xeb,0x62,0x7e,0xea,0x63,0x7d,0xee,0x62,0x7e,0xea,0x63,0x7f,0xe9,0x63,0x7d,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x00,0x80,0xe9,0x60,0x7c,0xea,0x61,0x7f,0xea,0x60,0x7e,0xea,0x61,0x7e,0xea,0x62,0x7d,0xeb,0x62,0x7e,0xe9,0x61,0x7d,0xea,0x62,0x7e,0xeb,0x62,0x7e,0xe9,0x62,0x7f,0x00,0xea,0x62,0x7d,0xea,0x62,0x7e,0xea,0x63,0x7f,0xeb,0x62,0x7f,0xea,0x62,0x7e,0xea,0x62,0x7d,0xea,0x61,0x7d,0xec,0x62,0x80,0xea,0x5e,0x79,0xe4,0x62,0x7e,0xea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,0xfc,0xff,0x7d,0x94,0xee,0xa3,0xb4,0xf3,0x9b,0xad,0xf2,0x9c,0xae,0xf2,0x84,0x9a,0xef,0x7a,0x92,0xed,0xd7,0xde,0xfa,0xde,0xe4,0xfb,0xfd,0xfd,0xff,0x8a,0x9f,0x00,0xef,0xc3,0xce,0xf7,0xf5,0xf6,0xfe,0xb4,0xc1,0xf5,0x79,0x91,0xed,0xf3,0xf5,0xfd,0xa5,0xb6,0xf3,0x90,0xa4,0xf0,0xe2,0xe7,0xfb,0xcb,0xd4,0xf8,0xf2,0xf4,0xfd,0x00,0xd6,0xdd,0xf9,0xe1,0xe6,0xfb,0xa8,0xb7,0xf3,0xee,0xf1,0xfd,0xc1,0xcd,0xf6,0xf7,0xf8,0xfe,0xcd,0xd6,0xf8,0xe8,0xec,0xfc,0xf0,0xf3,0xfd,0xb8,0xc4,0xf5,0xba,0x00,0xc6,0xf6,0xc9,0xd2,0xf8,0xb3,0xc1,0xf5,0xd9,0xe0,0xfa,0xeb,0xee,0xfc,0x9a,0xac,0xf2,0xf9,0xfa,0xfe,0xcf,0xd8,0xf9,0xc6,0xd0,0xf7,0x93,0xa6,0xf1,0x7c,0x94,0x00,0xee,0xa0,0xb1,0xf2,0xc5,0xcf,0xf7,0xda,0xe1,0xfa,0x95,0xa8,0xf1,0xbd,0xc9,0xf6,0xe4,0xe9,0xfb,0xb3,0xc0,0xf5,0x96,0xa8,0xf1,0xd3,0xdb,0xf9,0xaf,0xbd,0xf4,0x00,0x4f,0x05,0xb1,0xc2,0x00,0x00,0x00,0x72,0x74,0x52,0x4e,0x53,0x00,0xfb,0x
|
|
|
|
int res0 = compute_aggregate_kzg_proof_wrap(proof, blobs, 1, s);
|
|
|
|
blob_to_kzg_commitment_wrap(commitments, blobs, s);
|
|
|
|
int res = verify_aggregate_kzg_proof_wrap(blobs, commitments, n, proof, s);
|
|
|
|
printf("Proof: %x %x %x\nComm: %x %x %x\nComp: %d\nVerify: %d\n", proof[0], proof[1], proof[2], commitments[0], commitments[1], commitments[2], res0, res);
|
|
|
|
free(commitments);
|
|
|
|
free(proof);
|
|
|
|
free_trusted_setup_wrap(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestGeth(char * path){
|
|
|
|
KZGSettings *s = load_trusted_setup_wrap(path);
|
|
|
|
size_t n = 1;
|
|
|
|
uint8_t commitments[48] = {0xac,0xfd,0xec,0x40,0xe9,0x9b,0x30,0x78,0xb1,0xbe,0x2b,0x19,0xbb,0x48,0x49,0x85,0x44,0x75,0xf1,0xc1,0xd4,0x13,0x77,0xea,0xe5,0x75,0x89,0x73,0x98,0xa2,0x8d,0x1e,0x92,0x1d,0x9f,0x19,0xbc,0x78,0x27,0xb6,0x21,0x12,0x5b,0x3f,0x28,0xe2,0xa0,0x57};
|
|
|
|
uint8_t proof[48] = {0xb4,0x77,0xd9,0x33,0x14,0x10,0xc7,0x40,0x0e,0xe5,0x92,0x21,0xf0,0x49,0x45,0xba,0xf6,0x37,0xae,0x2e,0xa3,0x85,0x00,0xe2,0x90,0x26,0xf2,0x96,0x0a,0xf3,0x7d,0xb7,0xc4,0xa4,0x23,0x46,0xa9,0xf7,0x90,0x99,0x0f,0x12,0x02,0x2b,0xee,0x3c,0x1d,0x2e,};
|
|
|
|
uint8_t blobs[] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0xf0,0x08,0x03,0x00,0x00,0x00,0x09,0x8b,0x00,0x19,0xa0,0x00,0x00,0x00,0x04,0x67,0x41,0x4d,0x41,0x00,0x00,0xb1,0x8f,0x0b,0xfc,0x61,0x05,0x00,0x00,0x00,0x01,0x73,0x52,0x47,0x42,0x00,0xae,0xce,0x1c,0xe9,0x00,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0d,0xd7,0x00,0x00,0x0d,0xd7,0x01,0x42,0x28,0x9b,0x78,0x00,0x00,0x02,0xac,0x50,0x4c,0x54,0x45,0x47,0x70,0x00,0x4c,0x62,0x7e,0xea,0x62,0x7e,0xea,0x61,0x7e,0xea,0x62,0x7e,0xea,0x63,0x7d,0xe9,0x62,0x7e,0xea,0x5d,0x5d,0xff,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x00,0x66,0x7c,0xeb,0x5e,0x72,0xff,0x62,0x7e,0xea,0x80,0x80,0xff,0x62,0x7e,0xea,0x00,0x00,0xff,0x62,0x7e,0xea,0x60,0x80,0xdf,0x62,0x7e,0xea,0x62,0x7f,0xea,0x6d,0x00,0x6d,0xdb,0x62,0x7e,0xea,0x62,0x7e,0xea,0x61,0x7d,0xea,0x62,0x7e,0xeb,0x61,0x7f,0xe9,0x62,0x7e,0xea,0x55,0x71,0xe3,0x63,0x7f,0xeb,0x62,0x7e,0xea,0x62,0x7d,0x00,0xe9,0x61,0x7e,0xeb,0x62,0x7e,0xea,0x62,0x7e,0xea,0x61,0x7f,0xe9,0x61,0x7e,0xea,0x62,0x7e,0xea,0x63,0x7e,0xea,0x5d,0x74,0xe8,0x62,0x7f,0xea,0x64,0x7d,0xeb,0x00,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7f,0xe9,0x62,0x7e,0xeb,0x66,0x80,0xe6,0x62,0x7e,0xea,0x61,0x7f,0xea,0x61,0x7d,0xea,0x62,0x7e,0xea,0x64,0x00,0x7d,0xe7,0x62,0x7e,0xea,0x62,0x7d,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x7e,0xeb,0x62,0x7e,0xea,0x62,0x7f,0xe9,0x62,0x7d,0xea,0x61,0x7d,0x00,0xed,0x64,0x80,0xe8,0x62,0x7e,0xea,0x62,0x7e,0xeb,0x61,0x7f,0xea,0x62,0x7d,0xeb,0x62,0x7e,0xea,0x63,0x7e,0xeb,0x62,0x7d,0xeb,0x62,0x7d,0xe7,0x62,0x7e,0xe9,0x00,0x62,0x7e,0xeb,0x62,0x7d,0xeb,0x63,0x7d,0xeb,0x62,0x7e,0xea,0x63,0x7d,0xee,0x62,0x7e,0xea,0x63,0x7f,0xe9,0x63,0x7d,0xea,0x62,0x7e,0xea,0x62,0x7e,0xea,0x62,0x00,0x80,0xe9,0x60,0x7c,0xea,0x61,0x7f,0xea,0x60,0x7e,0xea,0x61,0x7e,0xea,0x62,0x7d,0xeb,0x62,0x7e,0xe9,0x61,0x7d,0xea,0x62,0x7e,0xeb,0x62,0x7e,0xe9,0x62,0x7f,0x00,0xea,0x62,0x7d,0xea,0x62,0x7e,0xea,0x63,0x7f,0xeb,0x62,0x7f,0xea,0x62,0x7e,0xea,0x62,0x7d,0xea,0x61,0x7d,0xec,0x62,0x80,0xea,0x5e,0x79,0xe4,0x62,0x7e,0xea,0x00,0x63,0x7e,0xeb,0x62,0x7e,0xea,0x63,0x7f,0xea,0x62,0x7e,0xea,0x62,0x7f,0xea,0x61,0x7e,0xe9,0x5e,0x80,0xef,0x63,0x7e,0xeb,0x62,0x7d,0xea,0x61,0x7e,0xea,0xc1,0x00,0xcc,0xf7,0x62,0x7e,0xea,0xff,0xff,0xff,0x81,0x98,0xee,0xdc,0xe2,0xfa,0xad,0xbb,0xf4,0x63,0x7f,0xea,0xc0,0xcb,0xf7,0x64,0x80,0xea,0x65,0x81,0xea,0x6c,0x87,0x00,0xeb,0x68,0x83,0xeb,0xbf,0xca,0xf6,0x66,0x82,0xeb,0x71,0x8a,0xec,0x69,0x84,0xeb,0xfe,0xfe,0xff,0xb1,0xbf,0xf5,0x7b,0x93,0xed,0x98,0xab,0xf2,0x81,0x97,0xee,0x00,0xbd,0xc8,0xf6,0x73,0x8c,0xec,0xa1,0xb2,0xf3,0xbe,0xc9,0xf6,0xbb,0xc7,0xf6,0x91,0xa5,0xf0,0xf8,0xf9,0xfe,0x9e,0xb0,0xf2,0x74,0x8d,0xec,0x88,0x9d,0xef,0x70,0x00,0x89,0xec,0xaa,0x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f1,0x7c,0x94,0x00,0xee,0xa0,0xb1,0xf2,0xc5,0xcf,0xf7,0xda,0xe1,0xfa,0x95,0xa8,0xf1,0xbd,0xc9,0xf6,0xe4,0xe9,0xfb,0xb3,0xc0,0xf5,0x96,0xa8,0xf1,0xd3,0xdb,0xf9,0xaf,0xbd,0xf4,0x00,0x4f,0x05,0xb1,0xc2,0x00,0x00,0x00,0x72,0x74,0x52,0x4e,0x53,0x00,0xfb,0x
|
|
|
|
int res = verify_aggregate_kzg_proof_wrap(blobs, commitments, n, proof, s);
|
|
|
|
printf("Proof: %x %x %x\nComm: %x %x %x\nVerify: %d\n", proof[0], proof[1], proof[2], commitments[0], commitments[1], commitments[2], res);
|
|
|
|
free_trusted_setup_wrap(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
printf("\ndevnetv2-geth.txt\n");
|
|
|
|
TestE2e("devnetv2-geth.txt");
|
|
|
|
printf("\n");
|
|
|
|
TestGeth("devnetv2-geth.txt");
|
|
|
|
|
|
|
|
printf("\ntrusted_setup.txt\n");
|
2022-11-07 16:50:32 +00:00
|
|
|
TestE2e("../../src/trusted_setup.txt");
|
2022-11-03 13:08:17 +00:00
|
|
|
printf("\n");
|
2022-11-07 16:50:32 +00:00
|
|
|
TestGeth("../../src/trusted_setup.txt");
|
2022-11-03 13:08:17 +00:00
|
|
|
}
|