def smul
import bend-collections@1.0.0.0/src/crypto/ed25519/point.bend as Pointimport Base
import bend-collections@1.0.0.0/src/crypto/curve25519/x25519.bend as X
100# [bits t = n - 1 .. 0 of bs] p added to 2^n q: double, add, select
101def smul(n: Nat, +c: Cs, +bs: List<&2, U32>, +p: Pt, q: Pt) -> Pt:
102 match n:
103 case 0n:
104 q
105 case 1n+ +t:
106 +q2 = double(q)
107 smul(t, c, bs, p, select(X.kbit(bs, t), q2, add(c, q2, p)))