Big H2(ZZn6 y) { // Hash and compress an Fp6 to a big number sha sh; ZZn u,v,w; ZZn2 x; Big a,h,p,xx[2]; char s[HASH_LEN]; int i,j,m; shs_init(&sh); y.get(x); x.get(u,v); xx[0]=u; xx[1]=v; for (i=0;i<2;i++) { a=xx[i]; while (a>0) { m=a%256; shs_process(&sh,m); a/=256; } } shs_hash(&sh,s); h=from_binary(HASH_LEN,s); return h; }
Big H2(ZZn6 x) { // Hash an Fp6 to a big number sha256 sh; ZZn2 u,v,w; ZZn h,l; Big a,hash,p,xx[6]; char s[HASH_LEN]; int i,j,m; shs256_init(&sh); x.get(u,v,w); u.get(l,h); xx[0]=l; xx[1]=h; v.get(l,h); xx[2]=l; xx[3]=h; w.get(l,h); xx[4]=l; xx[5]=h; for (i=0;i<6;i++) { a=xx[i]; while (a>0) { m=a%256; shs256_process(&sh,m); a/=256; } } shs256_hash(&sh,s); hash=from_binary(HASH_LEN,s); return hash; }
Big H2(ZZn18 x) { // Compress and hash an Fp18 to a big number sha256 sh; ZZn6 u; ZZn3 h,l; Big a,hash; ZZn xx[6]; char s[HASH_LEN]; int i,j,m; shs256_init(&sh); x.get(u); // compress to single ZZn6 u.get(l,h); l.get(xx[0],xx[1],xx[2]); h.get(xx[3],xx[4],xx[5]); for (i=0;i<6;i++) { a=(Big)xx[i]; while (a>0) { m=a%256; shs256_process(&sh,m); a/=256; } } shs256_hash(&sh,s); hash=from_binary(HASH_LEN,s); return hash; }
void PFC::add_to_hash(const GT& x) { ZZn6 u; ZZn18 v=x.g; ZZn3 h,l; Big a; ZZn xx[6]; int i,j,m; v.get(u); u.get(l,h); l.get(xx[0],xx[1],xx[2]); h.get(xx[3],xx[4],xx[5]); for (i=0;i<6;i++) { a=(Big)xx[i]; while (a>0) { m=a%256; shs256_process(&SH,m); a/=256; } } }
void unshuffle(ZZn6 &S,ZZn3 &first,ZZn3 &second) { // unshuffle a ZZn6 into two ZZn3's ZZn x0,x1,x2,x3,x4,x5; ZZn2 t0,t1,t2; S.get(t0,t1,t2); t0.get(x0,x3); t1.get(x1,x4); t2.get(x2,x5); first.set(x0,x2,x4); second.set(x1,x3,x5); }
Big H2(ZZn6 x) { // Hash an Fp6 to a big number sha sh; Big a,h,p,xx[6]; char s[20]; int i,j,m; shs_init(&sh); x.get(xx); for (i=0;i<6;i++) { a=xx[i]; while (a>0) { m=a%256; shs_process(&sh,m); a/=256; } } shs_hash(&sh,s); h=from_binary(20,s); return h; }