| Algorithm A1: Calculation of u∙P + v·Q using the Straus–Shamir trick. |
| Input: u = (ul−1 … u1 u0)2, v = (vl−1 … v1 v0)2 with (ul−1,vl−1) ≠ (0,0); |
| P, Q are points of EC over GF(p), P ≠ Q |
| Output: R = u∙P + v·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 |