Skip to content

Commit 369177f

Browse files
authored
crypto: add sub function to Ristretto255 (ziglang#23724)
1 parent 7401f06 commit 369177f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/std/crypto/25519/ristretto255.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,16 @@ pub const Ristretto255 = struct {
150150
return .{ .p = p.p.add(q.p) };
151151
}
152152

153+
/// Subtract two Ristretto255 elements.
154+
pub inline fn sub(p: Ristretto255, q: Ristretto255) Ristretto255 {
155+
return .{ .p = p.p.sub(q.p) };
156+
}
157+
153158
/// Multiply a Ristretto255 element with a scalar.
154159
/// Return error.WeakPublicKey if the resulting element is
155160
/// the identity element.
156161
pub inline fn mul(p: Ristretto255, s: [encoded_length]u8) (IdentityElementError || WeakPublicKeyError)!Ristretto255 {
157-
return Ristretto255{ .p = try p.p.mul(s) };
162+
return .{ .p = try p.p.mul(s) };
158163
}
159164

160165
/// Return true if two Ristretto255 elements are equivalent

0 commit comments

Comments
 (0)