pub fn sub(self: Self, x: Fe, y: Fe) Fe 563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580 pub fn sub(self: Self, x: Fe, y: Fe) Fe {
var out = x;
if (x.montgomery == y.montgomery) {
const underflow: bool = @bitCast(out.v.subWithOverflow(y.v));
_ = out.v.conditionalAddWithOverflow(underflow, self.v);
return out;
} else {
var y_ = y;
if (y.montgomery) {
self.fromMontgomery(&y_) catch unreachable;
} else {
self.toMontgomery(&y_) catch unreachable;
}
const underflow: bool = @bitCast(out.v.subWithOverflow(y_.v));
_ = out.v.conditionalAddWithOverflow(underflow, self.v);
return out;
}
}
Subtracts two field elements (mod m).