| ... | ... | @@ -175,6 +175,10 @@ pub const Ed25519 = struct { |
| 175 | 175 | self.h.update(msg); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | fn isIdentity(p: Curve) bool { |
| 179 | return p.x.isZero() and p.y.equivalent(p.z); |
| 180 | } |
| 181 | |
| 178 | 182 | pub const VerifyError = WeakPublicKeyError || IdentityElementError || |
| 179 | 183 | SignatureVerificationError; |
| 180 | 184 | |
| ... | ... | @@ -195,9 +199,9 @@ pub const Ed25519 = struct { |
| 195 | 199 | hram, |
| 196 | 200 | )); |
| 197 | 201 | const check = sb_ah.sub(self.expected_r.clearCofactor()); |
| 198 | | if (check.rejectIdentity()) |_| { |
| 202 | if (!isIdentity(check)) { |
| 199 | 203 | return error.SignatureVerificationFailed; |
| 200 | | } else |_| {} |
| 204 | } |
| 201 | 205 | } |
| 202 | 206 | |
| 203 | 207 | /// Verify that the signature is valid for the entire message using cofactorless verification. |
| ... | ... | @@ -221,9 +225,9 @@ pub const Ed25519 = struct { |
| 221 | 225 | hram, |
| 222 | 226 | )); |
| 223 | 227 | const check = sb_ah.sub(self.expected_r); |
| 224 | | if (check.rejectIdentity()) |_| { |
| 228 | if (!isIdentity(check)) { |
| 225 | 229 | return error.SignatureVerificationFailed; |
| 226 | | } else |_| {} |
| 230 | } |
| 227 | 231 | } |
| 228 | 232 | }; |
| 229 | 233 | |