File : fz_modex.ads


   1 ------------------------------------------------------------------------------
   2 ------------------------------------------------------------------------------
   3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'.               --
   4 --                                                                          --
   5 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org )                      --
   6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html     --
   7 --                                                                          --
   8 -- You do not have, nor can you ever acquire the right to use, copy or      --
   9 -- distribute this software ; Should you use this software for any purpose, --
  10 -- or copy and distribute it to anyone or in any manner, you are breaking   --
  11 -- the laws of whatever soi-disant jurisdiction, and you promise to         --
  12 -- continue doing so for the indefinite future. In any case, please         --
  13 -- always : read and understand any software ; verify any PGP signatures    --
  14 -- that you use - for any purpose.                                          --
  15 --                                                                          --
  16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm .     --
  17 ------------------------------------------------------------------------------
  18 ------------------------------------------------------------------------------
  19 
  20 with FZ_Type; use FZ_Type;
  21 
  22 
  23 package FZ_ModEx is
  24    
  25    pragma Pure;
  26    
  27    -- Modular Multiply: Product := X*Y mod Modulus
  28    procedure FZ_Mod_Mul(X        : in  FZ;
  29                         Y        : in  FZ;
  30                         Modulus  : in  FZ;
  31                         Product  : out FZ)
  32      with Pre => X'Length = Y'Length and
  33      Modulus'Length = X'Length and
  34      Product'Length = Modulus'Length;
  35    
  36    -- Modular Square: Product := X*X mod Modulus
  37    procedure FZ_Mod_Sqr(X        : in  FZ;
  38                         Modulus  : in  FZ;
  39                         Product  : out FZ)
  40      with Pre => Modulus'Length = X'Length and
  41      Product'Length = Modulus'Length;
  42    
  43    -- Modular Exponent: Result := Base^Exponent mod Modulus
  44    procedure FZ_Mod_Exp(Base     : in  FZ;
  45                         Exponent : in  FZ;
  46                         Modulus  : in  FZ;
  47                         Result   : out FZ) with
  48      Pre => Base'Length = Exponent'Length and
  49      Base'Length = Result'Length and
  50      Base'Length = Modulus'Length;
  51    
  52 end FZ_ModEx;