瀏覽代碼

add ScalarSplitParameters class

- some refactorings
- Add experimental support for GLV Type A endomorphisms
Ugochukwu Mmaduekwe 6 年之前
父節點
當前提交
8ed07a9408
共有 25 個文件被更改,包括 863 次插入179 次删除
  1. 10 0
      CryptoLib.Samples/Delphi.Samples/UsageSamples.dpr
  2. 10 0
      CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.TestInsight.dpr
  3. 10 0
      CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr
  4. 27 18
      CryptoLib/src/Asn1/Sec/ClpSecNamedCurves.pas
  5. 8 4
      CryptoLib/src/Crypto/EC/ClpCustomNamedCurves.pas
  6. 3 0
      CryptoLib/src/Interfaces/ClpIECC.pas
  7. 36 0
      CryptoLib/src/Interfaces/ClpIGlvTypeAEndomorphism.pas
  8. 46 0
      CryptoLib/src/Interfaces/ClpIGlvTypeAParameters.pas
  9. 0 2
      CryptoLib/src/Interfaces/ClpIGlvTypeBEndomorphism.pas
  10. 4 15
      CryptoLib/src/Interfaces/ClpIGlvTypeBParameters.pas
  11. 52 0
      CryptoLib/src/Interfaces/ClpIScalarSplitParameters.pas
  12. 36 0
      CryptoLib/src/Interfaces/ClpIScaleXNegateYPointMap.pas
  13. 36 0
      CryptoLib/src/Interfaces/ClpIScaleYNegateXPointMap.pas
  14. 49 0
      CryptoLib/src/Math/EC/ClpECAlgorithms.pas
  15. 44 0
      CryptoLib/src/Math/EC/ClpECC.pas
  16. 56 0
      CryptoLib/src/Math/EC/ClpScaleXNegateYPointMap.pas
  17. 56 0
      CryptoLib/src/Math/EC/ClpScaleYNegateXPointMap.pas
  18. 92 0
      CryptoLib/src/Math/EC/Endo/ClpGlvTypeAEndomorphism.pas
  19. 81 0
      CryptoLib/src/Math/EC/Endo/ClpGlvTypeAParameters.pas
  20. 3 48
      CryptoLib/src/Math/EC/Endo/ClpGlvTypeBEndomorphism.pas
  21. 16 89
      CryptoLib/src/Math/EC/Endo/ClpGlvTypeBParameters.pas
  22. 131 0
      CryptoLib/src/Math/EC/Endo/ClpScalarSplitParameters.pas
  23. 11 1
      CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk
  24. 41 1
      CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk
  25. 5 1
      CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas

+ 10 - 0
CryptoLib.Samples/Delphi.Samples/UsageSamples.dpr

@@ -376,6 +376,16 @@ uses
   ClpCryptLibObjectIdentifiers in '..\..\CryptoLib\src\Asn1\CryptLib\ClpCryptLibObjectIdentifiers.pas',
   ClpEndoPreCompInfo in '..\..\CryptoLib\src\Math\EC\Endo\ClpEndoPreCompInfo.pas',
   ClpIEndoPreCompInfo in '..\..\CryptoLib\src\Interfaces\ClpIEndoPreCompInfo.pas',
+  ClpScalarSplitParameters in '..\..\CryptoLib\src\Math\EC\Endo\ClpScalarSplitParameters.pas',
+  ClpIScalarSplitParameters in '..\..\CryptoLib\src\Interfaces\ClpIScalarSplitParameters.pas',
+  ClpScaleXNegateYPointMap in '..\..\CryptoLib\src\Math\EC\ClpScaleXNegateYPointMap.pas',
+  ClpIScaleXNegateYPointMap in '..\..\CryptoLib\src\Interfaces\ClpIScaleXNegateYPointMap.pas',
+  ClpIScaleYNegateXPointMap in '..\..\CryptoLib\src\Interfaces\ClpIScaleYNegateXPointMap.pas',
+  ClpScaleYNegateXPointMap in '..\..\CryptoLib\src\Math\EC\ClpScaleYNegateXPointMap.pas',
+  ClpGlvTypeAEndomorphism in '..\..\CryptoLib\src\Math\EC\Endo\ClpGlvTypeAEndomorphism.pas',
+  ClpIGlvTypeAEndomorphism in '..\..\CryptoLib\src\Interfaces\ClpIGlvTypeAEndomorphism.pas',
+  ClpIGlvTypeAParameters in '..\..\CryptoLib\src\Interfaces\ClpIGlvTypeAParameters.pas',
+  ClpGlvTypeAParameters in '..\..\CryptoLib\src\Math\EC\Endo\ClpGlvTypeAParameters.pas',
   UsageExamples in '..\src\UsageExamples.pas';
 
 begin

+ 10 - 0
CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.TestInsight.dpr

@@ -386,6 +386,16 @@ uses
   ClpCryptLibObjectIdentifiers in '..\..\CryptoLib\src\Asn1\CryptLib\ClpCryptLibObjectIdentifiers.pas',
   ClpEndoPreCompInfo in '..\..\CryptoLib\src\Math\EC\Endo\ClpEndoPreCompInfo.pas',
   ClpIEndoPreCompInfo in '..\..\CryptoLib\src\Interfaces\ClpIEndoPreCompInfo.pas',
+  ClpScalarSplitParameters in '..\..\CryptoLib\src\Math\EC\Endo\ClpScalarSplitParameters.pas',
+  ClpIScalarSplitParameters in '..\..\CryptoLib\src\Interfaces\ClpIScalarSplitParameters.pas',
+  ClpScaleXNegateYPointMap in '..\..\CryptoLib\src\Math\EC\ClpScaleXNegateYPointMap.pas',
+  ClpIScaleXNegateYPointMap in '..\..\CryptoLib\src\Interfaces\ClpIScaleXNegateYPointMap.pas',
+  ClpIScaleYNegateXPointMap in '..\..\CryptoLib\src\Interfaces\ClpIScaleYNegateXPointMap.pas',
+  ClpScaleYNegateXPointMap in '..\..\CryptoLib\src\Math\EC\ClpScaleYNegateXPointMap.pas',
+  ClpGlvTypeAEndomorphism in '..\..\CryptoLib\src\Math\EC\Endo\ClpGlvTypeAEndomorphism.pas',
+  ClpIGlvTypeAEndomorphism in '..\..\CryptoLib\src\Interfaces\ClpIGlvTypeAEndomorphism.pas',
+  ClpIGlvTypeAParameters in '..\..\CryptoLib\src\Interfaces\ClpIGlvTypeAParameters.pas',
+  ClpGlvTypeAParameters in '..\..\CryptoLib\src\Math\EC\Endo\ClpGlvTypeAParameters.pas',
   ClpFixedSecureRandom in '..\src\Utils\ClpFixedSecureRandom.pas',
   ClpIFixedSecureRandom in '..\src\Utils\ClpIFixedSecureRandom.pas',
   ClpIShortenedDigest in '..\src\Utils\ClpIShortenedDigest.pas',

+ 10 - 0
CryptoLib.Tests/Delphi.Tests/CryptoLib.Tests.dpr

@@ -389,6 +389,16 @@ uses
   ClpCryptLibObjectIdentifiers in '..\..\CryptoLib\src\Asn1\CryptLib\ClpCryptLibObjectIdentifiers.pas',
   ClpEndoPreCompInfo in '..\..\CryptoLib\src\Math\EC\Endo\ClpEndoPreCompInfo.pas',
   ClpIEndoPreCompInfo in '..\..\CryptoLib\src\Interfaces\ClpIEndoPreCompInfo.pas',
+  ClpScalarSplitParameters in '..\..\CryptoLib\src\Math\EC\Endo\ClpScalarSplitParameters.pas',
+  ClpIScalarSplitParameters in '..\..\CryptoLib\src\Interfaces\ClpIScalarSplitParameters.pas',
+  ClpScaleXNegateYPointMap in '..\..\CryptoLib\src\Math\EC\ClpScaleXNegateYPointMap.pas',
+  ClpIScaleXNegateYPointMap in '..\..\CryptoLib\src\Interfaces\ClpIScaleXNegateYPointMap.pas',
+  ClpIScaleYNegateXPointMap in '..\..\CryptoLib\src\Interfaces\ClpIScaleYNegateXPointMap.pas',
+  ClpScaleYNegateXPointMap in '..\..\CryptoLib\src\Math\EC\ClpScaleYNegateXPointMap.pas',
+  ClpGlvTypeAEndomorphism in '..\..\CryptoLib\src\Math\EC\Endo\ClpGlvTypeAEndomorphism.pas',
+  ClpIGlvTypeAEndomorphism in '..\..\CryptoLib\src\Interfaces\ClpIGlvTypeAEndomorphism.pas',
+  ClpIGlvTypeAParameters in '..\..\CryptoLib\src\Interfaces\ClpIGlvTypeAParameters.pas',
+  ClpGlvTypeAParameters in '..\..\CryptoLib\src\Math\EC\Endo\ClpGlvTypeAParameters.pas',
   ClpFixedSecureRandom in '..\src\Utils\ClpFixedSecureRandom.pas',
   ClpIFixedSecureRandom in '..\src\Utils\ClpIFixedSecureRandom.pas',
   ClpIShortenedDigest in '..\src\Utils\ClpIShortenedDigest.pas',

+ 27 - 18
CryptoLib/src/Asn1/Sec/ClpSecNamedCurves.pas

@@ -37,6 +37,8 @@ uses
   ClpIX9ECC,
   ClpIAsn1Objects,
   ClpGlvTypeBEndomorphism,
+  ClpIScalarSplitParameters,
+  ClpScalarSplitParameters,
   ClpX9ECParameters,
   ClpIX9ECParameters,
   ClpX9ECParametersHolder,
@@ -1052,14 +1054,16 @@ begin
   glv := TGlvTypeBParameters.Create
     (TBigInteger.Create('9ba48cba5ebcb9b6bd33b92830b2a2e0e192f10a', 16),
     TBigInteger.Create('c39c6c3b3a36d7701b9c71a1f5804ae5d0003f4', 16),
-    TCryptoLibGenericArray<TBigInteger>.Create
+
+    TScalarSplitParameters.Create(TCryptoLibGenericArray<TBigInteger>.Create
     (TBigInteger.Create('9162fbe73984472a0a9e', 16),
     TBigInteger.Create('-96341f1138933bc2f505', 16)),
-    TCryptoLibGenericArray<TBigInteger>.Create
-    (TBigInteger.Create('127971af8721782ecffa3', 16),
-    TBigInteger.Create('9162fbe73984472a0a9e', 16)),
-    TBigInteger.Create('9162fbe73984472a0a9d0590', 16),
-    TBigInteger.Create('96341f1138933bc2f503fd44', 16), 176);
+
+    TCryptoLibGenericArray<TBigInteger>.Create(TBigInteger.Create
+    ('127971af8721782ecffa3', 16), TBigInteger.Create('9162fbe73984472a0a9e',
+    16)), TBigInteger.Create('9162fbe73984472a0a9d0590', 16),
+    TBigInteger.Create('96341f1138933bc2f503fd44', 16), 176)
+    as IScalarSplitParameters);
 
   curve := ConfigureCurveGlv(TFpCurve.Create(p, a, b, n, h) as IFpCurve, glv);
   G := ConfigureBasepoint(curve,
@@ -1152,14 +1156,16 @@ begin
   glv := TGlvTypeBParameters.Create
     (TBigInteger.Create('bb85691939b869c1d087f601554b96b80cb4f55b35f433c2', 16),
     TBigInteger.Create('3d84f26c12238d7b4f3d516613c1759033b1a5800175d0b1', 16),
-    TCryptoLibGenericArray<TBigInteger>.Create
+
+    TScalarSplitParameters.Create(TCryptoLibGenericArray<TBigInteger>.Create
     (TBigInteger.Create('71169be7330b3038edb025f1', 16),
     TBigInteger.Create('-b3fb3400dec5c4adceb8655c', 16)),
-    TCryptoLibGenericArray<TBigInteger>.Create
-    (TBigInteger.Create('12511cfe811d0f4e6bc688b4d', 16),
+    TCryptoLibGenericArray<TBigInteger>.Create(TBigInteger.Create
+    ('12511cfe811d0f4e6bc688b4d', 16),
     TBigInteger.Create('71169be7330b3038edb025f1', 16)),
     TBigInteger.Create('71169be7330b3038edb025f1d0f9', 16),
-    TBigInteger.Create('b3fb3400dec5c4adceb8655d4c94', 16), 208);
+    TBigInteger.Create('b3fb3400dec5c4adceb8655d4c94', 16), 208)
+    as IScalarSplitParameters);
 
   curve := ConfigureCurveGlv(TFpCurve.Create(p, a, b, n, h) as IFpCurve, glv);
   G := ConfigureBasepoint(curve,
@@ -1225,14 +1231,15 @@ begin
     ('fe0e87005b4e83761908c5131d552a850b3f58b749c37cf5b84d6768', 16),
     TBigInteger.Create
     ('60dcd2104c4cbc0be6eeefc2bdd610739ec34e317f9b33046c9e4788', 16),
-    TCryptoLibGenericArray<TBigInteger>.Create
+    TScalarSplitParameters.Create(TCryptoLibGenericArray<TBigInteger>.Create
     (TBigInteger.Create('6b8cf07d4ca75c88957d9d670591', 16),
     TBigInteger.Create('-b8adf1378a6eb73409fa6c9c637d', 16)),
-    TCryptoLibGenericArray<TBigInteger>.Create
-    (TBigInteger.Create('1243ae1b4d71613bc9f780a03690e', 16),
+    TCryptoLibGenericArray<TBigInteger>.Create(TBigInteger.Create
+    ('1243ae1b4d71613bc9f780a03690e', 16),
     TBigInteger.Create('6b8cf07d4ca75c88957d9d670591', 16)),
     TBigInteger.Create('6b8cf07d4ca75c88957d9d67059037a4', 16),
-    TBigInteger.Create('b8adf1378a6eb73409fa6c9c637ba7f5', 16), 240);
+    TBigInteger.Create('b8adf1378a6eb73409fa6c9c637ba7f5', 16), 240)
+    as IScalarSplitParameters);
 
   curve := ConfigureCurveGlv(TFpCurve.Create(p, a, b, n, h) as IFpCurve, glv);
   G := ConfigureBasepoint(curve,
@@ -1300,14 +1307,16 @@ begin
     ('7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', 16),
     TBigInteger.Create
     ('5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', 16),
-    TCryptoLibGenericArray<TBigInteger>.Create
+
+    TScalarSplitParameters.Create(TCryptoLibGenericArray<TBigInteger>.Create
     (TBigInteger.Create('3086d221a7d46bcde86c90e49284eb15', 16),
     TBigInteger.Create('-e4437ed6010e88286f547fa90abfe4c3', 16)),
-    TCryptoLibGenericArray<TBigInteger>.Create
-    (TBigInteger.Create('114ca50f7a8e2f3f657c1108d9d44cfd8', 16),
+    TCryptoLibGenericArray<TBigInteger>.Create(TBigInteger.Create
+    ('114ca50f7a8e2f3f657c1108d9d44cfd8', 16),
     TBigInteger.Create('3086d221a7d46bcde86c90e49284eb15', 16)),
     TBigInteger.Create('3086d221a7d46bcde86c90e49284eb153dab', 16),
-    TBigInteger.Create('e4437ed6010e88286f547fa90abfe4c42212', 16), 272);
+    TBigInteger.Create('e4437ed6010e88286f547fa90abfe4c42212', 16), 272)
+    as IScalarSplitParameters);
 
   curve := ConfigureCurveGlv(TFpCurve.Create(p, a, b, n, h) as IFpCurve, glv);
   G := ConfigureBasepoint(curve,

+ 8 - 4
CryptoLib/src/Crypto/EC/ClpCustomNamedCurves.pas

@@ -49,6 +49,8 @@ uses
   ClpX9ECC,
   ClpIX9ECC,
   ClpIAsn1Objects,
+  ClpScalarSplitParameters,
+  ClpIScalarSplitParameters,
   ClpGlvTypeBEndomorphism,
   ClpX9ECParameters,
   ClpIX9ECParameters,
@@ -437,14 +439,16 @@ begin
     ('7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', 16),
     TBigInteger.Create
     ('5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', 16),
-    TCryptoLibGenericArray<TBigInteger>.Create
+
+    TScalarSplitParameters.Create(TCryptoLibGenericArray<TBigInteger>.Create
     (TBigInteger.Create('3086d221a7d46bcde86c90e49284eb15', 16),
     TBigInteger.Create('-e4437ed6010e88286f547fa90abfe4c3', 16)),
-    TCryptoLibGenericArray<TBigInteger>.Create
-    (TBigInteger.Create('114ca50f7a8e2f3f657c1108d9d44cfd8', 16),
+    TCryptoLibGenericArray<TBigInteger>.Create(TBigInteger.Create
+    ('114ca50f7a8e2f3f657c1108d9d44cfd8', 16),
     TBigInteger.Create('3086d221a7d46bcde86c90e49284eb15', 16)),
     TBigInteger.Create('3086d221a7d46bcde86c90e49284eb153dab', 16),
-    TBigInteger.Create('e4437ed6010e88286f547fa90abfe4c42212', 16), 272);
+    TBigInteger.Create('e4437ed6010e88286f547fa90abfe4c42212', 16), 272)
+    as IScalarSplitParameters);
   curve := ConfigureCurveGlv(TSecP256K1Curve.Create() as ISecP256K1Curve, glv);
   G := ConfigureBasepoint(curve,
     '0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8');

+ 3 - 0
CryptoLib/src/Interfaces/ClpIECC.pas

@@ -253,6 +253,9 @@ type
     function ScaleX(const scale: IECFieldElement): IECPoint;
     function ScaleY(const scale: IECFieldElement): IECPoint;
 
+    function ScaleXNegateY(const scale: IECFieldElement): IECPoint;
+    function ScaleYNegateX(const scale: IECFieldElement): IECPoint;
+
     function GetEncoded(): TCryptoLibByteArray; overload;
     function GetEncoded(compressed: Boolean): TCryptoLibByteArray; overload;
 

+ 36 - 0
CryptoLib/src/Interfaces/ClpIGlvTypeAEndomorphism.pas

@@ -0,0 +1,36 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpIGlvTypeAEndomorphism;
+
+{$I ..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpBigInteger,
+  ClpIGlvEndomorphism;
+
+type
+  IGlvTypeAEndomorphism = interface(IGlvEndomorphism)
+    ['{961A1588-7D37-46C5-BC67-F71063641B42}']
+
+  end;
+
+implementation
+
+end.

+ 46 - 0
CryptoLib/src/Interfaces/ClpIGlvTypeAParameters.pas

@@ -0,0 +1,46 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpIGlvTypeAParameters;
+
+{$I ..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpBigInteger,
+  ClpIScalarSplitParameters,
+  ClpCryptoLibTypes;
+
+type
+
+  IGlvTypeAParameters = interface(IInterface)
+    ['{B5DDABB5-B51C-41F4-B2FD-6C8733300502}']
+
+    function GetI: TBigInteger;
+    function GetLambda: TBigInteger;
+    function GetSplitParams: IScalarSplitParameters;
+
+    property I: TBigInteger read GetI;
+    property lambda: TBigInteger read GetLambda;
+    property splitParams: IScalarSplitParameters read GetSplitParams;
+
+  end;
+
+implementation
+
+end.

+ 0 - 2
CryptoLib/src/Interfaces/ClpIGlvTypeBEndomorphism.pas

@@ -29,8 +29,6 @@ type
   IGlvTypeBEndomorphism = interface(IGlvEndomorphism)
     ['{4F285F6A-F627-4873-9F4C-FBC7A7B83A9C}']
 
-    function CalculateB(const k, g: TBigInteger; t: Int32): TBigInteger;
-
   end;
 
 implementation

+ 4 - 15
CryptoLib/src/Interfaces/ClpIGlvTypeBParameters.pas

@@ -23,6 +23,7 @@ interface
 
 uses
   ClpBigInteger,
+  ClpIScalarSplitParameters,
   ClpCryptoLibTypes;
 
 type
@@ -30,25 +31,13 @@ type
   IGlvTypeBParameters = interface(IInterface)
     ['{089AC2AB-15A1-47F5-BED0-C09EA77BECB9}']
 
-    function GetG1: TBigInteger;
-    function GetG2: TBigInteger;
-    function GetV1A: TBigInteger;
-    function GetV1B: TBigInteger;
-    function GetV2A: TBigInteger;
-    function GetV2B: TBigInteger;
     function GetLambda: TBigInteger;
     function GetBeta: TBigInteger;
-    function GetBits: Int32;
-
-    property g1: TBigInteger read GetG1;
-    property g2: TBigInteger read GetG2;
-    property V1A: TBigInteger read GetV1A;
-    property V1B: TBigInteger read GetV1B;
-    property V2A: TBigInteger read GetV2A;
-    property V2B: TBigInteger read GetV2B;
+    function GetSplitParams: IScalarSplitParameters;
+
     property lambda: TBigInteger read GetLambda;
     property beta: TBigInteger read GetBeta;
-    property bits: Int32 read GetBits;
+    property splitParams: IScalarSplitParameters read GetSplitParams;
 
   end;
 

+ 52 - 0
CryptoLib/src/Interfaces/ClpIScalarSplitParameters.pas

@@ -0,0 +1,52 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpIScalarSplitParameters;
+
+{$I ..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpBigInteger,
+  ClpIGlvEndomorphism;
+
+type
+  IScalarSplitParameters = interface(IInterface)
+    ['{C36FF223-C4F3-4483-B280-A50EF95497AF}']
+
+    function GetG1: TBigInteger;
+    function GetG2: TBigInteger;
+    function GetV1A: TBigInteger;
+    function GetV1B: TBigInteger;
+    function GetV2A: TBigInteger;
+    function GetV2B: TBigInteger;
+    function GetBits: Int32;
+
+    property g1: TBigInteger read GetG1;
+    property g2: TBigInteger read GetG2;
+    property V1A: TBigInteger read GetV1A;
+    property V1B: TBigInteger read GetV1B;
+    property V2A: TBigInteger read GetV2A;
+    property V2B: TBigInteger read GetV2B;
+    property bits: Int32 read GetBits;
+
+  end;
+
+implementation
+
+end.

+ 36 - 0
CryptoLib/src/Interfaces/ClpIScaleXNegateYPointMap.pas

@@ -0,0 +1,36 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpIScaleXNegateYPointMap;
+
+{$I ..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpIECC;
+
+type
+  IScaleXNegateYPointMap = interface(IECPointMap)
+
+    ['{D4FF6900-B627-45AB-8066-00E763213CE5}']
+
+  end;
+
+implementation
+
+end.

+ 36 - 0
CryptoLib/src/Interfaces/ClpIScaleYNegateXPointMap.pas

@@ -0,0 +1,36 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpIScaleYNegateXPointMap;
+
+{$I ..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpIECC;
+
+type
+  IScaleYNegateXPointMap = interface(IECPointMap)
+
+    ['{6284EFA2-DE75-437F-86D3-DD93BCAF511B}']
+
+  end;
+
+implementation
+
+end.

+ 49 - 0
CryptoLib/src/Math/EC/ClpECAlgorithms.pas

@@ -31,6 +31,7 @@ uses
   ClpIPolynomialExtensionField,
   ClpIGlvEndomorphism,
   ClpIWNafPreCompInfo,
+  ClpIScalarSplitParameters,
   ClpIPreCompInfo,
   ClpIEndoPreCompInfo,
   ClpEndoPreCompInfo,
@@ -328,6 +329,9 @@ type
 
     end;
 
+  class function CalculateB(const k, g: TBigInteger; t: Int32)
+    : TBigInteger; static;
+
   public
 
     const
@@ -337,6 +341,9 @@ type
     class function MapPoint(const endomorphism: IECEndomorphism;
       const p: IECPoint): IECPoint; static;
 
+    class function DecomposeScalar(const p: IScalarSplitParameters;
+      const k: TBigInteger): TCryptoLibGenericArray<TBigInteger>; static;
+
   end;
 
 type
@@ -2179,6 +2186,48 @@ end;
 
 { TEndoUtilities }
 
+class function TEndoUtilities.CalculateB(const k, g: TBigInteger; t: Int32)
+  : TBigInteger;
+var
+  negative, extra: Boolean;
+  b: TBigInteger;
+begin
+  negative := (g.SignValue < 0);
+  b := k.Multiply(g.Abs());
+  extra := b.TestBit(t - 1);
+  b := b.ShiftRight(t);
+  if (extra) then
+  begin
+    b := b.Add(TBigInteger.One);
+  end;
+
+  if negative then
+  begin
+    result := b.Negate();
+  end
+  else
+  begin
+    result := b;
+  end;
+end;
+
+class function TEndoUtilities.DecomposeScalar(const p: IScalarSplitParameters;
+  const k: TBigInteger): TCryptoLibGenericArray<TBigInteger>;
+var
+  bits: Int32;
+  b1, b2, a, b: TBigInteger;
+begin
+
+  bits := p.bits;
+  b1 := CalculateB(k, p.G1, bits);
+  b2 := CalculateB(k, p.G2, bits);
+
+  a := k.Subtract((b1.Multiply(p.V1A)).Add(b2.Multiply(p.V2A)));
+  b := (b1.Multiply(p.V1B)).Add(b2.Multiply(p.V2B)).Negate();
+
+  result := TCryptoLibGenericArray<TBigInteger>.Create(a, b);
+end;
+
 class function TEndoUtilities.MapPoint(const endomorphism: IECEndomorphism;
   const p: IECPoint): IECPoint;
 var

+ 44 - 0
CryptoLib/src/Math/EC/ClpECC.pas

@@ -1159,6 +1159,9 @@ type
     function ScaleX(const scale: IECFieldElement): IECPoint; virtual;
     function ScaleY(const scale: IECFieldElement): IECPoint; virtual;
 
+    function ScaleXNegateY(const scale: IECFieldElement): IECPoint; virtual;
+    function ScaleYNegateX(const scale: IECFieldElement): IECPoint; virtual;
+
     function GetEncoded(): TCryptoLibByteArray; overload; virtual;
     function GetEncoded(compressed: Boolean): TCryptoLibByteArray; overload;
       virtual; abstract;
@@ -1401,6 +1404,9 @@ type
     function ScaleX(const scale: IECFieldElement): IECPoint; override;
     function ScaleY(const scale: IECFieldElement): IECPoint; override;
 
+    function ScaleXNegateY(const scale: IECFieldElement): IECPoint; override;
+    function ScaleYNegateX(const scale: IECFieldElement): IECPoint; override;
+
     function Subtract(const b: IECPoint): IECPoint; override;
 
     function Tau(): IAbstractF2mPoint; virtual;
@@ -3845,6 +3851,19 @@ begin
   end;
 end;
 
+function TECPoint.ScaleXNegateY(const scale: IECFieldElement): IECPoint;
+begin
+  if IsInfinity then
+  begin
+    result := Self;
+  end
+  else
+  begin
+    result := curve.CreateRawPoint(RawXCoord.Multiply(scale), RawYCoord.Negate,
+      RawZCoords, IsCompressed);
+  end;
+end;
+
 function TECPoint.ScaleY(const scale: IECFieldElement): IECPoint;
 begin
   if IsInfinity then
@@ -3858,6 +3877,19 @@ begin
   end;
 end;
 
+function TECPoint.ScaleYNegateX(const scale: IECFieldElement): IECPoint;
+begin
+  if IsInfinity then
+  begin
+    result := Self;
+  end
+  else
+  begin
+    result := curve.CreateRawPoint(RawXCoord.Negate, RawYCoord.Multiply(scale),
+      RawZCoords, IsCompressed);
+  end;
+end;
+
 procedure TECPoint.SetpreCompTable(const Value
   : TDictionary<String, IPreCompInfo>);
 begin
@@ -6357,6 +6389,12 @@ begin
 
 end;
 
+function TAbstractF2mPoint.ScaleXNegateY(const scale: IECFieldElement)
+  : IECPoint;
+begin
+  result := ScaleX(scale);
+end;
+
 function TAbstractF2mPoint.ScaleY(const scale: IECFieldElement): IECPoint;
 var
   Lx, L, L2: IECFieldElement;
@@ -6388,6 +6426,12 @@ begin
 
 end;
 
+function TAbstractF2mPoint.ScaleYNegateX(const scale: IECFieldElement)
+  : IECPoint;
+begin
+  result := ScaleY(scale);
+end;
+
 function TAbstractF2mPoint.Subtract(const b: IECPoint): IECPoint;
 begin
   if (b.IsInfinity) then

+ 56 - 0
CryptoLib/src/Math/EC/ClpScaleXNegateYPointMap.pas

@@ -0,0 +1,56 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpScaleXNegateYPointMap;
+
+{$I ..\..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpIECC,
+  ClpIScaleXNegateYPointMap;
+
+type
+  TScaleXNegateYPointMap = class(TInterfacedObject, IECPointMap,
+    IScaleXNegateYPointMap)
+
+  strict protected
+  var
+    Fscale: IECFieldElement;
+
+  public
+    constructor Create(const scale: IECFieldElement);
+    function Map(const p: IECPoint): IECPoint; virtual;
+  end;
+
+implementation
+
+{ TScaleXNegateYPointMap }
+
+constructor TScaleXNegateYPointMap.Create(const scale: IECFieldElement);
+begin
+  Inherited Create();
+  Fscale := scale;
+end;
+
+function TScaleXNegateYPointMap.Map(const p: IECPoint): IECPoint;
+begin
+  Result := p.ScaleXNegateY(Fscale);
+end;
+
+end.

+ 56 - 0
CryptoLib/src/Math/EC/ClpScaleYNegateXPointMap.pas

@@ -0,0 +1,56 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpScaleYNegateXPointMap;
+
+{$I ..\..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpIECC,
+  ClpIScaleYNegateXPointMap;
+
+type
+  TScaleYNegateXPointMap = class(TInterfacedObject, IECPointMap,
+    IScaleYNegateXPointMap)
+
+  strict protected
+  var
+    Fscale: IECFieldElement;
+
+  public
+    constructor Create(const scale: IECFieldElement);
+    function Map(const p: IECPoint): IECPoint; virtual;
+  end;
+
+implementation
+
+{ TScaleYNegateXPointMap }
+
+constructor TScaleYNegateXPointMap.Create(const scale: IECFieldElement);
+begin
+  Inherited Create();
+  Fscale := scale;
+end;
+
+function TScaleYNegateXPointMap.Map(const p: IECPoint): IECPoint;
+begin
+  Result := p.ScaleYNegateX(Fscale);
+end;
+
+end.

+ 92 - 0
CryptoLib/src/Math/EC/Endo/ClpGlvTypeAEndomorphism.pas

@@ -0,0 +1,92 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpGlvTypeAEndomorphism;
+
+{$I ..\..\..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpCryptoLibTypes,
+  ClpBigInteger,
+  ClpECAlgorithms,
+  ClpScaleYNegateXPointMap,
+  ClpIGlvTypeAEndomorphism,
+  ClpIECC,
+  ClpIGlvTypeAParameters,
+  ClpIGlvEndomorphism;
+
+type
+  TGlvTypeAEndomorphism = class(TInterfacedObject, IECEndomorphism,
+    IGlvEndomorphism, IGlvTypeAEndomorphism)
+
+  strict private
+    function GetHasEfficientPointMap: Boolean; virtual;
+    function GetPointMap: IECPointMap; virtual;
+
+  strict protected
+  var
+    FParameters: IGlvTypeAParameters;
+    FPointMap: IECPointMap;
+
+  public
+    constructor Create(const curve: IECCurve;
+      const parameters: IGlvTypeAParameters);
+
+    function DecomposeScalar(const k: TBigInteger)
+      : TCryptoLibGenericArray<TBigInteger>; virtual;
+
+    property PointMap: IECPointMap read GetPointMap;
+    property HasEfficientPointMap: Boolean read GetHasEfficientPointMap;
+  end;
+
+implementation
+
+{ TGlvTypeAEndomorphism }
+
+constructor TGlvTypeAEndomorphism.Create(const curve: IECCurve;
+  const parameters: IGlvTypeAParameters);
+begin
+  Inherited Create();
+  (*
+    * NOTE: 'curve' MUST only be used to create a suitable ECFieldElement. Due to the way
+    * ECCurve configuration works, 'curve' will not be the actual instance of ECCurve that the
+    * endomorphism is being used with.
+  *)
+  FParameters := parameters;
+  FPointMap := TScaleYNegateXPointMap.Create
+    (curve.FromBigInteger(parameters.I));
+end;
+
+function TGlvTypeAEndomorphism.DecomposeScalar(const k: TBigInteger)
+  : TCryptoLibGenericArray<TBigInteger>;
+begin
+  Result := TEndoUtilities.DecomposeScalar(FParameters.SplitParams, k);
+end;
+
+function TGlvTypeAEndomorphism.GetHasEfficientPointMap: Boolean;
+begin
+  Result := true;
+end;
+
+function TGlvTypeAEndomorphism.GetPointMap: IECPointMap;
+begin
+  Result := FPointMap;
+end;
+
+end.

+ 81 - 0
CryptoLib/src/Math/EC/Endo/ClpGlvTypeAParameters.pas

@@ -0,0 +1,81 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpGlvTypeAParameters;
+
+{$I ..\..\..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpBigInteger,
+  ClpIGlvTypeAParameters,
+  ClpIScalarSplitParameters,
+  ClpCryptoLibTypes;
+
+type
+  TGlvTypeAParameters = class sealed(TInterfacedObject, IGlvTypeAParameters)
+
+  strict private
+  var
+    FI, Flambda: TBigInteger;
+    FsplitParams: IScalarSplitParameters;
+
+    function GetLambda: TBigInteger; inline;
+    function GetI: TBigInteger; inline;
+    function GetSplitParams: IScalarSplitParameters; inline;
+
+  public
+
+    constructor Create(const I, lambda: TBigInteger;
+      const splitParams: IScalarSplitParameters);
+
+    property lambda: TBigInteger read GetLambda;
+    property beta: TBigInteger read GetI;
+    property splitParams: IScalarSplitParameters read GetSplitParams;
+
+  end;
+
+implementation
+
+{ TGlvTypeAParameters }
+
+constructor TGlvTypeAParameters.Create(const I, lambda: TBigInteger;
+  const splitParams: IScalarSplitParameters);
+begin
+  Inherited Create();
+  FI := I;
+  Flambda := lambda;
+  FsplitParams := splitParams;
+end;
+
+function TGlvTypeAParameters.GetI: TBigInteger;
+begin
+  Result := FI;
+end;
+
+function TGlvTypeAParameters.GetLambda: TBigInteger;
+begin
+  Result := Flambda;
+end;
+
+function TGlvTypeAParameters.GetSplitParams: IScalarSplitParameters;
+begin
+  Result := FsplitParams;
+end;
+
+end.

+ 3 - 48
CryptoLib/src/Math/EC/Endo/ClpGlvTypeBEndomorphism.pas

@@ -24,6 +24,7 @@ interface
 uses
   ClpCryptoLibTypes,
   ClpBigInteger,
+  ClpECAlgorithms,
   ClpScaleXPointMap,
   ClpIGlvTypeBEndomorphism,
   ClpIECC,
@@ -43,13 +44,10 @@ type
     FParameters: IGlvTypeBParameters;
     FPointMap: IECPointMap;
 
-    function CalculateB(const k, g: TBigInteger; t: Int32)
-      : TBigInteger; virtual;
-
   public
     constructor Create(const curve: IECCurve;
       const parameters: IGlvTypeBParameters);
-    destructor Destroy; override;
+
     function DecomposeScalar(const k: TBigInteger)
       : TCryptoLibGenericArray<TBigInteger>; virtual;
 
@@ -61,31 +59,6 @@ implementation
 
 { TGlvTypeBEndomorphism }
 
-function TGlvTypeBEndomorphism.CalculateB(const k, g: TBigInteger; t: Int32)
-  : TBigInteger;
-var
-  negative, extra: Boolean;
-  b: TBigInteger;
-begin
-  negative := (g.SignValue < 0);
-  b := k.Multiply(g.Abs());
-  extra := b.TestBit(t - 1);
-  b := b.ShiftRight(t);
-  if (extra) then
-  begin
-    b := b.Add(TBigInteger.One);
-  end;
-
-  if negative then
-  begin
-    Result := b.Negate();
-  end
-  else
-  begin
-    Result := b;
-  end;
-end;
-
 constructor TGlvTypeBEndomorphism.Create(const curve: IECCurve;
   const parameters: IGlvTypeBParameters);
 begin
@@ -101,26 +74,8 @@ end;
 
 function TGlvTypeBEndomorphism.DecomposeScalar(const k: TBigInteger)
   : TCryptoLibGenericArray<TBigInteger>;
-var
-  bits: Int32;
-  b1, b2, a, b: TBigInteger;
-  p: IGlvTypeBParameters;
-begin
-  p := FParameters;
-
-  bits := p.bits;
-  b1 := CalculateB(k, p.G1, bits);
-  b2 := CalculateB(k, p.G2, bits);
-
-  a := k.subtract((b1.Multiply(p.V1A)).Add(b2.Multiply(p.V2A)));
-  b := (b1.Multiply(p.V1B)).Add(b2.Multiply(p.V2B)).Negate();
-
-  Result := TCryptoLibGenericArray<TBigInteger>.Create(a, b);
-end;
-
-destructor TGlvTypeBEndomorphism.Destroy;
 begin
-  inherited Destroy;
+  Result := TEndoUtilities.DecomposeScalar(FParameters.SplitParams, k);
 end;
 
 function TGlvTypeBEndomorphism.GetHasEfficientPointMap: Boolean;

+ 16 - 89
CryptoLib/src/Math/EC/Endo/ClpGlvTypeBParameters.pas

@@ -24,48 +24,29 @@ interface
 uses
   ClpBigInteger,
   ClpIGlvTypeBParameters,
+  ClpIScalarSplitParameters,
   ClpCryptoLibTypes;
 
-resourcestring
-  SInvalidParameters = '"%s" must consist of exactly 2 (initialized) values';
-
 type
   TGlvTypeBParameters = class sealed(TInterfacedObject, IGlvTypeBParameters)
 
   strict private
-    function GetG1: TBigInteger; inline;
-    function GetG2: TBigInteger; inline;
-    function GetV1A: TBigInteger; inline;
-    function GetV1B: TBigInteger; inline;
-    function GetV2A: TBigInteger; inline;
-    function GetV2B: TBigInteger; inline;
+  var
+    Fbeta, Flambda: TBigInteger;
+    FsplitParams: IScalarSplitParameters;
+
     function GetLambda: TBigInteger; inline;
     function GetBeta: TBigInteger; inline;
-    function GetBits: Int32; inline;
-
-    class procedure CheckVector(const v: TCryptoLibGenericArray<TBigInteger>;
-      const name: String); static;
-
-  strict protected
-    Fbeta, Flambda, Fg1, Fg2, Fv1A, Fv1B, Fv2A, Fv2B: TBigInteger;
-    Fbits: Int32;
+    function GetSplitParams: IScalarSplitParameters; inline;
 
   public
-    constructor Create(const beta, lambda: TBigInteger;
-      const v1, v2: TCryptoLibGenericArray<TBigInteger>;
-      const g1, g2: TBigInteger; bits: Int32);
 
-    destructor Destroy; override;
+    constructor Create(const beta, lambda: TBigInteger;
+      const splitParams: IScalarSplitParameters);
 
-    property g1: TBigInteger read GetG1;
-    property g2: TBigInteger read GetG2;
-    property V1A: TBigInteger read GetV1A;
-    property V1B: TBigInteger read GetV1B;
-    property V2A: TBigInteger read GetV2A;
-    property V2B: TBigInteger read GetV2B;
     property lambda: TBigInteger read GetLambda;
     property beta: TBigInteger read GetBeta;
-    property bits: Int32 read GetBits;
+    property splitParams: IScalarSplitParameters read GetSplitParams;
 
   end;
 
@@ -73,67 +54,13 @@ implementation
 
 { TGlvTypeBParameters }
 
-class procedure TGlvTypeBParameters.CheckVector
-  (const v: TCryptoLibGenericArray<TBigInteger>; const name: String);
-begin
-  if ((v = Nil) or (System.length(v) <> 2) or (not v[0].IsInitialized) or
-    (not v[1].IsInitialized)) then
-  begin
-    raise EArgumentCryptoLibException.CreateResFmt(@SInvalidParameters, [name]);
-  end;
-end;
-
 constructor TGlvTypeBParameters.Create(const beta, lambda: TBigInteger;
-  const v1, v2: TCryptoLibGenericArray<TBigInteger>; const g1, g2: TBigInteger;
-  bits: Int32);
+  const splitParams: IScalarSplitParameters);
 begin
-  CheckVector(v1, 'v1');
-  CheckVector(v2, 'v2');
-
+  Inherited Create();
   Fbeta := beta;
   Flambda := lambda;
-  Fv1A := v1[0];
-  Fv1B := v1[1];
-  Fv2A := v2[0];
-  Fv2B := v2[1];
-  Fg1 := g1;
-  Fg2 := g2;
-  Fbits := bits;
-end;
-
-destructor TGlvTypeBParameters.Destroy;
-begin
-  inherited Destroy;
-end;
-
-function TGlvTypeBParameters.GetG1: TBigInteger;
-begin
-  Result := Fg1;
-end;
-
-function TGlvTypeBParameters.GetG2: TBigInteger;
-begin
-  Result := Fg2;
-end;
-
-function TGlvTypeBParameters.GetV1A: TBigInteger;
-begin
-  Result := Fv1A;
-end;
-
-function TGlvTypeBParameters.GetV1B: TBigInteger;
-begin
-  Result := Fv1B;
-end;
-
-function TGlvTypeBParameters.GetV2A: TBigInteger;
-begin
-  Result := Fv2A;
-end;
-
-function TGlvTypeBParameters.GetV2B: TBigInteger;
-begin
-  Result := Fv2B;
+  FsplitParams := splitParams;
 end;
 
 function TGlvTypeBParameters.GetBeta: TBigInteger;
@@ -141,14 +68,14 @@ begin
   Result := Fbeta;
 end;
 
-function TGlvTypeBParameters.GetBits: Int32;
+function TGlvTypeBParameters.GetLambda: TBigInteger;
 begin
-  Result := Fbits;
+  Result := Flambda;
 end;
 
-function TGlvTypeBParameters.GetLambda: TBigInteger;
+function TGlvTypeBParameters.GetSplitParams: IScalarSplitParameters;
 begin
-  Result := Flambda;
+  Result := FsplitParams;
 end;
 
 end.

+ 131 - 0
CryptoLib/src/Math/EC/Endo/ClpScalarSplitParameters.pas

@@ -0,0 +1,131 @@
+{ *********************************************************************************** }
+{ *                              CryptoLib Library                                  * }
+{ *                Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe                    * }
+{ *                 Github Repository <https://github.com/Xor-el>                   * }
+
+{ *  Distributed under the MIT software license, see the accompanying file LICENSE  * }
+{ *          or visit http://www.opensource.org/licenses/mit-license.php.           * }
+
+{ *                              Acknowledgements:                                  * }
+{ *                                                                                 * }
+{ *      Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring     * }
+{ *                           development of this library                           * }
+
+{ * ******************************************************************************* * }
+
+(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
+
+unit ClpScalarSplitParameters;
+
+{$I ..\..\..\Include\CryptoLib.inc}
+
+interface
+
+uses
+  ClpBigInteger,
+  ClpIScalarSplitParameters,
+  ClpCryptoLibTypes;
+
+resourcestring
+  SInvalidParameters = '"%s" must consist of exactly 2 (initialized) values';
+
+type
+  TScalarSplitParameters = class sealed(TInterfacedObject,
+    IScalarSplitParameters)
+
+  strict private
+    function GetG1: TBigInteger; inline;
+    function GetG2: TBigInteger; inline;
+    function GetV1A: TBigInteger; inline;
+    function GetV1B: TBigInteger; inline;
+    function GetV2A: TBigInteger; inline;
+    function GetV2B: TBigInteger; inline;
+    function GetBits: Int32; inline;
+
+    class procedure CheckVector(const v: TCryptoLibGenericArray<TBigInteger>;
+      const name: String); static;
+
+  strict protected
+    Fg1, Fg2, Fv1A, Fv1B, Fv2A, Fv2B: TBigInteger;
+    Fbits: Int32;
+
+  public
+    constructor Create(const v1, v2: TCryptoLibGenericArray<TBigInteger>;
+      const g1, g2: TBigInteger; bits: Int32);
+
+    property g1: TBigInteger read GetG1;
+    property g2: TBigInteger read GetG2;
+    property V1A: TBigInteger read GetV1A;
+    property V1B: TBigInteger read GetV1B;
+    property V2A: TBigInteger read GetV2A;
+    property V2B: TBigInteger read GetV2B;
+    property bits: Int32 read GetBits;
+
+  end;
+
+implementation
+
+{ TScalarSplitParameters }
+
+class procedure TScalarSplitParameters.CheckVector
+  (const v: TCryptoLibGenericArray<TBigInteger>; const name: String);
+begin
+  if ((v = Nil) or (System.length(v) <> 2) or (not v[0].IsInitialized) or
+    (not v[1].IsInitialized)) then
+  begin
+    raise EArgumentCryptoLibException.CreateResFmt(@SInvalidParameters, [name]);
+  end;
+end;
+
+constructor TScalarSplitParameters.Create(const v1,
+  v2: TCryptoLibGenericArray<TBigInteger>; const g1, g2: TBigInteger;
+  bits: Int32);
+begin
+  CheckVector(v1, 'v1');
+  CheckVector(v2, 'v2');
+
+  Fv1A := v1[0];
+  Fv1B := v1[1];
+  Fv2A := v2[0];
+  Fv2B := v2[1];
+  Fg1 := g1;
+  Fg2 := g2;
+  Fbits := bits;
+end;
+
+function TScalarSplitParameters.GetG1: TBigInteger;
+begin
+  Result := Fg1;
+end;
+
+function TScalarSplitParameters.GetG2: TBigInteger;
+begin
+  Result := Fg2;
+end;
+
+function TScalarSplitParameters.GetV1A: TBigInteger;
+begin
+  Result := Fv1A;
+end;
+
+function TScalarSplitParameters.GetV1B: TBigInteger;
+begin
+  Result := Fv1B;
+end;
+
+function TScalarSplitParameters.GetV2A: TBigInteger;
+begin
+  Result := Fv2A;
+end;
+
+function TScalarSplitParameters.GetV2B: TBigInteger;
+begin
+  Result := Fv2B;
+end;
+
+function TScalarSplitParameters.GetBits: Int32;
+begin
+  Result := Fbits;
+end;
+
+end.

+ 11 - 1
CryptoLib/src/Packages/Delphi/CryptoLib4PascalPackage.dpk

@@ -403,7 +403,17 @@ contains
   ClpIDHValidationParams in '..\..\Interfaces\ClpIDHValidationParams.pas',
   ClpAESPRNGRandom in '..\..\Utils\Randoms\ClpAESPRNGRandom.pas',
   ClpCryptLibObjectIdentifiers in '..\..\Asn1\CryptLib\ClpCryptLibObjectIdentifiers.pas',
+  ClpIGlvTypeAParameters in '..\..\Interfaces\ClpIGlvTypeAParameters.pas',
+  ClpIGlvTypeAEndomorphism in '..\..\Interfaces\ClpIGlvTypeAEndomorphism.pas',
+  ClpIScaleXNegateYPointMap in '..\..\Interfaces\ClpIScaleXNegateYPointMap.pas',
+  ClpIScaleYNegateXPointMap in '..\..\Interfaces\ClpIScaleYNegateXPointMap.pas',
+  ClpIScalarSplitParameters in '..\..\Interfaces\ClpIScalarSplitParameters.pas',
+  ClpIEndoPreCompInfo in '..\..\Interfaces\ClpIEndoPreCompInfo.pas',
+  ClpScaleXNegateYPointMap in '..\..\Math\EC\ClpScaleXNegateYPointMap.pas',
+  ClpScaleYNegateXPointMap in '..\..\Math\EC\ClpScaleYNegateXPointMap.pas',
   ClpEndoPreCompInfo in '..\..\Math\EC\Endo\ClpEndoPreCompInfo.pas',
-  ClpIEndoPreCompInfo in '..\..\Interfaces\ClpIEndoPreCompInfo.pas';
+  ClpGlvTypeAEndomorphism in '..\..\Math\EC\Endo\ClpGlvTypeAEndomorphism.pas',
+  ClpGlvTypeAParameters in '..\..\Math\EC\Endo\ClpGlvTypeAParameters.pas',
+  ClpScalarSplitParameters in '..\..\Math\EC\Endo\ClpScalarSplitParameters.pas';
 
 end.

+ 41 - 1
CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.lpk

@@ -25,7 +25,7 @@
  Acknowledgements: 
 Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the development of this library "/>
     <Version Major="3" Minor="1"/>
-    <Files Count="372">
+    <Files Count="382">
       <Item1>
         <Filename Value="..\..\Asn1\ClpOidTokenizer.pas"/>
         <UnitName Value="ClpOidTokenizer"/>
@@ -1516,6 +1516,46 @@ Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring the devel
         <Filename Value="..\..\Math\EC\Endo\ClpEndoPreCompInfo.pas"/>
         <UnitName Value="ClpEndoPreCompInfo"/>
       </Item372>
+      <Item373>
+        <Filename Value="..\..\Math\EC\ClpScaleXNegateYPointMap.pas"/>
+        <UnitName Value="ClpScaleXNegateYPointMap"/>
+      </Item373>
+      <Item374>
+        <Filename Value="..\..\Math\EC\ClpScaleYNegateXPointMap.pas"/>
+        <UnitName Value="ClpScaleYNegateXPointMap"/>
+      </Item374>
+      <Item375>
+        <Filename Value="..\..\Math\EC\Endo\ClpGlvTypeAEndomorphism.pas"/>
+        <UnitName Value="ClpGlvTypeAEndomorphism"/>
+      </Item375>
+      <Item376>
+        <Filename Value="..\..\Math\EC\Endo\ClpGlvTypeAParameters.pas"/>
+        <UnitName Value="ClpGlvTypeAParameters"/>
+      </Item376>
+      <Item377>
+        <Filename Value="..\..\Math\EC\Endo\ClpScalarSplitParameters.pas"/>
+        <UnitName Value="ClpScalarSplitParameters"/>
+      </Item377>
+      <Item378>
+        <Filename Value="..\..\Interfaces\ClpIGlvTypeAParameters.pas"/>
+        <UnitName Value="ClpIGlvTypeAParameters"/>
+      </Item378>
+      <Item379>
+        <Filename Value="..\..\Interfaces\ClpIGlvTypeAEndomorphism.pas"/>
+        <UnitName Value="ClpIGlvTypeAEndomorphism"/>
+      </Item379>
+      <Item380>
+        <Filename Value="..\..\Interfaces\ClpIScaleXNegateYPointMap.pas"/>
+        <UnitName Value="ClpIScaleXNegateYPointMap"/>
+      </Item380>
+      <Item381>
+        <Filename Value="..\..\Interfaces\ClpIScaleYNegateXPointMap.pas"/>
+        <UnitName Value="ClpIScaleYNegateXPointMap"/>
+      </Item381>
+      <Item382>
+        <Filename Value="..\..\Interfaces\ClpIScalarSplitParameters.pas"/>
+        <UnitName Value="ClpIScalarSplitParameters"/>
+      </Item382>
     </Files>
     <RequiredPkgs Count="3">
       <Item1>

+ 5 - 1
CryptoLib/src/Packages/FPC/CryptoLib4PascalPackage.pas

@@ -133,7 +133,11 @@ uses
   ClpDHPublicKeyParameters, ClpDHKeyGenerationParameters, ClpDHKeyParameters, 
   ClpDHValidationParameters, ClpDHParameters, ClpDHDomainParameters, 
   ClpDHValidationParams, ClpAESPRNGRandom, ClpCryptLibObjectIdentifiers, 
-  ClpIEndoPreCompInfo, ClpEndoPreCompInfo;
+  ClpIEndoPreCompInfo, ClpEndoPreCompInfo, ClpScaleXNegateYPointMap, 
+  ClpScaleYNegateXPointMap, ClpGlvTypeAEndomorphism, ClpGlvTypeAParameters, 
+  ClpScalarSplitParameters, ClpIGlvTypeAParameters, ClpIGlvTypeAEndomorphism, 
+  ClpIScaleXNegateYPointMap, ClpIScaleYNegateXPointMap, 
+  ClpIScalarSplitParameters;
 
 implementation