| ... | ... | @@ -115,7 +115,7 @@ pub const Edwards25519 = struct { |
| 115 | 115 | .add(_1010011)).shift(9).add(_11110101))).shift(7).add(_1100111)).shift(9).add(_11110101).shift(11) |
| 116 | 116 | .add(_10111101)).shift(8).add(_11100111)).shift(9))).shift(6).add(_1011)).shift(14).add(_10010011).shift(10) |
| 117 | 117 | .add(_1100011)).shift(9).add(_10010111)).shift(10))).shift(8).add(_11010011)).shift(8).add(_11101101); |
| 118 | | q.rejectIdentity() catch return; |
| 118 | if (q.x.isZero() and q.y.equivalent(q.z)) return; |
| 119 | 119 | return error.UnexpectedSubgroup; |
| 120 | 120 | } |
| 121 | 121 | |
| ... | ... | @@ -634,4 +634,9 @@ test "subgroup check" { |
| 634 | 634 | _ = try std.fmt.hexToBytes(&bogus, "4dc95e3c28d78c48a60531525e6327e259b7ba0d2f5c81b694052c766a14b625"); |
| 635 | 635 | const p = try Edwards25519.fromBytes(bogus); |
| 636 | 636 | try std.testing.expectError(error.UnexpectedSubgroup, p.rejectUnexpectedSubgroup()); |
| 637 | |
| 638 | var torsion2L: [Edwards25519.encoded_length]u8 = undefined; |
| 639 | _ = try std.fmt.hexToBytes(&torsion2L, "9599999999999999999999999999999999999999999999999999999999999999"); |
| 640 | const p2L = try Edwards25519.fromBytes(torsion2L); |
| 641 | try std.testing.expectError(error.UnexpectedSubgroup, p2L.rejectUnexpectedSubgroup()); |
| 637 | 642 | } |