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