authorgravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2025-05-05 06:30:59-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-05-05 15:30:59+02:00
log369177f0bac119998c573754ad14896a0492d8c7
tree369c1b90f38cb19a1c3d2a42842edd7d84eeb766
parent7401f06f99ac93aa479dcde2b6e17e2cdbf34a60
signaturebadge-check Signed by PGP key B5690EEEBB952194

crypto: add `sub` function to `Ristretto255` (#23724)


1 files changed, 6 insertions(+), 1 deletions(-)

lib/std/crypto/25519/ristretto255.zig+6-1
......@@ -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