Browse Source

cleanup and formatting fixes in ClpNat

Ugochukwu Mmaduekwe 6 years ago
parent
commit
e02c0d942a
1 changed files with 1 additions and 92 deletions
  1. 1 92
      CryptoLib/src/Math/Raw/ClpNat.pas

+ 1 - 92
CryptoLib/src/Math/Raw/ClpNat.pas

@@ -108,10 +108,6 @@ type
       xOff: Int32; const z: TCryptoLibUInt32Array; zOff: Int32);
       xOff: Int32; const z: TCryptoLibUInt32Array; zOff: Int32);
       overload; static;
       overload; static;
 
 
-    // class procedure CMov(len, mask: Int32; const x: TCryptoLibInt32Array;
-    // xOff: Int32; const z: TCryptoLibInt32Array; zOff: Int32);
-    // overload; static;
-
     class procedure Copy(len: Int32; const x, z: TCryptoLibUInt32Array);
     class procedure Copy(len: Int32; const x, z: TCryptoLibUInt32Array);
       overload; static; inline;
       overload; static; inline;
 
 
@@ -292,13 +288,6 @@ type
       xOff: Int32; const zz: TCryptoLibUInt32Array; zzOff: Int32);
       xOff: Int32; const zz: TCryptoLibUInt32Array; zzOff: Int32);
       overload; static;
       overload; static;
 
 
-    // class function SquareWordAdd(const x: TCryptoLibUInt32Array; xPos: Int32;
-    // const z: TCryptoLibUInt32Array): UInt32; overload; static;
-    //
-    // class function SquareWordAdd(const x: TCryptoLibUInt32Array;
-    // xOff, xPos: Int32; const z: TCryptoLibUInt32Array; zOff: Int32): UInt32;
-    // overload; static;
-
     class function SquareWordAddTo(const x: TCryptoLibUInt32Array; xPos: Int32;
     class function SquareWordAddTo(const x: TCryptoLibUInt32Array; xPos: Int32;
       const z: TCryptoLibUInt32Array): UInt32; overload; static;
       const z: TCryptoLibUInt32Array): UInt32; overload; static;
 
 
@@ -433,11 +422,9 @@ begin
   I := 0;
   I := 0;
 
 
   repeat
   repeat
-
     c := c + (xVal * y[yOff + I] + z[zOff + I]);
     c := c + (xVal * y[yOff + I] + z[zOff + I]);
     z[zOff + I] := UInt32(c);
     z[zOff + I] := UInt32(c);
     c := c shr 32;
     c := c shr 32;
-
     System.Inc(I);
     System.Inc(I);
   until (not(I < len));
   until (not(I < len));
 
 
@@ -484,11 +471,9 @@ begin
   I := 0;
   I := 0;
 
 
   repeat
   repeat
-
     c := c + (xVal * y[I]);
     c := c + (xVal * y[I]);
     z[I] := UInt32(c);
     z[I] := UInt32(c);
     c := c shr 32;
     c := c shr 32;
-
     System.Inc(I);
     System.Inc(I);
   until (not(I < len));
   until (not(I < len));
 
 
@@ -507,58 +492,15 @@ begin
   I := 0;
   I := 0;
 
 
   repeat
   repeat
-
     c := c + (xVal * y[yOff + I]);
     c := c + (xVal * y[yOff + I]);
     z[zOff + I] := UInt32(c);
     z[zOff + I] := UInt32(c);
     c := c shr 32;
     c := c shr 32;
-
     System.Inc(I);
     System.Inc(I);
   until (not(I < len));
   until (not(I < len));
 
 
   Result := UInt32(c);
   Result := UInt32(c);
 end;
 end;
 
 
-// class function TNat.SquareWordAdd(const x: TCryptoLibUInt32Array;
-// xOff, xPos: Int32; const z: TCryptoLibUInt32Array; zOff: Int32): UInt32;
-// var
-// c, xVal: UInt64;
-// I: Int32;
-// begin
-// c := 0;
-// xVal := UInt64(x[xOff + xPos]);
-// I := 0;
-//
-// repeat
-// c := c + (xVal * (x[xOff + I] and M) + (z[xPos + zOff] and M));
-// z[xPos + zOff] := UInt32(c);
-// c := c shr 32;
-// System.Inc(zOff);
-// System.Inc(I);
-// until (not(I < xPos));
-//
-// Result := UInt32(c);
-// end;
-//
-// class function TNat.SquareWordAdd(const x: TCryptoLibUInt32Array; xPos: Int32;
-// const z: TCryptoLibUInt32Array): UInt32;
-// var
-// c, xVal: UInt64;
-// I: Int32;
-// begin
-// c := 0;
-// xVal := UInt64(x[xPos]);
-// I := 0;
-//
-// repeat
-// c := c + (xVal * x[I] + z[xPos + I]);
-// z[xPos + I] := UInt32(c);
-// c := c shr 32;
-// System.Inc(I);
-// until (not(I < xPos));
-//
-// Result := UInt32(c);
-// end;
-
 class function TNat.SquareWordAddTo(const x: TCryptoLibUInt32Array;
 class function TNat.SquareWordAddTo(const x: TCryptoLibUInt32Array;
   xOff, xPos: Int32; const z: TCryptoLibUInt32Array; zOff: Int32): UInt32;
   xOff, xPos: Int32; const z: TCryptoLibUInt32Array; zOff: Int32): UInt32;
 var
 var
@@ -1033,22 +975,6 @@ begin
   end;
   end;
 end;
 end;
 
 
-// class procedure TNat.CMov(len, mask: Int32; const x: TCryptoLibInt32Array;
-// xOff: Int32; const z: TCryptoLibInt32Array; zOff: Int32);
-// var
-// z_i, diff, I: Int32;
-// begin
-// mask := -(mask and 1);
-//
-// for I := 0 to System.Pred(len) do
-// begin
-// z_i := z[zOff + I];
-// diff := z_i xor x[xOff + I];
-// z_i := z_i xor ((diff and mask));
-// z[zOff + I] := z_i;
-// end;
-// end;
-
 class function TNat.Copy(len: Int32; const x: TCryptoLibUInt32Array)
 class function TNat.Copy(len: Int32; const x: TCryptoLibUInt32Array)
   : TCryptoLibUInt32Array;
   : TCryptoLibUInt32Array;
 begin
 begin
@@ -1243,7 +1169,6 @@ begin
     raise EArgumentCryptoLibException.Create('');
     raise EArgumentCryptoLibException.Create('');
   end;
   end;
 
 
-  // len := (bits + 31) shr 5;
   len := TBits.Asr32((bits + 31), 5);
   len := TBits.Asr32((bits + 31), 5);
   Result := Create(len);
   Result := Create(len);
   I := 0;
   I := 0;
@@ -1264,7 +1189,7 @@ begin
     Result := x[0] and 1;
     Result := x[0] and 1;
     Exit;
     Exit;
   end;
   end;
-  // w := bit shr 5;
+
   w := TBits.Asr32(bit, 5);
   w := TBits.Asr32(bit, 5);
   if ((w < 0) or (w >= System.Length(x))) then
   if ((w < 0) or (w >= System.Length(x))) then
   begin
   begin
@@ -1359,7 +1284,6 @@ begin
       begin
       begin
         z[I] := x[I];
         z[I] := x[I];
         System.Inc(I);
         System.Inc(I);
-
       end;
       end;
       Result := 0;
       Result := 0;
       Exit;
       Exit;
@@ -1415,7 +1339,6 @@ begin
   zz[len] := MulWord(len, x[0], y, zz);
   zz[len] := MulWord(len, x[0], y, zz);
 
 
   for I := 1 to System.Pred(len) do
   for I := 1 to System.Pred(len) do
-
   begin
   begin
     zz[I + len] := MulWordAddTo(len, x[I], y, 0, zz, I);
     zz[I + len] := MulWordAddTo(len, x[I], y, 0, zz, I);
   end;
   end;
@@ -1500,11 +1423,9 @@ begin
   I := 0;
   I := 0;
 
 
   repeat
   repeat
-
     c := c + (aVal * x[I] + bVal * y[I] + z[zOff + I]);
     c := c + (aVal * x[I] + bVal * y[I] + z[zOff + I]);
     z[zOff + I] := UInt32(c);
     z[zOff + I] := UInt32(c);
     c := c shr 32;
     c := c shr 32;
-
     System.Inc(I);
     System.Inc(I);
   until (not(I < len));
   until (not(I < len));
 
 
@@ -1692,7 +1613,6 @@ var
   next: UInt32;
   next: UInt32;
 begin
 begin
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     next := x[I];
     next := x[I];
     z[I] := (next shl 1) or (c shr 31);
     z[I] := (next shl 1) or (c shr 31);
@@ -1708,7 +1628,6 @@ var
   next: UInt32;
   next: UInt32;
 begin
 begin
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     next := x[xOff + I];
     next := x[xOff + I];
     z[zOff + I] := (next shl 1) or (c shr 31);
     z[zOff + I] := (next shl 1) or (c shr 31);
@@ -1724,7 +1643,6 @@ var
   next: UInt32;
   next: UInt32;
 begin
 begin
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     next := z[I];
     next := z[I];
     z[I] := (next shl 1) or (c shr 31);
     z[I] := (next shl 1) or (c shr 31);
@@ -1740,7 +1658,6 @@ var
   next: UInt32;
   next: UInt32;
 begin
 begin
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     next := z[zOff + I];
     next := z[zOff + I];
     z[zOff + I] := (next shl 1) or (c shr 31);
     z[zOff + I] := (next shl 1) or (c shr 31);
@@ -1756,7 +1673,6 @@ var
   next: UInt64;
   next: UInt64;
 begin
 begin
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     next := x[xOff + I];
     next := x[xOff + I];
     z[zOff + I] := (next shl 1) or (c shr 63);
     z[zOff + I] := (next shl 1) or (c shr 63);
@@ -1971,7 +1887,6 @@ var
 begin
 begin
   c := 0;
   c := 0;
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     c := c + (Int64(x[xOff + I]) - y[yOff + I]);
     c := c + (Int64(x[xOff + I]) - y[yOff + I]);
     z[zOff + I] := UInt32(c);
     z[zOff + I] := UInt32(c);
@@ -1988,7 +1903,6 @@ var
 begin
 begin
   c := 0;
   c := 0;
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     c := c + (Int64(x[I]) - y[I]);
     c := c + (Int64(x[I]) - y[I]);
     z[I] := UInt32(c);
     z[I] := UInt32(c);
@@ -2095,7 +2009,6 @@ var
 begin
 begin
   c := 0;
   c := 0;
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     c := c + (Int64(z[I]) - x[I] - y[I]);
     c := c + (Int64(z[I]) - x[I] - y[I]);
     z[I] := UInt32(c);
     z[I] := UInt32(c);
@@ -2113,7 +2026,6 @@ var
 begin
 begin
   c := 0;
   c := 0;
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     c := c + (Int64(z[zOff + I]) - x[xOff + I] - y[yOff + I]);
     c := c + (Int64(z[zOff + I]) - x[xOff + I] - y[yOff + I]);
     z[zOff + I] := UInt32(c);
     z[zOff + I] := UInt32(c);
@@ -2221,7 +2133,6 @@ var
 begin
 begin
   c := 0;
   c := 0;
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     c := c + (Int64(z[I]) - x[I]);
     c := c + (Int64(z[I]) - x[I]);
     z[I] := UInt32(c);
     z[I] := UInt32(c);
@@ -2238,7 +2149,6 @@ var
 begin
 begin
   c := 0;
   c := 0;
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     c := c + (Int64(z[zOff + I]) - x[xOff + I]);
     c := c + (Int64(z[zOff + I]) - x[xOff + I]);
     z[zOff + I] := UInt32(c);
     z[zOff + I] := UInt32(c);
@@ -2340,7 +2250,6 @@ var
 begin
 begin
   System.SetLength(bs, len shl 2);
   System.SetLength(bs, len shl 2);
   for I := 0 to System.Pred(len) do
   for I := 0 to System.Pred(len) do
-
   begin
   begin
     x_i := x[I];
     x_i := x[I];
     if (x_i <> 0) then
     if (x_i <> 0) then