in src/mpin256.js [937:987]
KANGAROO: function(E, F) {
var ge = ctx.FP48.fromBytes(E),
gf = ctx.FP48.fromBytes(F),
distance = [],
t = new ctx.FP48(gf),
table = [],
i, j, m, s, dn, dm, res, steps;
s = 1;
for (m = 0; m < this.TS; m++) {
distance[m] = s;
table[m] = new ctx.FP48(t);
s *= 2;
t.usqr();
}
t.one();
dn = 0;
for (j = 0; j < this.TRAP; j++) {
i = t.geta().geta().geta().geta().getA().lastbits(20) % this.TS;
t.mul(table[i]);
dn += distance[i];
}
gf.copy(t);
gf.conj();
steps = 0;
dm = 0;
res = 0;
while (dm - dn < this.MAXPIN) {
steps++;
if (steps > 4 * this.TRAP) {
break;
}
i = ge.geta().geta().geta().geta().getA().lastbits(20) % this.TS;
ge.mul(table[i]);
dm += distance[i];
if (ge.equals(t)) {
res = dm - dn;
break;
}
if (ge.equals(gf)) {
res = dn - dm;
break;
}
}
if (steps > 4 * this.TRAP || dm - dn >= this.MAXPIN) {
res = 0;
} // Trap Failed - probable invalid token
return res;
},