Elliptic curve
epoints := proc(ec, x, ub, p)
local ecurve, z, pct, k, i;
pct := 0;
for k from 0 to p-1 while pct <= ub do
z := subs(x=k, ec) mod p;
if z = 0 then
pct := pct + 1;
ecurve[pct] := [k, z];
fi:
if z &^ ((p-1)/2) mod p = 1 then
z := z &^ ((p+1)/4) mod p; ecurve[pct+1] := [k, z]; ecurve[pct+2] := [k, -z mod p]; pct := pct + 2;
fi: od:
if pct > ub then
pct := ub:
fi:
seq(ecurve[i], i = 1..pct): end:
addec := proc(le, re, c, p)
local i, cle, cre, lambda, res, x3, y3;
cle := le mod p;
cre := re mod p;
if cle = 0 or cre = 0 then
res := cle + cre;
elif cle[1] = cre[1] and cle[2] = -cre[2] mod p then
res := 0; else
if cle[1] = cre[1] mod p and cle[2] = cre[2] mod p
then
lambda := ((3*cle[1]^2+c)/2/cle[2]) mod p; else
lambda := (cre[2]-cle[2])/(cre[1]-cle[1]) mod p; fi:
x3 := (lambda^2-cle[1]-cre[1]) mod p;
y3 := (lambda*(cle[1]-x3)-cle[2]) mod p; res := [x3, y3];
fi:
res; end:
elgamal := proc(alpha, e, c, p)
local calpha, n, y;
read(addec);
calpha := alpha;
n := e;
y := 0;
while n > 0 do
if irem(n, 2, ’n’) = 1 then
y := addec(calpha, y, c, p):
fi:
calpha := addec(calpha, calpha, c, p):
od:
y; end:
a := epoints(eqn, x, 1, p);
b := elgamal(a, n, c, p);
k := 431235145514:
y := elgamal(a, k, c, p);
kb := elgamal(b, k, c, p);
w := [1704130304252114, 2018001913141413]:
z := [ kb[1]*w[1] mod p, kb[2]*w[2] mod p ];
ny := elgamal(y, n, c, p);
The field of post-quantum cryptography is about designing public-key algorithms that cannot be broken by a quantum computer; that is, they would be quantum safe and able to replace RSA and elliptic curve–based algorithms in a future
沒有留言:
發佈留言