mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
std: fix compile errors in std.crypto.ecc (#23797)
Implemented `neg()` method for `AffineCoordinates` struct of p256, p384 and secp256k1 curves. Resolves: #20505 (partially)
This commit is contained in:
parent
369177f0ba
commit
a14352b0b2
@ -471,6 +471,10 @@ pub const AffineCoordinates = struct {
|
|||||||
/// Identity element in affine coordinates.
|
/// Identity element in affine coordinates.
|
||||||
pub const identityElement = AffineCoordinates{ .x = P256.identityElement.x, .y = P256.identityElement.y };
|
pub const identityElement = AffineCoordinates{ .x = P256.identityElement.x, .y = P256.identityElement.y };
|
||||||
|
|
||||||
|
pub fn neg(p: AffineCoordinates) AffineCoordinates {
|
||||||
|
return .{ .x = p.x, .y = p.y.neg() };
|
||||||
|
}
|
||||||
|
|
||||||
fn cMov(p: *AffineCoordinates, a: AffineCoordinates, c: u1) void {
|
fn cMov(p: *AffineCoordinates, a: AffineCoordinates, c: u1) void {
|
||||||
p.x.cMov(a.x, c);
|
p.x.cMov(a.x, c);
|
||||||
p.y.cMov(a.y, c);
|
p.y.cMov(a.y, c);
|
||||||
|
|||||||
@ -471,6 +471,10 @@ pub const AffineCoordinates = struct {
|
|||||||
/// Identity element in affine coordinates.
|
/// Identity element in affine coordinates.
|
||||||
pub const identityElement = AffineCoordinates{ .x = P384.identityElement.x, .y = P384.identityElement.y };
|
pub const identityElement = AffineCoordinates{ .x = P384.identityElement.x, .y = P384.identityElement.y };
|
||||||
|
|
||||||
|
pub fn neg(p: AffineCoordinates) AffineCoordinates {
|
||||||
|
return .{ .x = p.x, .y = p.y.neg() };
|
||||||
|
}
|
||||||
|
|
||||||
fn cMov(p: *AffineCoordinates, a: AffineCoordinates, c: u1) void {
|
fn cMov(p: *AffineCoordinates, a: AffineCoordinates, c: u1) void {
|
||||||
p.x.cMov(a.x, c);
|
p.x.cMov(a.x, c);
|
||||||
p.y.cMov(a.y, c);
|
p.y.cMov(a.y, c);
|
||||||
|
|||||||
@ -549,6 +549,10 @@ pub const AffineCoordinates = struct {
|
|||||||
/// Identity element in affine coordinates.
|
/// Identity element in affine coordinates.
|
||||||
pub const identityElement = AffineCoordinates{ .x = Secp256k1.identityElement.x, .y = Secp256k1.identityElement.y };
|
pub const identityElement = AffineCoordinates{ .x = Secp256k1.identityElement.x, .y = Secp256k1.identityElement.y };
|
||||||
|
|
||||||
|
pub fn neg(p: AffineCoordinates) AffineCoordinates {
|
||||||
|
return .{ .x = p.x, .y = p.y.neg() };
|
||||||
|
}
|
||||||
|
|
||||||
fn cMov(p: *AffineCoordinates, a: AffineCoordinates, c: u1) void {
|
fn cMov(p: *AffineCoordinates, a: AffineCoordinates, c: u1) void {
|
||||||
p.x.cMov(a.x, c);
|
p.x.cMov(a.x, c);
|
||||||
p.y.cMov(a.y, c);
|
p.y.cMov(a.y, c);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user