libbrandt/gp-scripts/smc.gp

36 lines
666 B
Plaintext
Raw Normal View History

2016-06-01 01:08:43 +02:00
/* search for a random prime with the specified amount of bits */
\\ randomprime(bits:small=127)=
\\ {
\\ local(r:int=4);
\\ while(!isprime(r),
\\ r = bitor(2^(bits-1) + random(2^(bits-1)-1), 1);
\\ );
\\ r;
\\ }
smc_hextodec(s:str) =
{
local(v:vecsmall = Vecsmall(s), ret:int = 0);
for(i = 1, #v,
ret = (ret<<4) + if(v[i]<=57 && v[i]>=48, v[i]-48, v[i]<=70 && v[i]>=65, v[i]-55, v[i]<=102 && v[i]>=97, v[i]-87, error("invalid input format"))
);
ret;
}
2016-06-07 15:49:22 +02:00
smc_genbid(k:small, bid:small, g)=
2016-06-01 01:08:43 +02:00
{
2016-06-07 15:49:22 +02:00
vector(k,j,g^(bid==j));
2016-06-01 01:08:43 +02:00
}
2016-06-07 15:49:22 +02:00
smc_genalpha(k:small, b:vec, r:vec, y)=
2016-06-01 01:08:43 +02:00
{
2016-06-07 15:49:22 +02:00
vector(k, j, b[j]*y^r[j]);
2016-06-01 01:08:43 +02:00
}
2016-06-07 15:49:22 +02:00
smc_genbeta(k:small, r:vec, g)=
{
vector(k, j, g^r[j]);
}