GeScalarMultVartime function
Implementation
void GeScalarMultVartime(
ProjectiveGroupElement r, Uint8List a, ExtendedGroupElement A) {
Int8List aSlide = new Int8List(256);
var Ai = List.generate(8, (index) => CachedGroupElement()); // A,
CompletedGroupElement t = new CompletedGroupElement();
ExtendedGroupElement u = new ExtendedGroupElement();
ExtendedGroupElement A2 = new ExtendedGroupElement();
int i;
slide(aSlide, a);
A.ToCached(Ai[0]);
A.Double(t);
t.ToExtended(A2);
for (i = 0; i < 7; i++) {
geAdd(t, A2, Ai[i]);
t.ToExtended(u);
u.ToCached(Ai[i + 1]);
}
r.Zero();
for (i = 255; i >= 0; i--) {
if (aSlide[i] != 0) {
break;
}
}
for (; i >= 0; i--) {
r.Double(t);
if (aSlide[i] > 0) {
t.ToExtended(u);
geAdd(t, u, Ai[aSlide[i] ~/ 2]);
} else if (aSlide[i] < 0) {
t.ToExtended(u);
geSub(t, u, Ai[(-aSlide[i]) ~/ 2]);
}
t.ToProjective(r);
}
ProjectiveGroupElement ProjBytesExt(ExtendedGroupElement r) {
ProjectiveGroupElement p = new ProjectiveGroupElement();
Uint8List buff = new Uint8List(32);
p.ToBytes(buff);
r.FromBytes(buff);
return p;
}
// I AM FAILING TO ASSERT FromBytes()
//var A2 edwards25519.ExtendedGroupElement
//if ok := r.FromBytes(buff); !ok {
// return nil, errors.New("failed to create an extended group element A2 from A")
//}
}