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 Exponent: Result := Base^Exponent mod Modulus
  37    procedure FZ_Mod_Exp(Base     : in  FZ;
  38                         Exponent : in  FZ;
  39                         Modulus  : in  FZ;
  40                         Result   : out FZ) with
  41      Pre => Base'Length = Exponent'Length and
  42      Base'Length = Result'Length and
  43      Base'Length = Modulus'Length;
  44    
  45 end FZ_ModEx;