File : fz_basic.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 Words;   use Words;
  21 with FZ_Type; use FZ_Type;
  22 
  23 
  24 package FZ_Basic is
  25    
  26    pragma Pure;
  27    
  28    -- Determine the Bitness of N
  29    function FZ_Bitness(N : in FZ) return Bit_Count;
  30    pragma Inline_Always(FZ_Bitness);
  31    
  32    -- Determine the Bitness of the given FZ's Length
  33    function FZ_Bitness_Log2(N : in FZ) return Positive;
  34    pragma Inline_Always(FZ_Bitness_Log2);
  35    
  36    -- N := 0
  37    procedure FZ_Clear(N : out FZ);
  38    pragma Inline_Always(FZ_Clear);
  39    
  40    -- Set given FZ to a given truth value
  41    procedure WBool_To_FZ(V : in WBool; N : out FZ);
  42    pragma Inline_Always(WBool_To_FZ);
  43    
  44    -- First word of N := Source
  45    procedure FZ_Set_Head(N : out FZ; Source : in Word);
  46    pragma Inline_Always(FZ_Set_Head);
  47    
  48    -- First word of N
  49    function FZ_Get_Head(N : in FZ) return Word;
  50    pragma Inline_Always(FZ_Get_Head);
  51    
  52    -- Exchange X and Y
  53    procedure FZ_Swap(X : in out FZ; Y : in out FZ);
  54    pragma Inline_Always(FZ_Swap);
  55    
  56    -- Constant-time MUX: Sel = 0: Result := X; Sel = 1: Result := Y
  57    procedure FZ_Mux(X : in FZ; Y : in FZ; Result : out FZ; Sel : in WBool);
  58    pragma Inline_Always(FZ_Mux);
  59    
  60 end FZ_Basic;