Work in Progress on EC / P+P
parent
7f47ca2eed
commit
91f770c6b1
|
@ -39,14 +39,14 @@
|
|||
<Folder Include="EC\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\sharp-biginteger\BigInt.csproj">
|
||||
<Project>{E745E261-9E3E-4401-B3BA-78B38753A82E}</Project>
|
||||
<Name>BigInt</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\sharp-extensions\sharp.extensions.csproj">
|
||||
<Project>{97CA3CA9-98B3-4492-B072-D7A5995B68E9}</Project>
|
||||
<Name>sharp.extensions</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\BigInteger\BigInt.csproj">
|
||||
<Project>{E745E261-9E3E-4401-B3BA-78B38753A82E}</Project>
|
||||
<Name>BigInt</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -56,7 +56,7 @@ namespace Crypto.EC
|
|||
}
|
||||
|
||||
public bool isOnCurve(CurvePoint p){
|
||||
UInteger py2 = p.Y.Pow(2);
|
||||
UInteger py2 = this.Fp.Fit(p.Y.Pow(2));
|
||||
UInteger pcy2 = Y2(p.X);
|
||||
|
||||
Console.WriteLine("CHECK A: {0}",py2.toHexString());
|
||||
|
@ -79,16 +79,20 @@ namespace Crypto.EC
|
|||
|
||||
if (p1 == p2)
|
||||
{
|
||||
UInteger s = p1.X.Pow(2);
|
||||
s *= 3;
|
||||
// UInteger inv2y = Euclid.inverse(this.Fp.Fit(p1.Y << 1),this.Fp.FieldModulo);
|
||||
UInteger inv2y = Euclid.inverse((p1.Y * 2),this.Fp.FieldModulo);
|
||||
UInteger s = Fp.Fit(p1.X.Pow(3)) * 3;
|
||||
s += p1.Curve.a;
|
||||
s /= (p1.Y << 1);
|
||||
s *= inv2y;
|
||||
|
||||
//(((p1.X.Pow(2) * 3) + p1.Curve.a) / (p1.Y << 1));
|
||||
|
||||
UInteger xR = (s.Pow(2) - (p1.X << 1));
|
||||
UInteger xR = (s.Pow(2) - (p1.X * 2));
|
||||
UInteger yR = ((s * (p1.X - xR)) - p1.Y);
|
||||
|
||||
xR = this.Fp.Fit(xR);
|
||||
yR = this.Fp.Fit(yR);
|
||||
|
||||
return new CurvePoint(p1.Curve, xR, yR);
|
||||
}
|
||||
|
||||
|
@ -102,6 +106,9 @@ namespace Crypto.EC
|
|||
UInteger xR = (s.Pow(2) - p1.X - p2.X);
|
||||
UInteger yR = ((s * (p1.X - xR)) - p1.Y);
|
||||
|
||||
xR = this.Fp.Fit(xR);
|
||||
yR = this.Fp.Fit(yR);
|
||||
|
||||
return new CurvePoint(p1.Curve, xR, yR);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue