Skip to content

Commit

Permalink
Improve points structs code
Browse files Browse the repository at this point in the history
  • Loading branch information
Coding-Enthusiast committed Dec 31, 2023
1 parent 3891b85 commit 028ee93
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 356 deletions.
2 changes: 1 addition & 1 deletion Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/Calc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void ECMultGenContext()
numsBase = numsBase.AddVar(numsGJ, out _);
}
}
Point.SetAllPointsToJacobianVar(prec, preJ, 1024);
Point.SetAllPointsToJacobianVar(prec, preJ);

for (int j = 0; j < 64; j++)
{
Expand Down
6 changes: 3 additions & 3 deletions Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/DSA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private static PointJacobian StraussWnaf(StraussState state, PointJacobian[] a,
#if DEBUG
Z = Z.NormalizeVar();
#endif
Z.Rescale(ref tmp);
tmp = tmp.Rescale(Z);
}

int index = no * TableSizeWindowA;
Expand Down Expand Up @@ -576,7 +576,7 @@ public bool Verify(Signature sig, in Point pubkey, in Scalar8x32 hash, bool lowS
//
// Thus, we can avoid the inversion, but we have to check both cases separately.
// secp256k1_gej_eq_x implements the (xr * pr.z^2 mod p == pr.x) test.
if (pr.EqualsXVar(xr))
if (pr.EqualsVar(xr))
{
// xr * pr.z^2 mod p == pr.x, so the signature is valid.
return true;
Expand All @@ -588,7 +588,7 @@ public bool Verify(Signature sig, in Point pubkey, in Scalar8x32 hash, bool lowS
}

xr += UInt256_10x26.N;
if (pr.EqualsXVar(xr))
if (pr.EqualsVar(xr))
{
// (xr + n) * pr.z^2 mod p == pr.x, so the signature is valid.
return true;
Expand Down
Loading

0 comments on commit 028ee93

Please sign in to comment.