diff --git a/src/zpie.c b/src/zpie.c index 351c397..d006814 100644 --- a/src/zpie.c +++ b/src/zpie.c @@ -490,9 +490,9 @@ void store_proof(proof p) int size = 0; - size += mclBnG1_serialize(buff, 32, &p.piA); - size += mclBnG2_serialize(buff + size, 64, &p.piB2); - size += mclBnG1_serialize(buff + size, 32, &p.piC); + size += mclBnG1_serialize(buff, SIZE_G1, &p.piA); + size += mclBnG2_serialize(buff + size, SIZE_G2, &p.piB2); + size += mclBnG1_serialize(buff + size, SIZE_G1, &p.piC); fwrite(buff, 1, size, fproof); fclose(fproof); @@ -516,10 +516,10 @@ proof read_proof() int size = 0; - fread(buff, 1, 128, fproof); - size += mclBnG1_deserialize(&p.piA, buff, 32); - size += mclBnG2_deserialize(&p.piB2, buff + size, 64); - size += mclBnG1_deserialize(&p.piC, buff + size, 32); + fread(buff, 1, SIZE_G1 + SIZE_G2 + SIZE_G1, fproof); + size += mclBnG1_deserialize(&p.piA, buff, SIZE_G1); + size += mclBnG2_deserialize(&p.piB2, buff + size, SIZE_G2); + size += mclBnG1_deserialize(&p.piC, buff + size, SIZE_G1); fclose(fproof); diff --git a/src/zpie.h b/src/zpie.h index 9735422..c367fd5 100644 --- a/src/zpie.h +++ b/src/zpie.h @@ -3,6 +3,8 @@ #ifdef BN128 #define USEDCURVE MCL_BN_SNARK1 #define BITS 254 + #define SIZE_G1 32 + #define SIZE_G2 64 #define PRIMESTR "21888242871839275222246405745257275088548364400416034343698204186575808495617" #define GROUPGEN 5 #define GGEN "1 1 2" @@ -13,6 +15,8 @@ #elif BLS12_381 #define USEDCURVE MCL_BLS12_381 #define BITS 255 + #define SIZE_G1 48 + #define SIZE_G2 96 #define PRIMESTR "52435875175126190479447740508185965837690552500527637822603658699938581184513" #define GROUPGEN 7 #define GGEN "1 3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507 1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569"