init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using System;
using Org.BouncyCastle.Math.Field;
namespace Org.BouncyCastle.Math.EC;
public abstract class AbstractFpCurve : ECCurve
{
protected AbstractFpCurve(BigInteger q)
: base(FiniteFields.GetPrimeField(q))
{
}
public override bool IsValidFieldElement(BigInteger x)
{
if (x != null && x.SignValue >= 0)
{
return x.CompareTo(Field.Characteristic) < 0;
}
return false;
}
protected override ECPoint DecompressPoint(int yTilde, BigInteger X1)
{
ECFieldElement eCFieldElement = FromBigInteger(X1);
ECFieldElement eCFieldElement2 = eCFieldElement.Square().Add(A).Multiply(eCFieldElement)
.Add(B);
ECFieldElement eCFieldElement3 = eCFieldElement2.Sqrt();
if (eCFieldElement3 == null)
{
throw new ArgumentException("Invalid point compression");
}
if (eCFieldElement3.TestBitZero() != (yTilde == 1))
{
eCFieldElement3 = eCFieldElement3.Negate();
}
return CreateRawPoint(eCFieldElement, eCFieldElement3, withCompression: true);
}
}