Skip to main content
. 2022 Apr 18;22(8):3083. doi: 10.3390/s22083083
Algorithm A1: Calculation of uP + v·Q using the Straus–Shamir trick.
Input: u = (ul−1u1 u0)2, v = (vl−1v1 v0)2 with (ul−1,vl−1) (0,0);
P, Q are points of EC over GF(p), P ≠ Q
Output: R = u∙P +Q
Precompute: W = P + Q
R = ul−1 ·P+ vl−1 ·Q
for i from l − 2 downto 0 do
  R = 2·R
  if ui = 1 and vi = 1 then R = R + W
   else if ui = 1 and vi  = 0 then R = R + P
     else if ui = 0 and vi = 1 then R = R + Q
end for
return R