ffa_ch6_simplest_... 1
ffa_ch6_simplest_... 2
ffa_ch6_simplest_... 3
ffa_ch6_simplest_... 4
ffa_ch15_gcd.kv 5
ffa_ch6_simplest_... 6
ffa_ch6_simplest_... 7
ffa_ch6_simplest_... 8
ffa_ch6_simplest_... 9
ffa_ch6_simplest_... 10
ffa_ch6_simplest_... 11
ffa_ch6_simplest_... 12
ffa_ch6_simplest_... 13
ffa_ch6_simplest_... 14
ffa_ch6_simplest_... 15
ffa_ch6_simplest_... 16
ffa_ch6_simplest_... 17
ffa_ch6_simplest_... 18
ffa_ch6_simplest_... 19
ffa_ch14_barrett.kv 20 with Words; use Words;
ffa_ch14_barrett.kv 21 with W_Shifts; use W_Shifts;
ffa_ch6_simplest_... 22 with FZ_Basic; use FZ_Basic;
ffa_ch6_simplest_... 23 with FZ_Mul; use FZ_Mul;
ffa_ch12_karatsub... 24 with FZ_Sqr; use FZ_Sqr;
ffa_ch6_simplest_... 25 with FZ_Divis; use FZ_Divis;
ffa_ch14_barrett.kv 26 with FZ_Barr; use FZ_Barr;
ffa_ch6_simplest_... 27
ffa_ch6_simplest_... 28
ffa_ch6_simplest_... 29 package body FZ_ModEx is
ffa_ch6_simplest_... 30
ffa_ch14_barrett.kv 31
ffa_ch6_simplest_... 32 procedure FZ_Mod_Mul(X : in FZ;
ffa_ch6_simplest_... 33 Y : in FZ;
ffa_ch6_simplest_... 34 Modulus : in FZ;
ffa_ch6_simplest_... 35 Product : out FZ) is
ffa_ch6_simplest_... 36
ffa_ch6_simplest_... 37
ffa_ch6_simplest_... 38 L : constant Indices := X'Length;
ffa_ch6_simplest_... 39
ffa_ch6_simplest_... 40
ffa_ch6_simplest_... 41 XY : FZ(1 .. L * 2);
ffa_ch6_simplest_... 42
ffa_ch6_simplest_... 43
ffa_ch6_simplest_... 44 XY_Lo : FZ renames XY(1 .. L);
ffa_ch6_simplest_... 45 XY_Hi : FZ renames XY(L + 1 .. XY'Last);
ffa_ch6_simplest_... 46
ffa_ch6_simplest_... 47 begin
ffa_ch6_simplest_... 48
ffa_ch6_simplest_... 49
ffa_ch11_tuning_a... 50 FZ_Multiply_Buffered(X, Y, XY_Lo, XY_Hi);
ffa_ch6_simplest_... 51
ffa_ch7_turbo_egy... 52
ffa_ch7_turbo_egy... 53 FZ_Mod(XY, Modulus, Product);
ffa_ch6_simplest_... 54
ffa_ch6_simplest_... 55 end FZ_Mod_Mul;
ffa_ch6_simplest_... 56
ffa_ch6_simplest_... 57
ffa_ch14_barrett.kv 58
ffa_ch12_karatsub... 59 procedure FZ_Mod_Sqr(X : in FZ;
ffa_ch12_karatsub... 60 Modulus : in FZ;
ffa_ch12_karatsub... 61 Product : out FZ) is
ffa_ch12_karatsub... 62
ffa_ch12_karatsub... 63
ffa_ch12_karatsub... 64 L : constant Indices := X'Length;
ffa_ch12_karatsub... 65
ffa_ch12_karatsub... 66
ffa_ch12_karatsub... 67 XX : FZ(1 .. L * 2);
ffa_ch12_karatsub... 68
ffa_ch12_karatsub... 69
ffa_ch12_karatsub... 70 XX_Lo : FZ renames XX(1 .. L);
ffa_ch12_karatsub... 71 XX_Hi : FZ renames XX(L + 1 .. XX'Last);
ffa_ch12_karatsub... 72
ffa_ch12_karatsub... 73 begin
ffa_ch12_karatsub... 74
ffa_ch12_karatsub... 75
ffa_ch12_karatsub... 76 FZ_Square_Buffered(X, XX_Lo, XX_Hi);
ffa_ch12_karatsub... 77
ffa_ch12_karatsub... 78
ffa_ch12_karatsub... 79 FZ_Mod(XX, Modulus, Product);
ffa_ch12_karatsub... 80
ffa_ch12_karatsub... 81 end FZ_Mod_Sqr;
ffa_ch12_karatsub... 82
ffa_ch12_karatsub... 83
ffa_ch14_barrett.kv 84
ffa_ch6_simplest_... 85 procedure FZ_Mod_Exp(Base : in FZ;
ffa_ch6_simplest_... 86 Exponent : in FZ;
ffa_ch6_simplest_... 87 Modulus : in FZ;
ffa_ch6_simplest_... 88 Result : out FZ) is
ffa_ch6_simplest_... 89
ffa_ch14_barrett.kv 90
ffa_ch14_barrett.kv 91 D : FZ(1 .. Base'Length * 2);
ffa_ch6_simplest_... 92
ffa_ch14_barrett.kv 93
ffa_ch14_barrett.kv 94 B : FZ(Base'Range) := Base;
ffa_ch6_simplest_... 95
ffa_ch6_simplest_... 96
ffa_ch14_barrett.kv 97 T : FZ(Result'Range);
ffa_ch6_simplest_... 98
ffa_ch8_randomism.kv 99
ffa_ch14_barrett.kv 100 R : FZ(Result'Range);
ffa_ch14_barrett.kv 101
ffa_ch14_barrett.kv 102
ffa_ch14_barrett.kv 103 Bar : Barretoid(ZXMLength => Modulus'Length + 1,
ffa_ch14_barrett.kv 104 BarretoidLength => 2 * B'Length);
ffa_ch8_randomism.kv 105
ffa_ch6_simplest_... 106 begin
ffa_ch14_barrett.kv 107
ffa_ch14_barrett.kv 108
ffa_ch14_barrett.kv 109 FZ_Make_Barrettoid(Modulus => Modulus, Result => Bar);
ffa_ch14_barrett.kv 110
ffa_ch6_simplest_... 111
ffa_ch8_randomism.kv 112 WBool_To_FZ(1, R);
ffa_ch6_simplest_... 113
ffa_ch14_barrett.kv 114
ffa_ch14_barrett.kv 115 for i in Exponent'Range loop
ffa_ch6_simplest_... 116
ffa_ch14_barrett.kv 117 declare
ffa_ch14_barrett.kv 118
ffa_ch14_barrett.kv 119
ffa_ch14_barrett.kv 120 Wi : Word := Exponent(i);
ffa_ch14_barrett.kv 121
ffa_ch14_barrett.kv 122 begin
ffa_ch14_barrett.kv 123
ffa_ch14_barrett.kv 124
ffa_ch14_barrett.kv 125 for j in 1 .. Bitness loop
ffa_ch14_barrett.kv 126
ffa_ch14_barrett.kv 127
ffa_ch14_barrett.kv 128 FZ_Multiply_Unbuffered(X => R, Y => B, XY => D);
ffa_ch14_barrett.kv 129 FZ_Barrett_Reduce(X => D, Bar => Bar, XReduced => T);
ffa_ch14_barrett.kv 130
ffa_ch14_barrett.kv 131
ffa_ch14_barrett.kv 132
ffa_ch14_barrett.kv 133
ffa_ch14_barrett.kv 134 FZ_Mux(X => R, Y => T, Result => R, Sel => Wi and 1);
ffa_ch14_barrett.kv 135
ffa_ch14_barrett.kv 136
ffa_ch14_barrett.kv 137 Wi := Shift_Right(Wi, 1);
ffa_ch14_barrett.kv 138
ffa_ch14_barrett.kv 139
ffa_ch14_barrett.kv 140 FZ_Square_Unbuffered(X => B, XX => D);
ffa_ch14_barrett.kv 141 FZ_Barrett_Reduce(X => D, Bar => Bar, XReduced => B);
ffa_ch14_barrett.kv 142
ffa_ch14_barrett.kv 143 end loop;
ffa_ch6_simplest_... 144
ffa_ch14_barrett.kv 145 end;
ffa_ch6_simplest_... 146
ffa_ch6_simplest_... 147 end loop;
ffa_ch6_simplest_... 148
ffa_ch8_randomism.kv 149
ffa_ch8_randomism.kv 150 Result := R;
ffa_ch8_randomism.kv 151
ffa_ch6_simplest_... 152 end FZ_Mod_Exp;
ffa_ch6_simplest_... 153
ffa_ch6_simplest_... 154 end FZ_ModEx;