|
@@ -399,7 +399,7 @@ var
|
|
|
begin
|
|
begin
|
|
|
LCoord := GetCurveCoordinateSystem();
|
|
LCoord := GetCurveCoordinateSystem();
|
|
|
Result := (LCoord = TECCurveConstants.COORD_AFFINE) or (LCoord = TECCurveConstants.COORD_LAMBDA_AFFINE) or
|
|
Result := (LCoord = TECCurveConstants.COORD_AFFINE) or (LCoord = TECCurveConstants.COORD_LAMBDA_AFFINE) or
|
|
|
- GetIsInfinity or RawZCoords[0].GetIsOne;
|
|
|
|
|
|
|
+ IsInfinity or RawZCoords[0].IsOne;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
function TECPoint.SatisfiesOrder: Boolean;
|
|
function TECPoint.SatisfiesOrder: Boolean;
|
|
@@ -413,7 +413,7 @@ begin
|
|
|
if LOrder.Equals(TBigInteger.GetDefault()) then
|
|
if LOrder.Equals(TBigInteger.GetDefault()) then
|
|
|
Exit(True);
|
|
Exit(True);
|
|
|
LMult := TECAlgorithms.ReferenceMultiply(Self as IECPoint, LOrder);
|
|
LMult := TECAlgorithms.ReferenceMultiply(Self as IECPoint, LOrder);
|
|
|
- Result := LMult.GetIsInfinity;
|
|
|
|
|
|
|
+ Result := LMult.IsInfinity;
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
function TECPoint.CreateScaledPoint(const ASx, ASy: IECFieldElement): IECPoint;
|
|
function TECPoint.CreateScaledPoint(const ASx, ASy: IECFieldElement): IECPoint;
|
|
@@ -563,7 +563,7 @@ var
|
|
|
LX, LY: TCryptoLibByteArray;
|
|
LX, LY: TCryptoLibByteArray;
|
|
|
LLen: Int32;
|
|
LLen: Int32;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
begin
|
|
begin
|
|
|
System.SetLength(Result, 1);
|
|
System.SetLength(Result, 1);
|
|
|
Result[0] := $00;
|
|
Result[0] := $00;
|
|
@@ -590,7 +590,7 @@ end;
|
|
|
|
|
|
|
|
function TECPointBase.GetEncodedLength(ACompressed: Boolean): Int32;
|
|
function TECPointBase.GetEncodedLength(ACompressed: Boolean): Int32;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(1);
|
|
Exit(1);
|
|
|
if ACompressed then
|
|
if ACompressed then
|
|
|
Exit(1 + XCoord.GetEncodedLength())
|
|
Exit(1 + XCoord.GetEncodedLength())
|
|
@@ -603,7 +603,7 @@ var
|
|
|
LNormed: IECPoint;
|
|
LNormed: IECPoint;
|
|
|
LXLen: Int32;
|
|
LXLen: Int32;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
begin
|
|
begin
|
|
|
ABuf[AOff] := $00;
|
|
ABuf[AOff] := $00;
|
|
|
Exit;
|
|
Exit;
|
|
@@ -659,7 +659,7 @@ var
|
|
|
LValidity: IValidityPreCompInfo;
|
|
LValidity: IValidityPreCompInfo;
|
|
|
LResult: IPreCompInfo;
|
|
LResult: IPreCompInfo;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(True);
|
|
Exit(True);
|
|
|
LCallback := TValidityCallback.Create(Self, ADecompressed, ACheckOrder);
|
|
LCallback := TValidityCallback.Create(Self, ADecompressed, ACheckOrder);
|
|
|
LResult := FCurve.Precompute(Self as IECPoint, TValidityPreCompInfo.PRECOMP_NAME, LCallback);
|
|
LResult := FCurve.Precompute(Self as IECPoint, TValidityPreCompInfo.PRECOMP_NAME, LCallback);
|
|
@@ -679,7 +679,7 @@ end;
|
|
|
|
|
|
|
|
function TECPoint.ScaleX(const AScale: IECFieldElement): IECPoint;
|
|
function TECPoint.ScaleX(const AScale: IECFieldElement): IECPoint;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Result := Self as IECPoint
|
|
Result := Self as IECPoint
|
|
|
else
|
|
else
|
|
|
Result := FCurve.CreateRawPoint(RawXCoord.Multiply(AScale), RawYCoord, RawZCoords);
|
|
Result := FCurve.CreateRawPoint(RawXCoord.Multiply(AScale), RawYCoord, RawZCoords);
|
|
@@ -687,7 +687,7 @@ end;
|
|
|
|
|
|
|
|
function TECPoint.ScaleXNegateY(const AScale: IECFieldElement): IECPoint;
|
|
function TECPoint.ScaleXNegateY(const AScale: IECFieldElement): IECPoint;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Result := Self as IECPoint
|
|
Result := Self as IECPoint
|
|
|
else
|
|
else
|
|
|
Result := FCurve.CreateRawPoint(RawXCoord.Multiply(AScale), RawYCoord.Negate(), RawZCoords);
|
|
Result := FCurve.CreateRawPoint(RawXCoord.Multiply(AScale), RawYCoord.Negate(), RawZCoords);
|
|
@@ -695,7 +695,7 @@ end;
|
|
|
|
|
|
|
|
function TECPoint.ScaleY(const AScale: IECFieldElement): IECPoint;
|
|
function TECPoint.ScaleY(const AScale: IECFieldElement): IECPoint;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Result := Self as IECPoint
|
|
Result := Self as IECPoint
|
|
|
else
|
|
else
|
|
|
Result := FCurve.CreateRawPoint(RawXCoord, RawYCoord.Multiply(AScale), RawZCoords);
|
|
Result := FCurve.CreateRawPoint(RawXCoord, RawYCoord.Multiply(AScale), RawZCoords);
|
|
@@ -703,7 +703,7 @@ end;
|
|
|
|
|
|
|
|
function TECPoint.ScaleYNegateX(const AScale: IECFieldElement): IECPoint;
|
|
function TECPoint.ScaleYNegateX(const AScale: IECFieldElement): IECPoint;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Result := Self as IECPoint
|
|
Result := Self as IECPoint
|
|
|
else
|
|
else
|
|
|
Result := FCurve.CreateRawPoint(RawXCoord.Negate(), RawYCoord.Multiply(AScale), RawZCoords);
|
|
Result := FCurve.CreateRawPoint(RawXCoord.Negate(), RawYCoord.Multiply(AScale), RawZCoords);
|
|
@@ -721,12 +721,12 @@ begin
|
|
|
if (Self as IECPoint) = AOther then
|
|
if (Self as IECPoint) = AOther then
|
|
|
Exit(True);
|
|
Exit(True);
|
|
|
|
|
|
|
|
- LC1 := GetCurve();
|
|
|
|
|
|
|
+ LC1 := Curve;
|
|
|
LC2 := AOther.Curve;
|
|
LC2 := AOther.Curve;
|
|
|
LN1 := LC1 = nil;
|
|
LN1 := LC1 = nil;
|
|
|
LN2 := LC2 = nil;
|
|
LN2 := LC2 = nil;
|
|
|
- LI1 := GetIsInfinity;
|
|
|
|
|
- LI2 := AOther.GetIsInfinity;
|
|
|
|
|
|
|
+ LI1 := IsInfinity;
|
|
|
|
|
+ LI2 := AOther.IsInfinity;
|
|
|
|
|
|
|
|
if LI1 or LI2 then
|
|
if LI1 or LI2 then
|
|
|
Exit((LI1 and LI2) and (LN1 or LN2 or LC1.Equals(LC2)));
|
|
Exit((LI1 and LI2) and (LN1 or LN2 or LC1.Equals(LC2)));
|
|
@@ -764,7 +764,7 @@ begin
|
|
|
else
|
|
else
|
|
|
Result := not LC.GetHashCode();
|
|
Result := not LC.GetHashCode();
|
|
|
|
|
|
|
|
- if not GetIsInfinity then
|
|
|
|
|
|
|
+ if not IsInfinity then
|
|
|
begin
|
|
begin
|
|
|
LP := Normalize();
|
|
LP := Normalize();
|
|
|
Result := Result xor ((LP.XCoord.GetHashCode()) * 17);
|
|
Result := Result xor ((LP.XCoord.GetHashCode()) * 17);
|
|
@@ -776,7 +776,7 @@ function TECPoint.ToString: String;
|
|
|
var
|
|
var
|
|
|
I: Int32;
|
|
I: Int32;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit('INF');
|
|
Exit('INF');
|
|
|
|
|
|
|
|
Result := '(' + RawXCoord.ToString() + ',' + RawYCoord.ToString();
|
|
Result := '(' + RawXCoord.ToString() + ',' + RawYCoord.ToString();
|
|
@@ -810,7 +810,7 @@ begin
|
|
|
TECCurveConstants.COORD_HOMOGENEOUS:
|
|
TECCurveConstants.COORD_HOMOGENEOUS:
|
|
|
begin
|
|
begin
|
|
|
Z := RawZCoords[0];
|
|
Z := RawZCoords[0];
|
|
|
- if not Z.GetIsOne then
|
|
|
|
|
|
|
+ if not Z.IsOne then
|
|
|
begin
|
|
begin
|
|
|
Z2 := Z.Square();
|
|
Z2 := Z.Square();
|
|
|
Z3 := Z2.Multiply(Z);
|
|
Z3 := Z2.Multiply(Z);
|
|
@@ -822,7 +822,7 @@ begin
|
|
|
TECCurveConstants.COORD_JACOBIAN, TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY, TECCurveConstants.COORD_JACOBIAN_MODIFIED:
|
|
TECCurveConstants.COORD_JACOBIAN, TECCurveConstants.COORD_JACOBIAN_CHUDNOVSKY, TECCurveConstants.COORD_JACOBIAN_MODIFIED:
|
|
|
begin
|
|
begin
|
|
|
Z := RawZCoords[0];
|
|
Z := RawZCoords[0];
|
|
|
- if not Z.GetIsOne then
|
|
|
|
|
|
|
+ if not Z.IsOne then
|
|
|
begin
|
|
begin
|
|
|
Z2 := Z.Square();
|
|
Z2 := Z.Square();
|
|
|
Z4 := Z2.Square();
|
|
Z4 := Z2.Square();
|
|
@@ -840,7 +840,7 @@ end;
|
|
|
|
|
|
|
|
function TAbstractFpPoint.Subtract(const AB: IECPoint): IECPoint;
|
|
function TAbstractFpPoint.Subtract(const AB: IECPoint): IECPoint;
|
|
|
begin
|
|
begin
|
|
|
- if AB.GetIsInfinity then
|
|
|
|
|
|
|
+ if AB.IsInfinity then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
Result := Add(AB.Negate());
|
|
Result := Add(AB.Negate());
|
|
|
end;
|
|
end;
|
|
@@ -902,7 +902,7 @@ var
|
|
|
La4, La4Neg, LW, LZSq: IECFieldElement;
|
|
La4, La4Neg, LW, LZSq: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
La4 := FCurve.A;
|
|
La4 := FCurve.A;
|
|
|
- if La4.GetIsZero or AZ.IsOne then
|
|
|
|
|
|
|
+ if La4.IsZero or AZ.IsOne then
|
|
|
Exit(La4);
|
|
Exit(La4);
|
|
|
|
|
|
|
|
LZSq := AZSquared;
|
|
LZSq := AZSquared;
|
|
@@ -1071,9 +1071,9 @@ begin
|
|
|
// coZ addition
|
|
// coZ addition
|
|
|
Dx := X1.Subtract(X2);
|
|
Dx := X1.Subtract(X2);
|
|
|
Dy := Y1.Subtract(Y2);
|
|
Dy := Y1.Subtract(Y2);
|
|
|
- if Dx.GetIsZero then
|
|
|
|
|
|
|
+ if Dx.IsZero then
|
|
|
begin
|
|
begin
|
|
|
- if Dy.GetIsZero then
|
|
|
|
|
|
|
+ if Dy.IsZero then
|
|
|
Exit(Twice());
|
|
Exit(Twice());
|
|
|
Exit(LCurve.Infinity);
|
|
Exit(LCurve.Infinity);
|
|
|
end;
|
|
end;
|
|
@@ -1311,8 +1311,8 @@ begin
|
|
|
TECCurveConstants.COORD_AFFINE:
|
|
TECCurveConstants.COORD_AFFINE:
|
|
|
begin
|
|
begin
|
|
|
X1 := RawXCoord;
|
|
X1 := RawXCoord;
|
|
|
- X2 := AB.GetRawXCoord;
|
|
|
|
|
- Y2 := AB.GetRawYCoord;
|
|
|
|
|
|
|
+ X2 := AB.RawXCoord;
|
|
|
|
|
+ Y2 := AB.RawYCoord;
|
|
|
|
|
|
|
|
Dx := X2.Subtract(X1);
|
|
Dx := X2.Subtract(X1);
|
|
|
Dy := Y2.Subtract(Y1);
|
|
Dy := Y2.Subtract(Y1);
|
|
@@ -1658,7 +1658,7 @@ function TAbstractF2mPoint.ScaleX(const AScale: IECFieldElement): IECPoint;
|
|
|
var
|
|
var
|
|
|
LX, LL, LX2, LL2, LZ, LZ2: IECFieldElement;
|
|
LX, LL, LX2, LL2, LZ, LZ2: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
|
|
|
|
|
case GetCurveCoordinateSystem() of
|
|
case GetCurveCoordinateSystem() of
|
|
@@ -1698,7 +1698,7 @@ function TAbstractF2mPoint.ScaleY(const AScale: IECFieldElement): IECPoint;
|
|
|
var
|
|
var
|
|
|
LX, LL, LL2: IECFieldElement;
|
|
LX, LL, LL2: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
|
|
|
|
|
case GetCurveCoordinateSystem() of
|
|
case GetCurveCoordinateSystem() of
|
|
@@ -1723,7 +1723,7 @@ end;
|
|
|
|
|
|
|
|
function TAbstractF2mPoint.Subtract(const AB: IECPoint): IECPoint;
|
|
function TAbstractF2mPoint.Subtract(const AB: IECPoint): IECPoint;
|
|
|
begin
|
|
begin
|
|
|
- if AB.GetIsInfinity then
|
|
|
|
|
|
|
+ if AB.IsInfinity then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
Result := Add(AB.Negate());
|
|
Result := Add(AB.Negate());
|
|
|
end;
|
|
end;
|
|
@@ -1734,7 +1734,7 @@ var
|
|
|
LCoord: Int32;
|
|
LCoord: Int32;
|
|
|
LX1, LY1, LZ1: IECFieldElement;
|
|
LX1, LY1, LZ1: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(Self as IAbstractF2mPoint);
|
|
Exit(Self as IAbstractF2mPoint);
|
|
|
|
|
|
|
|
LCurve := GetCurve;
|
|
LCurve := GetCurve;
|
|
@@ -1768,7 +1768,7 @@ var
|
|
|
LCoord: Int32;
|
|
LCoord: Int32;
|
|
|
LX1, LY1, LZ1: IECFieldElement;
|
|
LX1, LY1, LZ1: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(Self as IAbstractF2mPoint);
|
|
Exit(Self as IAbstractF2mPoint);
|
|
|
|
|
|
|
|
LCurve := GetCurve;
|
|
LCurve := GetCurve;
|
|
@@ -1803,7 +1803,7 @@ var
|
|
|
LX, LY: IECFieldElement;
|
|
LX, LY: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
LX := RawXCoord;
|
|
LX := RawXCoord;
|
|
|
- if LX.GetIsZero then
|
|
|
|
|
|
|
+ if LX.IsZero then
|
|
|
Exit(False);
|
|
Exit(False);
|
|
|
|
|
|
|
|
LY := RawYCoord;
|
|
LY := RawYCoord;
|
|
@@ -1853,7 +1853,7 @@ begin
|
|
|
LX := RawXCoord;
|
|
LX := RawXCoord;
|
|
|
LL := RawYCoord;
|
|
LL := RawYCoord;
|
|
|
|
|
|
|
|
- if GetIsInfinity or LX.GetIsZero then
|
|
|
|
|
|
|
+ if IsInfinity or LX.IsZero then
|
|
|
Exit(LL);
|
|
Exit(LL);
|
|
|
|
|
|
|
|
// Y is actually Lambda (X + Y/X) here; convert to affine value on the fly
|
|
// Y is actually Lambda (X + Y/X) here; convert to affine value on the fly
|
|
@@ -1882,29 +1882,29 @@ var
|
|
|
L1, L2, LS1, LS2, LA2, LB2, LAU1, LAU2, LABZ2, L3: IECFieldElement;
|
|
L1, L2, LS1, LS2, LA2, LB2, LAU1, LAU2, LABZ2, L3: IECFieldElement;
|
|
|
LP: IECPoint;
|
|
LP: IECPoint;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(AB);
|
|
Exit(AB);
|
|
|
- if AB.GetIsInfinity then
|
|
|
|
|
|
|
+ if AB.IsInfinity then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
|
|
|
|
|
LCurve := FCurve;
|
|
LCurve := FCurve;
|
|
|
LCoord := GetCurveCoordinateSystem();
|
|
LCoord := GetCurveCoordinateSystem();
|
|
|
|
|
|
|
|
X1 := RawXCoord;
|
|
X1 := RawXCoord;
|
|
|
- X2 := AB.GetRawXCoord;
|
|
|
|
|
|
|
+ X2 := AB.RawXCoord;
|
|
|
|
|
|
|
|
case LCoord of
|
|
case LCoord of
|
|
|
TECCurveConstants.COORD_AFFINE:
|
|
TECCurveConstants.COORD_AFFINE:
|
|
|
begin
|
|
begin
|
|
|
Y1 := RawYCoord;
|
|
Y1 := RawYCoord;
|
|
|
- Y2 := AB.GetRawYCoord;
|
|
|
|
|
|
|
+ Y2 := AB.RawYCoord;
|
|
|
|
|
|
|
|
Dx := X1.Add(X2);
|
|
Dx := X1.Add(X2);
|
|
|
Dy := Y1.Add(Y2);
|
|
Dy := Y1.Add(Y2);
|
|
|
|
|
|
|
|
- if Dx.GetIsZero then
|
|
|
|
|
|
|
+ if Dx.IsZero then
|
|
|
begin
|
|
begin
|
|
|
- if Dy.GetIsZero then
|
|
|
|
|
|
|
+ if Dy.IsZero then
|
|
|
Exit(Twice());
|
|
Exit(Twice());
|
|
|
Exit(LCurve.Infinity);
|
|
Exit(LCurve.Infinity);
|
|
|
end;
|
|
end;
|
|
@@ -1919,7 +1919,7 @@ begin
|
|
|
begin
|
|
begin
|
|
|
Y1 := RawYCoord;
|
|
Y1 := RawYCoord;
|
|
|
Z1 := RawZCoords[0];
|
|
Z1 := RawZCoords[0];
|
|
|
- Y2 := AB.GetRawYCoord;
|
|
|
|
|
|
|
+ Y2 := AB.RawYCoord;
|
|
|
Z2 := AB.GetZCoord(0);
|
|
Z2 := AB.GetZCoord(0);
|
|
|
|
|
|
|
|
LZ1IsOne := Z1.IsOne;
|
|
LZ1IsOne := Z1.IsOne;
|
|
@@ -1943,9 +1943,9 @@ begin
|
|
|
LU := LU1.Add(LU2);
|
|
LU := LU1.Add(LU2);
|
|
|
LV := LV1.Add(LV2);
|
|
LV := LV1.Add(LV2);
|
|
|
|
|
|
|
|
- if LV.GetIsZero then
|
|
|
|
|
|
|
+ if LV.IsZero then
|
|
|
begin
|
|
begin
|
|
|
- if LU.GetIsZero then
|
|
|
|
|
|
|
+ if LU.IsZero then
|
|
|
Exit(Twice());
|
|
Exit(Twice());
|
|
|
Exit(LCurve.Infinity);
|
|
Exit(LCurve.Infinity);
|
|
|
end;
|
|
end;
|
|
@@ -1969,16 +1969,16 @@ begin
|
|
|
|
|
|
|
|
TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
|
|
TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
|
|
|
begin
|
|
begin
|
|
|
- if X1.GetIsZero then
|
|
|
|
|
|
|
+ if X1.IsZero then
|
|
|
begin
|
|
begin
|
|
|
- if X2.GetIsZero then
|
|
|
|
|
|
|
+ if X2.IsZero then
|
|
|
Exit(LCurve.Infinity);
|
|
Exit(LCurve.Infinity);
|
|
|
Exit(AB.Add(Self as IECPoint));
|
|
Exit(AB.Add(Self as IECPoint));
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
L1 := RawYCoord;
|
|
L1 := RawYCoord;
|
|
|
Z1 := RawZCoords[0];
|
|
Z1 := RawZCoords[0];
|
|
|
- L2 := AB.GetRawYCoord;
|
|
|
|
|
|
|
+ L2 := AB.RawYCoord;
|
|
|
Z2 := AB.GetZCoord(0);
|
|
Z2 := AB.GetZCoord(0);
|
|
|
|
|
|
|
|
LZ1IsOne := Z1.IsOne;
|
|
LZ1IsOne := Z1.IsOne;
|
|
@@ -2002,25 +2002,25 @@ begin
|
|
|
LA2 := LS1.Add(LS2);
|
|
LA2 := LS1.Add(LS2);
|
|
|
LB2 := LU1.Add(LU2);
|
|
LB2 := LU1.Add(LU2);
|
|
|
|
|
|
|
|
- if LB2.GetIsZero then
|
|
|
|
|
|
|
+ if LB2.IsZero then
|
|
|
begin
|
|
begin
|
|
|
- if LA2.GetIsZero then
|
|
|
|
|
|
|
+ if LA2.IsZero then
|
|
|
Exit(Twice());
|
|
Exit(Twice());
|
|
|
Exit(LCurve.Infinity);
|
|
Exit(LCurve.Infinity);
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
- if X2.GetIsZero then
|
|
|
|
|
|
|
+ if X2.IsZero then
|
|
|
begin
|
|
begin
|
|
|
// TODO This can probably be optimized quite a bit
|
|
// TODO This can probably be optimized quite a bit
|
|
|
LP := (Self as IECPoint).Normalize();
|
|
LP := (Self as IECPoint).Normalize();
|
|
|
- X1 := LP.GetRawXCoord;
|
|
|
|
|
- Y1 := LP.GetYCoord;
|
|
|
|
|
|
|
+ X1 := LP.RawXCoord;
|
|
|
|
|
+ Y1 := LP.YCoord;
|
|
|
|
|
|
|
|
Y2 := L2;
|
|
Y2 := L2;
|
|
|
LL := Y1.Add(Y2).Divide(X1);
|
|
LL := Y1.Add(Y2).Divide(X1);
|
|
|
|
|
|
|
|
X3 := LL.Square().Add(LL).Add(X1).Add(LCurve.A);
|
|
X3 := LL.Square().Add(LL).Add(X1).Add(LCurve.A);
|
|
|
- if X3.GetIsZero then
|
|
|
|
|
|
|
+ if X3.IsZero then
|
|
|
Exit(TF2mPoint.Create(LCurve, X3, LCurve.B.Sqrt()));
|
|
Exit(TF2mPoint.Create(LCurve, X3, LCurve.B.Sqrt()));
|
|
|
|
|
|
|
|
Y3 := LL.Multiply(X1.Add(X3)).Add(X3).Add(Y1);
|
|
Y3 := LL.Multiply(X1.Add(X3)).Add(X3).Add(Y1);
|
|
@@ -2035,7 +2035,7 @@ begin
|
|
|
LAU2 := LA2.Multiply(LU2);
|
|
LAU2 := LA2.Multiply(LU2);
|
|
|
|
|
|
|
|
X3 := LAU1.Multiply(LAU2);
|
|
X3 := LAU1.Multiply(LAU2);
|
|
|
- if X3.GetIsZero then
|
|
|
|
|
|
|
+ if X3.IsZero then
|
|
|
Exit(TF2mPoint.Create(LCurve, X3, LCurve.B.Sqrt()));
|
|
Exit(TF2mPoint.Create(LCurve, X3, LCurve.B.Sqrt()));
|
|
|
|
|
|
|
|
LABZ2 := LA2.Multiply(LB2);
|
|
LABZ2 := LA2.Multiply(LB2);
|
|
@@ -2066,13 +2066,13 @@ var
|
|
|
LZ1IsOne: Boolean;
|
|
LZ1IsOne: Boolean;
|
|
|
LL1Z1, LZ1Sq, La, LaZ1Sq, LT, Lb, Lt1, Lt2, LX1Z1b: IECFieldElement;
|
|
LL1Z1, LZ1Sq, La, LaZ1Sq, LT, Lb, Lt1, Lt2, LX1Z1b: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
|
|
|
|
|
LCurve := FCurve;
|
|
LCurve := FCurve;
|
|
|
X1 := RawXCoord;
|
|
X1 := RawXCoord;
|
|
|
|
|
|
|
|
- if X1.GetIsZero then
|
|
|
|
|
|
|
+ if X1.IsZero then
|
|
|
Exit(LCurve.Infinity);
|
|
Exit(LCurve.Infinity);
|
|
|
|
|
|
|
|
LCoord := GetCurveCoordinateSystem();
|
|
LCoord := GetCurveCoordinateSystem();
|
|
@@ -2122,7 +2122,7 @@ begin
|
|
|
La := LCurve.A;
|
|
La := LCurve.A;
|
|
|
if LZ1IsOne then LaZ1Sq := La else LaZ1Sq := La.Multiply(LZ1Sq);
|
|
if LZ1IsOne then LaZ1Sq := La else LaZ1Sq := La.Multiply(LZ1Sq);
|
|
|
LT := L1.Square().Add(LL1Z1).Add(LaZ1Sq);
|
|
LT := L1.Square().Add(LL1Z1).Add(LaZ1Sq);
|
|
|
- if LT.GetIsZero then
|
|
|
|
|
|
|
+ if LT.IsZero then
|
|
|
Exit(TF2mPoint.Create(LCurve, LT, LCurve.B.Sqrt()));
|
|
Exit(TF2mPoint.Create(LCurve, LT, LCurve.B.Sqrt()));
|
|
|
|
|
|
|
|
X3 := LT.Square();
|
|
X3 := LT.Square();
|
|
@@ -2138,7 +2138,7 @@ begin
|
|
|
// TODO Can be calculated with one square if we pre-compute sqrt(b)
|
|
// TODO Can be calculated with one square if we pre-compute sqrt(b)
|
|
|
Lt2 := LaZ1Sq.SquarePlusProduct(Lb, LZ1Sq.Square());
|
|
Lt2 := LaZ1Sq.SquarePlusProduct(Lb, LZ1Sq.Square());
|
|
|
L3 := Lt1.Add(LT).Add(LZ1Sq).Multiply(Lt1).Add(Lt2).Add(X3);
|
|
L3 := Lt1.Add(LT).Add(LZ1Sq).Multiply(Lt1).Add(Lt2).Add(X3);
|
|
|
- if La.GetIsZero then
|
|
|
|
|
|
|
+ if La.IsZero then
|
|
|
L3 := L3.Add(Z3)
|
|
L3 := L3.Add(Z3)
|
|
|
else if not La.IsOne then
|
|
else if not La.IsOne then
|
|
|
L3 := L3.Add(La.AddOne().Multiply(Z3));
|
|
L3 := L3.Add(La.AddOne().Multiply(Z3));
|
|
@@ -2165,14 +2165,14 @@ var
|
|
|
LX1Sq, LL1Sq, LZ1Sq, LL1Z1, LT, LL2plus1, LA, LX2Z1Sq, LB2: IECFieldElement;
|
|
LX1Sq, LL1Sq, LZ1Sq, LL1Z1, LT, LL2plus1, LA, LX2Z1Sq, LB2: IECFieldElement;
|
|
|
X3, Z3, L3: IECFieldElement;
|
|
X3, Z3, L3: IECFieldElement;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(AB);
|
|
Exit(AB);
|
|
|
- if AB.GetIsInfinity then
|
|
|
|
|
|
|
+ if AB.IsInfinity then
|
|
|
Exit(Twice());
|
|
Exit(Twice());
|
|
|
|
|
|
|
|
LCurve := FCurve;
|
|
LCurve := FCurve;
|
|
|
X1 := RawXCoord;
|
|
X1 := RawXCoord;
|
|
|
- if X1.GetIsZero then
|
|
|
|
|
|
|
+ if X1.IsZero then
|
|
|
Exit(AB);
|
|
Exit(AB);
|
|
|
|
|
|
|
|
LCoord := GetCurveCoordinateSystem();
|
|
LCoord := GetCurveCoordinateSystem();
|
|
@@ -2181,14 +2181,14 @@ begin
|
|
|
TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
|
|
TECCurveConstants.COORD_LAMBDA_PROJECTIVE:
|
|
|
begin
|
|
begin
|
|
|
// NOTE: twicePlus() only optimized for lambda-affine argument
|
|
// NOTE: twicePlus() only optimized for lambda-affine argument
|
|
|
- X2 := AB.GetRawXCoord;
|
|
|
|
|
|
|
+ X2 := AB.RawXCoord;
|
|
|
Z2 := AB.GetZCoord(0);
|
|
Z2 := AB.GetZCoord(0);
|
|
|
- if X2.GetIsZero or (not Z2.IsOne) then
|
|
|
|
|
|
|
+ if X2.IsZero or (not Z2.IsOne) then
|
|
|
Exit(Twice().Add(AB));
|
|
Exit(Twice().Add(AB));
|
|
|
|
|
|
|
|
L1 := RawYCoord;
|
|
L1 := RawYCoord;
|
|
|
Z1 := RawZCoords[0];
|
|
Z1 := RawZCoords[0];
|
|
|
- L2 := AB.GetRawYCoord;
|
|
|
|
|
|
|
+ L2 := AB.RawYCoord;
|
|
|
|
|
|
|
|
LX1Sq := X1.Square();
|
|
LX1Sq := X1.Square();
|
|
|
LL1Sq := L1.Square();
|
|
LL1Sq := L1.Square();
|
|
@@ -2201,14 +2201,14 @@ begin
|
|
|
LX2Z1Sq := X2.Multiply(LZ1Sq);
|
|
LX2Z1Sq := X2.Multiply(LZ1Sq);
|
|
|
LB2 := LX2Z1Sq.Add(LT).Square();
|
|
LB2 := LX2Z1Sq.Add(LT).Square();
|
|
|
|
|
|
|
|
- if LB2.GetIsZero then
|
|
|
|
|
|
|
+ if LB2.IsZero then
|
|
|
begin
|
|
begin
|
|
|
- if LA.GetIsZero then
|
|
|
|
|
|
|
+ if LA.IsZero then
|
|
|
Exit(AB.Twice());
|
|
Exit(AB.Twice());
|
|
|
Exit(LCurve.Infinity);
|
|
Exit(LCurve.Infinity);
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
- if LA.GetIsZero then
|
|
|
|
|
|
|
+ if LA.IsZero then
|
|
|
Exit(TF2mPoint.Create(LCurve, LA, LCurve.B.Sqrt()));
|
|
Exit(TF2mPoint.Create(LCurve, LA, LCurve.B.Sqrt()));
|
|
|
|
|
|
|
|
X3 := LA.Square().Multiply(LX2Z1Sq);
|
|
X3 := LA.Square().Multiply(LX2Z1Sq);
|
|
@@ -2229,11 +2229,11 @@ var
|
|
|
LX, LY, LZ, LL: IECFieldElement;
|
|
LX, LY, LZ, LL: IECFieldElement;
|
|
|
LCoord: Int32;
|
|
LCoord: Int32;
|
|
|
begin
|
|
begin
|
|
|
- if GetIsInfinity then
|
|
|
|
|
|
|
+ if IsInfinity then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
|
|
|
|
|
LX := RawXCoord;
|
|
LX := RawXCoord;
|
|
|
- if LX.GetIsZero then
|
|
|
|
|
|
|
+ if LX.IsZero then
|
|
|
Exit(Self as IECPoint);
|
|
Exit(Self as IECPoint);
|
|
|
|
|
|
|
|
LCurve := FCurve;
|
|
LCurve := FCurve;
|