Browse Source

minor refactoring

Ugochukwu Mmaduekwe 7 years ago
parent
commit
3e1477d64b
1 changed files with 6 additions and 11 deletions
  1. 6 11
      CryptoLib/src/Crypto/Signers/ClpECSchnorrSigner.pas

+ 6 - 11
CryptoLib/src/Crypto/Signers/ClpECSchnorrSigner.pas

@@ -54,12 +54,9 @@ type
 
   strict private
 
-    class var
-
-      FRandom: ISecureRandom;
-
   var
     FDigest: IDigest;
+    FRandom: ISecureRandom;
     FSigner: ISchnorr;
     FforSigning: Boolean;
     Fkey: IECKeyParameters;
@@ -85,8 +82,6 @@ type
     function Sign_K(const pv_key: IECPrivateKeyParameters; const k: TBigInteger)
       : TCryptoLibByteArray;
 
-    class constructor ECSchnorrSigner();
-
   public
 
     function Do_Sign(const pv_key: IECPrivateKeyParameters;
@@ -222,11 +217,6 @@ implementation
 
 { TECSchnorrSigner }
 
-class constructor TECSchnorrSigner.ECSchnorrSigner;
-begin
-  FRandom := TSecureRandom.Create();
-end;
-
 class function TECSchnorrSigner.Encode_Sig(const r, s: TBigInteger)
   : TCryptoLibByteArray;
 begin
@@ -336,7 +326,12 @@ begin
 
     if (Supports(Lparameters, IParametersWithRandom, rParam)) then
     begin
+      FRandom := rParam.Random;
       Lparameters := rParam.parameters;
+    end
+    else
+    begin
+      FRandom := TSecureRandom.Create();
     end;
 
     if (not(Supports(Lparameters, IECPrivateKeyParameters))) then