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_ch11_tuning_a... 31 Product : out FZ)
ffa_ch11_tuning_a... 32 with Pre => X'Length = Y'Length and
ffa_ch11_tuning_a... 33 Modulus'Length = X'Length and
ffa_ch11_tuning_a... 34 Product'Length = Modulus'Length;
ffa_ch6_simplest_... 35
ffa_ch12_karatsub... 36 -- Modular Square: Product := X*X mod Modulus
ffa_ch12_karatsub... 37 procedure FZ_Mod_Sqr(X : in FZ;
ffa_ch12_karatsub... 38 Modulus : in FZ;
ffa_ch12_karatsub... 39 Product : out FZ)
ffa_ch12_karatsub... 40 with Pre => Modulus'Length = X'Length and
ffa_ch12_karatsub... 41 Product'Length = Modulus'Length;
ffa_ch12_karatsub... 42
ffa_ch6_simplest_... 43 -- Modular Exponent: Result := Base^Exponent mod Modulus
ffa_ch6_simplest_... 44 procedure FZ_Mod_Exp(Base : in FZ;
ffa_ch6_simplest_... 45 Exponent : in FZ;
ffa_ch6_simplest_... 46 Modulus : in FZ;
ffa_ch11_tuning_a... 47 Result : out FZ) with
ffa_ch11_tuning_a... 48 Pre => Base'Length = Exponent'Length and
ffa_ch11_tuning_a... 49 Base'Length = Result'Length and
ffa_ch11_tuning_a... 50 Base'Length = Modulus'Length;
ffa_ch6_simplest_... 51
ffa_ch6_simplest_... 52 end FZ_ModEx;