commit 37bc2b60eabc8233e23e32d017fb744c53d5dffe
parent 1a8c646542dcd7f6dad59f60c303289565cef824
Author: Armin Preiml <apreiml@strohwolke.at>
Date: Tue, 25 Jun 2024 14:47:38 +0200
crypto:ec: be more strict with return values
Signed-off-by: Armin Preiml <apreiml@strohwolke.at>
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/ec/types.ha b/crypto/ec/types.ha
@@ -38,7 +38,7 @@ export type curve = struct {
generator: *fn () const []u8, // XXX: change to const []u8, when possible
// Multiply curve point 'p' by scalar 'x'. The result is stored in 'r'.
- // Returns a value > 0 on success.
+ // Returns 1 on success.
//
// Point 'p' must be a valid point on the curve subgroup. If this is
// not the case the function fails with 0 as result.
@@ -60,7 +60,7 @@ export type curve = struct {
// Returns 0 in case of failure. Validates that the provided points are
// part of the relevant curve subgroup.
//
- // Returns a value > 0 on success and 0 otherwise.
+ // Returns 1 on success.
muladd: *fn (a: []u8, b: []u8, x: []u8, y: []u8) u32,
// Generate a private key from given random seed 'rand'. The function
diff --git a/crypto/ecdsa/ecdsa.ha b/crypto/ecdsa/ecdsa.ha
@@ -162,7 +162,7 @@ export fn verify(pub: *pubkey, hash: []u8, sig: []u8) (void | error) = {
res &= ~bigint::sub(t1, r, 1);
res &= bigint::iszero(t1);
- if (res == 0) {
+ if (res != 1) {
return invalidsig;
};
};