Explorar o código

consistency fix.

Ugochukwu Mmaduekwe %!s(int64=7) %!d(string=hai) anos
pai
achega
3ff2e81f91

+ 1 - 1
CryptoLib/src/Interfaces/ClpIECInterface.pas

@@ -190,7 +190,7 @@ type
       bSquared: IECFieldElement): IECFieldElement;
       bSquared: IECFieldElement): IECFieldElement;
 
 
     function CalculateJacobianModifiedW(const Z: IECFieldElement;
     function CalculateJacobianModifiedW(const Z: IECFieldElement;
-      ZSquared: IECFieldElement): IECFieldElement;
+     const ZSquared: IECFieldElement): IECFieldElement;
 
 
     function GetJacobianModifiedW(): IECFieldElement;
     function GetJacobianModifiedW(): IECFieldElement;
 
 

+ 6 - 4
CryptoLib/src/Math/EC/ClpECAlgorithms.pas

@@ -87,7 +87,7 @@ type
     // * 9: return R
     // * 9: return R
     // */
     // */
     class function ShamirsTrick(const P: IECPoint; const k: TBigInteger;
     class function ShamirsTrick(const P: IECPoint; const k: TBigInteger;
-      Q: IECPoint; const l: TBigInteger): IECPoint; static;
+      const Q: IECPoint; const l: TBigInteger): IECPoint; static;
 
 
     class function ImportPoint(const c: IECCurve; const P: IECPoint)
     class function ImportPoint(const c: IECCurve; const P: IECPoint)
       : IECPoint; static;
       : IECPoint; static;
@@ -837,14 +837,16 @@ begin
 end;
 end;
 
 
 class function TECAlgorithms.ShamirsTrick(const P: IECPoint;
 class function TECAlgorithms.ShamirsTrick(const P: IECPoint;
-  const k: TBigInteger; Q: IECPoint; const l: TBigInteger): IECPoint;
+  const k: TBigInteger; const Q: IECPoint; const l: TBigInteger): IECPoint;
 var
 var
   cp: IECCurve;
   cp: IECCurve;
+  LQ: IECPoint;
 begin
 begin
   cp := P.Curve;
   cp := P.Curve;
-  Q := ImportPoint(cp, Q);
+  LQ := Q;
+  LQ := ImportPoint(cp, LQ);
 
 
-  result := ImplCheckResult(ImplShamirsTrickJsf(P, k, Q, l));
+  result := ImplCheckResult(ImplShamirsTrickJsf(P, k, LQ, l));
 end;
 end;
 
 
 class function TECAlgorithms.SumOfMultiplies
 class function TECAlgorithms.SumOfMultiplies

+ 7 - 6
CryptoLib/src/Math/EC/ClpECPoint.pas

@@ -327,7 +327,7 @@ type
       bSquared: IECFieldElement): IECFieldElement; virtual;
       bSquared: IECFieldElement): IECFieldElement; virtual;
 
 
     function CalculateJacobianModifiedW(const Z: IECFieldElement;
     function CalculateJacobianModifiedW(const Z: IECFieldElement;
-      ZSquared: IECFieldElement): IECFieldElement; virtual;
+      const ZSquared: IECFieldElement): IECFieldElement; virtual;
 
 
     function GetJacobianModifiedW(): IECFieldElement; virtual;
     function GetJacobianModifiedW(): IECFieldElement; virtual;
 
 
@@ -2182,23 +2182,24 @@ begin
 end;
 end;
 
 
 function TFpPoint.CalculateJacobianModifiedW(const Z: IECFieldElement;
 function TFpPoint.CalculateJacobianModifiedW(const Z: IECFieldElement;
-  ZSquared: IECFieldElement): IECFieldElement;
+  const ZSquared: IECFieldElement): IECFieldElement;
 var
 var
-  a4, W, a4Neg: IECFieldElement;
+  a4, W, a4Neg, LZSquared: IECFieldElement;
 begin
 begin
   a4 := curve.a;
   a4 := curve.a;
+  LZSquared := ZSquared;
   if ((a4.IsZero) or (Z.IsOne)) then
   if ((a4.IsZero) or (Z.IsOne)) then
   begin
   begin
     result := a4;
     result := a4;
     Exit;
     Exit;
   end;
   end;
 
 
-  if (ZSquared = Nil) then
+  if (LZSquared = Nil) then
   begin
   begin
-    ZSquared := Z.Square();
+    LZSquared := Z.Square();
   end;
   end;
 
 
-  W := ZSquared.Square();
+  W := LZSquared.Square();
   a4Neg := a4.Negate();
   a4Neg := a4.Negate();
   if (a4Neg.BitLength < a4.BitLength) then
   if (a4Neg.BitLength < a4.BitLength) then
   begin
   begin