pub fn mul(self: Self, x: Fe, y: Fe) Fe 796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817 pub fn mul(self: Self, x: Fe, y: Fe) Fe {
if (x.montgomery) {
const y_ = if (!y.montgomery) blk: {
var yy = y;
self.toMontgomery(&yy) catch unreachable;
break :blk yy;
} else y;
return self.montgomeryMul(x, y_);
} else {
var x_m = x;
var y_m = if (y.montgomery) blk: {
var yy = y;
self.fromMontgomery(&yy) catch unreachable;
break :blk yy;
} else y;
self.toMontgomery(&x_m) catch unreachable;
self.toMontgomery(&y_m) catch unreachable;
var out = self.montgomeryMul(x_m, y_m);
self.fromMontgomery(&out) catch unreachable;
return out;
}
}
Multiplies two field elements. Result preserves the first operand's form.