Skip to content

Commit

Permalink
Fix serialization for BLS
Browse files Browse the repository at this point in the history
  • Loading branch information
xevisalle committed Nov 4, 2023
1 parent 5d65975 commit 225dea6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/zpie.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions src/zpie.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 225dea6

Please sign in to comment.