authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-09-28 08:01:16+02:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2026-10-01 12:06:49+02:00
loga14e2cda6388e4b3eb2098d01208636b0a1165da
treec0884de18e6e739143e9fffe5a867e130bca34b6
parent4e38cc560315a8f5813fbd976a930601fc7f463b

Fix typo by the way: Endormorphism -> Endomorphism


2 files changed, 4 insertions(+), 4 deletions(-)

lib/std/crypto/pcurves/secp256k1.zig+3-3
...@@ -35,7 +35,7 @@ pub const Secp256k1 = struct {...@@ -35,7 +35,7 @@ pub const Secp256k1 = struct {
3535
36 pub const B = Fe.fromInt(7) catch unreachable;36 pub const B = Fe.fromInt(7) catch unreachable;
3737
38 pub const Endormorphism = struct {38 pub const Endomorphism = struct {
39 const lambda = scalarFromInt(37718080363155996902926221483475020450927657555482586988616620542887997980018);39 const lambda = scalarFromInt(37718080363155996902926221483475020450927657555482586988616620542887997980018);
40 const beta = Fe.fromInt(55594575648329892869085402983802832744385952214688224221778511981742606582254) catch unreachable;40 const beta = Fe.fromInt(55594575648329892869085402983802832744385952214688224221778511981742606582254) catch unreachable;
41 const b1_neg = scalarFromInt(303414439467246543595250775667605759171);41 const b1_neg = scalarFromInt(303414439467246543595250775667605759171);
...@@ -359,11 +359,11 @@ pub const Secp256k1 = struct {...@@ -359,11 +359,11 @@ pub const Secp256k1 = struct {
359 pcs[2 * i] = if (point.is_base) basePointPc[0..9].* else precompute(point, 8);359 pcs[2 * i] = if (point.is_base) basePointPc[0..9].* else precompute(point, 8);
360 // lambda*P360 // lambda*P
361 for (&pcs[2 * i + 1], pcs[2 * i]) |*pc_lambda, pc| {361 for (&pcs[2 * i + 1], pcs[2 * i]) |*pc_lambda, pc| {
362 pc_lambda.* = .{ .x = pc.x.mul(Endormorphism.beta), .y = pc.y, .z = pc.z };362 pc_lambda.* = .{ .x = pc.x.mul(Endomorphism.beta), .y = pc.y, .z = pc.z };
363 }363 }
364 var s48: [48]u8 = undefined;364 var s48: [48]u8 = undefined;
365 mem.writeInt(u384, &s48, mem.readInt(u256, &k, endian), .little);365 mem.writeInt(u384, &s48, mem.readInt(u256, &k, endian), .little);
366 const split = Endormorphism.splitScalar(scalar.reduce48(s48, .little), .little) catch unreachable;366 const split = Endomorphism.splitScalar(scalar.reduce48(s48, .little), .little) catch unreachable;
367367
368 for ([_][32]u8{ split.r1, split.r2 }, es[2 * i ..][0..2]) |r, *e| {368 for ([_][32]u8{ split.r1, split.r2 }, es[2 * i ..][0..2]) |r, *e| {
369 const x = mem.readInt(u256, &r, .little);369 const x = mem.readInt(u256, &r, .little);
lib/std/crypto/pcurves/tests/secp256k1.zig+1-1
...@@ -164,7 +164,7 @@ test "secp256k1 scalar split" {...@@ -164,7 +164,7 @@ test "secp256k1 scalar split" {
164 var lambda_s: [32]u8 = undefined;164 var lambda_s: [32]u8 = undefined;
165 std.mem.writeInt(u256, &lambda_s, lambda, endian);165 std.mem.writeInt(u256, &lambda_s, lambda, endian);
166 const k = Secp256k1.scalar.random(io, endian);166 const k = Secp256k1.scalar.random(io, endian);
167 const split = try Secp256k1.Endormorphism.splitScalar(k, endian);167 const split = try Secp256k1.Endomorphism.splitScalar(k, endian);
168 try testing.expectEqual(k, try Secp256k1.scalar.mulAdd(split.r2, lambda_s, split.r1, endian));168 try testing.expectEqual(k, try Secp256k1.scalar.mulAdd(split.r2, lambda_s, split.r1, endian));
169 for ([_][32]u8{ split.r1, split.r2 }) |r_s| {169 for ([_][32]u8{ split.r1, split.r2 }) |r_s| {
170 const r = std.mem.readInt(u256, &r_s, endian);170 const r = std.mem.readInt(u256, &r_s, endian);