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