authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-07-15 16:48:50-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-05 03:19:32+02:00
logb18436dfad20428e661197a71f4dc12143f4dac0
tree8440fe1aaeb33ef948c8d3076fc1b43e9b589995
parent2bc025186677145805cf97ef75e50c5711597f20

std.crypto.sign.ecdsa: pub Curve and Hash parameters


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

lib/std/crypto/ecdsa.zig+6-3
...@@ -24,14 +24,17 @@ pub const EcdsaSecp256k1Sha256 = Ecdsa(crypto.ecc.Secp256k1, crypto.hash.sha2.Sh...@@ -24,14 +24,17 @@ pub const EcdsaSecp256k1Sha256 = Ecdsa(crypto.ecc.Secp256k1, crypto.hash.sha2.Sh
24pub const EcdsaSecp256k1Sha256oSha256 = Ecdsa(crypto.ecc.Secp256k1, crypto.hash.composition.Sha256oSha256);24pub const EcdsaSecp256k1Sha256oSha256 = Ecdsa(crypto.ecc.Secp256k1, crypto.hash.composition.Sha256oSha256);
2525
26/// Elliptic Curve Digital Signature Algorithm (ECDSA).26/// Elliptic Curve Digital Signature Algorithm (ECDSA).
27pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {27pub fn Ecdsa(comptime C: type, comptime H: type) type {
28 const Prf = switch (Hash) {28 const Prf = switch (H) {
29 sha3.Shake128 => sha3.KMac128,29 sha3.Shake128 => sha3.KMac128,
30 sha3.Shake256 => sha3.KMac256,30 sha3.Shake256 => sha3.KMac256,
31 else => crypto.auth.hmac.Hmac(Hash),31 else => crypto.auth.hmac.Hmac(H),
32 };32 };
3333
34 return struct {34 return struct {
35 pub const Curve = C;
36 pub const Hash = H;
37
35 /// Length (in bytes) of optional random bytes, for non-deterministic signatures.38 /// Length (in bytes) of optional random bytes, for non-deterministic signatures.
36 pub const noise_length = Curve.scalar.encoded_length;39 pub const noise_length = Curve.scalar.encoded_length;
3740