| ... | @@ -127,12 +127,10 @@ pub const Edwards25519 = struct { | ... | @@ -127,12 +127,10 @@ pub const Edwards25519 = struct { |
| 127 | /// Check that the point does not generate a low-order group. | 127 | /// Check that the point does not generate a low-order group. |
| 128 | /// Return a `WeakPublicKey` error if it does. | 128 | /// Return a `WeakPublicKey` error if it does. |
| 129 | pub fn rejectLowOrder(p: Edwards25519) WeakPublicKeyError!void { | 129 | pub fn rejectLowOrder(p: Edwards25519) WeakPublicKeyError!void { |
| 130 | const zi = p.z.invert(); | 130 | const y_sqrtm1 = Fe.sqrtm1.mul(p.y); |
| 131 | const x = p.x.mul(zi); | 131 | if (p.x.isZero() or p.y.isZero() or p.z.isZero() or |
| 132 | const y = p.y.mul(zi); | 132 | y_sqrtm1.sub(p.x).isZero() or y_sqrtm1.add(p.x).isZero()) |
| 133 | const x_neg = x.neg(); | 133 | { |
| 134 | const iy = Fe.sqrtm1.mul(y); | | |
| 135 | if (x.isZero() or y.isZero() or iy.equivalent(x) or iy.equivalent(x_neg)) { | | |
| 136 | return error.WeakPublicKey; | 134 | return error.WeakPublicKey; |
| 137 | } | 135 | } |
| 138 | } | 136 | } |