├── README.md └── libScarab1.0.0 ├── Makefile ├── VERSION ├── integer-fhe.c ├── integer-fhe.h ├── integer-fhe.nb ├── integer-fhe.o ├── main.c ├── main.o ├── parameters.h ├── test.c ├── test.h ├── test.o ├── types.c ├── types.h ├── types.o ├── util.c ├── util.h └── util.o /README.md: -------------------------------------------------------------------------------- 1 | Quick Action 2 | ============ 3 | 4 | To get started quickly, do the following: 5 | 6 | 1: Install Ubuntu 12.04 32 bit on a clean box, just to have a common ground (it should come with the default installation but make sure that gcc is installed) 7 | 8 | 2: Download libScarab-1.0.0.zip, gmp-5.1.1.tar.lz, flint-1.6.tgz, mpir-2.6.0.tar.bz2, mpfr-3.1.1.tar.bz2 from hcrypt.com and the linked web pages 9 | 10 | 3: Install m4 and lzip 11 | 12 | 3.1. sudo apt-get install m4 13 | 14 | 3.2. sudo apt-get install lzip 15 | 16 | 4: Install gmp 17 | 18 | 4.1. lzip -d gmp-5.1.1.tar.lz 19 | 20 | 4.2. tar xf gmp-5.1.1.tar 21 | 22 | 4.3. cd gmp-5.1.1 23 | 24 | 4.4. ./configure 25 | 26 | 4.5. make 27 | 28 | 4.6. make check #(never ever skip the checks!) 29 | 30 | 4.7. sudo make install 31 | 32 | 5: Install mpfr 33 | 34 | 5.1. tar xjf mpfr-3.1.1.tar.bz2 35 | 36 | 5.2. cd mpfr-3.1.1 37 | 38 | 5.3. make 39 | 40 | 5.4. make check 41 | 42 | 5.5. sudo make install 43 | 44 | 6: Install mpir 45 | 46 | 6.1. tar xjf mpir-2.6.0.tar.bz2 47 | 48 | 6.2. cd mpir-2.6.0 49 | 50 | 6.3. ./configure 51 | 52 | 6.4. make 53 | 54 | 6.5. make check 55 | 56 | 6.6. sudo make install 57 | 58 | 7: Install flint (ok, this is perhaps quite a bit strange) 59 | 60 | 7.1. tar xf flint-1.6.tgz 61 | 62 | 7.2. cd flint-1.6 63 | 64 | 7.3. source flint_env 65 | 66 | 7.4. make library 67 | 68 | 7.5. sudo cp libflint.so /usr/local/lib 69 | 70 | 7.6. sudo cp *.h /usr/local/include 71 | 72 | 7.7. sudo mkdir -p /usr/local/include/zn_poly/src 73 | 74 | 7.8. sudo cp zn_poly/include/*.h /usr/local/include/zn_poly/src/ 75 | 76 | 8: Run libscarab test 77 | 78 | 8.1. mkdir libscarab 79 | 80 | 8.2. cd libscarab 81 | 82 | 8.3. unzip ../libScarab-1.0.0.zip 83 | 84 | 8.4. make 85 | 86 | 8.5. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib 87 | 88 | 8.6. ./integer-fhe 89 | 90 | ta-daaa! 91 | 92 | Introduction 93 | ============ 94 | 95 | This is an implementation of a fully homomorphic encryption scheme using large integers. The mathematical foundation is based on work by C. Gentry [1] for the initial concept as well as N. Smart and F. Vercauteren [2] for the integer-based approach used in this implementation. 96 | 97 | The library presented here is beta software and should not be used for any mission critical applications. No warranty expressed or implied is given. 98 | 99 | Installation and usage 100 | ====================== 101 | 102 | Requirements 103 | ------------ 104 | 105 | The following libraries are required for building hcrypt: 106 | 107 | GMP: GNU Multiple Precision Arithmetic Library — http://gmplib.org/ 108 | FLINT: Fast Library for Number Theory version 1.6 — http://flintlib.org/flint-1.6.tgz 109 | MPIR: Multiple Precision Integers and Rationals — http://mpir.org/ (required by FLINT) 110 | MPFR — http://www.mpfr.org/ (required by FLINT) 111 | 112 | The library expects the flint headers under in your include directory. Also, copy zn_poly/include/*.h to ./zn_poly/src/ relative to your include path. 113 | 114 | Building 115 | -------- 116 | 117 | The compilation is done using make. 118 | 119 | $ make 120 | 121 | This builds an integer-fhe executeable in the current directory that runs a test of the library. 122 | Usage 123 | 124 | You can use the library as demonstrated in test.c. The following methods are exposed: 125 | function prototype meaning 126 | 127 | fhe_keygen(fhe_pk_t pk, fhe_sk_t sk); Generate a keypair 128 | fhe_encrypt(mpz_t c, fhe_pk_t pk, int m); Encrypt a message (0 or 1) 129 | fhe_decrypt(mpz_t c, fhe_sk_t sk); Decrypt a cyphertext 130 | fhe_recrypt(mpz_t c, fhe_pk_t pk, fhe_sk_t sk); Recrypt a cyphertext (“refreshing” it) 131 | fhe_add(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); Add cyphertexts (= XOR) 132 | fhe_mul(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); Multiply cyphertexts (= AND) 133 | fhe_fulladd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, mpz_t c_in, fhe_pk_t pk); Add with carry in and carry out 134 | fhe_halfadd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, fhe_pk_t pk); Add with carry out 135 | 136 | References 137 | ========== 138 | 139 | [1] C. Gentry, A fully homomorphic encryption scheme 140 | 141 | [2] N. Smart and F. Vercauteren, Fully Homomorphic Encryption with Relatively Small Key and Ciphertext Sizes 142 | 143 | [3] H. Perl, M. Brenner and M. Smith, POSTER: An Implementation of the Fully Homomorphic Smart-Vercauteren Crypto-System 144 | 145 | License 146 | ======= 147 | 148 | Copyright © 2011 149 | 150 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 151 | 152 | SOFTWARE AND SOURCE CODE MAY BE DOWNLOADED AND MODIFIED FOR EDUCATIONAL OR ACADEMIC USE. PATENT PCT/EP2678772B1. 153 | -------------------------------------------------------------------------------- /libScarab1.0.0/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -Wall -g3 -ggdb -std=c99 -I/usr/local/include -I/usr/local/include/libflint -L/usr/local/lib 3 | LDFLAGS += -lgmp -lflint 4 | SOURCE = $(shell find * -name '*.c') 5 | OBJECTS = $(SOURCE:.c=.o) 6 | .PHONY: clean 7 | 8 | all: integer-fhe 9 | 10 | integer-fhe: $(OBJECTS) 11 | $(CC) -o integer-fhe $^ $(LDFLAGS) 12 | 13 | clean: 14 | rm -f $(OBJECTS) integer-fhe 15 | 16 | -------------------------------------------------------------------------------- /libScarab1.0.0/VERSION: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /libScarab1.0.0/integer-fhe.c: -------------------------------------------------------------------------------- 1 | /* 2 | * keygen.c 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 01.03.10. 6 | * 7 | */ 8 | 9 | #include "integer-fhe.h" 10 | #undef DEBUG 11 | 12 | #ifdef DETERMINISTIC 13 | #define SEED 0 14 | #else 15 | #define SEED time(NULL) 16 | #endif 17 | 18 | void 19 | fhe_keygen(fhe_pk_t pk, fhe_sk_t sk) 20 | { 21 | mpz_t temp; 22 | mpz_init(temp); 23 | fmpz_t fmpz_p; 24 | 25 | fmpz_poly_t F; 26 | fmpz_poly_init(F); 27 | // set f = x^n + 1 28 | fmpz_poly_set_coeff_ui(F, N, 1); 29 | fmpz_poly_set_coeff_ui(F, 0, 1); 30 | 31 | fmpz_poly_t G; 32 | fmpz_poly_init(G); 33 | 34 | gmp_randstate_t randstate; 35 | gmp_randinit_default(randstate); 36 | gmp_randseed_ui(randstate, SEED); // make it deterministic for now 37 | do { 38 | fmpz_poly_rand_coeff_even(G, N, LOG_NU, &randstate); 39 | fmpz_t G_0 = fmpz_poly_get_coeff_ptr(G, 0); 40 | fmpz_add_ui(G_0, G_0, 1); 41 | // set p = resultant(G(x), F(x)) 42 | fmpz_p = fmpz_init(fmpz_poly_resultant_bound(G, F)/FLINT_BITS + 2); 43 | fmpz_poly_resultant(fmpz_p, G, F); 44 | fmpz_to_mpz(temp, fmpz_p); 45 | fmpz_clear(fmpz_p); 46 | } while (!mpz_probab_prime_p(temp, 10)); 47 | 48 | #ifdef DEBUG 49 | gmp_printf("Choosing Prime p = %Zd\n", temp); 50 | printf("Choosing F(x) = "); 51 | fmpz_poly_print_pretty(F, "x"); 52 | printf("\n"); 53 | printf("Choosing G(x) = "); 54 | fmpz_poly_print_pretty(G, "x"); 55 | printf("\n"); 56 | #endif 57 | 58 | F_mpz_t P; 59 | F_mpz_init(P); 60 | F_mpz_set_mpz(P, temp); 61 | 62 | F_mpz_mod_poly_t F_mod_p, G_mod_p, D_mod_p; 63 | F_mpz_mod_poly_init(F_mod_p, P); 64 | F_mpz_mod_poly_init(G_mod_p, P); 65 | F_mpz_mod_poly_init(D_mod_p, P); 66 | fmpz_poly_to_F_mpz_mod_poly(F_mod_p, F); 67 | fmpz_poly_to_F_mpz_mod_poly(G_mod_p, G); 68 | 69 | F_mpz_mod_poly_gcd_euclidean(D_mod_p, F_mod_p, G_mod_p); 70 | 71 | #ifdef DEBUG 72 | printf("gcd(G(x), F(x) = "); 73 | F_mpz_mod_poly_print_pretty(D_mod_p, "x"); 74 | printf("\n"); 75 | #endif 76 | 77 | F_mpz_t *root = (F_mpz_t *)D_mod_p->coeffs; 78 | F_mpz_neg(*root, *root); // root of D = -coeff[0] 79 | F_mpz_mod(*root, *root, P); 80 | 81 | fmpz_t r = fmpz_init(fmpz_poly_resultant_bound(G, F)/FLINT_BITS + 2); 82 | 83 | fmpz_poly_t Z, t; 84 | fmpz_poly_init(Z); 85 | fmpz_poly_init(t); 86 | 87 | #ifdef DEBUG 88 | printf("Executing XGCD with Polynomials G = "); 89 | fmpz_poly_print_pretty(G, "x"); 90 | printf("\n and F = "); 91 | fmpz_poly_print_pretty(F, "x"); 92 | printf("\n"); 93 | #endif 94 | fmpz_poly_xgcd(r, Z, t, G, F); 95 | 96 | #ifdef DEBUG 97 | printf("r = "); 98 | fmpz_print(r); 99 | printf("\n"); 100 | printf("Z(x) = "); 101 | fmpz_poly_print_pretty(Z, "x"); 102 | printf("\n"); 103 | #endif 104 | fmpz_p = fmpz_init(mpz_size(temp)); 105 | mpz_to_fmpz(fmpz_p, temp); 106 | assert(fmpz_equal(fmpz_p, r)); 107 | 108 | // build pk 109 | mpz_set(pk->p, temp); 110 | F_mpz_get_mpz(pk->alpha, *root); 111 | // build sk 112 | mpz_set(sk->p, temp); 113 | fmpz_poly_get_coeff_mpz(sk->B, Z, 0); 114 | mpz_mul_ui(temp, temp, 2); 115 | mpz_mod(sk->B, sk->B, temp); 116 | 117 | // Build hint 118 | mpz_t B_i, r_plus, r_minus; 119 | mpz_init(B_i); 120 | mpz_init(r_plus); 121 | mpz_init(r_minus); 122 | 123 | mpz_fdiv_q_ui(B_i, sk->B, S2); 124 | for (int i = 0; i < S2; i++) { 125 | mpz_set(pk->B[i], B_i); 126 | fhe_encrypt(pk->c[i], pk, 1); 127 | } 128 | mpz_add(pk->B[0], pk->B[0], sk->B); 129 | mpz_submul_ui(pk->B[0], B_i, S2); 130 | for (int i = S2; i < S1; i++) { 131 | mpz_urandomm(B_i, randstate, temp); // p is already 2*pk->p ! 132 | mpz_sub(B_i, B_i, pk->p); 133 | mpz_set(pk->B[i], B_i); 134 | fhe_encrypt(pk->c[i], pk, 0); 135 | } 136 | 137 | // add/sub values randomly 138 | for (int i = 0; i < S2; i++) { 139 | mpz_urandomm(r_plus, randstate, pk->p); 140 | mpz_neg(r_minus, r_plus); 141 | while (1) { 142 | int j = rand() % S2; 143 | mpz_add(pk->B[j], pk->B[j], r_plus); 144 | if (mpz_cmp(pk->B[j], pk->p) > 0) { 145 | mpz_sub(r_plus, pk->B[j], pk->p); 146 | mpz_set(pk->B[j], pk->p); 147 | } else { 148 | break; 149 | } 150 | } 151 | while (1) { 152 | int j = rand() % S2; 153 | mpz_add(pk->B[j], pk->B[j], r_minus); 154 | mpz_neg(temp, pk->p); 155 | if (mpz_cmp(pk->B[j], temp) < 0) { 156 | mpz_add(r_minus, pk->B[j], pk->p); 157 | mpz_neg(pk->B[j], pk->p); 158 | } else { 159 | break; 160 | } 161 | } 162 | } 163 | // shuffle 164 | for (int i = 0; i < S1; i++) { 165 | int j = rand() % S1; 166 | mpz_swap(pk->B[i], pk->B[j]); 167 | mpz_swap(pk->c[i], pk->c[j]); 168 | } 169 | 170 | #ifndef NDEBUG 171 | // assert that it really sums up to B 172 | mpz_set_ui(temp, 0L); 173 | for (int i = 0; i < S1; i++) { 174 | if (fhe_decrypt(pk->c[i], sk) == 1) { 175 | mpz_add(temp, temp, pk->B[i]); 176 | } 177 | } 178 | assert(mpz_cmp(temp, sk->B) == 0); 179 | #endif 180 | 181 | // cleanup 182 | mpz_clear(B_i); 183 | mpz_clear(r_plus); 184 | mpz_clear(r_minus); 185 | mpz_clear(temp); 186 | fmpz_clear(fmpz_p); 187 | fmpz_clear(r); 188 | fmpz_poly_clear(Z); 189 | fmpz_poly_clear(t); 190 | fmpz_poly_clear(F); 191 | fmpz_poly_clear(G); 192 | F_mpz_mod_poly_clear(F_mod_p); 193 | F_mpz_mod_poly_clear(G_mod_p); 194 | F_mpz_mod_poly_clear(D_mod_p); 195 | F_mpz_clear(P); 196 | gmp_randclear(randstate); 197 | } 198 | 199 | void 200 | fhe_encrypt(mpz_t c, fhe_pk_t pk, int m) 201 | { 202 | #ifdef DEBUG 203 | printf("ENCRYPT %i\n", m); 204 | #endif 205 | if ((m != 0) && (m != 1)) { 206 | fprintf(stderr, "\nm must be either 0 or 1\n"); 207 | abort(); 208 | } 209 | 210 | fmpz_poly_t C; 211 | fmpz_t C_0, fmpz_c, alpha; 212 | 213 | fmpz_poly_init(C); 214 | fmpz_c = fmpz_init(1000000); 215 | 216 | alpha = fmpz_init(mpz_size(pk->alpha)); 217 | mpz_to_fmpz(alpha, pk->alpha); 218 | 219 | gmp_randstate_t randstate; 220 | gmp_randinit_default(randstate); 221 | gmp_randseed_ui(randstate, SEED); 222 | 223 | fmpz_poly_rand_coeff_even(C, N, 2, &randstate); 224 | 225 | C_0 = fmpz_poly_get_coeff_ptr(C, 0); 226 | fmpz_add_ui(C_0, C_0, m); 227 | 228 | 229 | #ifdef DEBUG 230 | printf("C(x) = "); 231 | fmpz_poly_print_pretty(C, "x"); 232 | printf("\n"); 233 | printf("alpha = "); 234 | fmpz_print(alpha); 235 | printf("\n"); 236 | printf("C(alpha) = "); 237 | fmpz_print(fmpz_c); 238 | printf("\n"); 239 | #endif 240 | 241 | fmpz_poly_evaluate(fmpz_c, C, alpha); 242 | 243 | #ifdef DEBUG 244 | printf("C(x) = "); 245 | fmpz_poly_print_pretty(C, "x"); 246 | printf("\n"); 247 | printf("C(alpha) = "); 248 | fmpz_print(fmpz_c); 249 | printf("\n"); 250 | #endif 251 | 252 | fmpz_to_mpz(c, fmpz_c); 253 | fmpz_clear(fmpz_c); 254 | 255 | mpz_mod(c, c, pk->p); 256 | 257 | 258 | #ifdef DEBUG 259 | gmp_printf("c = %Zd\n", c); 260 | #endif 261 | 262 | // cleanup 263 | fmpz_poly_clear(C); 264 | fmpz_clear(alpha); 265 | gmp_randclear(randstate); 266 | } 267 | 268 | 269 | int 270 | fhe_decrypt(mpz_t c, fhe_sk_t sk) 271 | { 272 | #ifdef DEBUG 273 | gmp_printf("DECRYPT %Zd\n", c); 274 | #endif 275 | int m; 276 | 277 | mpz_t temp, q, r; 278 | mpz_init(temp); 279 | mpz_init(q); 280 | mpz_init(r); 281 | 282 | mpq_t n, d, one_half; 283 | mpq_init(n); 284 | mpq_init(d); 285 | mpq_init(one_half); 286 | 287 | mpz_mul(temp, c, sk->B); 288 | mpz_fdiv_qr(q, r, temp, sk->p); 289 | 290 | // round: add 1 to q if r/p > 1/2 291 | mpq_set_ui(one_half, 1, 2); 292 | mpq_set_z(n, r); 293 | mpq_set_z(d, sk->p); 294 | mpq_div(n, n, d); 295 | 296 | if (mpq_cmp(n, one_half) > 0) { // n > 1/2 297 | mpz_add_ui(q, q, 1); 298 | } 299 | 300 | #ifdef DEBUG 301 | gmp_printf("q: %Zd\n", q); 302 | #endif 303 | 304 | mpz_add(temp, c, q); 305 | mpz_mod_ui(temp, temp, 2); 306 | 307 | m = mpz_get_si(temp); 308 | 309 | // cleanup 310 | mpz_clear(temp); 311 | mpz_clear(q); 312 | mpz_clear(r); 313 | mpq_clear(n); 314 | mpq_clear(d); 315 | mpq_clear(one_half); 316 | 317 | return m; 318 | } 319 | 320 | 321 | void 322 | fhe_add(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk) 323 | { 324 | mpz_add(res, a, b); 325 | mpz_mod(res, res, pk->p); 326 | fhe_recrypt(res, pk); 327 | } 328 | 329 | 330 | void 331 | fhe_mul(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk) 332 | { 333 | mpz_mul(res, a, b); 334 | mpz_mod(res, res, pk->p); 335 | fhe_recrypt(res, pk); 336 | } 337 | 338 | 339 | void 340 | fhe_fulladd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, mpz_t c_in, fhe_pk_t pk) 341 | { 342 | mpz_t temp; 343 | mpz_init(temp); 344 | 345 | mpz_add(temp, a, b); 346 | mpz_add(temp, temp, c_in); 347 | mpz_mod(sum, temp, pk->p); 348 | 349 | mpz_mul(temp, a, b); 350 | mpz_addmul(temp, c_in, a); 351 | mpz_addmul(temp, c_in, b); 352 | mpz_mod(c_out, temp, pk->p); 353 | 354 | mpz_clear(temp); 355 | } 356 | 357 | 358 | void 359 | fhe_halfadd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, fhe_pk_t pk) 360 | { 361 | mpz_add(sum, a, b); 362 | mpz_mod(sum, sum, pk->p); 363 | 364 | mpz_mul(c_out, a, b); 365 | mpz_mod(c_out, c_out, pk->p); 366 | } 367 | 368 | 369 | #define PRINT_C \ 370 | printf("(Zeile %i): C-Matrix\n\t", __LINE__); \ 371 | for (int __i = 0; __i < S1; __i++) { \ 372 | for (int __j = 0; __j < T; __j++) { \ 373 | printf("%i ", fhe_decrypt(C[__i][__j], sk)); \ 374 | } \ 375 | printf("\n\t"); \ 376 | }; printf("\n") 377 | 378 | #define PRINT_H \ 379 | printf("(Zeile %i): H-Matrix\n\t", __LINE__); \ 380 | for (int __i = 0; __i < T; __i++) { \ 381 | for (int __j = 0; __j < T; __j++) { \ 382 | printf("%i ", fhe_decrypt(H[__i][__j], sk)); \ 383 | } \ 384 | printf("\n\t"); \ 385 | }; printf("\n") 386 | 387 | #define PRINT_ham \ 388 | printf("(Zeile %i): ham-Matrix\n\t", __LINE__); \ 389 | for (int __i = 0; __i < T; __i++) { \ 390 | for (int __j = 0; __j < T; __j++) { \ 391 | printf("%i ", fhe_decrypt(ham(__i,__j), sk)); \ 392 | } \ 393 | printf("\n\t"); \ 394 | }; printf("\n") 395 | 396 | void 397 | fhe_recrypt(mpz_t c, fhe_pk_t pk) 398 | { 399 | #undef DEBUG 400 | assert(S <= T); 401 | 402 | mpz_t C[S1][T], H[T][T], temp, p; 403 | mpq_t q; 404 | 405 | mpz_init(temp); 406 | mpz_init(p); 407 | mpq_init(q); 408 | for (int i = 0; i < S1; i++) { 409 | for (int j = 0; j < T; j++) { 410 | mpz_init(C[i][j]); 411 | } 412 | } 413 | for (int i = 0; i < T; i++) { 414 | for (int j = 0; j < T; j++) { 415 | mpz_init_set_ui(H[i][j], 0); 416 | } 417 | } 418 | 419 | // Fill C-matrix 420 | mpz_mul_ui(p, pk->p, 2); 421 | for (int i = 0; i < S1; i++) { 422 | mpz_mul(temp, c, pk->B[i]); 423 | mpz_mod(temp, temp, p); 424 | mpq_set_num(q, temp); 425 | mpq_set_den(q, pk->p); 426 | mpq_canonicalize(q); 427 | double d = mpq_get_d(q); 428 | 429 | #ifdef DEBUG 430 | printf("\t%i: %1.5f\t\t[", i, d); 431 | #endif 432 | 433 | // base convert and encrypt d 434 | for (int j = 0; j < T; j++) { 435 | #ifdef DEBUG 436 | printf(" %i", (int)d); 437 | #endif 438 | fhe_encrypt(C[i][j], pk, (int)d); 439 | mpz_mul(C[i][j], C[i][j], pk->c[i]); 440 | mpz_mod(C[i][j], C[i][j], pk->p); 441 | d -= (int)d; 442 | d *= 2; 443 | } 444 | #ifdef DEBUG 445 | printf(" ]\n"); 446 | #endif 447 | } 448 | #ifdef DEBUG 449 | PRINT_C; 450 | #endif 451 | 452 | // Construct Hammingweight in H-matrix 453 | #define ham(_i,_j) H[_i][_j] 454 | for (int j = 0; j < T; j++) { 455 | for (int i = 1; i <= S1; i++) { 456 | for (int k = (i < (2<<(S-2))) ? i : (2<<(S-2)); k >= 2; k--) { 457 | mpz_addmul(ham(k-1,j), ham(k-2,j), C[i-1][j]); 458 | mpz_mod(ham(k-1,j), ham(k-1,j), pk->p); 459 | } 460 | mpz_add(ham(0,j), ham(0,j), C[i-1][j]); 461 | mpz_mod(ham(0,j), ham(0,j), p); 462 | } 463 | } 464 | for (int j = 0; j < T; j++) { 465 | mpz_set(ham(2,j), ham(3,j)); 466 | } 467 | #ifdef DEBUG 468 | PRINT_ham; 469 | #endif 470 | #undef ham 471 | for (int j = 1; j < T; j++) { 472 | for (int i = min(S, j+1)-1; i >= 0; i--) { 473 | mpz_swap(H[i][j], H[j][j-i]); 474 | } 475 | } 476 | 477 | #ifdef DEBUG 478 | PRINT_H; 479 | #endif 480 | 481 | // merge rows 0 and 3; 1 and 4 482 | for (int i = 0; i < 2; i++) { 483 | for (int j = 0; j < S; j++) { 484 | mpz_set(H[i][i+j+1], H[i+S][i+j+1]); 485 | } 486 | } 487 | 488 | #ifdef DEBUG 489 | PRINT_H; 490 | #endif 491 | 492 | // carry save adder of rows 0,1,2 --> 0,1 (columnwise) 493 | for (int j = 0; j < T; j++) { 494 | fhe_fulladd(H[3][j], H[4][j], H[0][j], H[1][j], H[2][j], pk); 495 | } 496 | // leftshift the row with the carry bits 497 | mpz_swap(H[0][T-1], H[3][T-1]); 498 | fhe_encrypt(H[1][T-1], pk, 0); 499 | for (int j = 0; j < T-1; j++) { 500 | mpz_swap(H[0][j], H[3][j]); 501 | mpz_swap(H[1][j], H[4][j+1]); 502 | } 503 | 504 | #ifdef DEBUG 505 | PRINT_H; 506 | #endif 507 | 508 | // ripple-carry-add rows 0 and 1 --> 0 (LSB at T-1) 509 | // special cases: nothing to do for col T-1, halfadder for T-2 510 | // note: carry is in temp, result in last row (4) 511 | fhe_halfadd(H[4][T-2], temp, H[0][T-2], H[1][T-2], pk); 512 | for (int j = T-3; j >= 0; j--) { 513 | fhe_fulladd(H[4][j], temp, H[0][j], H[1][j], temp, pk); 514 | } 515 | 516 | #ifdef DEBUG 517 | PRINT_H; 518 | #endif 519 | 520 | // round to nearest integer 521 | mpz_add(temp, H[4][0], H[4][1]); 522 | mpz_mod_ui(c, c, 2); 523 | mpz_add(c, c, temp); 524 | mpz_mod(c, c, pk->p); 525 | 526 | // cleanup 527 | for (int i = 0; i < S1; i++) { 528 | for (int j = 0; j < T; j++) { 529 | mpz_clear(C[i][j]); 530 | } 531 | } 532 | for (int i = 0; i < T; i++) { 533 | for (int j = 0; j < T; j++) { 534 | mpz_clear(H[i][j]); 535 | } 536 | } 537 | 538 | mpz_clear(temp); 539 | mpz_clear(p); 540 | mpq_clear(q); 541 | } 542 | -------------------------------------------------------------------------------- /libScarab1.0.0/integer-fhe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * keygen.h 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 01.03.10. 6 | * 7 | */ 8 | 9 | #pragma once 10 | #ifndef INTEGER_FHE_H 11 | #define INTEGER_FHE_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "types.h" 18 | #include "parameters.h" 19 | #include "util.h" 20 | 21 | /** main function **/ 22 | 23 | void fhe_keygen(fhe_pk_t pk, fhe_sk_t sk); 24 | 25 | void fhe_encrypt(mpz_t c, fhe_pk_t pk, int m); 26 | 27 | int fhe_decrypt(mpz_t c, fhe_sk_t sk); 28 | 29 | void fhe_recrypt(mpz_t c, fhe_pk_t pk); 30 | 31 | void fhe_add(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); 32 | 33 | void fhe_mul(mpz_t res, mpz_t a, mpz_t b, fhe_pk_t pk); 34 | 35 | void fhe_fulladd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, mpz_t c_in, fhe_pk_t pk); 36 | 37 | void fhe_halfadd(mpz_t sum, mpz_t c_out, mpz_t a, mpz_t b, fhe_pk_t pk); 38 | 39 | #endif -------------------------------------------------------------------------------- /libScarab1.0.0/integer-fhe.nb: -------------------------------------------------------------------------------- 1 | (* Content-type: application/mathematica *) 2 | 3 | (*** Wolfram Notebook File ***) 4 | (* http://www.wolfram.com/nb *) 5 | 6 | (* CreatedBy='Mathematica 7.0' *) 7 | 8 | (*CacheID: 234*) 9 | (* Internal cache information: 10 | NotebookFileLineBreakTest 11 | NotebookFileLineBreakTest 12 | NotebookDataPosition[ 145, 7] 13 | NotebookDataLength[ 151499, 3149] 14 | NotebookOptionsPosition[ 150521, 3116] 15 | NotebookOutlinePosition[ 150880, 3132] 16 | CellTagsIndexPosition[ 150837, 3129] 17 | WindowFrame->Normal*) 18 | 19 | (* Beginning of Notebook Content *) 20 | Notebook[{ 21 | Cell["\<\ 22 | Status: 23 | \[Dash] Hamming-Gewicht funktioniert ausreichend 24 | \[Dash] Recrypt funktioniert noch nicht in Kombination mit Mult (nur mit Add) 25 | -> (noch) kein Homomorphismus :( 26 | 27 | To Do: 28 | \[Dash] Vergleich mit \[RightGuillemet]Original\[LeftGuillemet]-HammingWeight 29 | \[Dash] Testing\ 30 | \>", "Input", 31 | CellChangeTimes->{{3.489211236763377*^9, 3.4892113205537786`*^9}, { 32 | 3.489225700903225*^9, 3.4892257517033653`*^9}, {3.4892276742505407`*^9, 33 | 3.489227697254777*^9}, 3.489414747711113*^9, {3.489414923156703*^9, 34 | 3.489414946388945*^9}, {3.4894154759170637`*^9, 3.489415489157419*^9}, { 35 | 3.496395221418174*^9, 3.496395222737793*^9}}, 36 | EmphasizeSyntaxErrors->True], 37 | 38 | Cell[BoxData[{ 39 | RowBox[{ 40 | RowBox[{"n", "=", "8"}], ";"}], "\[IndentingNewLine]", 41 | RowBox[{ 42 | RowBox[{"\[Eta]", "=", 43 | SuperscriptBox["2", "256"]}], ";"}], "\[IndentingNewLine]", 44 | RowBox[{ 45 | RowBox[{ 46 | RowBox[{"\[Mu]", "=", "4"}], ";"}], 47 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 48 | RowBox[{ 49 | RowBox[{ 50 | RowBox[{ 51 | RowBox[{"OrigEncrypt", "[", 52 | RowBox[{"m_", ",", "pk_"}], "]"}], ":=", 53 | RowBox[{"Module", "[", 54 | RowBox[{ 55 | RowBox[{"{", 56 | RowBox[{"p", ",", "\[Alpha]", ",", "r", ",", "c"}], "}"}], ",", 57 | "\[IndentingNewLine]", 58 | RowBox[{ 59 | RowBox[{ 60 | RowBox[{"{", 61 | RowBox[{"p", ",", "\[Alpha]"}], "}"}], "=", "pk"}], ";", 62 | "\[IndentingNewLine]", 63 | RowBox[{"If", "[", 64 | RowBox[{ 65 | RowBox[{ 66 | RowBox[{"m", "\[NotEqual]", "0"}], "&&", 67 | RowBox[{"m", "\[NotEqual]", "1"}]}], ",", 68 | RowBox[{"Throw", "[", 69 | RowBox[{"\"\\"", ",", " ", "m"}], "]"}]}], "]"}], 70 | ";", "\[IndentingNewLine]", 71 | RowBox[{"r", "=", 72 | RowBox[{ 73 | RowBox[{ 74 | RowBox[{"(", 75 | RowBox[{"2", "#"}], ")"}], "&"}], "/@", 76 | RowBox[{"RandomInteger", "[", 77 | RowBox[{ 78 | RowBox[{"{", 79 | RowBox[{ 80 | RowBox[{"-", 81 | FractionBox["\[Mu]", "2"]}], ",", 82 | FractionBox["\[Mu]", "2"]}], "}"}], ",", "n"}], "]"}]}]}], ";", 83 | "\[IndentingNewLine]", 84 | RowBox[{ 85 | RowBox[{"r", "[", 86 | RowBox[{"[", "1", "]"}], "]"}], "+=", "m"}], ";", 87 | "\[IndentingNewLine]", 88 | RowBox[{ 89 | RowBox[{"c", "[", "x_", "]"}], ":=", 90 | RowBox[{"Sum", "[", 91 | RowBox[{ 92 | RowBox[{ 93 | RowBox[{"MapIndexed", "[", 94 | RowBox[{ 95 | RowBox[{ 96 | RowBox[{"#1", " ", 97 | SuperscriptBox["x", 98 | RowBox[{ 99 | RowBox[{"First", "[", "#2", "]"}], "-", "1"}]]}], "&"}], ",", 100 | "r"}], "]"}], "[", 101 | RowBox[{"[", "i", "]"}], "]"}], ",", 102 | RowBox[{"{", 103 | RowBox[{"i", ",", "n"}], "}"}]}], "]"}]}], ";", 104 | "\[IndentingNewLine]", 105 | RowBox[{"Mod", "[", 106 | RowBox[{ 107 | RowBox[{"c", "[", "\[Alpha]", "]"}], ",", "p"}], "]"}]}]}], 108 | "\[IndentingNewLine]", "]"}]}], ";"}], 109 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 110 | RowBox[{ 111 | RowBox[{ 112 | RowBox[{ 113 | RowBox[{"Encrypt", "[", 114 | RowBox[{"m_", ",", "pk_"}], "]"}], ":=", 115 | RowBox[{"Module", "[", 116 | RowBox[{ 117 | RowBox[{"{", 118 | RowBox[{ 119 | "p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", "SK", ",", "H", ",", 120 | "r", ",", "c"}], "}"}], ",", "\[IndentingNewLine]", 121 | RowBox[{ 122 | RowBox[{ 123 | RowBox[{"{", 124 | RowBox[{"p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", 125 | RowBox[{"{", 126 | RowBox[{"SK", ",", "H"}], "}"}]}], "}"}], "=", "pk"}], ";", 127 | "\[IndentingNewLine]", 128 | RowBox[{"If", "[", 129 | RowBox[{ 130 | RowBox[{ 131 | RowBox[{"m", "\[NotEqual]", "0"}], "&&", 132 | RowBox[{"m", "\[NotEqual]", "1"}]}], ",", 133 | RowBox[{"Throw", "[", 134 | RowBox[{"\"\\"", ",", " ", "m"}], "]"}]}], "]"}], 135 | ";", "\[IndentingNewLine]", 136 | RowBox[{"r", "=", 137 | RowBox[{ 138 | RowBox[{ 139 | RowBox[{"(", 140 | RowBox[{"2", "#"}], ")"}], "&"}], "/@", 141 | RowBox[{"RandomInteger", "[", 142 | RowBox[{ 143 | RowBox[{"{", 144 | RowBox[{ 145 | RowBox[{"-", 146 | FractionBox["\[Mu]", "2"]}], ",", 147 | FractionBox["\[Mu]", "2"]}], "}"}], ",", "n"}], "]"}]}]}], ";", 148 | "\[IndentingNewLine]", 149 | RowBox[{ 150 | RowBox[{"r", "[", 151 | RowBox[{"[", "1", "]"}], "]"}], "+=", "m"}], ";", 152 | "\[IndentingNewLine]", 153 | RowBox[{ 154 | RowBox[{"c", "[", "x_", "]"}], ":=", 155 | RowBox[{"Sum", "[", 156 | RowBox[{ 157 | RowBox[{ 158 | RowBox[{"MapIndexed", "[", 159 | RowBox[{ 160 | RowBox[{ 161 | RowBox[{"#1", " ", 162 | SuperscriptBox["x", 163 | RowBox[{ 164 | RowBox[{"First", "[", "#2", "]"}], "-", "1"}]]}], "&"}], ",", 165 | "r"}], "]"}], "[", 166 | RowBox[{"[", "i", "]"}], "]"}], ",", 167 | RowBox[{"{", 168 | RowBox[{"i", ",", "n"}], "}"}]}], "]"}]}], ";", 169 | "\[IndentingNewLine]", 170 | RowBox[{"Mod", "[", 171 | RowBox[{ 172 | RowBox[{"c", "[", "\[Alpha]", "]"}], ",", "p"}], "]"}]}]}], 173 | "\[IndentingNewLine]", "]"}]}], ";"}], 174 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 175 | RowBox[{ 176 | RowBox[{ 177 | RowBox[{ 178 | RowBox[{"Decrypt", "[", 179 | RowBox[{"c_", ",", "sk_"}], "]"}], ":=", 180 | RowBox[{"Module", "[", 181 | RowBox[{ 182 | RowBox[{"{", 183 | RowBox[{"p", ",", "B"}], "}"}], ",", "\[IndentingNewLine]", 184 | RowBox[{ 185 | RowBox[{ 186 | RowBox[{"{", 187 | RowBox[{"p", ",", "B"}], "}"}], "=", "sk"}], ";", 188 | "\[IndentingNewLine]", 189 | RowBox[{"Mod", "[", 190 | RowBox[{ 191 | RowBox[{"c", "+", 192 | RowBox[{"Round", "[", 193 | RowBox[{"c", 194 | FractionBox["B", "p"]}], "]"}]}], ",", "2"}], "]"}]}]}], 195 | "\[IndentingNewLine]", "]"}]}], ";"}], 196 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 197 | RowBox[{ 198 | RowBox[{ 199 | RowBox[{ 200 | RowBox[{"Add", "[", 201 | RowBox[{"c1_", ",", "c2_", ",", "pk_"}], "]"}], ":=", 202 | RowBox[{"Module", "[", 203 | RowBox[{ 204 | RowBox[{"{", 205 | RowBox[{ 206 | "p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", "SK", ",", "H"}], 207 | "}"}], ",", "\[IndentingNewLine]", 208 | RowBox[{ 209 | RowBox[{ 210 | RowBox[{"{", 211 | RowBox[{"p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", 212 | RowBox[{"{", 213 | RowBox[{"SK", ",", "H"}], "}"}]}], "}"}], "=", "pk"}], ";", 214 | "\[IndentingNewLine]", 215 | RowBox[{"Mod", "[", 216 | RowBox[{ 217 | RowBox[{"c1", "+", "c2"}], ",", "p"}], "]"}]}]}], 218 | "\[IndentingNewLine]", "]"}]}], ";"}], 219 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 220 | RowBox[{ 221 | RowBox[{ 222 | RowBox[{"RAdd", "[", 223 | RowBox[{"c1_", ",", "c2_", ",", "pk_"}], "]"}], ":=", 224 | RowBox[{"(", 225 | RowBox[{"Recrypt", "[", 226 | RowBox[{ 227 | RowBox[{"Add", "[", 228 | RowBox[{"c1", ",", "c2", ",", "pk"}], "]"}], ",", "pk"}], "]"}], 229 | ")"}]}], ";"}], "\[IndentingNewLine]", 230 | RowBox[{ 231 | RowBox[{ 232 | RowBox[{ 233 | RowBox[{"RMult", "[", 234 | RowBox[{"c1_", ",", "c2_", ",", "pk_"}], "]"}], ":=", 235 | RowBox[{"(", 236 | RowBox[{"Recrypt", "[", 237 | RowBox[{ 238 | RowBox[{"Mult", "[", 239 | RowBox[{"c1", ",", "c2", ",", "pk"}], "]"}], ",", "pk"}], "]"}], 240 | ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 241 | RowBox[{ 242 | RowBox[{ 243 | RowBox[{ 244 | RowBox[{"TreeAdd", "[", 245 | RowBox[{"x_", ",", "pk_"}], "]"}], ":=", 246 | RowBox[{"(", "\[IndentingNewLine]", 247 | RowBox[{"If", "[", 248 | RowBox[{ 249 | RowBox[{ 250 | RowBox[{"Length", "[", "x", "]"}], "\[Equal]", "1"}], ",", 251 | "\[IndentingNewLine]", 252 | RowBox[{"x", "[", 253 | RowBox[{"[", "1", "]"}], "]"}], ",", "\[IndentingNewLine]", 254 | RowBox[{"Add", "[", 255 | RowBox[{ 256 | RowBox[{"TreeAdd", "[", 257 | RowBox[{ 258 | RowBox[{"x", "[", 259 | RowBox[{"[", 260 | RowBox[{"1", ";;", 261 | RowBox[{"Floor", "[", 262 | RowBox[{ 263 | RowBox[{"Length", "[", "x", "]"}], "/", "2"}], "]"}]}], "]"}], 264 | "]"}], ",", "pk"}], "]"}], ",", 265 | RowBox[{"TreeAdd", "[", 266 | RowBox[{ 267 | RowBox[{"x", "[", 268 | RowBox[{"[", 269 | RowBox[{ 270 | RowBox[{ 271 | RowBox[{"Floor", "[", 272 | RowBox[{ 273 | RowBox[{"Length", "[", "x", "]"}], "/", "2"}], "]"}], "+", 274 | "1"}], ";;", 275 | RowBox[{"Length", "[", "x", "]"}]}], "]"}], "]"}], ",", "pk"}], 276 | "]"}], ",", "pk"}], "]"}]}], "\[IndentingNewLine]", "]"}], 277 | "\[IndentingNewLine]", ")"}]}], ";"}], 278 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 279 | RowBox[{ 280 | RowBox[{ 281 | RowBox[{ 282 | RowBox[{"Mult", "[", 283 | RowBox[{"c1_", ",", "c2_", ",", "pk_"}], "]"}], ":=", 284 | RowBox[{"Module", "[", 285 | RowBox[{ 286 | RowBox[{"{", 287 | RowBox[{ 288 | "p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", "SK", ",", "H"}], 289 | "}"}], ",", "\[IndentingNewLine]", 290 | RowBox[{ 291 | RowBox[{ 292 | RowBox[{"{", 293 | RowBox[{"p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", 294 | RowBox[{"{", 295 | RowBox[{"SK", ",", "H"}], "}"}]}], "}"}], "=", "pk"}], ";", 296 | "\[IndentingNewLine]", 297 | RowBox[{"Mod", "[", 298 | RowBox[{ 299 | RowBox[{"c1", " ", "*", "c2"}], ",", "p"}], "]"}]}]}], 300 | "\[IndentingNewLine]", "]"}]}], ";"}], 301 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 302 | RowBox[{ 303 | RowBox[{ 304 | RowBox[{ 305 | RowBox[{"TreeMult", "[", 306 | RowBox[{"x_", ",", "pk_"}], "]"}], ":=", 307 | RowBox[{"(", "\[IndentingNewLine]", 308 | RowBox[{"If", "[", 309 | RowBox[{ 310 | RowBox[{ 311 | RowBox[{"Length", "[", "x", "]"}], "\[Equal]", "1"}], ",", 312 | "\[IndentingNewLine]", 313 | RowBox[{"x", "[", 314 | RowBox[{"[", "1", "]"}], "]"}], ",", "\[IndentingNewLine]", 315 | RowBox[{"Mult", "[", 316 | RowBox[{ 317 | RowBox[{"TreeMult", "[", 318 | RowBox[{ 319 | RowBox[{"x", "[", 320 | RowBox[{"[", 321 | RowBox[{"1", ";;", 322 | RowBox[{"Floor", "[", 323 | RowBox[{ 324 | RowBox[{"Length", "[", "x", "]"}], "/", "2"}], "]"}]}], "]"}], 325 | "]"}], ",", "pk"}], "]"}], ",", 326 | RowBox[{"TreeMult", "[", 327 | RowBox[{ 328 | RowBox[{"x", "[", 329 | RowBox[{"[", 330 | RowBox[{ 331 | RowBox[{ 332 | RowBox[{"Floor", "[", 333 | RowBox[{ 334 | RowBox[{"Length", "[", "x", "]"}], "/", "2"}], "]"}], "+", 335 | "1"}], ";;", 336 | RowBox[{"Length", "[", "x", "]"}]}], "]"}], "]"}], ",", "pk"}], 337 | "]"}], ",", "pk"}], "]"}]}], "\[IndentingNewLine]", "]"}], 338 | "\[IndentingNewLine]", ")"}]}], ";"}], 339 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 340 | RowBox[{ 341 | RowBox[{ 342 | RowBox[{ 343 | RowBox[{"HalfAdder", "[", 344 | RowBox[{"a_", ",", "b_", ",", "pk_"}], "]"}], ":=", 345 | RowBox[{"(", "\[IndentingNewLine]", 346 | RowBox[{"(*", " ", 347 | RowBox[{"returns", " ", 348 | RowBox[{"{", 349 | RowBox[{"carry", ",", " ", "sum"}], "}"}]}], " ", "*)"}], 350 | "\[IndentingNewLine]", 351 | RowBox[{"{", 352 | RowBox[{ 353 | RowBox[{"Mult", "[", 354 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}], ",", 355 | RowBox[{"Add", "[", 356 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}]}], "}"}], 357 | "\[IndentingNewLine]", ")"}]}], ";"}], 358 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 359 | RowBox[{ 360 | RowBox[{ 361 | RowBox[{ 362 | RowBox[{"FullAdder", "[", 363 | RowBox[{"a_", ",", "b_", ",", "cIn_", ",", "pk_"}], "]"}], ":=", 364 | RowBox[{"(", "\[IndentingNewLine]", 365 | RowBox[{"(*", " ", 366 | RowBox[{"return", " ", 367 | RowBox[{"{", 368 | RowBox[{"carry", ",", " ", "sum"}], "}"}]}], " ", "*)"}], 369 | "\[IndentingNewLine]", 370 | RowBox[{"{", 371 | RowBox[{ 372 | RowBox[{"Add", "[", 373 | RowBox[{ 374 | RowBox[{"Mult", "[", 375 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}], ",", 376 | RowBox[{"Mult", "[", 377 | RowBox[{"cIn", ",", 378 | RowBox[{"Add", "[", 379 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}], ",", "pk"}], "]"}], 380 | ",", "pk"}], "]"}], ",", 381 | RowBox[{"Add", "[", 382 | RowBox[{ 383 | RowBox[{"Add", "[", 384 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}], ",", "cIn", ",", "pk"}], 385 | "]"}]}], "}"}], "\[IndentingNewLine]", ")"}]}], ";"}], 386 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 387 | RowBox[{ 388 | RowBox[{ 389 | RowBox[{ 390 | RowBox[{"RippleCarryAdder", "[", 391 | RowBox[{"A_", ",", "B_", ",", "pk_"}], "]"}], ":=", 392 | RowBox[{"Module", "[", 393 | RowBox[{ 394 | RowBox[{"{", 395 | RowBox[{ 396 | "i", ",", "carry", ",", "S", ",", "sizeA", ",", "sizeB", ",", "newA", 397 | ",", "newB"}], "}"}], ",", "\[IndentingNewLine]", 398 | RowBox[{ 399 | RowBox[{"carry", "=", 400 | RowBox[{"Encrypt", "[", 401 | RowBox[{"0", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 402 | RowBox[{"sizeA", "=", 403 | RowBox[{"Length", "[", "A", "]"}]}], ";", 404 | RowBox[{"sizeB", "=", 405 | RowBox[{"Length", "[", "B", "]"}]}], ";", "\[IndentingNewLine]", 406 | RowBox[{"If", "[", 407 | RowBox[{ 408 | RowBox[{"sizeA", "\[NotEqual]", "sizeB"}], ",", 409 | "\[IndentingNewLine]", 410 | RowBox[{ 411 | RowBox[{"If", "[", 412 | RowBox[{ 413 | RowBox[{"sizeA", "<", "sizeB"}], ",", "\[IndentingNewLine]", 414 | RowBox[{ 415 | RowBox[{"newA", "=", 416 | RowBox[{"Join", "[", 417 | RowBox[{ 418 | RowBox[{"Array", "[", 419 | RowBox[{ 420 | RowBox[{ 421 | RowBox[{"Encrypt", "[", 422 | RowBox[{"0", ",", "pk"}], "]"}], "&"}], ",", 423 | RowBox[{"sizeB", "-", "sizeA"}]}], "]"}], ",", "A"}], 424 | "]"}]}], ";", "\[IndentingNewLine]", 425 | RowBox[{"newB", "=", "B"}]}], ",", "\[IndentingNewLine]", 426 | RowBox[{ 427 | RowBox[{"newA", "=", "A"}], ";", "\[IndentingNewLine]", 428 | RowBox[{"newB", "=", 429 | RowBox[{"Join", "[", 430 | RowBox[{ 431 | RowBox[{"Array", "[", 432 | RowBox[{ 433 | RowBox[{ 434 | RowBox[{"Encrypt", "[", 435 | RowBox[{"0", ",", "pk"}], "]"}], "&"}], ",", 436 | RowBox[{"sizeA", "-", "sizeB"}]}], "]"}], ",", "B"}], 437 | "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";"}], ",", 438 | "\[IndentingNewLine]", 439 | RowBox[{ 440 | RowBox[{"newA", "=", "A"}], ";", 441 | RowBox[{"newB", "=", "B"}]}]}], "]"}], ";", "\[IndentingNewLine]", 442 | RowBox[{"S", "=", 443 | RowBox[{"Array", "[", 444 | RowBox[{ 445 | RowBox[{"0", "&"}], ",", 446 | RowBox[{ 447 | RowBox[{"Length", "[", "newA", "]"}], "+", "1"}]}], "]"}]}], ";", 448 | "\[IndentingNewLine]", 449 | RowBox[{"For", "[", 450 | RowBox[{ 451 | RowBox[{"i", "=", 452 | RowBox[{"Count", "[", 453 | RowBox[{"newA", ",", "_Integer"}], "]"}]}], ",", 454 | RowBox[{"i", ">", "0"}], ",", 455 | RowBox[{"i", "--"}], ",", "\[IndentingNewLine]", 456 | RowBox[{ 457 | RowBox[{ 458 | RowBox[{"{", 459 | RowBox[{"carry", ",", 460 | RowBox[{"S", "[", 461 | RowBox[{"[", 462 | RowBox[{"i", "+", "1"}], "]"}], "]"}]}], "}"}], "=", 463 | RowBox[{"FullAdder", "[", 464 | RowBox[{ 465 | RowBox[{"newA", "[", 466 | RowBox[{"[", "i", "]"}], "]"}], ",", 467 | RowBox[{"newB", "[", 468 | RowBox[{"[", "i", "]"}], "]"}], ",", "carry", ",", "pk"}], 469 | "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", 470 | "\[IndentingNewLine]", 471 | RowBox[{ 472 | RowBox[{"S", "[", 473 | RowBox[{"[", "1", "]"}], "]"}], "=", "carry"}], ";", 474 | "\[IndentingNewLine]", "S"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 475 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 476 | RowBox[{ 477 | RowBox[{ 478 | RowBox[{ 479 | RowBox[{"RFullAdder", "[", 480 | RowBox[{"a_", ",", "b_", ",", "cIn_", ",", "pk_"}], "]"}], ":=", 481 | RowBox[{"(", "\[IndentingNewLine]", 482 | RowBox[{"(*", " ", 483 | RowBox[{"return", " ", 484 | RowBox[{"{", 485 | RowBox[{"carry", ",", " ", "sum"}], "}"}]}], " ", "*)"}], 486 | "\[IndentingNewLine]", 487 | RowBox[{"{", 488 | RowBox[{ 489 | RowBox[{"RAdd", "[", 490 | RowBox[{ 491 | RowBox[{"RMult", "[", 492 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}], ",", 493 | RowBox[{"RMult", "[", 494 | RowBox[{"cIn", ",", 495 | RowBox[{"RAdd", "[", 496 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}], ",", "pk"}], "]"}], 497 | ",", "pk"}], "]"}], ",", 498 | RowBox[{"RAdd", "[", 499 | RowBox[{ 500 | RowBox[{"RAdd", "[", 501 | RowBox[{"a", ",", "b", ",", "pk"}], "]"}], ",", "cIn", ",", "pk"}], 502 | "]"}]}], "}"}], "\[IndentingNewLine]", ")"}]}], ";"}], 503 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 504 | RowBox[{ 505 | RowBox[{ 506 | RowBox[{ 507 | RowBox[{"RRippleCarryAdder", "[", 508 | RowBox[{"A_", ",", "B_", ",", "pk_"}], "]"}], ":=", 509 | RowBox[{"Module", "[", 510 | RowBox[{ 511 | RowBox[{"{", 512 | RowBox[{ 513 | "i", ",", "carry", ",", "S", ",", "sizeA", ",", "sizeB", ",", "newA", 514 | ",", "newB"}], "}"}], ",", "\[IndentingNewLine]", 515 | RowBox[{ 516 | RowBox[{"carry", "=", 517 | RowBox[{"Encrypt", "[", 518 | RowBox[{"0", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 519 | RowBox[{"sizeA", "=", 520 | RowBox[{"Length", "[", "A", "]"}]}], ";", 521 | RowBox[{"sizeB", "=", 522 | RowBox[{"Length", "[", "B", "]"}]}], ";", "\[IndentingNewLine]", 523 | RowBox[{"If", "[", 524 | RowBox[{ 525 | RowBox[{"sizeA", "\[NotEqual]", "sizeB"}], ",", 526 | "\[IndentingNewLine]", 527 | RowBox[{ 528 | RowBox[{"If", "[", 529 | RowBox[{ 530 | RowBox[{"sizeA", "<", "sizeB"}], ",", "\[IndentingNewLine]", 531 | RowBox[{ 532 | RowBox[{"newA", "=", 533 | RowBox[{"Join", "[", 534 | RowBox[{ 535 | RowBox[{"Array", "[", 536 | RowBox[{ 537 | RowBox[{ 538 | RowBox[{"Encrypt", "[", 539 | RowBox[{"0", ",", "pk"}], "]"}], "&"}], ",", 540 | RowBox[{"sizeB", "-", "sizeA"}]}], "]"}], ",", "A"}], 541 | "]"}]}], ";", "\[IndentingNewLine]", 542 | RowBox[{"newB", "=", "B"}]}], ",", "\[IndentingNewLine]", 543 | RowBox[{ 544 | RowBox[{"newA", "=", "A"}], ";", "\[IndentingNewLine]", 545 | RowBox[{"newB", "=", 546 | RowBox[{"Join", "[", 547 | RowBox[{ 548 | RowBox[{"Array", "[", 549 | RowBox[{ 550 | RowBox[{ 551 | RowBox[{"Encrypt", "[", 552 | RowBox[{"0", ",", "pk"}], "]"}], "&"}], ",", 553 | RowBox[{"sizeA", "-", "sizeB"}]}], "]"}], ",", "B"}], 554 | "]"}]}]}]}], "\[IndentingNewLine]", "]"}], ";"}], ",", 555 | "\[IndentingNewLine]", 556 | RowBox[{ 557 | RowBox[{"newA", "=", "A"}], ";", 558 | RowBox[{"newB", "=", "B"}]}]}], "]"}], ";", "\[IndentingNewLine]", 559 | RowBox[{"S", "=", 560 | RowBox[{"Array", "[", 561 | RowBox[{ 562 | RowBox[{"0", "&"}], ",", 563 | RowBox[{ 564 | RowBox[{"Length", "[", "newA", "]"}], "+", "1"}]}], "]"}]}], ";", 565 | "\[IndentingNewLine]", 566 | RowBox[{"For", "[", 567 | RowBox[{ 568 | RowBox[{"i", "=", 569 | RowBox[{"Count", "[", 570 | RowBox[{"newA", ",", "_Integer"}], "]"}]}], ",", 571 | RowBox[{"i", ">", "0"}], ",", 572 | RowBox[{"i", "--"}], ",", "\[IndentingNewLine]", 573 | RowBox[{ 574 | RowBox[{ 575 | RowBox[{"{", 576 | RowBox[{"carry", ",", 577 | RowBox[{"S", "[", 578 | RowBox[{"[", 579 | RowBox[{"i", "+", "1"}], "]"}], "]"}]}], "}"}], "=", 580 | RowBox[{"RFullAdder", "[", 581 | RowBox[{ 582 | RowBox[{"newA", "[", 583 | RowBox[{"[", "i", "]"}], "]"}], ",", 584 | RowBox[{"newB", "[", 585 | RowBox[{"[", "i", "]"}], "]"}], ",", "carry", ",", "pk"}], 586 | "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", 587 | "\[IndentingNewLine]", 588 | RowBox[{ 589 | RowBox[{"S", "[", 590 | RowBox[{"[", "1", "]"}], "]"}], "=", "carry"}], ";", 591 | "\[IndentingNewLine]", "S"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 592 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 593 | RowBox[{ 594 | RowBox[{ 595 | RowBox[{ 596 | RowBox[{"CryptTotal", "[", 597 | RowBox[{"A_", ",", "pk_"}], "]"}], ":=", 598 | RowBox[{"Module", "[", 599 | RowBox[{ 600 | RowBox[{"{", 601 | RowBox[{"left", ",", "right", ",", "res"}], "}"}], ",", 602 | "\[IndentingNewLine]", 603 | RowBox[{ 604 | RowBox[{"If", "[", 605 | RowBox[{ 606 | RowBox[{ 607 | RowBox[{"Length", "[", "A", "]"}], "\[Equal]", "2"}], ",", 608 | "\[IndentingNewLine]", 609 | RowBox[{"res", "=", 610 | RowBox[{"HalfAdder", "[", 611 | RowBox[{ 612 | RowBox[{"A", "[", 613 | RowBox[{"[", "1", "]"}], "]"}], ",", 614 | RowBox[{"A", "[", 615 | RowBox[{"[", "2", "]"}], "]"}], ",", "pk"}], "]"}]}], ",", 616 | "\[IndentingNewLine]", 617 | RowBox[{ 618 | RowBox[{ 619 | RowBox[{"{", 620 | RowBox[{"left", ",", "right"}], "}"}], "=", 621 | RowBox[{"Partition", "[", 622 | RowBox[{"A", ",", 623 | RowBox[{ 624 | RowBox[{"Length", "[", "A", "]"}], "/", "2"}]}], "]"}]}], ";", 625 | "\[IndentingNewLine]", 626 | RowBox[{"res", "=", 627 | RowBox[{"RippleCarryAdder", "[", 628 | RowBox[{ 629 | RowBox[{"CryptTotal", "[", 630 | RowBox[{"left", ",", "pk"}], "]"}], ",", 631 | RowBox[{"CryptTotal", "[", 632 | RowBox[{"right", ",", "pk"}], "]"}], ",", "pk"}], "]"}]}]}]}], 633 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "res"}]}], 634 | "\[IndentingNewLine]", "]"}]}], ";"}], 635 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 636 | RowBox[{ 637 | RowBox[{ 638 | RowBox[{ 639 | RowBox[{"CryptSymmetricPolynomial", "[", 640 | RowBox[{"k_", ",", "x_", ",", "pk_"}], "]"}], ":=", 641 | RowBox[{"(", "\[IndentingNewLine]", 642 | RowBox[{"TreeAdd", "[", 643 | RowBox[{ 644 | RowBox[{ 645 | RowBox[{ 646 | RowBox[{"TreeMult", "[", 647 | RowBox[{"#", ",", "pk"}], "]"}], "&"}], "/@", 648 | RowBox[{"Subsets", "[", 649 | RowBox[{"x", ",", 650 | RowBox[{"{", "k", "}"}]}], "]"}]}], ",", "pk"}], "]"}], 651 | "\[IndentingNewLine]", ")"}]}], ";"}], 652 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 653 | RowBox[{ 654 | RowBox[{ 655 | RowBox[{ 656 | RowBox[{"Hamming2", "[", 657 | RowBox[{"x_", ",", "len_", ",", "pk_"}], "]"}], ":=", 658 | RowBox[{"(", "\[IndentingNewLine]", 659 | RowBox[{ 660 | RowBox[{ 661 | RowBox[{"CryptSymmetricPolynomial", "[", 662 | RowBox[{ 663 | SuperscriptBox["2", "#"], ",", "x", ",", "pk"}], "]"}], "&"}], "/@", 664 | 665 | RowBox[{"Array", "[", 666 | RowBox[{ 667 | RowBox[{ 668 | RowBox[{"#", "-", "1"}], "&"}], ",", 669 | RowBox[{"Min", "[", 670 | RowBox[{"len", ",", 671 | RowBox[{"Floor", "[", 672 | RowBox[{"1", "+", 673 | RowBox[{"Log", "[", 674 | RowBox[{"2", ",", 675 | RowBox[{"Length", "[", "x", "]"}]}], "]"}]}], "]"}]}], "]"}]}], 676 | "]"}]}], "\[IndentingNewLine]", ")"}]}], ";"}], "\[IndentingNewLine]", 677 | "\[IndentingNewLine]", 678 | RowBox[{"(*", " ", 679 | RowBox[{ 680 | RowBox[{"Parameter", ":", "\[IndentingNewLine]", " ", 681 | RowBox[{"x", ":", " ", "Eingabe"}]}], ";", "\[IndentingNewLine]", 682 | " ", 683 | RowBox[{"s", ":", " ", 684 | RowBox[{"L\[ADoubleDot]nge", " ", "des", " ", "Hamminggewichts"}]}], 685 | ";"}], "\[IndentingNewLine]", "*)"}]}], "\[IndentingNewLine]", 686 | RowBox[{ 687 | RowBox[{ 688 | RowBox[{ 689 | RowBox[{"Hamming", "[", 690 | RowBox[{"x_", ",", "s_", ",", "pk_"}], "]"}], ":=", 691 | RowBox[{"Module", "[", 692 | RowBox[{ 693 | RowBox[{"{", 694 | RowBox[{ 695 | RowBox[{"S", "=", 696 | SuperscriptBox["2", 697 | RowBox[{"s", "-", "1"}]]}], ",", 698 | RowBox[{"s1", "=", 699 | RowBox[{"Length", "[", "x", "]"}]}], ",", "i", ",", "k", ",", 700 | "result"}], "}"}], ",", "\[IndentingNewLine]", 701 | RowBox[{ 702 | RowBox[{"result", "=", 703 | RowBox[{"Array", "[", 704 | RowBox[{ 705 | RowBox[{ 706 | RowBox[{"Encrypt", "[", 707 | RowBox[{"0", ",", "pk"}], "]"}], "&"}], ",", "S"}], "]"}]}], ";", 708 | "\[IndentingNewLine]", 709 | RowBox[{"For", "[", 710 | RowBox[{ 711 | RowBox[{"i", "=", "1"}], ",", 712 | RowBox[{"i", "\[LessEqual]", "s1"}], ",", 713 | RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 714 | RowBox[{ 715 | RowBox[{"For", "[", 716 | RowBox[{ 717 | RowBox[{"k", "=", 718 | RowBox[{"Min", "[", 719 | RowBox[{"i", ",", "S"}], "]"}]}], ",", 720 | RowBox[{"k", "\[GreaterEqual]", "2"}], ",", 721 | RowBox[{"k", "--"}], ",", "\[IndentingNewLine]", 722 | RowBox[{ 723 | RowBox[{ 724 | RowBox[{"result", "[", 725 | RowBox[{"[", "k", "]"}], "]"}], "=", 726 | RowBox[{"Add", "[", 727 | RowBox[{ 728 | RowBox[{"result", "[", 729 | RowBox[{"[", "k", "]"}], "]"}], ",", 730 | RowBox[{"Mult", "[", 731 | RowBox[{ 732 | RowBox[{"result", "[", 733 | RowBox[{"[", 734 | RowBox[{"k", "-", "1"}], "]"}], "]"}], ",", 735 | RowBox[{"x", "[", 736 | RowBox[{"[", "i", "]"}], "]"}], ",", "pk"}], "]"}], ",", 737 | "pk"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", 738 | "\[IndentingNewLine]", 739 | RowBox[{ 740 | RowBox[{"result", "[", 741 | RowBox[{"[", "1", "]"}], "]"}], "=", 742 | RowBox[{"Add", "[", 743 | RowBox[{ 744 | RowBox[{"result", "[", 745 | RowBox[{"[", "1", "]"}], "]"}], ",", 746 | RowBox[{"x", "[", 747 | RowBox[{"[", "i", "]"}], "]"}], ",", "pk"}], "]"}]}], ";"}]}], 748 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 749 | RowBox[{ 750 | RowBox[{ 751 | RowBox[{"(", 752 | RowBox[{"result", "[", 753 | RowBox[{"[", "#", "]"}], "]"}], ")"}], "&"}], "/@", 754 | RowBox[{"Array", "[", 755 | RowBox[{ 756 | RowBox[{ 757 | SuperscriptBox["2", 758 | RowBox[{"#", "-", "1"}]], "&"}], ",", "s"}], "]"}]}]}]}], 759 | "\[IndentingNewLine]", "]"}]}], ";"}], 760 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 761 | RowBox[{ 762 | RowBox[{ 763 | RowBox[{ 764 | RowBox[{"Reencrypt", "[", 765 | RowBox[{"c_", ",", "pk_", ",", "sk_"}], "]"}], ":=", 766 | RowBox[{"(", "\[IndentingNewLine]", 767 | RowBox[{"Encrypt", "[", 768 | RowBox[{ 769 | RowBox[{"Decrypt", "[", 770 | RowBox[{"c", ",", "sk"}], "]"}], ",", "pk"}], "]"}], 771 | "\[IndentingNewLine]", ")"}]}], ";"}], 772 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 773 | RowBox[{ 774 | RowBox[{ 775 | RowBox[{ 776 | RowBox[{"Recrypt", "[", 777 | RowBox[{"c_", ",", "pk_"}], "]"}], ":=", 778 | RowBox[{"Module", "[", 779 | RowBox[{ 780 | RowBox[{"{", 781 | RowBox[{ 782 | "p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", "SK", ",", "B", ",", 783 | "SKdec", ",", "H", ",", "t", ",", "s", ",", "cmatrix", ",", "ham", 784 | ",", "HAM", ",", "temp", ",", "i", ",", "j", ",", "e0", ",", "e1", 785 | ",", "e2", ",", "res"}], "}"}], ",", "\[IndentingNewLine]", 786 | RowBox[{ 787 | RowBox[{ 788 | RowBox[{"{", 789 | RowBox[{"p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", 790 | RowBox[{"{", 791 | RowBox[{"SK", ",", "H"}], "}"}]}], "}"}], "=", "pk"}], ";", 792 | "\[IndentingNewLine]", 793 | RowBox[{"t", "=", 794 | RowBox[{ 795 | RowBox[{"Ceiling", "[", 796 | RowBox[{"Log", "[", 797 | RowBox[{"2", ",", "s2"}], "]"}], "]"}], "+", "2"}]}], ";", 798 | "\[IndentingNewLine]", 799 | RowBox[{"s", "=", 800 | RowBox[{ 801 | RowBox[{"Floor", "[", 802 | RowBox[{"Log", "[", 803 | RowBox[{"2", ",", "s2"}], "]"}], "]"}], "+", "1"}]}], ";", 804 | "\[IndentingNewLine]", 805 | RowBox[{"(*", " ", "1.", " ", "*)"}], "\[IndentingNewLine]", 806 | RowBox[{"cmatrix", "=", 807 | RowBox[{"Array", "[", 808 | RowBox[{ 809 | RowBox[{ 810 | RowBox[{"First", "[", 811 | RowBox[{"RealDigits", "[", 812 | RowBox[{ 813 | RowBox[{ 814 | RowBox[{"Mod", "[", 815 | RowBox[{ 816 | RowBox[{"c", " ", 817 | RowBox[{"H", "[", 818 | RowBox[{"[", "#1", "]"}], "]"}]}], ",", 819 | RowBox[{"2", "p"}]}], "]"}], "/", "p"}], ",", "2", ",", "t", 820 | ",", "0"}], "]"}], "]"}], "&"}], ",", "s1"}], "]"}]}], ";", 821 | "\[IndentingNewLine]", 822 | RowBox[{"(*", " ", "2.", " ", "*)"}], "\[IndentingNewLine]", 823 | RowBox[{"cmatrix", "=", 824 | RowBox[{"Map", "[", 825 | RowBox[{ 826 | RowBox[{ 827 | RowBox[{"(", 828 | RowBox[{"Encrypt", "[", 829 | RowBox[{"#1", ",", "pk"}], "]"}], ")"}], "&"}], ",", "cmatrix", 830 | ",", 831 | RowBox[{"{", "2", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 832 | RowBox[{"(*", " ", "3.", " ", "*)"}], "\[IndentingNewLine]", 833 | RowBox[{"cmatrix", "=", 834 | RowBox[{"MapIndexed", "[", 835 | RowBox[{ 836 | RowBox[{ 837 | RowBox[{"(", 838 | RowBox[{"Mult", "[", 839 | RowBox[{"#1", ",", 840 | RowBox[{"SK", "[", 841 | RowBox[{"[", 842 | RowBox[{"First", "[", "#2", "]"}], "]"}], "]"}], ",", "pk"}], 843 | "]"}], ")"}], "&"}], ",", "cmatrix", ",", 844 | RowBox[{"{", "2", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", " ", 845 | RowBox[{"(*", " ", "4.", " ", "*)"}], "\[IndentingNewLine]", 846 | RowBox[{"ham", "=", 847 | RowBox[{"Map", "[", 848 | RowBox[{ 849 | RowBox[{ 850 | RowBox[{"Hamming", "[", 851 | RowBox[{"#", ",", "s", ",", "pk"}], "]"}], "&"}], ",", 852 | RowBox[{"cmatrix", "\[Transpose]"}]}], "]"}]}], ";", 853 | "\[IndentingNewLine]", 854 | RowBox[{"HAM", "=", 855 | RowBox[{"ham", "\[Transpose]"}]}], ";", "\[IndentingNewLine]", 856 | RowBox[{"For", "[", 857 | RowBox[{ 858 | RowBox[{"i", "=", "2"}], ",", 859 | RowBox[{"i", "\[LessEqual]", "s"}], ",", 860 | RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 861 | RowBox[{ 862 | RowBox[{"For", "[", 863 | RowBox[{ 864 | RowBox[{"j", "=", "1"}], ",", 865 | RowBox[{"j", "\[LessEqual]", 866 | RowBox[{"i", "-", "1"}]}], ",", 867 | RowBox[{"j", "++"}], ",", "\[IndentingNewLine]", 868 | RowBox[{ 869 | RowBox[{ 870 | RowBox[{ 871 | RowBox[{"HAM", "[", 872 | RowBox[{"[", "i", "]"}], "]"}], "[", 873 | RowBox[{"[", "j", "]"}], "]"}], "=", 874 | RowBox[{"Encrypt", "[", 875 | RowBox[{"0", ",", "pk"}], "]"}]}], ";"}]}], 876 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 877 | RowBox[{ 878 | RowBox[{"HAM", "[", 879 | RowBox[{"[", "i", "]"}], "]"}], "=", 880 | RowBox[{"RotateLeft", "[", 881 | RowBox[{ 882 | RowBox[{"HAM", "[", 883 | RowBox[{"[", "i", "]"}], "]"}], ",", 884 | RowBox[{"i", "-", "1"}]}], "]"}]}], ";"}]}], 885 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 886 | RowBox[{"(*", " ", "5.", " ", "*)"}], "\[IndentingNewLine]", 887 | RowBox[{"(*", " ", 888 | RowBox[{"nicht", " ", "mehr", " ", "n\[ODoubleDot]tig", " ", 889 | RowBox[{"(", 890 | RowBox[{ 891 | "passiert", " ", "schon", " ", "in", " ", "Schritt", " ", "4"}], 892 | ")"}]}], " ", "*)"}], "\[IndentingNewLine]", 893 | RowBox[{"(*", " ", "6.", " ", "*)"}], "\[IndentingNewLine]", 894 | RowBox[{"(*", " ", 895 | RowBox[{"Carry", " ", "save", " ", "adder", " ", 896 | RowBox[{"(", 897 | RowBox[{ 898 | RowBox[{"nur", " ", "1", "x"}], ",", " ", 899 | RowBox[{ 900 | "da", " ", "wir", " ", "nur", " ", "drei", " ", "Zeilen", " ", 901 | "haben"}]}], ")"}]}], " ", "*)"}], "\[IndentingNewLine]", 902 | RowBox[{"temp", "=", 903 | RowBox[{ 904 | RowBox[{"Array", "[", 905 | RowBox[{ 906 | RowBox[{ 907 | RowBox[{"FullAdder", "[", 908 | RowBox[{ 909 | RowBox[{ 910 | RowBox[{"HAM", "[", 911 | RowBox[{"[", "1", "]"}], "]"}], "[", 912 | RowBox[{"[", "#1", "]"}], "]"}], ",", 913 | RowBox[{ 914 | RowBox[{"HAM", "[", 915 | RowBox[{"[", "2", "]"}], "]"}], "[", 916 | RowBox[{"[", "#1", "]"}], "]"}], ",", 917 | RowBox[{ 918 | RowBox[{"HAM", "[", 919 | RowBox[{"[", "3", "]"}], "]"}], "[", 920 | RowBox[{"[", "#1", "]"}], "]"}], ",", "pk"}], "]"}], "&"}], 921 | ",", "t"}], "]"}], "\[Transpose]"}]}], ";", "\[IndentingNewLine]", 922 | 923 | RowBox[{ 924 | RowBox[{ 925 | RowBox[{"temp", "[", 926 | RowBox[{"[", "1", "]"}], "]"}], "[", 927 | RowBox[{"[", "1", "]"}], "]"}], "=", 928 | RowBox[{"Encrypt", "[", 929 | RowBox[{"0", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 930 | RowBox[{ 931 | RowBox[{"temp", "[", 932 | RowBox[{"[", "1", "]"}], "]"}], "=", 933 | RowBox[{"RotateLeft", "[", 934 | RowBox[{"temp", "[", 935 | RowBox[{"[", "1", "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 936 | RowBox[{"(*", " ", "7.", " ", "*)"}], "\[IndentingNewLine]", 937 | RowBox[{"(*", " ", 938 | RowBox[{ 939 | "letzte", " ", "Addition", " ", "der", " ", "verbleibenden", " ", 940 | "zwei", " ", "Zeilen"}], " ", "*)"}], "\[IndentingNewLine]", 941 | RowBox[{ 942 | RowBox[{"temp", "[", 943 | RowBox[{"[", "1", "]"}], "]"}], "=", 944 | RowBox[{"RippleCarryAdder", "[", 945 | RowBox[{ 946 | RowBox[{"temp", "[", 947 | RowBox[{"[", "1", "]"}], "]"}], ",", 948 | RowBox[{"temp", "[", 949 | RowBox[{"[", "2", "]"}], "]"}], ",", "pk"}], "]"}]}], ";", 950 | "\[IndentingNewLine]", 951 | RowBox[{"(*", " ", 952 | RowBox[{ 953 | RowBox[{"e0", "=", "2"}], ",", " ", 954 | RowBox[{"e1", "=", "3"}], ",", " ", 955 | RowBox[{ 956 | RowBox[{"e2", "=", "4"}], " ", ";", " ", 957 | RowBox[{ 958 | RowBox[{"s", ".", " ", "S", ".", " ", "14"}], " ", "oben"}]}]}], 959 | " ", "*)"}], "\[IndentingNewLine]", 960 | RowBox[{ 961 | RowBox[{"{", 962 | RowBox[{"e0", ",", "e1", ",", "e2"}], "}"}], "=", 963 | RowBox[{"{", 964 | RowBox[{ 965 | RowBox[{ 966 | RowBox[{"temp", "[", 967 | RowBox[{"[", "1", "]"}], "]"}], "[", 968 | RowBox[{"[", "2", "]"}], "]"}], ",", 969 | RowBox[{ 970 | RowBox[{"temp", "[", 971 | RowBox[{"[", "1", "]"}], "]"}], "[", 972 | RowBox[{"[", "3", "]"}], "]"}], ",", 973 | RowBox[{ 974 | RowBox[{"temp", "[", 975 | RowBox[{"[", "1", "]"}], "]"}], "[", 976 | RowBox[{"[", "4", "]"}], "]"}]}], "}"}]}], ";", 977 | "\[IndentingNewLine]", 978 | RowBox[{"res", "=", 979 | RowBox[{"CryptRound", "[", 980 | RowBox[{"e0", ",", "e1", ",", "e2", ",", "pk"}], "]"}]}], ";", 981 | "\[IndentingNewLine]", 982 | RowBox[{"Add", "[", 983 | RowBox[{ 984 | RowBox[{"Mod", "[", 985 | RowBox[{"c", ",", "2"}], "]"}], ",", "res", ",", "pk"}], "]"}]}]}], 986 | "\[IndentingNewLine]", "]"}]}], ";"}], 987 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 988 | RowBox[{ 989 | RowBox[{ 990 | RowBox[{ 991 | RowBox[{"CryptRound", "[", 992 | RowBox[{"e0_", ",", "e1_", ",", "e2_", ",", "pk_"}], "]"}], ":=", 993 | RowBox[{"(", "\[IndentingNewLine]", 994 | RowBox[{"Add", "[", 995 | RowBox[{"e0", ",", "e1", ",", "pk"}], "]"}], "\[IndentingNewLine]", 996 | ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 997 | RowBox[{ 998 | RowBox[{ 999 | RowBox[{"KeyGen", ":=", 1000 | RowBox[{"Module", "[", 1001 | RowBox[{ 1002 | RowBox[{"{", 1003 | RowBox[{ 1004 | RowBox[{"p", "=", "4"}], ",", "f", ",", "S", ",", "g", ",", "g2", ",", 1005 | "z", ",", "\[Alpha]", ",", "d", ",", "b", ",", "pk", ",", "sk", ",", 1006 | "H", ",", "SK", ",", "i", ",", "j", ",", "rplus", ",", "rminus", ",", 1007 | "h", ",", 1008 | RowBox[{"s1", "=", "8"}], ",", 1009 | RowBox[{"s2", "=", "5"}]}], "}"}], ",", "\[IndentingNewLine]", 1010 | RowBox[{ 1011 | RowBox[{ 1012 | RowBox[{"f", "[", "x_", "]"}], ":=", 1013 | RowBox[{ 1014 | SuperscriptBox["x", "n"], "+", "1"}]}], ";", "\[IndentingNewLine]", 1015 | RowBox[{"While", "[", 1016 | RowBox[{ 1017 | RowBox[{"!", 1018 | RowBox[{"PrimeQ", "[", "p", "]"}]}], ",", "\[IndentingNewLine]", 1019 | RowBox[{ 1020 | RowBox[{"S", "=", 1021 | RowBox[{ 1022 | RowBox[{ 1023 | RowBox[{"(", 1024 | RowBox[{"2", "#"}], ")"}], "&"}], "/@", 1025 | RowBox[{"RandomInteger", "[", 1026 | RowBox[{ 1027 | RowBox[{"{", 1028 | RowBox[{ 1029 | RowBox[{"-", 1030 | FractionBox["\[Eta]", "2"]}], ",", 1031 | FractionBox["\[Eta]", "2"]}], "}"}], ",", "n"}], "]"}]}]}], 1032 | ";", "\[IndentingNewLine]", 1033 | RowBox[{"(*", 1034 | RowBox[{ 1035 | RowBox[{"S", "=", 1036 | RowBox[{"{", 1037 | RowBox[{ 1038 | RowBox[{"-", "2"}], ",", 1039 | RowBox[{"-", "4"}], ",", "2", ",", "0"}], "}"}]}], ";"}], 1040 | "*)"}], "\[IndentingNewLine]", 1041 | RowBox[{ 1042 | RowBox[{"S", "[", 1043 | RowBox[{"[", "1", "]"}], "]"}], "+=", "1"}], ";", 1044 | "\[IndentingNewLine]", 1045 | RowBox[{ 1046 | RowBox[{"g", "[", "x_", "]"}], ":=", 1047 | RowBox[{"Sum", "[", 1048 | RowBox[{ 1049 | RowBox[{ 1050 | RowBox[{"MapIndexed", "[", 1051 | RowBox[{ 1052 | RowBox[{ 1053 | RowBox[{"#1", " ", 1054 | SuperscriptBox["x", 1055 | RowBox[{ 1056 | RowBox[{"First", "[", "#2", "]"}], "-", "1"}]]}], "&"}], 1057 | ",", "S"}], "]"}], "[", 1058 | RowBox[{"[", "i", "]"}], "]"}], ",", 1059 | RowBox[{"{", 1060 | RowBox[{"i", ",", "n"}], "}"}]}], "]"}]}], ";", 1061 | "\[IndentingNewLine]", 1062 | RowBox[{"p", "=", 1063 | RowBox[{"Resultant", "[", 1064 | RowBox[{ 1065 | RowBox[{"g", "[", "x", "]"}], ",", 1066 | RowBox[{"f", "[", "x", "]"}], ",", "x"}], "]"}]}], ";"}]}], 1067 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 1068 | RowBox[{"Print", "[", 1069 | RowBox[{"\"\\"", ",", "p"}], "]"}], ";", "\[IndentingNewLine]", 1070 | 1071 | RowBox[{"Print", "[", 1072 | RowBox[{"\"\\"", ",", 1073 | RowBox[{"g", "[", "x", "]"}], ",", "\"\< = \>\"", ",", 1074 | RowBox[{"Factor", "[", 1075 | RowBox[{ 1076 | RowBox[{"g", "[", "x", "]"}], ",", 1077 | RowBox[{"Modulus", "\[Rule]", "p"}]}], "]"}]}], "]"}], ";", 1078 | "\[IndentingNewLine]", 1079 | RowBox[{"Print", "[", 1080 | RowBox[{"\"\\"", ",", 1081 | RowBox[{"f", "[", "x", "]"}], ",", "\"\< = \>\"", ",", 1082 | RowBox[{"Factor", "[", 1083 | RowBox[{ 1084 | RowBox[{"f", "[", "x", "]"}], ",", 1085 | RowBox[{"Modulus", "\[Rule]", "p"}]}], "]"}]}], "]"}], ";", " ", 1086 | "\[IndentingNewLine]", 1087 | RowBox[{ 1088 | RowBox[{"d", "[", "x_", "]"}], ":=", 1089 | RowBox[{"PolynomialGCD", "[", 1090 | RowBox[{ 1091 | RowBox[{"g", "[", "x", "]"}], ",", 1092 | RowBox[{"f", "[", "x", "]"}], ",", 1093 | RowBox[{"Modulus", "\[Rule]", "p"}]}], "]"}]}], ";", 1094 | "\[IndentingNewLine]", 1095 | RowBox[{"Print", "[", 1096 | RowBox[{"\"\\"", ",", 1097 | RowBox[{"d", "[", "x", "]"}]}], "]"}], ";", "\[IndentingNewLine]", 1098 | RowBox[{"Print", "[", 1099 | RowBox[{"\"\\"", ",", 1100 | RowBox[{"PolynomialGCD", "[", 1101 | RowBox[{ 1102 | RowBox[{"g", "[", "x", "]"}], ",", 1103 | RowBox[{"f", "[", "x", "]"}]}], "]"}]}], "]"}], ";", 1104 | "\[IndentingNewLine]", 1105 | RowBox[{"\[Alpha]", "=", 1106 | RowBox[{"Mod", "[", 1107 | RowBox[{ 1108 | RowBox[{"Root", "[", 1109 | RowBox[{ 1110 | RowBox[{"d", "[", "x", "]"}], ",", "1"}], "]"}], ",", "p"}], 1111 | "]"}]}], ";", "\[IndentingNewLine]", 1112 | RowBox[{"(*", 1113 | RowBox[{ 1114 | RowBox[{"Print", "[", 1115 | RowBox[{"\"\<\[Alpha]: \>\"", ",", "\[Alpha]"}], "]"}], ";"}], 1116 | "*)"}], "\[IndentingNewLine]", 1117 | RowBox[{ 1118 | RowBox[{"{", 1119 | RowBox[{"r", ",", 1120 | RowBox[{"{", 1121 | RowBox[{"z", ",", "b"}], "}"}]}], "}"}], "=", 1122 | RowBox[{"PolynomialExtendedGCD", "[", 1123 | RowBox[{ 1124 | RowBox[{ 1125 | RowBox[{"g", "[", "x", "]"}], "/", "p"}], ",", 1126 | RowBox[{ 1127 | RowBox[{"f", "[", "x", "]"}], "/", "p"}], ",", "x"}], "]"}]}], ";", 1128 | "\[IndentingNewLine]", 1129 | RowBox[{"Print", "[", 1130 | RowBox[{"\"\\"", ",", "r"}], "]"}], ";", "\[IndentingNewLine]", 1131 | RowBox[{"Print", "[", 1132 | RowBox[{"\"\\"", ",", "z"}], "]"}], ";", "\[IndentingNewLine]", 1133 | RowBox[{"Print", "[", 1134 | RowBox[{"\"\\"", ",", 1135 | RowBox[{ 1136 | RowBox[{"g", "[", "x", "]"}], "/", "p"}]}], "]"}], ";", 1137 | "\[IndentingNewLine]", 1138 | RowBox[{"If", "[", 1139 | RowBox[{ 1140 | RowBox[{ 1141 | RowBox[{ 1142 | RowBox[{ 1143 | RowBox[{"z", " ", 1144 | RowBox[{"g", "[", "x", "]"}]}], " ", "+", 1145 | RowBox[{"b", " ", 1146 | RowBox[{"f", "[", "x", "]"}]}]}], "\[NotEqual]", " ", "p"}], "//", 1147 | "Expand"}], ",", 1148 | RowBox[{"Throw", "[", 1149 | RowBox[{ 1150 | RowBox[{"z", " ", 1151 | RowBox[{"g", "[", "x", "]"}]}], " ", "+", 1152 | RowBox[{"b", " ", 1153 | RowBox[{"f", "[", "x", "]"}]}]}], "]"}]}], "]"}], ";", 1154 | "\[IndentingNewLine]", 1155 | RowBox[{"b", "=", 1156 | RowBox[{"Mod", "[", 1157 | RowBox[{ 1158 | RowBox[{"Coefficient", "[", 1159 | RowBox[{"z", ",", "x", ",", "0"}], "]"}], ",", 1160 | RowBox[{"2", " ", "p"}]}], "]"}]}], ";", "\[IndentingNewLine]", 1161 | RowBox[{"pk", "=", 1162 | RowBox[{"{", 1163 | RowBox[{"p", ",", "\[Alpha]"}], "}"}]}], ";", "\[IndentingNewLine]", 1164 | 1165 | RowBox[{"sk", "=", 1166 | RowBox[{"{", 1167 | RowBox[{"p", ",", "b"}], "}"}]}], ";", "\[IndentingNewLine]", 1168 | RowBox[{"(*", 1169 | RowBox[{ 1170 | RowBox[{"Print", "[", 1171 | RowBox[{"\"\\"", ",", "z"}], "]"}], ";", 1172 | "\[IndentingNewLine]", 1173 | RowBox[{"Print", "[", 1174 | RowBox[{"\"\\"", ",", 1175 | RowBox[{"g", "[", "x", "]"}]}], "]"}], ";", "\[IndentingNewLine]", 1176 | 1177 | RowBox[{"Print", "[", 1178 | RowBox[{"\"\\"", ",", " ", "b"}], "]"}], ";"}], "*)"}], 1179 | "\[IndentingNewLine]", 1180 | RowBox[{"(*", 1181 | RowBox[{ 1182 | RowBox[{ 1183 | "Print", "[", 1184 | "\"\<---------------------------------------------------\>\"", 1185 | "]"}], ";", "\[IndentingNewLine]", 1186 | RowBox[{"Print", "[", 1187 | RowBox[{"\"\\"", ",", " ", "pk"}], "]"}], ";", 1188 | "\[IndentingNewLine]", 1189 | RowBox[{"Print", "[", 1190 | RowBox[{"\"\\"", ",", " ", "sk"}], "]"}], ";"}], "*)"}], 1191 | "\[IndentingNewLine]", 1192 | RowBox[{"(*", 1193 | RowBox[{ 1194 | RowBox[{"Print", "[", 1195 | RowBox[{"Mod", "[", 1196 | RowBox[{ 1197 | RowBox[{"g", "[", "\[Alpha]", "]"}], ",", "p"}], "]"}], "]"}], 1198 | ";"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 1199 | RowBox[{"(*", 1200 | RowBox[{"Zusatzinfos", " ", "f\[UDoubleDot]r", " ", "Recrypt"}], 1201 | "*)"}], "\[IndentingNewLine]", 1202 | RowBox[{"(*", " ", 1203 | RowBox[{ 1204 | RowBox[{"1.", ":", " ", 1205 | RowBox[{"Konstruiere", " ", 1206 | SubscriptBox["s", "2"], " ", "Elemente", " ", "genau", " ", 1207 | "so"}]}], ",", " ", 1208 | RowBox[{ 1209 | "dass", " ", "als", " ", "Summe", " ", "b", " ", "herauskommt"}]}], 1210 | " ", "*)"}], "\[IndentingNewLine]", 1211 | RowBox[{"H", "=", 1212 | RowBox[{ 1213 | RowBox[{"Array", "[", 1214 | RowBox[{ 1215 | RowBox[{ 1216 | RowBox[{"Floor", "[", 1217 | RowBox[{"b", "/", "s2"}], "]"}], "&"}], ",", "s2"}], "]"}], "~", 1218 | "Join", "~", 1219 | RowBox[{"Array", "[", 1220 | RowBox[{ 1221 | RowBox[{ 1222 | RowBox[{"RandomInteger", "[", 1223 | RowBox[{"{", 1224 | RowBox[{ 1225 | RowBox[{"-", "p"}], ",", "p"}], "}"}], "]"}], "&"}], ",", 1226 | RowBox[{"s1", "-", "s2"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", 1227 | RowBox[{ 1228 | RowBox[{"H", "[", 1229 | RowBox[{"[", "1", "]"}], "]"}], "+=", 1230 | RowBox[{"b", "-", 1231 | RowBox[{ 1232 | RowBox[{"Floor", "[", 1233 | RowBox[{"b", "/", "s2"}], "]"}], " ", "s2"}]}]}], ";", 1234 | "\[IndentingNewLine]", 1235 | RowBox[{"SK", "=", 1236 | RowBox[{ 1237 | RowBox[{"Array", "[", 1238 | RowBox[{ 1239 | RowBox[{"1", "&"}], ",", "s2"}], "]"}], "~", "Join", "~", 1240 | RowBox[{"Array", "[", 1241 | RowBox[{ 1242 | RowBox[{"0", "&"}], ",", 1243 | RowBox[{"s1", "-", "s2"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", 1244 | RowBox[{"(*", " ", 1245 | RowBox[{ 1246 | RowBox[{"2.", ":", " ", 1247 | RowBox[{ 1248 | RowBox[{"Addiere", "/", "Subtrahiere"}], " ", 1249 | "zuf\[ADoubleDot]llige", " ", "Werte", " ", "genau", " ", "so"}]}], 1250 | ",", " ", 1251 | RowBox[{ 1252 | "dass", " ", "die", " ", "Summe", " ", "erhalten", " ", "bleibt"}]}], 1253 | " ", "*)"}], "\[IndentingNewLine]", 1254 | RowBox[{"For", "[", 1255 | RowBox[{ 1256 | RowBox[{"i", "=", "1"}], ",", 1257 | RowBox[{"i", "\[LessEqual]", "s2"}], ",", 1258 | RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 1259 | RowBox[{ 1260 | RowBox[{"rplus", "=", 1261 | RowBox[{"RandomInteger", "[", 1262 | RowBox[{"{", 1263 | RowBox[{"0", ",", "p"}], "}"}], "]"}]}], ";", 1264 | "\[IndentingNewLine]", 1265 | RowBox[{"rminus", "=", 1266 | RowBox[{"-", "rplus"}]}], ";", "\[IndentingNewLine]", 1267 | RowBox[{"While", "[", 1268 | RowBox[{ 1269 | RowBox[{"rplus", "\[NotEqual]", "0"}], ",", "\[IndentingNewLine]", 1270 | RowBox[{ 1271 | RowBox[{"j", "=", 1272 | RowBox[{"RandomInteger", "[", 1273 | RowBox[{"{", 1274 | RowBox[{"1", ",", "s2"}], "}"}], "]"}]}], ";", 1275 | "\[IndentingNewLine]", 1276 | RowBox[{ 1277 | RowBox[{"H", "[", 1278 | RowBox[{"[", "j", "]"}], "]"}], "+=", "rplus"}], ";", 1279 | "\[IndentingNewLine]", 1280 | RowBox[{"If", "[", 1281 | RowBox[{ 1282 | RowBox[{ 1283 | RowBox[{"H", "[", 1284 | RowBox[{"[", "j", "]"}], "]"}], ">", "p"}], ",", 1285 | "\[IndentingNewLine]", 1286 | RowBox[{"(*", "then", "*)"}], "\[IndentingNewLine]", 1287 | RowBox[{ 1288 | RowBox[{"rplus", "=", 1289 | RowBox[{ 1290 | RowBox[{"H", "[", 1291 | RowBox[{"[", "j", "]"}], "]"}], "-", "p"}]}], ";", 1292 | "\[IndentingNewLine]", 1293 | RowBox[{ 1294 | RowBox[{"H", "[", 1295 | RowBox[{"[", "j", "]"}], "]"}], "=", "p"}]}], ",", 1296 | "\[IndentingNewLine]", 1297 | RowBox[{"(*", "else", "*)"}], "\[IndentingNewLine]", 1298 | RowBox[{ 1299 | RowBox[{"rplus", "=", "0"}], ";"}]}], "\[IndentingNewLine]", 1300 | "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", 1301 | "\[IndentingNewLine]", 1302 | RowBox[{"While", "[", 1303 | RowBox[{ 1304 | RowBox[{"rminus", "\[NotEqual]", "0"}], ",", 1305 | "\[IndentingNewLine]", 1306 | RowBox[{ 1307 | RowBox[{"j", "=", 1308 | RowBox[{"RandomInteger", "[", 1309 | RowBox[{"{", 1310 | RowBox[{"1", ",", "s2"}], "}"}], "]"}]}], ";", 1311 | "\[IndentingNewLine]", 1312 | RowBox[{ 1313 | RowBox[{"H", "[", 1314 | RowBox[{"[", "j", "]"}], "]"}], "+=", "rminus"}], ";", 1315 | "\[IndentingNewLine]", 1316 | RowBox[{"If", "[", 1317 | RowBox[{ 1318 | RowBox[{ 1319 | RowBox[{"H", "[", 1320 | RowBox[{"[", "j", "]"}], "]"}], "<", 1321 | RowBox[{"-", "p"}]}], ",", "\[IndentingNewLine]", 1322 | RowBox[{"(*", "then", "*)"}], "\[IndentingNewLine]", 1323 | RowBox[{ 1324 | RowBox[{"rminus", "=", 1325 | RowBox[{ 1326 | RowBox[{"H", "[", 1327 | RowBox[{"[", "j", "]"}], "]"}], "+", "p"}]}], ";", 1328 | "\[IndentingNewLine]", 1329 | RowBox[{ 1330 | RowBox[{"H", "[", 1331 | RowBox[{"[", "j", "]"}], "]"}], "=", 1332 | RowBox[{"-", "p"}]}]}], ",", "\[IndentingNewLine]", 1333 | RowBox[{"(*", "else", "*)"}], "\[IndentingNewLine]", 1334 | RowBox[{ 1335 | RowBox[{"rminus", "=", "0"}], ";"}]}], "\[IndentingNewLine]", 1336 | "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], 1337 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 1338 | RowBox[{"(*", " ", 1339 | RowBox[{"3.", ":", " ", "Mischen"}], " ", "*)"}], 1340 | "\[IndentingNewLine]", 1341 | RowBox[{"For", "[", 1342 | RowBox[{ 1343 | RowBox[{"i", "=", "1"}], ",", 1344 | RowBox[{"i", "\[LessEqual]", "s1"}], ",", 1345 | RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 1346 | RowBox[{ 1347 | RowBox[{"j", "=", 1348 | RowBox[{"RandomInteger", "[", 1349 | RowBox[{"{", 1350 | RowBox[{"1", ",", "s1"}], "}"}], "]"}]}], ";", 1351 | "\[IndentingNewLine]", 1352 | RowBox[{"h", "=", 1353 | RowBox[{"H", "[", 1354 | RowBox[{"[", "i", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 1355 | RowBox[{ 1356 | RowBox[{"H", "[", 1357 | RowBox[{"[", "i", "]"}], "]"}], "=", 1358 | RowBox[{"H", "[", 1359 | RowBox[{"[", "j", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 1360 | RowBox[{ 1361 | RowBox[{"H", "[", 1362 | RowBox[{"[", "j", "]"}], "]"}], "=", "h"}], ";", 1363 | "\[IndentingNewLine]", 1364 | RowBox[{"h", "=", 1365 | RowBox[{"SK", "[", 1366 | RowBox[{"[", "i", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 1367 | RowBox[{ 1368 | RowBox[{"SK", "[", 1369 | RowBox[{"[", "i", "]"}], "]"}], "=", 1370 | RowBox[{"SK", "[", 1371 | RowBox[{"[", "j", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 1372 | RowBox[{ 1373 | RowBox[{"SK", "[", 1374 | RowBox[{"[", "j", "]"}], "]"}], "=", "h"}], ";"}]}], 1375 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 1376 | RowBox[{"(*", " ", 1377 | RowBox[{"4.", ":", " ", 1378 | RowBox[{"SK", " ", "verschl\[UDoubleDot]sseln"}]}], " ", "*)"}], 1379 | "\[IndentingNewLine]", 1380 | RowBox[{"SK", "=", 1381 | RowBox[{ 1382 | RowBox[{ 1383 | RowBox[{"(", 1384 | RowBox[{"OrigEncrypt", "[", 1385 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "SK"}]}], 1386 | ";", "\[IndentingNewLine]", 1387 | RowBox[{"pk", "=", 1388 | RowBox[{"{", 1389 | RowBox[{"p", ",", "\[Alpha]", ",", "s1", ",", "s2", ",", 1390 | RowBox[{"{", 1391 | RowBox[{"SK", ",", "H"}], "}"}]}], "}"}]}], ";", 1392 | "\[IndentingNewLine]", 1393 | RowBox[{"(*", " ", "Ausgabe", " ", "*)"}], "\[IndentingNewLine]", 1394 | RowBox[{"{", 1395 | RowBox[{"pk", ",", "sk"}], "}"}]}]}], "\[IndentingNewLine]", "]"}]}], 1396 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1397 | RowBox[{ 1398 | RowBox[{ 1399 | RowBox[{ 1400 | RowBox[{"Test", "[", "x_", "]"}], ":=", 1401 | RowBox[{"(", "\[IndentingNewLine]", 1402 | RowBox[{ 1403 | RowBox[{ 1404 | RowBox[{"{", 1405 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1406 | "\[IndentingNewLine]", 1407 | RowBox[{"Decrypt", "[", 1408 | RowBox[{ 1409 | RowBox[{"Recrypt", "[", 1410 | RowBox[{ 1411 | RowBox[{"Encrypt", "[", 1412 | RowBox[{"x", ",", "pk"}], "]"}], ",", "pk"}], "]"}], ",", "sk"}], 1413 | "]"}]}], "\[IndentingNewLine]", ")"}]}], ";"}], 1414 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1415 | RowBox[{ 1416 | RowBox[{ 1417 | RowBox[{ 1418 | RowBox[{"TestRound", "[", 1419 | RowBox[{"a_", ",", "b_", ",", "c_"}], "]"}], ":=", 1420 | RowBox[{"(", "\[IndentingNewLine]", 1421 | RowBox[{ 1422 | RowBox[{ 1423 | RowBox[{"{", 1424 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1425 | "\[IndentingNewLine]", 1426 | RowBox[{"Decrypt", "[", 1427 | RowBox[{ 1428 | RowBox[{"CryptRound", "[", 1429 | RowBox[{ 1430 | RowBox[{"Encrypt", "[", 1431 | RowBox[{"a", ",", "pk"}], "]"}], ",", 1432 | RowBox[{"Encrypt", "[", 1433 | RowBox[{"b", ",", "pk"}], "]"}], ",", 1434 | RowBox[{"Encrypt", "[", 1435 | RowBox[{"c", ",", "pk"}], "]"}], ",", "pk"}], "]"}], ",", "sk"}], 1436 | "]"}]}], "\[IndentingNewLine]", ")"}]}], ";"}], 1437 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1438 | RowBox[{ 1439 | RowBox[{ 1440 | RowBox[{ 1441 | RowBox[{"TestAdd", "[", 1442 | RowBox[{"a_", ",", "b_", ",", "cIn_"}], "]"}], ":=", 1443 | RowBox[{"(", "\[IndentingNewLine]", 1444 | RowBox[{ 1445 | RowBox[{ 1446 | RowBox[{"{", 1447 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1448 | "\[IndentingNewLine]", 1449 | RowBox[{ 1450 | RowBox[{"{", 1451 | RowBox[{"c", ",", "s"}], "}"}], "=", 1452 | RowBox[{"FullAdder", "[", 1453 | RowBox[{ 1454 | RowBox[{"Encrypt", "[", 1455 | RowBox[{"a", ",", "pk"}], "]"}], ",", 1456 | RowBox[{"Encrypt", "[", 1457 | RowBox[{"b", ",", "pk"}], "]"}], ",", 1458 | RowBox[{"Encrypt", "[", 1459 | RowBox[{"cIn", ",", "pk"}], "]"}], ",", "pk"}], "]"}]}], ";", 1460 | "\[IndentingNewLine]", 1461 | RowBox[{"Print", "[", 1462 | RowBox[{"Decrypt", "[", 1463 | RowBox[{"c", ",", "sk"}], "]"}], "]"}], ";", "\[IndentingNewLine]", 1464 | RowBox[{"Print", "[", 1465 | RowBox[{"Decrypt", "[", 1466 | RowBox[{"s", ",", "sk"}], "]"}], "]"}], ";"}], "\[IndentingNewLine]", 1467 | ")"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1468 | RowBox[{ 1469 | RowBox[{ 1470 | RowBox[{ 1471 | RowBox[{"TestDepth", "[", 1472 | RowBox[{"a_", ",", "depth_", ",", "count_"}], "]"}], ":=", 1473 | RowBox[{"Module", "[", 1474 | RowBox[{ 1475 | RowBox[{"{", 1476 | RowBox[{ 1477 | RowBox[{"sum", "=", "0"}], ",", "temp", ",", "i", ",", "j", ",", "pk", 1478 | ",", "sk"}], "}"}], ",", "\[IndentingNewLine]", 1479 | RowBox[{ 1480 | RowBox[{ 1481 | RowBox[{"{", 1482 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1483 | "\[IndentingNewLine]", 1484 | RowBox[{"For", "[", 1485 | RowBox[{ 1486 | RowBox[{"i", "=", "0"}], ",", 1487 | RowBox[{"i", "<", "count"}], ",", 1488 | RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 1489 | RowBox[{ 1490 | RowBox[{"temp", "=", 1491 | RowBox[{"Encrypt", "[", 1492 | RowBox[{"a", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 1493 | RowBox[{"For", "[", 1494 | RowBox[{ 1495 | RowBox[{"j", "=", "0"}], ",", 1496 | RowBox[{"j", "<", "depth"}], ",", 1497 | RowBox[{"j", "++"}], ",", "\[IndentingNewLine]", 1498 | RowBox[{ 1499 | RowBox[{"temp", "=", 1500 | RowBox[{"Mult", "[", 1501 | RowBox[{"temp", ",", "a", ",", "pk"}], "]"}]}], ";"}]}], 1502 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 1503 | RowBox[{"sum", "=", 1504 | RowBox[{"sum", "+", 1505 | RowBox[{"Decrypt", "[", 1506 | RowBox[{"temp", ",", "sk"}], "]"}]}]}], ";"}]}], 1507 | "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "sum"}]}], 1508 | "\[IndentingNewLine]", "]"}]}], ";"}], 1509 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1510 | RowBox[{ 1511 | RowBox[{ 1512 | RowBox[{ 1513 | RowBox[{"TestRipple", "[", 1514 | RowBox[{"A_", ",", "B_"}], "]"}], ":=", 1515 | RowBox[{"Module", "[", 1516 | RowBox[{ 1517 | RowBox[{"{", 1518 | RowBox[{ 1519 | "encA", ",", "encB", ",", "res", ",", "a", ",", "b", ",", "x"}], "}"}], 1520 | ",", "\[IndentingNewLine]", 1521 | RowBox[{ 1522 | RowBox[{ 1523 | RowBox[{"{", 1524 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1525 | "\[IndentingNewLine]", 1526 | RowBox[{ 1527 | RowBox[{"{", 1528 | RowBox[{"a", ",", "x"}], "}"}], "=", 1529 | RowBox[{"RealDigits", "[", 1530 | RowBox[{"A", ",", "2"}], "]"}]}], ";", "\[IndentingNewLine]", 1531 | RowBox[{ 1532 | RowBox[{"{", 1533 | RowBox[{"b", ",", "x"}], "}"}], "=", 1534 | RowBox[{"RealDigits", "[", 1535 | RowBox[{"B", ",", "2"}], "]"}]}], ";", "\[IndentingNewLine]", 1536 | RowBox[{"encA", "=", 1537 | RowBox[{ 1538 | RowBox[{ 1539 | RowBox[{"(", 1540 | RowBox[{"Encrypt", "[", 1541 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "a"}]}], ";", 1542 | "\[IndentingNewLine]", 1543 | RowBox[{"encB", "=", 1544 | RowBox[{ 1545 | RowBox[{ 1546 | RowBox[{"(", 1547 | RowBox[{"Encrypt", "[", 1548 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "b"}]}], ";", 1549 | "\[IndentingNewLine]", 1550 | RowBox[{"res", "=", 1551 | RowBox[{ 1552 | RowBox[{ 1553 | RowBox[{"(", 1554 | RowBox[{"Decrypt", "[", 1555 | RowBox[{"#", ",", "sk"}], "]"}], ")"}], "&"}], "/@", 1556 | RowBox[{"RippleCarryAdder", "[", 1557 | RowBox[{"encA", ",", "encB", ",", "pk"}], "]"}]}]}], ";", 1558 | "\[IndentingNewLine]", 1559 | RowBox[{"FromDigits", "[", 1560 | RowBox[{"res", ",", "2"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], 1561 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1562 | RowBox[{ 1563 | RowBox[{ 1564 | RowBox[{ 1565 | RowBox[{"TestRRipple", "[", 1566 | RowBox[{"A_", ",", "B_"}], "]"}], ":=", 1567 | RowBox[{"Module", "[", 1568 | RowBox[{ 1569 | RowBox[{"{", 1570 | RowBox[{ 1571 | "encA", ",", "encB", ",", "res", ",", "a", ",", "b", ",", "x"}], "}"}], 1572 | ",", "\[IndentingNewLine]", 1573 | RowBox[{ 1574 | RowBox[{ 1575 | RowBox[{"{", 1576 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1577 | "\[IndentingNewLine]", 1578 | RowBox[{ 1579 | RowBox[{"{", 1580 | RowBox[{"a", ",", "x"}], "}"}], "=", 1581 | RowBox[{"RealDigits", "[", 1582 | RowBox[{"A", ",", "2"}], "]"}]}], ";", "\[IndentingNewLine]", 1583 | RowBox[{ 1584 | RowBox[{"{", 1585 | RowBox[{"b", ",", "x"}], "}"}], "=", 1586 | RowBox[{"RealDigits", "[", 1587 | RowBox[{"B", ",", "2"}], "]"}]}], ";", "\[IndentingNewLine]", 1588 | RowBox[{"encA", "=", 1589 | RowBox[{ 1590 | RowBox[{ 1591 | RowBox[{"(", 1592 | RowBox[{"Encrypt", "[", 1593 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "a"}]}], ";", 1594 | "\[IndentingNewLine]", 1595 | RowBox[{"encB", "=", 1596 | RowBox[{ 1597 | RowBox[{ 1598 | RowBox[{"(", 1599 | RowBox[{"Encrypt", "[", 1600 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "b"}]}], ";", 1601 | "\[IndentingNewLine]", 1602 | RowBox[{"res", "=", 1603 | RowBox[{ 1604 | RowBox[{ 1605 | RowBox[{"(", 1606 | RowBox[{"Decrypt", "[", 1607 | RowBox[{"#", ",", "sk"}], "]"}], ")"}], "&"}], "/@", 1608 | RowBox[{"RRippleCarryAdder", "[", 1609 | RowBox[{"encA", ",", "encB", ",", "pk"}], "]"}]}]}], ";", 1610 | "\[IndentingNewLine]", 1611 | RowBox[{"FromDigits", "[", 1612 | RowBox[{"res", ",", "2"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], 1613 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1614 | RowBox[{ 1615 | RowBox[{ 1616 | RowBox[{ 1617 | RowBox[{"TestHamming", "[", 1618 | RowBox[{"A_", ",", "length_"}], "]"}], ":=", 1619 | RowBox[{"Module", "[", 1620 | RowBox[{ 1621 | RowBox[{"{", 1622 | RowBox[{"encA", ",", "res", ",", "pk", ",", "sk"}], "}"}], ",", 1623 | "\[IndentingNewLine]", 1624 | RowBox[{ 1625 | RowBox[{ 1626 | RowBox[{"{", 1627 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1628 | "\[IndentingNewLine]", 1629 | RowBox[{"encA", "=", 1630 | RowBox[{ 1631 | RowBox[{ 1632 | RowBox[{"Encrypt", "[", 1633 | RowBox[{"#", ",", "pk"}], "]"}], "&"}], "/@", "A"}]}], ";", 1634 | "\[IndentingNewLine]", 1635 | RowBox[{"res", "=", 1636 | RowBox[{ 1637 | RowBox[{ 1638 | RowBox[{"Decrypt", "[", 1639 | RowBox[{"#", ",", "sk"}], "]"}], "&"}], "/@", 1640 | RowBox[{"Hamming", "[", 1641 | RowBox[{"encA", ",", "length", ",", "pk"}], "]"}]}]}], ";", 1642 | "\[IndentingNewLine]", "res"}]}], "\[IndentingNewLine]", "]"}]}], 1643 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1644 | RowBox[{ 1645 | RowBox[{ 1646 | RowBox[{ 1647 | RowBox[{"TestTotal", "[", "A_", "]"}], ":=", 1648 | RowBox[{"Module", "[", 1649 | RowBox[{ 1650 | RowBox[{"{", 1651 | RowBox[{"encA", ",", "res"}], "}"}], ",", "\[IndentingNewLine]", 1652 | RowBox[{ 1653 | RowBox[{ 1654 | RowBox[{"{", 1655 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1656 | "\[IndentingNewLine]", 1657 | RowBox[{"encA", "=", 1658 | RowBox[{ 1659 | RowBox[{ 1660 | RowBox[{"(", 1661 | RowBox[{"Encrypt", "[", 1662 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "A"}]}], ";", 1663 | "\[IndentingNewLine]", 1664 | RowBox[{"res", "=", 1665 | RowBox[{ 1666 | RowBox[{ 1667 | RowBox[{"(", 1668 | RowBox[{"Decrypt", "[", 1669 | RowBox[{"#", ",", "sk"}], "]"}], ")"}], "&"}], "/@", 1670 | RowBox[{"CryptTotal", "[", 1671 | RowBox[{"encA", ",", "pk"}], "]"}]}]}], ";", "\[IndentingNewLine]", 1672 | "res"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 1673 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1674 | RowBox[{ 1675 | RowBox[{ 1676 | RowBox[{ 1677 | RowBox[{"TestTreeMult", "[", "A_", "]"}], ":=", 1678 | RowBox[{"Module", "[", 1679 | RowBox[{ 1680 | RowBox[{"{", 1681 | RowBox[{"encA", ",", "res"}], "}"}], ",", "\[IndentingNewLine]", 1682 | RowBox[{ 1683 | RowBox[{ 1684 | RowBox[{"{", 1685 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1686 | "\[IndentingNewLine]", 1687 | RowBox[{"encA", "=", 1688 | RowBox[{ 1689 | RowBox[{ 1690 | RowBox[{"(", 1691 | RowBox[{"Encrypt", "[", 1692 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "A"}]}], ";", 1693 | "\[IndentingNewLine]", 1694 | RowBox[{"res", "=", 1695 | RowBox[{"Decrypt", "[", 1696 | RowBox[{ 1697 | RowBox[{"TreeMult", "[", 1698 | RowBox[{"A", ",", "pk"}], "]"}], ",", "sk"}], "]"}]}], ";", 1699 | "\[IndentingNewLine]", "res"}]}], "\[IndentingNewLine]", "]"}]}], 1700 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1701 | RowBox[{ 1702 | RowBox[{ 1703 | RowBox[{ 1704 | RowBox[{"TestTreeAdd", "[", "A_", "]"}], ":=", 1705 | RowBox[{"Module", "[", 1706 | RowBox[{ 1707 | RowBox[{"{", 1708 | RowBox[{"encA", ",", "res"}], "}"}], ",", "\[IndentingNewLine]", 1709 | RowBox[{ 1710 | RowBox[{ 1711 | RowBox[{"{", 1712 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1713 | "\[IndentingNewLine]", 1714 | RowBox[{"encA", "=", 1715 | RowBox[{ 1716 | RowBox[{ 1717 | RowBox[{"(", 1718 | RowBox[{"Encrypt", "[", 1719 | RowBox[{"#", ",", "pk"}], "]"}], ")"}], "&"}], "/@", "A"}]}], ";", 1720 | "\[IndentingNewLine]", 1721 | RowBox[{"res", "=", 1722 | RowBox[{"Decrypt", "[", 1723 | RowBox[{ 1724 | RowBox[{"TreeAdd", "[", 1725 | RowBox[{"A", ",", "pk"}], "]"}], ",", "sk"}], "]"}]}], ";", 1726 | "\[IndentingNewLine]", "res"}]}], "\[IndentingNewLine]", "]"}]}], 1727 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1728 | RowBox[{ 1729 | RowBox[{ 1730 | RowBox[{ 1731 | RowBox[{"TestWithKey", "[", 1732 | RowBox[{"pk_", ",", "sk_", ",", "x_"}], "]"}], ":=", 1733 | RowBox[{"(", "\[IndentingNewLine]", 1734 | RowBox[{"Decrypt", "[", 1735 | RowBox[{ 1736 | RowBox[{"Encrypt", "[", 1737 | RowBox[{"x", ",", "pk"}], "]"}], ",", "sk"}], "]"}], 1738 | "\[IndentingNewLine]", ")"}]}], ";"}], 1739 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1740 | RowBox[{ 1741 | RowBox[{ 1742 | RowBox[{ 1743 | RowBox[{"TestMultiRecrypt", "[", "count_", "]"}], ":=", 1744 | RowBox[{"Module", "[", 1745 | RowBox[{ 1746 | RowBox[{"{", 1747 | RowBox[{"pk", ",", "sk", ",", "c0", ",", "c1", ",", "i"}], "}"}], ",", 1748 | "\[IndentingNewLine]", 1749 | RowBox[{ 1750 | RowBox[{ 1751 | RowBox[{"{", 1752 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1753 | "\[IndentingNewLine]", 1754 | RowBox[{"c0", "=", 1755 | RowBox[{"Encrypt", "[", 1756 | RowBox[{"0", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 1757 | RowBox[{"c1", "=", 1758 | RowBox[{"Encrypt", "[", 1759 | RowBox[{"1", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 1760 | RowBox[{"Monitor", "[", "\[IndentingNewLine]", 1761 | RowBox[{ 1762 | RowBox[{"For", "[", 1763 | RowBox[{ 1764 | RowBox[{"i", "=", "1"}], ",", 1765 | RowBox[{"i", "\[LessEqual]", "count"}], ",", 1766 | RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 1767 | RowBox[{ 1768 | RowBox[{"c0", "=", 1769 | RowBox[{"Recrypt", "[", 1770 | RowBox[{"c0", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 1771 | 1772 | RowBox[{"c1", "=", 1773 | RowBox[{"Recrypt", "[", 1774 | RowBox[{"c1", ",", "pk"}], "]"}]}], ";"}]}], 1775 | "\[IndentingNewLine]", "]"}], ",", 1776 | RowBox[{"ProgressIndicator", "[", 1777 | RowBox[{"i", ",", 1778 | RowBox[{"{", 1779 | RowBox[{"0", ",", "count"}], "}"}]}], "]"}]}], "]"}], ";", 1780 | "\[IndentingNewLine]", 1781 | RowBox[{"{", 1782 | RowBox[{ 1783 | RowBox[{"Decrypt", "[", 1784 | RowBox[{"c0", ",", "sk"}], "]"}], ",", 1785 | RowBox[{"Decrypt", "[", 1786 | RowBox[{"c1", ",", "sk"}], "]"}]}], "}"}]}]}], 1787 | "\[IndentingNewLine]", "]"}]}], ";"}], 1788 | "\[IndentingNewLine]"}], "\[IndentingNewLine]", 1789 | RowBox[{ 1790 | RowBox[{ 1791 | RowBox[{"TestHomomorph", "[", "count_", "]"}], ":=", 1792 | RowBox[{"Module", "[", 1793 | RowBox[{ 1794 | RowBox[{"{", 1795 | RowBox[{"pk", ",", "sk", ",", "c", ",", "i"}], "}"}], ",", 1796 | "\[IndentingNewLine]", 1797 | RowBox[{ 1798 | RowBox[{ 1799 | RowBox[{"{", 1800 | RowBox[{"pk", ",", "sk"}], "}"}], "=", "KeyGen"}], ";", 1801 | "\[IndentingNewLine]", 1802 | RowBox[{"c", "=", 1803 | RowBox[{"Encrypt", "[", 1804 | RowBox[{"1", ",", "pk"}], "]"}]}], ";", "\[IndentingNewLine]", 1805 | RowBox[{"For", "[", 1806 | RowBox[{ 1807 | RowBox[{"i", "=", "0"}], ",", 1808 | RowBox[{"i", "<", "count"}], ",", 1809 | RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 1810 | RowBox[{ 1811 | RowBox[{"c", "=", 1812 | RowBox[{"RMult", "[", 1813 | RowBox[{"c", ",", "c", ",", "pk"}], "]"}]}], ";", 1814 | "\[IndentingNewLine]", 1815 | RowBox[{"Print", "[", 1816 | RowBox[{"i", ",", "\"\<: \>\"", ",", 1817 | RowBox[{"Decrypt", "[", 1818 | RowBox[{"c", ",", "sk"}], "]"}]}], "]"}], ";"}]}], 1819 | "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], 1820 | ";"}]}], "Input", 1821 | CellChangeTimes->{{3.477736880882291*^9, 3.4777372242957573`*^9}, { 1822 | 3.477737550636429*^9, 3.477737555752627*^9}, {3.477737618009103*^9, 1823 | 3.47773762514986*^9}, {3.477738141717492*^9, 3.4777381956553926`*^9}, { 1824 | 3.477738332702284*^9, 3.477738407599428*^9}, {3.477738641121756*^9, 1825 | 3.477738641958028*^9}, {3.4777387421082783`*^9, 3.47773874732323*^9}, { 1826 | 3.47773886453446*^9, 3.477738901821496*^9}, {3.4777389429212513`*^9, 1827 | 3.477738959955579*^9}, {3.4777391132642317`*^9, 3.477739290623144*^9}, { 1828 | 3.477739396516608*^9, 3.477739470838254*^9}, {3.47773952536689*^9, 1829 | 3.47773957269005*^9}, {3.477739627122409*^9, 3.477739644015315*^9}, { 1830 | 3.477739674018564*^9, 3.477739674264288*^9}, {3.4777403970409403`*^9, 1831 | 3.477740432210644*^9}, {3.477740609558*^9, 3.477740618129189*^9}, { 1832 | 3.4777407797059917`*^9, 3.477740819405505*^9}, {3.477740857157709*^9, 1833 | 3.4777408572430573`*^9}, {3.477740898765153*^9, 3.477740926121706*^9}, 1834 | 3.477741005527701*^9, 3.477741082970883*^9, {3.4777411390338593`*^9, 1835 | 3.47774115958355*^9}, {3.4777413532758007`*^9, 3.477741401855802*^9}, { 1836 | 3.4777414408518133`*^9, 3.477741533570998*^9}, {3.477741572919346*^9, 1837 | 3.477741586296837*^9}, {3.4777418594277*^9, 3.477741874093858*^9}, { 1838 | 3.47774192953325*^9, 3.477741944367091*^9}, {3.477742019757028*^9, 1839 | 3.4777421200857*^9}, {3.477742201939052*^9, 3.477742288032065*^9}, { 1840 | 3.477742343430893*^9, 3.477742414731903*^9}, {3.477742462009001*^9, 1841 | 3.477742524869349*^9}, {3.477742571723248*^9, 3.477742675391062*^9}, { 1842 | 3.477742939601541*^9, 3.477742958065662*^9}, 3.477743050499736*^9, { 1843 | 3.4797956523234*^9, 3.4797956531432962`*^9}, {3.479795788191101*^9, 1844 | 3.479795793117963*^9}, {3.479795908809752*^9, 3.4797959499557467`*^9}, { 1845 | 3.479796017323489*^9, 3.479796050409513*^9}, {3.479796110818969*^9, 1846 | 3.4797961339784527`*^9}, {3.4797961749397097`*^9, 3.47979620132092*^9}, { 1847 | 3.479796255696931*^9, 3.479796284061849*^9}, {3.479796506694315*^9, 1848 | 3.4797965805692883`*^9}, {3.4797990738096647`*^9, 3.479799095782729*^9}, { 1849 | 3.479799208654388*^9, 3.4797992267959223`*^9}, {3.4798029926274023`*^9, 1850 | 3.4798030812457952`*^9}, {3.4798032683776627`*^9, 3.479803317493698*^9}, { 1851 | 3.479803419100567*^9, 3.479803543283144*^9}, {3.479803587333312*^9, 1852 | 3.479803608660549*^9}, {3.479803640189529*^9, 3.479803791296207*^9}, { 1853 | 3.479803829936884*^9, 3.479803930467433*^9}, {3.4798040277427998`*^9, 1854 | 3.479804185906106*^9}, {3.479804294804702*^9, 3.479804381673089*^9}, { 1855 | 3.479804436213488*^9, 3.4798044465990953`*^9}, {3.4798046222886543`*^9, 1856 | 3.479804794026181*^9}, {3.479804830092051*^9, 3.479804843197945*^9}, { 1857 | 3.479805043954707*^9, 3.479805188452496*^9}, {3.479805231187237*^9, 1858 | 3.479805285681404*^9}, {3.479805451486887*^9, 3.4798056328474283`*^9}, { 1859 | 3.479805670039237*^9, 3.479805702889805*^9}, {3.479805980090757*^9, 1860 | 3.4798061402081127`*^9}, {3.4798061878128567`*^9, 1861 | 3.4798061918293333`*^9}, {3.4798062350121307`*^9, 3.479806238332489*^9}, { 1862 | 3.4800584458499117`*^9, 3.480058478144003*^9}, {3.480058523177679*^9, 1863 | 3.480058717620088*^9}, {3.480058792053784*^9, 3.480058845495874*^9}, { 1864 | 3.480059014180812*^9, 3.480059044288835*^9}, {3.480059074720264*^9, 1865 | 3.480059453497829*^9}, {3.480059684037698*^9, 3.480059916279582*^9}, { 1866 | 3.480059967922476*^9, 3.4800599701045103`*^9}, {3.480060001957752*^9, 1867 | 3.480060006538887*^9}, {3.4800601342340937`*^9, 3.480060186166456*^9}, { 1868 | 3.480060247718009*^9, 3.480060283713806*^9}, {3.4800603502604094`*^9, 1869 | 3.480060362401361*^9}, {3.480060419535617*^9, 3.4800604385492983`*^9}, { 1870 | 3.480060560145133*^9, 3.480060648304553*^9}, {3.48006067841853*^9, 1871 | 3.480060934809649*^9}, {3.48006097343294*^9, 3.480060989502757*^9}, { 1872 | 3.4800610763891907`*^9, 3.480061107618125*^9}, {3.480061141820208*^9, 1873 | 3.48006118362324*^9}, {3.480061224942272*^9, 3.480061256524857*^9}, { 1874 | 3.480061340664769*^9, 3.480061357496851*^9}, {3.480061518028799*^9, 1875 | 3.480061621360052*^9}, {3.4800617077017937`*^9, 3.48006170823606*^9}, { 1876 | 3.4800617382537317`*^9, 3.4800617958637877`*^9}, {3.480062050066544*^9, 1877 | 3.48006226616013*^9}, {3.480062337288143*^9, 3.480062356323016*^9}, { 1878 | 3.4800623895703583`*^9, 3.4800623958610373`*^9}, {3.480062438777054*^9, 1879 | 3.4800625636074123`*^9}, {3.4800638939195347`*^9, 1880 | 3.4800639477123623`*^9}, {3.48006400795918*^9, 3.480064012197587*^9}, { 1881 | 3.480064070669849*^9, 3.4800640708056097`*^9}, {3.4800641103347692`*^9, 1882 | 3.480064244082621*^9}, {3.480064309702963*^9, 3.4800643589246883`*^9}, { 1883 | 3.480064468946575*^9, 3.480064502589489*^9}, {3.4800646243591347`*^9, 1884 | 3.480064630740962*^9}, 3.480064941330367*^9, {3.480064982565353*^9, 1885 | 3.480065007904571*^9}, 3.480065256291676*^9, {3.4800652911220818`*^9, 1886 | 3.480065327496887*^9}, {3.480065425100217*^9, 3.480065613070698*^9}, { 1887 | 3.4800656960267887`*^9, 3.4800656974401903`*^9}, {3.480065750292704*^9, 1888 | 3.480065850291257*^9}, {3.480066109613789*^9, 3.4800661103250504`*^9}, { 1889 | 3.480066293169929*^9, 3.4800663519382143`*^9}, 3.4806621923866377`*^9, { 1890 | 3.480662783836175*^9, 3.480662809632535*^9}, {3.480662839670826*^9, 1891 | 3.480662839862814*^9}, {3.480663044481732*^9, 3.480663149499511*^9}, 1892 | 3.4806639137318773`*^9, {3.4806639464175177`*^9, 3.480664023665802*^9}, { 1893 | 3.48066407497997*^9, 3.480664083833913*^9}, {3.480664187474682*^9, 1894 | 3.480664213345009*^9}, {3.480664259081472*^9, 3.480664260453072*^9}, { 1895 | 3.480664309190035*^9, 3.4806643522925377`*^9}, {3.480666478776724*^9, 1896 | 3.480666540700614*^9}, {3.480666579277355*^9, 3.480666598036203*^9}, { 1897 | 3.480667517549069*^9, 3.480667526675413*^9}, 3.48066758883293*^9, 1898 | 3.480667689653639*^9, {3.4806677589060287`*^9, 3.480667759291565*^9}, { 1899 | 3.480667873342555*^9, 3.480667927587887*^9}, 3.480667970791793*^9, { 1900 | 3.4806690157587357`*^9, 3.48066901585325*^9}, 3.480669109723928*^9, { 1901 | 3.480669163520781*^9, 3.480669174670849*^9}, {3.480669326185753*^9, 1902 | 3.480669351930047*^9}, {3.480669394534809*^9, 3.480669463809623*^9}, { 1903 | 3.4806697486616383`*^9, 3.480669748931686*^9}, {3.480669784266374*^9, 1904 | 3.4806697851656723`*^9}, {3.480669873295608*^9, 3.480669900846661*^9}, { 1905 | 3.480670167886105*^9, 3.4806701979762287`*^9}, {3.4806705495684423`*^9, 1906 | 3.480670549665732*^9}, {3.4806707044665127`*^9, 3.4806707132829514`*^9}, { 1907 | 3.480670753552403*^9, 3.480670754288679*^9}, {3.480670939742145*^9, 1908 | 3.4806709431181793`*^9}, {3.4822138693781033`*^9, 3.482213933711288*^9}, { 1909 | 3.482214126194118*^9, 3.48221417738472*^9}, {3.482221176377391*^9, 1910 | 3.482221263290208*^9}, {3.4822213070008307`*^9, 3.4822213229237423`*^9}, { 1911 | 3.4822213559174833`*^9, 3.482221357962455*^9}, 3.482221390829681*^9, { 1912 | 3.482221816226416*^9, 3.482222037714171*^9}, {3.482222225673769*^9, 1913 | 3.482222257129039*^9}, {3.482222306140332*^9, 3.482222322299168*^9}, { 1914 | 3.4822224067333183`*^9, 3.4822224148938637`*^9}, {3.482222476143873*^9, 1915 | 3.48222260315676*^9}, {3.4822226449052753`*^9, 3.482222665701769*^9}, { 1916 | 3.482223617832068*^9, 3.482223664202035*^9}, {3.482223729471917*^9, 1917 | 3.482223843716297*^9}, {3.482223879782547*^9, 3.4822239615938787`*^9}, { 1918 | 3.4822241898916597`*^9, 3.482224611412986*^9}, {3.4822246494459753`*^9, 1919 | 3.482224681783349*^9}, {3.482224721725062*^9, 3.482224750730239*^9}, { 1920 | 3.482225029992741*^9, 3.48222509200394*^9}, 3.482226464034006*^9, { 1921 | 3.4822269161428328`*^9, 3.4822269793071327`*^9}, {3.482227026386902*^9, 1922 | 3.48222706741064*^9}, {3.482227187594982*^9, 3.48222740811204*^9}, { 1923 | 3.4822274421283617`*^9, 3.4822275036492767`*^9}, {3.482227585030354*^9, 1924 | 3.482227598427424*^9}, {3.482227645398653*^9, 3.482227685960944*^9}, { 1925 | 3.482228069913764*^9, 3.48222810583525*^9}, {3.482228151349572*^9, 1926 | 3.482228229204473*^9}, {3.482228325815549*^9, 3.4822283614773827`*^9}, { 1927 | 3.482230146698284*^9, 3.482230196930986*^9}, 3.482230415732771*^9, { 1928 | 3.482230759202695*^9, 3.482230783756662*^9}, {3.482230843500293*^9, 1929 | 3.482230875196308*^9}, {3.482230908227697*^9, 3.482230970802821*^9}, { 1930 | 3.482231018700259*^9, 3.4822310761075983`*^9}, {3.4824715080212193`*^9, 1931 | 3.482471571493703*^9}, 3.482471688162674*^9, {3.48247397827958*^9, 1932 | 3.4824740715110273`*^9}, {3.482474106757181*^9, 3.482474134711948*^9}, { 1933 | 3.482474267012559*^9, 3.482474287026205*^9}, {3.482474326143034*^9, 1934 | 3.4824743360455513`*^9}, {3.482474395996683*^9, 3.482474440539366*^9}, 1935 | 3.482474575880755*^9, {3.482474908869236*^9, 3.482474947122615*^9}, { 1936 | 3.4824750072208*^9, 3.482475036219472*^9}, {3.4824750709000053`*^9, 1937 | 3.4824750752960243`*^9}, {3.482475108469673*^9, 3.482475151021841*^9}, { 1938 | 3.482475267439801*^9, 3.4824753516928463`*^9}, {3.4824754146064787`*^9, 1939 | 3.482475476549576*^9}, {3.482475553192576*^9, 3.482475575464611*^9}, { 1940 | 3.482475706752763*^9, 3.482475868386364*^9}, {3.482475993057848*^9, 1941 | 3.4824760476979713`*^9}, {3.482476106517982*^9, 3.4824762115018597`*^9}, { 1942 | 3.482476304813219*^9, 3.482476310017496*^9}, {3.482476486340377*^9, 1943 | 3.4824764917167873`*^9}, {3.4824765299720097`*^9, 3.48247661974137*^9}, { 1944 | 3.482476923638288*^9, 3.4824769431911287`*^9}, {3.482477111265915*^9, 1945 | 3.4824771113882093`*^9}, {3.4824772287634277`*^9, 1946 | 3.4824772339942493`*^9}, {3.48247732034632*^9, 3.482477326932448*^9}, { 1947 | 3.4824773822409143`*^9, 3.4824774398426456`*^9}, {3.482477764558663*^9, 1948 | 3.4824778536259747`*^9}, {3.482477905212051*^9, 3.482478000170459*^9}, { 1949 | 3.482478132625808*^9, 3.482478333190688*^9}, {3.482478442692279*^9, 1950 | 3.48247845475391*^9}, {3.482480420827115*^9, 3.482480468630419*^9}, { 1951 | 3.482480529235936*^9, 3.48248054017927*^9}, {3.482480575985992*^9, 1952 | 3.4824806069129972`*^9}, {3.4824806718386374`*^9, 1953 | 3.4824806727815104`*^9}, {3.4824808551914454`*^9, 3.482480855813821*^9}, { 1954 | 3.482480895447263*^9, 3.4824809021210318`*^9}, {3.48248095974977*^9, 1955 | 3.482481102512144*^9}, {3.4824811354369383`*^9, 3.482481150330847*^9}, { 1956 | 3.482487529607684*^9, 3.482487535281702*^9}, {3.4824875910601273`*^9, 1957 | 3.4824876102079887`*^9}, {3.482487642834318*^9, 3.4824877489101143`*^9}, { 1958 | 3.4824878686685133`*^9, 3.482487893448*^9}, {3.482487925447104*^9, 1959 | 3.4824879440391827`*^9}, {3.482488041987732*^9, 3.4824880718432198`*^9}, { 1960 | 3.48248812986911*^9, 3.482488155783524*^9}, {3.4824881878061028`*^9, 1961 | 3.48248821247412*^9}, {3.4824882933062983`*^9, 3.482488306394219*^9}, { 1962 | 3.4824883607138844`*^9, 3.482488366023178*^9}, {3.482488406199739*^9, 1963 | 3.482488411237299*^9}, {3.482488441334173*^9, 3.4824884418263817`*^9}, { 1964 | 3.482488595857383*^9, 3.482488596476152*^9}, {3.482488722482086*^9, 1965 | 3.482488751924904*^9}, {3.4824888073130083`*^9, 3.482488833707829*^9}, { 1966 | 3.482488910444812*^9, 3.4824889264346933`*^9}, {3.482488974619111*^9, 1967 | 3.482489022166369*^9}, {3.482491002050419*^9, 3.482491008174858*^9}, { 1968 | 3.483852101525511*^9, 3.483852203104084*^9}, {3.4838522635974903`*^9, 1969 | 3.4838522691178493`*^9}, {3.483852621321444*^9, 3.483852691821794*^9}, { 1970 | 3.483852801926076*^9, 3.4838528812995234`*^9}, {3.483852911650758*^9, 1971 | 3.483852929203835*^9}, {3.483853048850555*^9, 3.483853058635579*^9}, { 1972 | 3.483853399500031*^9, 3.4838534352075987`*^9}, {3.483853727906249*^9, 1973 | 3.483853732910606*^9}, {3.483854112751371*^9, 3.483854197790567*^9}, 1974 | 3.483854257070736*^9, {3.48385434886014*^9, 3.48385435240984*^9}, { 1975 | 3.483854438933332*^9, 3.483854458836631*^9}, {3.483854588914703*^9, 1976 | 3.483854758811905*^9}, {3.483855442674899*^9, 3.483855462903922*^9}, { 1977 | 3.483855633107745*^9, 3.483855653002973*^9}, {3.483855704677549*^9, 1978 | 3.483855721128304*^9}, {3.483855761927891*^9, 3.483855769237301*^9}, { 1979 | 3.483856805185815*^9, 3.48385685158619*^9}, {3.483858861675013*^9, 1980 | 3.483858864067258*^9}, {3.483861412895944*^9, 3.483861430654211*^9}, { 1981 | 3.4838614606714*^9, 3.483861513452548*^9}, {3.483861622887879*^9, 1982 | 3.4838616664542093`*^9}, {3.483861708968495*^9, 3.48386178798816*^9}, { 1983 | 3.483862100842689*^9, 3.4838622295090303`*^9}, {3.483862313938695*^9, 1984 | 3.483862381039969*^9}, {3.483863912975163*^9, 3.483863914620476*^9}, { 1985 | 3.483864546618545*^9, 3.483864587101677*^9}, {3.4838662818701677`*^9, 1986 | 3.483866286251301*^9}, {3.484292576878832*^9, 3.484292742174691*^9}, { 1987 | 3.484292863238448*^9, 3.484293033489949*^9}, {3.484293074361891*^9, 1988 | 3.4842932089437437`*^9}, {3.484293252034647*^9, 3.484293315405219*^9}, { 1989 | 3.4842939790144243`*^9, 3.484293991134444*^9}, {3.484297594118845*^9, 1990 | 3.484297594273004*^9}, {3.4843004763404512`*^9, 3.484300520884828*^9}, { 1991 | 3.484300629136545*^9, 3.484300690590726*^9}, {3.48430080136967*^9, 1992 | 3.484300826163376*^9}, {3.4843008633034077`*^9, 3.4843008653494673`*^9}, { 1993 | 3.484304992393331*^9, 3.484305042692066*^9}, {3.4850730304071503`*^9, 1994 | 3.485073030548341*^9}, {3.48507308699338*^9, 3.4850731607473392`*^9}, { 1995 | 3.4850732000631523`*^9, 3.485073311954718*^9}, {3.4850733737364817`*^9, 1996 | 3.485073402247707*^9}, {3.485073904545974*^9, 3.4850740330044518`*^9}, { 1997 | 3.4850741303257093`*^9, 3.485074148154785*^9}, {3.4850741858288393`*^9, 1998 | 3.485074266408331*^9}, {3.485074341447317*^9, 3.485074424037278*^9}, { 1999 | 3.4850744910185003`*^9, 3.485074634702388*^9}, {3.4854920752194643`*^9, 2000 | 3.485492312503579*^9}, 3.485492471562502*^9, {3.485492591004572*^9, 2001 | 3.485492596728671*^9}, {3.4854927442230988`*^9, 3.4854927967071133`*^9}, { 2002 | 3.48549284947447*^9, 3.485492892824164*^9}, 3.4855144204606743`*^9, { 2003 | 3.485514474944219*^9, 3.4855145301295*^9}, {3.485514593295597*^9, 2004 | 3.4855146535063457`*^9}, {3.4855147661045837`*^9, 3.485514802111693*^9}, { 2005 | 3.485514933601468*^9, 3.485514957519072*^9}, {3.485515199386095*^9, 2006 | 3.485515273420369*^9}, {3.485515333337764*^9, 3.485515443275576*^9}, { 2007 | 3.485515512007992*^9, 3.4855155852688513`*^9}, {3.485515617406082*^9, 2008 | 3.485515741889249*^9}, {3.485515785380246*^9, 3.4855158412948093`*^9}, { 2009 | 3.485515889439372*^9, 3.4855159218325787`*^9}, {3.485515968572369*^9, 2010 | 3.485515974528408*^9}, {3.4855160130085917`*^9, 3.485516230641528*^9}, { 2011 | 3.485516267816886*^9, 3.4855162679656677`*^9}, {3.485516841591289*^9, 2012 | 3.485516955660379*^9}, {3.485516989308075*^9, 3.485516999295652*^9}, { 2013 | 3.485517099599866*^9, 3.485517111551137*^9}, {3.485517243508964*^9, 2014 | 3.485517278978651*^9}, 3.485517330500311*^9, {3.485518386849327*^9, 2015 | 3.485518391789495*^9}, {3.485518435427204*^9, 3.4855184452648773`*^9}, { 2016 | 3.4856010652939157`*^9, 3.485601071729521*^9}, {3.4856011692168703`*^9, 2017 | 3.485601209133171*^9}, {3.4856012493234177`*^9, 3.485601283218007*^9}, 2018 | 3.485601372928759*^9, {3.485601746799488*^9, 3.4856020172631283`*^9}, { 2019 | 3.485602147082024*^9, 3.485602168003577*^9}, {3.485602420762167*^9, 2020 | 3.485602481823341*^9}, {3.4856026183280993`*^9, 3.4856026378179092`*^9}, { 2021 | 3.485602671411134*^9, 3.4856026944237833`*^9}, {3.485602737579976*^9, 2022 | 3.485602863092317*^9}, {3.4856029147821827`*^9, 3.485602922315783*^9}, { 2023 | 3.48560300705618*^9, 3.4856030863527603`*^9}, {3.485603184367518*^9, 2024 | 3.485603248287031*^9}, {3.485603280572349*^9, 3.485603320248199*^9}, { 2025 | 3.485603351801571*^9, 3.485603353398282*^9}, {3.485603419968747*^9, 2026 | 3.485603445438073*^9}, {3.485603565457563*^9, 3.485603653719208*^9}, { 2027 | 3.485603787971053*^9, 3.4856038506074257`*^9}, {3.4856042439846983`*^9, 2028 | 3.4856042880256042`*^9}, {3.48560435436535*^9, 3.485604398020824*^9}, { 2029 | 3.48560481925874*^9, 3.4856048251358128`*^9}, {3.485604958139393*^9, 2030 | 3.485604967105338*^9}, {3.4856050931661777`*^9, 3.485605133271552*^9}, { 2031 | 3.485605189892715*^9, 3.4856052035216103`*^9}, {3.485605357102729*^9, 2032 | 3.4856053839893837`*^9}, {3.4856054264595213`*^9, 3.485605429392737*^9}, { 2033 | 3.485605462186253*^9, 3.485605500116331*^9}, {3.485605574620611*^9, 2034 | 3.485605611997542*^9}, {3.485605661828375*^9, 3.4856056746972723`*^9}, { 2035 | 3.48560653368285*^9, 3.485606552093584*^9}, {3.4856066797092533`*^9, 2036 | 3.4856067248596153`*^9}, {3.4856072107403917`*^9, 3.485607254924506*^9}, { 2037 | 3.485608366461494*^9, 3.485608499863954*^9}, {3.485608544473462*^9, 2038 | 3.4856085467539053`*^9}, {3.485608590087071*^9, 3.4856086274490147`*^9}, { 2039 | 3.485608732952404*^9, 3.4856088246201057`*^9}, {3.485608945360964*^9, 2040 | 3.485608967512753*^9}, {3.48560908834904*^9, 3.485609108210348*^9}, { 2041 | 3.485609423014166*^9, 3.485609431007154*^9}, {3.485609528946471*^9, 2042 | 3.485609551009688*^9}, {3.485609659876926*^9, 3.48560974582799*^9}, { 2043 | 3.485609780348172*^9, 3.485609800778256*^9}, {3.485609852260194*^9, 2044 | 3.485609864016078*^9}, {3.485610006574086*^9, 3.485610012205871*^9}, { 2045 | 3.4856101268444223`*^9, 3.4856102092105837`*^9}, {3.485610248169999*^9, 2046 | 3.4856102486873627`*^9}, {3.4856110531919527`*^9, 3.485611092315843*^9}, 2047 | 3.485669717174489*^9, {3.485669857395302*^9, 3.4856698701228647`*^9}, { 2048 | 3.485669939766509*^9, 3.485670030232285*^9}, {3.4856701438023157`*^9, 2049 | 3.485670156981523*^9}, {3.4856702949615498`*^9, 3.485670297249803*^9}, { 2050 | 3.485670373310021*^9, 3.485670379365691*^9}, {3.485670417162651*^9, 2051 | 3.4856704207171097`*^9}, {3.485670462485281*^9, 3.4856704628426743`*^9}, { 2052 | 3.48567051161587*^9, 3.485670517898822*^9}, {3.4856772481333647`*^9, 2053 | 3.485677257710907*^9}, 3.485677299228032*^9, {3.485677620569518*^9, 2054 | 3.485677740409059*^9}, {3.485677785951626*^9, 3.4856779306909103`*^9}, { 2055 | 3.485677969137985*^9, 3.485677984411718*^9}, {3.485678226518236*^9, 2056 | 3.485678281323967*^9}, 3.4856783838976192`*^9, {3.485678476686112*^9, 2057 | 3.4856784846515627`*^9}, {3.4856788293369837`*^9, 2058 | 3.4856788325282173`*^9}, {3.485679015972011*^9, 3.485679033163015*^9}, { 2059 | 3.485679064611178*^9, 3.485679067396842*^9}, {3.485679694115171*^9, 2060 | 3.4856798228421097`*^9}, {3.485680917963743*^9, 3.485681000724498*^9}, { 2061 | 3.485681549350759*^9, 3.485681611483012*^9}, {3.485681667033761*^9, 2062 | 3.485681796254265*^9}, {3.4856818505137587`*^9, 3.485681942134652*^9}, { 2063 | 3.4856819955099697`*^9, 3.485682016578318*^9}, {3.485682134172694*^9, 2064 | 3.485682136300157*^9}, {3.485682166602832*^9, 3.485682307832869*^9}, { 2065 | 3.485683315153501*^9, 3.485683315266354*^9}, {3.4856839302861223`*^9, 2066 | 3.485684165910162*^9}, {3.4856842380961733`*^9, 3.4856843511847687`*^9}, { 2067 | 3.485684386292334*^9, 3.485684459859404*^9}, {3.4856844904712563`*^9, 2068 | 3.485684523774424*^9}, {3.48568458476483*^9, 3.485684605975256*^9}, { 2069 | 3.4856994443324757`*^9, 3.485699470296853*^9}, {3.485699578459963*^9, 2070 | 3.485699630772729*^9}, {3.485699707955092*^9, 3.485699708090296*^9}, { 2071 | 3.485699770651366*^9, 3.4856997786648207`*^9}, {3.485699817034149*^9, 2072 | 3.485699889825642*^9}, {3.4857000179780407`*^9, 3.485700019823332*^9}, { 2073 | 3.485700235009571*^9, 3.4857003744925203`*^9}, {3.485700470850333*^9, 2074 | 3.485700495581477*^9}, {3.4857005270796843`*^9, 3.485700843861329*^9}, { 2075 | 3.4857009295103617`*^9, 3.485701158029045*^9}, {3.4857012431218977`*^9, 2076 | 3.485701245656884*^9}, {3.4861038766598597`*^9, 3.4861039144815598`*^9}, { 2077 | 3.486104642441647*^9, 3.486104642548864*^9}, {3.486104782346136*^9, 2078 | 3.486104902461577*^9}, {3.48610494433162*^9, 3.486104968708193*^9}, { 2079 | 3.4861050005468283`*^9, 3.486105042266951*^9}, {3.486105135876403*^9, 2080 | 3.486105141260004*^9}, {3.486105401469736*^9, 3.486105473868539*^9}, { 2081 | 3.48610550522219*^9, 3.4861055581267347`*^9}, {3.486105601231003*^9, 2082 | 3.486105601423151*^9}, {3.4861056440054483`*^9, 3.486105751755653*^9}, { 2083 | 3.486105789778404*^9, 3.4861059021844683`*^9}, 3.486106253512891*^9, { 2084 | 3.4861062877586727`*^9, 3.486106317827661*^9}, {3.48610645948615*^9, 2085 | 3.486106510190724*^9}, {3.4861065896106997`*^9, 3.4861066928500853`*^9}, { 2086 | 3.486106749844734*^9, 3.486106824681024*^9}, {3.486106860772004*^9, 2087 | 3.4861068897675447`*^9}, 3.486107455389279*^9, 3.486107492187714*^9, { 2088 | 3.486107560817663*^9, 3.48610759695864*^9}, {3.486107740369009*^9, 2089 | 3.486107866251968*^9}, {3.486108101028528*^9, 3.486108105934173*^9}, { 2090 | 3.4861081504184237`*^9, 3.486108184071753*^9}, {3.486108463359779*^9, 2091 | 3.4861084653975554`*^9}, {3.4861087125576897`*^9, 3.486108726171912*^9}, { 2092 | 3.486108814093649*^9, 3.4861088154329557`*^9}, {3.486108852994684*^9, 2093 | 3.486108853536277*^9}, {3.486109744138466*^9, 3.486109773289982*^9}, { 2094 | 3.486109921431038*^9, 3.486109958907707*^9}, {3.486110979031069*^9, 2095 | 3.486110979709476*^9}, {3.486111059894153*^9, 3.486111113073995*^9}, { 2096 | 3.486111215119508*^9, 3.4861112519189177`*^9}, {3.4861113402604322`*^9, 2097 | 3.4861113641527348`*^9}, {3.486111428608718*^9, 3.486111510340747*^9}, { 2098 | 3.486453288612006*^9, 3.4864532890913153`*^9}, {3.4864533353018427`*^9, 2099 | 3.486453394852398*^9}, {3.4864558314229593`*^9, 3.48645606611874*^9}, { 2100 | 3.4864563550546103`*^9, 3.486456478056225*^9}, {3.486456537065598*^9, 2101 | 3.486456558650125*^9}, {3.48645659774279*^9, 3.4864565981320066`*^9}, { 2102 | 3.486457017736003*^9, 3.486457018285459*^9}, {3.4864572689671497`*^9, 2103 | 3.486457287625428*^9}, 3.486457491927279*^9, {3.4864575479806843`*^9, 2104 | 3.4864575484207163`*^9}, {3.486457664733614*^9, 3.486457665079994*^9}, { 2105 | 3.486457929367833*^9, 3.4864579300452223`*^9}, {3.486458010635347*^9, 2106 | 3.486458040234592*^9}, 3.486458131384296*^9, {3.486706550995036*^9, 2107 | 3.486706555862475*^9}, {3.486707475188368*^9, 3.48670747541743*^9}, { 2108 | 3.4867097130759172`*^9, 3.486709860645095*^9}, {3.486709941075715*^9, 2109 | 3.486710032024263*^9}, {3.486710094385775*^9, 3.486710102613853*^9}, { 2110 | 3.486710259192375*^9, 3.486710319825018*^9}, {3.486710391901767*^9, 2111 | 3.486710397401952*^9}, {3.486710532569871*^9, 3.486710554640171*^9}, { 2112 | 3.4867106666279297`*^9, 3.486710703882985*^9}, {3.486710747097633*^9, 2113 | 3.4867108249505777`*^9}, {3.486711130342832*^9, 3.486711134486292*^9}, { 2114 | 3.486711175522706*^9, 3.4867112809912024`*^9}, {3.48671157119833*^9, 2115 | 3.48671162989874*^9}, {3.486711687092937*^9, 3.486711792555903*^9}, { 2116 | 3.4867119564872427`*^9, 3.48671203552372*^9}, {3.4867121193904057`*^9, 2117 | 3.486712201797069*^9}, {3.486712285076243*^9, 3.4867122852473583`*^9}, { 2118 | 3.486712355263175*^9, 3.4867123716425133`*^9}, {3.48671240599407*^9, 2119 | 3.486712602439439*^9}, {3.487921917477573*^9, 3.4879219506278048`*^9}, { 2120 | 3.487922114896882*^9, 3.487922118789442*^9}, {3.487922841719283*^9, 2121 | 3.487922894059589*^9}, {3.487922995752372*^9, 3.487923082286169*^9}, { 2122 | 3.4879231627239513`*^9, 3.487923211726028*^9}, {3.487923439320277*^9, 2123 | 3.487923607696412*^9}, {3.4879236563567333`*^9, 3.487923760425818*^9}, { 2124 | 3.48792381966673*^9, 3.4879238256954727`*^9}, {3.487923920489811*^9, 2125 | 3.487923953453823*^9}, {3.48792447622943*^9, 3.48792451455621*^9}, { 2126 | 3.487924829845483*^9, 3.487924834739169*^9}, {3.4879248987653313`*^9, 2127 | 3.4879250002216883`*^9}, {3.487925046029634*^9, 3.4879251157713013`*^9}, 2128 | 3.48792550724599*^9, {3.487925721794922*^9, 3.487925791635581*^9}, { 2129 | 3.4879258220742893`*^9, 3.487925894825139*^9}, {3.487925937401588*^9, 2130 | 3.487925946683379*^9}, 3.4879260262772408`*^9, {3.48792606613269*^9, 2131 | 3.4879261995514593`*^9}, {3.487926229565529*^9, 3.4879262515106163`*^9}, { 2132 | 3.487926355643881*^9, 3.4879263769797173`*^9}, {3.48792643879526*^9, 2133 | 3.487926439725425*^9}, {3.487926520780888*^9, 3.4879265495688133`*^9}, { 2134 | 3.487926858259399*^9, 3.487926864735478*^9}, {3.487926897885682*^9, 2135 | 3.4879269029740477`*^9}, {3.4892103863909883`*^9, 2136 | 3.4892103983187017`*^9}, {3.4892105149947233`*^9, 3.489210548120318*^9}, { 2137 | 3.489210593022204*^9, 3.489210593627499*^9}, {3.4892107363248453`*^9, 2138 | 3.489210738342043*^9}, {3.489212794587307*^9, 3.489212795368864*^9}, { 2139 | 3.489212826877016*^9, 3.489212829619008*^9}, {3.48921286197297*^9, 2140 | 3.489212905699936*^9}, {3.4892131754237623`*^9, 3.489213200733039*^9}, { 2141 | 3.489213242539661*^9, 3.4892133178333817`*^9}, {3.4892133496845427`*^9, 2142 | 3.489213368888733*^9}, 3.489213447129129*^9, {3.489213498573689*^9, 2143 | 3.489213527363748*^9}, 3.4892156955288877`*^9, {3.48921587779782*^9, 2144 | 3.489215884246146*^9}, {3.489216091179614*^9, 3.489216094429119*^9}, { 2145 | 3.489217217477378*^9, 3.489217280240841*^9}, {3.489217428065363*^9, 2146 | 3.489217436314927*^9}, {3.489217521915224*^9, 3.4892175386883307`*^9}, { 2147 | 3.4892175825066757`*^9, 3.489217609192217*^9}, {3.489217654643833*^9, 2148 | 3.489217706725183*^9}, {3.4892187604990377`*^9, 3.489218761530086*^9}, { 2149 | 3.4892189286032057`*^9, 3.489218958681121*^9}, {3.4892189896953278`*^9, 2150 | 3.489218994685422*^9}, {3.4892190419676857`*^9, 3.48921913824831*^9}, { 2151 | 3.489219222100925*^9, 3.489219281546908*^9}, {3.4892194389389057`*^9, 2152 | 3.489219472238772*^9}, {3.489219587509529*^9, 3.489219606290907*^9}, { 2153 | 3.4892200080822477`*^9, 3.4892201905589237`*^9}, {3.489220269614575*^9, 2154 | 3.4892203902827787`*^9}, {3.4892204491986732`*^9, 3.489220461327318*^9}, { 2155 | 3.489222214649991*^9, 3.489222235978759*^9}, {3.489222294148326*^9, 2156 | 3.489222300866095*^9}, {3.489223229521924*^9, 3.489223230114883*^9}, { 2157 | 3.489223630905052*^9, 3.489223642212434*^9}, {3.489223676068836*^9, 2158 | 3.489223676274144*^9}, {3.489223787060347*^9, 3.489223827911337*^9}, { 2159 | 3.489223920629073*^9, 3.489223956544704*^9}, {3.489224154507485*^9, 2160 | 3.48922422377765*^9}, 3.489224299839641*^9, {3.489224366767695*^9, 2161 | 3.489224374077334*^9}, {3.489226373448516*^9, 3.489226391847471*^9}, { 2162 | 3.4892264299057693`*^9, 3.489226433701226*^9}, {3.489226471957548*^9, 2163 | 3.489226526843872*^9}, {3.489226632349638*^9, 3.4892267062466383`*^9}, { 2164 | 3.48941206943373*^9, 3.489412373020103*^9}, {3.489412424684317*^9, 2165 | 3.48941244889406*^9}, {3.48941249085266*^9, 3.4894125083375053`*^9}, { 2166 | 3.4894125756506453`*^9, 3.4894125896996613`*^9}, {3.489413279394576*^9, 2167 | 3.489413633807506*^9}, {3.489413765237252*^9, 3.489413877204911*^9}, { 2168 | 3.489413920441176*^9, 3.489413975514927*^9}, {3.489414023258617*^9, 2169 | 3.489414023836821*^9}, {3.489414360338258*^9, 3.489414441726932*^9}, { 2170 | 3.492750080440497*^9, 3.492750082520213*^9}, {3.492750231402685*^9, 2171 | 3.4927502613800497`*^9}, {3.492750339743648*^9, 3.492750339877331*^9}, { 2172 | 3.492751857467843*^9, 3.492751857577344*^9}, 3.4927673256852922`*^9, { 2173 | 3.492767372855562*^9, 3.492767409270577*^9}, {3.494840447632648*^9, 2174 | 3.494840609823887*^9}, {3.494840774111689*^9, 3.4948408180736094`*^9}, { 2175 | 3.494840864216916*^9, 3.494840937932115*^9}, {3.494840997325829*^9, 2176 | 3.494841044864675*^9}, {3.494841109274026*^9, 3.494841256733232*^9}, { 2177 | 3.4948413744654837`*^9, 3.4948413765115623`*^9}, {3.494841790988493*^9, 2178 | 3.494841820443226*^9}, {3.494841864766221*^9, 3.49484191618359*^9}, { 2179 | 3.4948419743474903`*^9, 3.494841992325241*^9}, {3.496381936353483*^9, 2180 | 3.4963819940220346`*^9}, {3.496382033303647*^9, 3.496382060883556*^9}, { 2181 | 3.4963822324380713`*^9, 3.4963822555581627`*^9}, {3.496384352908544*^9, 2182 | 3.496384359251474*^9}, {3.496384753259543*^9, 3.4963847879512243`*^9}, { 2183 | 3.496384825560151*^9, 3.4963848580765676`*^9}, {3.4963869396511793`*^9, 2184 | 3.496386955106401*^9}, {3.496387064151267*^9, 3.496387065979493*^9}, 2185 | 3.496387178195266*^9, 3.496387218027976*^9, {3.496387268123074*^9, 2186 | 3.496387268992752*^9}, {3.49638739344359*^9, 3.49638742086304*^9}, { 2187 | 3.496387494641295*^9, 3.496387495249971*^9}, {3.4963876605826893`*^9, 2188 | 3.496387689161592*^9}, {3.496387881100712*^9, 3.496387983398703*^9}, { 2189 | 3.4963881572369537`*^9, 3.49638821442374*^9}, {3.496388255174836*^9, 2190 | 3.496388291380928*^9}, {3.4963883300042543`*^9, 3.496388347622973*^9}, { 2191 | 3.4963884216095963`*^9, 3.496388524661734*^9}, {3.4963885629371862`*^9, 2192 | 3.4963885863378*^9}, {3.4963890014035463`*^9, 3.496389106873267*^9}, { 2193 | 3.496389157586083*^9, 3.496389300555925*^9}, {3.4963896131575003`*^9, 2194 | 3.496389614082699*^9}, {3.496389841730567*^9, 3.496389847966168*^9}, { 2195 | 3.4963900382977657`*^9, 3.496390045310882*^9}, {3.496390084144421*^9, 2196 | 3.4963901272443247`*^9}, {3.49639018662236*^9, 3.4963902711818132`*^9}, { 2197 | 3.4963909342454977`*^9, 3.4963910274350243`*^9}, {3.496391084356278*^9, 2198 | 3.496391155318255*^9}, {3.496391312787224*^9, 3.4963915126557426`*^9}, { 2199 | 3.49639154931291*^9, 3.496391624083428*^9}, {3.4963916557176943`*^9, 2200 | 3.4963917259434757`*^9}, {3.496391789439898*^9, 3.496391791260898*^9}, { 2201 | 3.496391821550704*^9, 3.4963918577123737`*^9}, {3.496391899883937*^9, 2202 | 3.496391904232559*^9}, {3.496392101770068*^9, 3.4963921197266912`*^9}, { 2203 | 3.496392152636568*^9, 3.496392154519755*^9}, {3.496392205065137*^9, 2204 | 3.4963923882925787`*^9}, {3.496392424734226*^9, 3.496392427405465*^9}, { 2205 | 3.496393885598843*^9, 3.496393886047586*^9}, {3.496393922692225*^9, 2206 | 3.496393923334405*^9}, {3.4963955547058773`*^9, 3.496395555533608*^9}, { 2207 | 3.496395725840458*^9, 3.496395760784931*^9}, {3.496395791991425*^9, 2208 | 3.496395804954542*^9}, {3.496395856646139*^9, 3.4963959299410553`*^9}, { 2209 | 3.496396004142571*^9, 3.496396004563755*^9}, {3.4963960549338913`*^9, 2210 | 3.496396056119113*^9}, {3.496396087538138*^9, 3.496396089221319*^9}, { 2211 | 3.496397758682493*^9, 3.4963977631894913`*^9}, {3.496397897506442*^9, 2212 | 3.49639791178168*^9}, {3.496399216162406*^9, 3.496399282863619*^9}, { 2213 | 3.496399485637596*^9, 3.496399575144865*^9}, 3.4963996620980988`*^9, { 2214 | 3.496399862632084*^9, 3.496399875330328*^9}, {3.497516895844252*^9, 2215 | 3.497516896840008*^9}, {3.497597930714415*^9, 3.497598005438168*^9}, { 2216 | 3.499681450044527*^9, 3.499681478626586*^9}, {3.500538360092225*^9, 2217 | 3.5005383986156597`*^9}, {3.500538532822596*^9, 3.500538574528953*^9}, { 2218 | 3.500540117063726*^9, 3.500540149094604*^9}, {3.5005409403460817`*^9, 2219 | 3.500540954687492*^9}, {3.5005410440541573`*^9, 3.50054105864495*^9}, { 2220 | 3.500541106884901*^9, 3.500541109806714*^9}, {3.50054118903089*^9, 2221 | 3.500541196435848*^9}, {3.500557577554813*^9, 3.500557578215008*^9}}], 2222 | 2223 | Cell[CellGroupData[{ 2224 | 2225 | Cell[BoxData[ 2226 | RowBox[{"KeyGen", ";"}]], "Input", 2227 | CellChangeTimes->{{3.497598022903984*^9, 3.497598024166692*^9}, 2228 | 3.500538424767268*^9}], 2229 | 2230 | Cell[CellGroupData[{ 2231 | 2232 | Cell[BoxData[ 2233 | InterpretationBox[ 2234 | RowBox[{"\<\"p: \"\>", "\[InvisibleSpace]", 2235 | "12310033003052705370670624285030616941168239217258475259867874823160384158\ 2236 | 035114844708574130040911862476213695763875262719218971368434168388798900783581\ 2237 | 399173927294571523658128544531908963889195149756026010927046986061033245275879\ 2238 | 145206230599816269073690717222786072439352014096768521195035489215353030539674\ 2239 | 736336159000323747741360458358326017519256719532915714092112868757210703692543\ 2240 | 129325260911788992408115833860505333428491905164625450391336035978514651159094\ 2241 | 369684387855043909599704562455246337722753425665125848429550038308213235054279\ 2242 | 89527454756799044898773585305778377574958277881195844180596507531084561788769"\ 2243 | }], 2244 | SequenceForm[ 2245 | "p: ", 123100330030527053706706242850306169411682392172584752598678748231603\ 2246 | 841580351148447085741300409118624762136957638752627192189713684341683887989007\ 2247 | 835813991739272945715236581285445319089638891951497560260109270469860610332452\ 2248 | 758791452062305998162690736907172227860724393520140967685211950354892153530305\ 2249 | 396747363361590003237477413604583583260175192567195329157140921128687572107036\ 2250 | 925431293252609117889924081158338605053334284919051646254503913360359785146511\ 2251 | 590943696843878550439095997045624552463377227534256651258484295500383082132350\ 2252 | 542798952745475679904489877358530577837757495827788119584418059650753108456178\ 2253 | 8769], 2254 | Editable->False]], "Print", 2255 | CellChangeTimes->{ 2256 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2257 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2258 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2259 | 3.500541202832284*^9}], 2260 | 2261 | Cell[BoxData[ 2262 | InterpretationBox[ 2263 | RowBox[{"\<\"G: \"\>", "\[InvisibleSpace]", 2264 | RowBox[{ 2265 | RowBox[{ 2266 | "-", "10749338244122057858306840553477730137510788363595610917759666509945\ 2267 | 8901227695"}], "+", 2268 | RowBox[{ 2269 | "3181083706953511564600936183113602858274002723550041397379220046841211517\ 2270 | 7870", " ", "x"}], "+", 2271 | RowBox[{ 2272 | "7106591325913687989931155657720832478892495530085890025103574204112334971\ 2273 | 6346", " ", 2274 | SuperscriptBox["x", "2"]}], "+", 2275 | RowBox[{ 2276 | "7268865245632797449675595425856387035944913172064619106019957541434879766\ 2277 | 8558", " ", 2278 | SuperscriptBox["x", "3"]}], "+", 2279 | RowBox[{ 2280 | "7142937515162077749770478350406630942703608898035253439278976168960288740\ 2281 | 348", " ", 2282 | SuperscriptBox["x", "4"]}], "-", 2283 | RowBox[{ 2284 | "1129928052452860460596067287082837588675748743672374861308895602197218439\ 2285 | 13462", " ", 2286 | SuperscriptBox["x", "5"]}], "+", 2287 | RowBox[{ 2288 | "3256568609173461226310736572669008071556782297852926241106829416647410662\ 2289 | 3498", " ", 2290 | SuperscriptBox["x", "6"]}], "-", 2291 | RowBox[{ 2292 | "1042022901267063588832540000949715778548643286650703131580505468808637738\ 2293 | 27642", " ", 2294 | SuperscriptBox["x", "7"]}]}], "\[InvisibleSpace]", "\<\" = \"\>", 2295 | "\[InvisibleSpace]", 2296 | RowBox[{ 2297 | "12310033003052705370670624285030616941168239217258475259867874823160384158\ 2298 | 035114844708574130040911862476213695763875262719218971368434168388798900783581\ 2299 | 399173927294571523658128544531908963889195149756026010927046986061033245275879\ 2300 | 145206230599816269073690717222786072439352014096768521195035489215353030539674\ 2301 | 736336159000323747741360458358326017519256719532915714092112868757210703692543\ 2302 | 129325260911788992408115833860505333428491905164625450391336035978514651159094\ 2303 | 369684387855043909599704562455246337722753425665125848429550038308213235054278\ 2304 | 85325164630092686015519585210806799720093949216125531022545960650220787961127"\ 2305 | , " ", 2306 | RowBox[{"(", 2307 | RowBox[{ 2308 | "112641912230334421507194210129379695569155730370078931719398781346076451\ 2309 | 013782331714557997580771993444212412777150453375279065175475042206358272260266\ 2310 | 893470812141068850324137850275609870803234422969805260840637209091695630825536\ 2311 | 389444194790856960630821280093441380204217356388618902721031131504445000805239\ 2312 | 140119539877318368599930961260715705768612554159776190114958532016770639568001\ 2313 | 641129452539918228196509546926056613756276158660363597278340862705926178688633\ 2314 | 087364217529195133059680242343826530228759081359760534149483676807294952750699\ 2315 | 146045714649399993128913985069777384293737572883819682754314184879883880345719\ 2316 | 9", "+", "x"}], ")"}], " ", 2317 | RowBox[{"(", 2318 | RowBox[{ 2319 | "242998026288456988405839702268331630442852529497097900494290059133785479\ 2320 | 522206976160098920448529325699601273696971074216874748651906769019752977019423\ 2321 | 101741786376643011893467537798968691199790418328342148577930406629659882517271\ 2322 | 900269551751734865332753597846026608396090558524768664771753256034693091878889\ 2323 | 960456459137119778346739060626707772411699546628328992334210115836946231671223\ 2324 | 146695008073173458601923905712679112533986262959086456904025538241458370307398\ 2325 | 406092418439876558219272410880111194908561897336693900139011303368217007741265\ 2326 | 994969645966937270607502746659948702155553048602456795639363763704910131889696\ 2327 | ", "+", 2328 | RowBox[{ 2329 | "71561725401108078777204069377381478374635282375204800138682862464775807\ 2330 | 140061355002154813811189755614300491082599189883968908044134610205848285747706\ 2331 | 126616854143815457971332036697104993579809089017572174373537911535137664095403\ 2332 | 865605904832454891449474628506780409164071599261054288404389646160904794516810\ 2333 | 184441001829179626629503650083288460362637928972783566728148499411914733102178\ 2334 | 606918064199102317108632256810669674244092636495720647080968534061912690041493\ 2335 | 263731886091500412377789303778721619856696005496090391965168634370492187826561\ 2336 | 309390787296582302397012309701621668360934729165260185015073877667307312715252\ 2337 | 8", " ", "x"}], "+", 2338 | RowBox[{ 2339 | "32884357109259502051869005039290006357736223745654969929295375878777170\ 2340 | 169742963139903127818857424498856917052908977951152293023180351989075307974781\ 2341 | 295781306759616685714266317009459467681895054693640509732500714339446673112086\ 2342 | 892384955039400423006710928836361707465676545996933033590773569498446904550082\ 2343 | 763971946715887992839394508126868806409278744114963879703469529416878152027916\ 2344 | 173285670722045570599968535893796527341802743209512921128186713769326129960523\ 2345 | 369338207691809167984485316467140054361774637700639301154133361790034009522354\ 2346 | 532168589161302032386503400862135539296629138632701545601286785351942614100369\ 2347 | 5", " ", 2348 | SuperscriptBox["x", "2"]}], "+", 2349 | RowBox[{ 2350 | "81438952503883895835578179407439463772456341607623900180153711045395187\ 2351 | 298413915613139218800103379077047491381768795735289777178093025153043958357300\ 2352 | 653933275418261264402807426788726145345443302086665674756374377048692312870436\ 2353 | 712073504802890755083086081514789022254813875861901339287646240381796017033739\ 2354 | 074207773914276198561536799914436946257076169027894642367965852956436874715361\ 2355 | 389075561571406389141519862416066369354356362493197072975831551438900430909738\ 2356 | 660777632295366007769186991461864270951156807071794183821297876711250702388928\ 2357 | 092878068288865823719027884151929980018419063372887439587894398020283606036565\ 2358 | 4", " ", 2359 | SuperscriptBox["x", "3"]}], "+", 2360 | RowBox[{ 2361 | "56444025984125322609599004849545400860857117189980405833356863748837303\ 2362 | 899000086782166705593807355028413803354540995730026914733122746560644309799948\ 2363 | 919826563920449104971438534407569310089146442344186288632838001890958241042847\ 2364 | 270069312291075679968050491523038365305441572099706942723666668598319868794136\ 2365 | 780238951405146342354651827657638595038393473675141255274164677620618283480332\ 2366 | 959527862568932228264755513159028626116352150095667070099407164441135159089331\ 2367 | 997788449019460960482246576666542201622905939607065962593577045804202432839208\ 2368 | 370047421468870965104183940633537018329559390070226901028172803562182257481769\ 2369 | 2", " ", 2370 | SuperscriptBox["x", "4"]}], "+", 2371 | RowBox[{ 2372 | "82314812777482452225640892629303432510892865526206435478147691231251101\ 2373 | 915802722092709072944467253365694788499080471691242744130235647353756110772992\ 2374 | 398730296742891638961060195119462376094814150997559869360660638614771731263385\ 2375 | 457268246357374090481109595844023286897392484056736078738540039937094165829324\ 2376 | 892819278683794286141943944061514779438554443383462751741918748838040866276563\ 2377 | 542530744519036482146618185963828937801420892034116294966495161321961080254432\ 2378 | 325935853013904570944811425565498894439475148323058479493534999970048477226518\ 2379 | 655058213920664340906722625167580133785577385591721073897632884533508210637286\ 2380 | 9", " ", 2381 | SuperscriptBox["x", "5"]}], "+", 2382 | SuperscriptBox["x", "6"]}], ")"}]}]}], 2383 | SequenceForm[ 2384 | "G: ", -10749338244122057858306840553477730137510788363595610917759666509945\ 2385 | 8901227695 + 2386 | 318108370695351156460093618311360285827400272355004139737922004684121151778\ 2387 | 70 $CellContext`x + 2388 | 710659132591368798993115565772083247889249553008589002510357420411233497163\ 2389 | 46 $CellContext`x^2 + 2390 | 726886524563279744967559542585638703594491317206461910601995754143487976685\ 2391 | 58 $CellContext`x^3 + 2392 | 714293751516207774977047835040663094270360889803525343927897616896028874034\ 2393 | 8 $CellContext`x^4 - 2394 | 112992805245286046059606728708283758867574874367237486130889560219721843913\ 2395 | 462 $CellContext`x^5 + 2396 | 325656860917346122631073657266900807155678229785292624110682941664741066234\ 2397 | 98 $CellContext`x^6 - 2398 | 104202290126706358883254000094971577854864328665070313158050546880863773827\ 2399 | 642 $CellContext`x^7, " = ", 2400 | 123100330030527053706706242850306169411682392172584752598678748231603841580\ 2401 | 351148447085741300409118624762136957638752627192189713684341683887989007835813\ 2402 | 991739272945715236581285445319089638891951497560260109270469860610332452758791\ 2403 | 452062305998162690736907172227860724393520140967685211950354892153530305396747\ 2404 | 363361590003237477413604583583260175192567195329157140921128687572107036925431\ 2405 | 293252609117889924081158338605053334284919051646254503913360359785146511590943\ 2406 | 696843878550439095997045624552463377227534256651258484295500383082132350542788\ 2407 | 5325164630092686015519585210806799720093949216125531022545960650220787961127 ( 2408 | 11264191223033442150719421012937969556915573037007893171939878134607645101\ 2409 | 378233171455799758077199344421241277715045337527906517547504220635827226026689\ 2410 | 347081214106885032413785027560987080323442296980526084063720909169563082553638\ 2411 | 944419479085696063082128009344138020421735638861890272103113150444500080523914\ 2412 | 011953987731836859993096126071570576861255415977619011495853201677063956800164\ 2413 | 112945253991822819650954692605661375627615866036359727834086270592617868863308\ 2414 | 736421752919513305968024234382653022875908135976053414948367680729495275069914\ 2415 | 60457146493999931289139850697773842937375728838196827543141848798838803457199 + \ 2416 | $CellContext`x) ( 2417 | 24299802628845698840583970226833163044285252949709790049429005913378547952\ 2418 | 220697616009892044852932569960127369697107421687474865190676901975297701942310\ 2419 | 174178637664301189346753779896869119979041832834214857793040662965988251727190\ 2420 | 026955175173486533275359784602660839609055852476866477175325603469309187888996\ 2421 | 045645913711977834673906062670777241169954662832899233421011583694623167122314\ 2422 | 669500807317345860192390571267911253398626295908645690402553824145837030739840\ 2423 | 609241843987655821927241088011119490856189733669390013901130336821700774126599\ 2424 | 4969645966937270607502746659948702155553048602456795639363763704910131889696 + 2425 | 71561725401108078777204069377381478374635282375204800138682862464775807140\ 2426 | 061355002154813811189755614300491082599189883968908044134610205848285747706126\ 2427 | 616854143815457971332036697104993579809089017572174373537911535137664095403865\ 2428 | 605904832454891449474628506780409164071599261054288404389646160904794516810184\ 2429 | 441001829179626629503650083288460362637928972783566728148499411914733102178606\ 2430 | 918064199102317108632256810669674244092636495720647080968534061912690041493263\ 2431 | 731886091500412377789303778721619856696005496090391965168634370492187826561309\ 2432 | 3907872965823023970123097016216683609347291652601850150738776673073127152528 \ 2433 | $CellContext`x + 2434 | 32884357109259502051869005039290006357736223745654969929295375878777170169\ 2435 | 742963139903127818857424498856917052908977951152293023180351989075307974781295\ 2436 | 781306759616685714266317009459467681895054693640509732500714339446673112086892\ 2437 | 384955039400423006710928836361707465676545996933033590773569498446904550082763\ 2438 | 971946715887992839394508126868806409278744114963879703469529416878152027916173\ 2439 | 285670722045570599968535893796527341802743209512921128186713769326129960523369\ 2440 | 338207691809167984485316467140054361774637700639301154133361790034009522354532\ 2441 | 1685891613020323865034008621355392966291386327015456012867853519426141003695 \ 2442 | $CellContext`x^2 + 2443 | 81438952503883895835578179407439463772456341607623900180153711045395187298\ 2444 | 413915613139218800103379077047491381768795735289777178093025153043958357300653\ 2445 | 933275418261264402807426788726145345443302086665674756374377048692312870436712\ 2446 | 073504802890755083086081514789022254813875861901339287646240381796017033739074\ 2447 | 207773914276198561536799914436946257076169027894642367965852956436874715361389\ 2448 | 075561571406389141519862416066369354356362493197072975831551438900430909738660\ 2449 | 777632295366007769186991461864270951156807071794183821297876711250702388928092\ 2450 | 8780682888658237190278841519299800184190633728874395878943980202836060365654 \ 2451 | $CellContext`x^3 + 2452 | 56444025984125322609599004849545400860857117189980405833356863748837303899\ 2453 | 000086782166705593807355028413803354540995730026914733122746560644309799948919\ 2454 | 826563920449104971438534407569310089146442344186288632838001890958241042847270\ 2455 | 069312291075679968050491523038365305441572099706942723666668598319868794136780\ 2456 | 238951405146342354651827657638595038393473675141255274164677620618283480332959\ 2457 | 527862568932228264755513159028626116352150095667070099407164441135159089331997\ 2458 | 788449019460960482246576666542201622905939607065962593577045804202432839208370\ 2459 | 0474214688709651041839406335370183295593900702269010281728035621822574817692 \ 2460 | $CellContext`x^4 + 2461 | 82314812777482452225640892629303432510892865526206435478147691231251101915\ 2462 | 802722092709072944467253365694788499080471691242744130235647353756110772992398\ 2463 | 730296742891638961060195119462376094814150997559869360660638614771731263385457\ 2464 | 268246357374090481109595844023286897392484056736078738540039937094165829324892\ 2465 | 819278683794286141943944061514779438554443383462751741918748838040866276563542\ 2466 | 530744519036482146618185963828937801420892034116294966495161321961080254432325\ 2467 | 935853013904570944811425565498894439475148323058479493534999970048477226518655\ 2468 | 0582139206643409067226251675801337855773855917210738976328845335082106372869 \ 2469 | $CellContext`x^5 + $CellContext`x^6)], 2470 | Editable->False]], "Print", 2471 | CellChangeTimes->{ 2472 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2473 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2474 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2475 | 3.5005412039821663`*^9}], 2476 | 2477 | Cell[BoxData[ 2478 | InterpretationBox[ 2479 | RowBox[{"\<\"F: \"\>", "\[InvisibleSpace]", 2480 | RowBox[{"1", "+", 2481 | SuperscriptBox["x", "8"]}], "\[InvisibleSpace]", "\<\" = \"\>", 2482 | "\[InvisibleSpace]", 2483 | RowBox[{ 2484 | RowBox[{"(", 2485 | RowBox[{ 2486 | "104584178001926321995120327209264738425266618025058208792799668855273905\ 2487 | 665688167325277437196371251805497241804882992519131245382092994775297167475689\ 2488 | 205209271318768649124434351697092188356575285277549992686332607689147016272224\ 2489 | 020078675151412020599156270787864805201761637523487824909192233877085295001576\ 2490 | 072438217126848688774826433228675544065800130355529670259625966708014674689237\ 2491 | 901638000691996617275716114125484395780087603912826572255724976538589678229578\ 2492 | 563326263493553060363168032807259331484684528968907243348118235757871795998436\ 2493 | 529070308262799113609633734608004534637582549042999016637454658732245758331570\ 2494 | ", "+", "x"}], ")"}], " ", 2495 | RowBox[{"(", 2496 | RowBox[{ 2497 | "190276948401411320506767900215420943620310835557364190877889064247258732\ 2498 | 851241225222697822303186589703095646776885045133508897758289400750751359572145\ 2499 | 384113296162428610327748521680004355245758921362255684071094164342144048341503\ 2500 | 174248236459501569194648180217923923429856545944505720870616159713979283980210\ 2501 | 545890743815315701331602560723073488745532175613667556529266174460348271009123\ 2502 | 105747923131763739802267941160491934973286649683225424021165567528739739901039\ 2503 | 544568864183976826703019617247179577345001437971051138858701668579596645045005\ 2504 | 862987686553312222629668230517487037586756876900999537356465625317652501523246\ 2505 | ", "+", "x"}], ")"}], " ", 2506 | RowBox[{"(", 2507 | RowBox[{ 2508 | "306215861287734058072771853672137125398701558911718338054749887048395029\ 2509 | 380131319283783641774718896455111977079969814329938283523676272671258051939861\ 2510 | 148727213276779411334510877854769287575699719840864853125757041945840492397800\ 2511 | 781267753988807158412804615563675299947545137121515240249609139987830633557504\ 2512 | 572512694482798583364485563771707363307040122956223318612951934751988904606195\ 2513 | 619404509269884874554560510641570392776720837025494309672050683564558884672597\ 2514 | 171306397767540834449141461425281586154196815449359832884525882950753822290605\ 2515 | 624072673040575578994614466122629862487396360066434502178644345610028683160912\ 2516 | ", "+", "x"}], ")"}], " ", 2517 | RowBox[{"(", 2518 | RowBox[{ 2519 | "504223318693716638987038003485186244642769998195251714428692463685376342\ 2520 | 194087452628886321249281229908272157979166402119396513018438593641156283180741\ 2521 | 743607810544781985831112407720059132723137659648926799525785514788544726612294\ 2522 | 814118247736022492881771102433315096139300518037369697878657899858265991882431\ 2523 | 784059176296853703212867134411985042228416974056524543576473155204000302361014\ 2524 | 674362089016712996730629722423391920266976873248326156109295561519698596798063\ 2525 | 703763911443063949496655805563754961478544222056811114787373492458140554447007\ 2526 | 283377560359652986771892543709010525013884791661465598751356954070433347292225\ 2527 | ", "+", "x"}], ")"}], " ", 2528 | RowBox[{"(", 2529 | RowBox[{ 2530 | "726779981611553898080024425017875449474053923530595811558095018630662073\ 2531 | 609424031841971091754809956339349211597221124152525384118404823197723606897616\ 2532 | 396309582184675166534700446733131763665781855326675801566919183817558597915293\ 2533 | 100402375323959134025597969288963511104634683372307154240845649063269311171535\ 2534 | 689574439603178671561268911423847559523508697896767027832738131671720768008239\ 2535 | 638570437074465902510181860962658613075872317268136388929838042078152868317845\ 2536 | 733204527342440441463314650681769672293731120509701470055581511372680769058420\ 2537 | 706149894397146058126881041596767852561073486219730245429239553460651214496544\ 2538 | ", "+", "x"}], ")"}], " ", 2539 | RowBox[{"(", 2540 | RowBox[{ 2541 | "924787439017536478994290574830924568718122362814129187932037595267643386\ 2542 | 423380165187073771229372289792509392496417711941983613613167144167621838138496\ 2543 | 991190179452677741031301976598421608813219795134737747966947656660262832129787\ 2544 | 133252869071174468494564456158603307296390064288161611869894408933704669496462\ 2545 | 901120921417233791409650482064125238444885548997068252796259352123732165763058\ 2546 | 693528016821294024686251072744480140566128353490968235367082920033292580443312\ 2547 | 265662041017963556510828994820243047618078527117152751958429120880067501214822\ 2548 | 365454781716223465904159119183148515087561917814761342001952161921055878627857\ 2549 | ", "+", "x"}], ")"}], " ", 2550 | RowBox[{"(", 2551 | RowBox[{ 2552 | "104072635190385921656029452828764075049651308616848333510889841806877968\ 2553 | 295227025924815959070090459654452572279950248113841299937855401608812853050621\ 2554 | 275580409656702854203806433277318654114316059361334691702161053426395927618608\ 2555 | 474027238660048005771272089150435468381407865546517113124888738920755601907375\ 2556 | 692774287208471667344253348511275911300639349633962401487994511241537279936013\ 2557 | 120718460295941515943854364222555859836956254083323712101796803606911172521486\ 2558 | 989239957460152756425695083899834505642727390459546144598425333525122467846042\ 2559 | 212653976820348682226910535478829133998820140098019630682413088221343206026552\ 2560 | 3", "+", "x"}], ")"}], " ", 2561 | RowBox[{"(", 2562 | RowBox[{ 2563 | "112641912230334421507194210129379695569155730370078931719398781346076451\ 2564 | 013782331714557997580771993444212412777150453375279065175475042206358272260266\ 2565 | 893470812141068850324137850275609870803234422969805260840637209091695630825536\ 2566 | 389444194790856960630821280093441380204217356388618902721031131504445000805239\ 2567 | 140119539877318368599930961260715705768612554159776190114958532016770639568001\ 2568 | 641129452539918228196509546926056613756276158660363597278340862705926178688633\ 2569 | 087364217529195133059680242343826530228759081359760534149483676807294952750699\ 2570 | 146045714649399993128913985069777384293737572883819682754314184879883880345719\ 2571 | 9", "+", "x"}], ")"}]}]}], 2572 | SequenceForm[ 2573 | "F: ", 1 + $CellContext`x^8, 2574 | " = ", (1045841780019263219951203272092647384252666180250582087927996688552\ 2575 | 739056656881673252774371963712518054972418048829925191312453820929947752971674\ 2576 | 756892052092713187686491244343516970921883565752852775499926863326076891470162\ 2577 | 722240200786751514120205991562707878648052017616375234878249091922338770852950\ 2578 | 015760724382171268486887748264332286755440658001303555296702596259667080146746\ 2579 | 892379016380006919966172757161141254843957800876039128265722557249765385896782\ 2580 | 295785633262634935530603631680328072593314846845289689072433481182357578717959\ 2581 | 984365290703082627991136096337346080045346375825490429990166374546587322457583\ 2582 | 31570 + $CellContext`x) ( 2583 | 19027694840141132050676790021542094362031083555736419087788906424725873285\ 2584 | 124122522269782230318658970309564677688504513350889775828940075075135957214538\ 2585 | 411329616242861032774852168000435524575892136225568407109416434214404834150317\ 2586 | 424823645950156919464818021792392342985654594450572087061615971397928398021054\ 2587 | 589074381531570133160256072307348874553217561366755652926617446034827100912310\ 2588 | 574792313176373980226794116049193497328664968322542402116556752873973990103954\ 2589 | 456886418397682670301961724717957734500143797105113885870166857959664504500586\ 2590 | 2987686553312222629668230517487037586756876900999537356465625317652501523246 + \ 2591 | $CellContext`x) ( 2592 | 30621586128773405807277185367213712539870155891171833805474988704839502938\ 2593 | 013131928378364177471889645511197707996981432993828352367627267125805193986114\ 2594 | 872721327677941133451087785476928757569971984086485312575704194584049239780078\ 2595 | 126775398880715841280461556367529994754513712151524024960913998783063355750457\ 2596 | 251269448279858336448556377170736330704012295622331861295193475198890460619561\ 2597 | 940450926988487455456051064157039277672083702549430967205068356455888467259717\ 2598 | 130639776754083444914146142528158615419681544935983288452588295075382229060562\ 2599 | 4072673040575578994614466122629862487396360066434502178644345610028683160912 + \ 2600 | $CellContext`x) ( 2601 | 50422331869371663898703800348518624464276999819525171442869246368537634219\ 2602 | 408745262888632124928122990827215797916640211939651301843859364115628318074174\ 2603 | 360781054478198583111240772005913272313765964892679952578551478854472661229481\ 2604 | 411824773602249288177110243331509613930051803736969787865789985826599188243178\ 2605 | 405917629685370321286713441198504222841697405652454357647315520400030236101467\ 2606 | 436208901671299673062972242339192026697687324832615610929556151969859679806370\ 2607 | 376391144306394949665580556375496147854422205681111478737349245814055444700728\ 2608 | 3377560359652986771892543709010525013884791661465598751356954070433347292225 + \ 2609 | $CellContext`x) ( 2610 | 72677998161155389808002442501787544947405392353059581155809501863066207360\ 2611 | 942403184197109175480995633934921159722112415252538411840482319772360689761639\ 2612 | 630958218467516653470044673313176366578185532667580156691918381755859791529310\ 2613 | 040237532395913402559796928896351110463468337230715424084564906326931117153568\ 2614 | 957443960317867156126891142384755952350869789676702783273813167172076800823963\ 2615 | 857043707446590251018186096265861307587231726813638892983804207815286831784573\ 2616 | 320452734244044146331465068176967229373112050970147005558151137268076905842070\ 2617 | 6149894397146058126881041596767852561073486219730245429239553460651214496544 + \ 2618 | $CellContext`x) ( 2619 | 92478743901753647899429057483092456871812236281412918793203759526764338642\ 2620 | 338016518707377122937228979250939249641771194198361361316714416762183813849699\ 2621 | 119017945267774103130197659842160881321979513473774796694765666026283212978713\ 2622 | 325286907117446849456445615860330729639006428816161186989440893370466949646290\ 2623 | 112092141723379140965048206412523844488554899706825279625935212373216576305869\ 2624 | 352801682129402468625107274448014056612835349096823536708292003329258044331226\ 2625 | 566204101796355651082899482024304761807852711715275195842912088006750121482236\ 2626 | 5454781716223465904159119183148515087561917814761342001952161921055878627857 + \ 2627 | $CellContext`x) ( 2628 | 10407263519038592165602945282876407504965130861684833351088984180687796829\ 2629 | 522702592481595907009045965445257227995024811384129993785540160881285305062127\ 2630 | 558040965670285420380643327731865411431605936133469170216105342639592761860847\ 2631 | 402723866004800577127208915043546838140786554651711312488873892075560190737569\ 2632 | 277428720847166734425334851127591130063934963396240148799451124153727993601312\ 2633 | 071846029594151594385436422255585983695625408332371210179680360691117252148698\ 2634 | 923995746015275642569508389983450564272739045954614459842533352512246784604221\ 2635 | 26539768203486822269105354788291339988201400980196306824130882213432060265523 + \ 2636 | $CellContext`x) ( 2637 | 11264191223033442150719421012937969556915573037007893171939878134607645101\ 2638 | 378233171455799758077199344421241277715045337527906517547504220635827226026689\ 2639 | 347081214106885032413785027560987080323442296980526084063720909169563082553638\ 2640 | 944419479085696063082128009344138020421735638861890272103113150444500080523914\ 2641 | 011953987731836859993096126071570576861255415977619011495853201677063956800164\ 2642 | 112945253991822819650954692605661375627615866036359727834086270592617868863308\ 2643 | 736421752919513305968024234382653022875908135976053414948367680729495275069914\ 2644 | 60457146493999931289139850697773842937375728838196827543141848798838803457199 + \ 2645 | $CellContext`x)], 2646 | Editable->False]], "Print", 2647 | CellChangeTimes->{ 2648 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2649 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2650 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2651 | 3.500541206768076*^9}], 2652 | 2653 | Cell[BoxData[ 2654 | InterpretationBox[ 2655 | RowBox[{"\<\"D: \"\>", "\[InvisibleSpace]", 2656 | RowBox[{ 2657 | "11264191223033442150719421012937969556915573037007893171939878134607645101\ 2658 | 378233171455799758077199344421241277715045337527906517547504220635827226026689\ 2659 | 347081214106885032413785027560987080323442296980526084063720909169563082553638\ 2660 | 944419479085696063082128009344138020421735638861890272103113150444500080523914\ 2661 | 011953987731836859993096126071570576861255415977619011495853201677063956800164\ 2662 | 112945253991822819650954692605661375627615866036359727834086270592617868863308\ 2663 | 736421752919513305968024234382653022875908135976053414948367680729495275069914\ 2664 | 60457146493999931289139850697773842937375728838196827543141848798838803457199"\ 2665 | , "+", "x"}]}], 2666 | SequenceForm[ 2667 | "D: ", 112641912230334421507194210129379695569155730370078931719398781346076\ 2668 | 451013782331714557997580771993444212412777150453375279065175475042206358272260\ 2669 | 266893470812141068850324137850275609870803234422969805260840637209091695630825\ 2670 | 536389444194790856960630821280093441380204217356388618902721031131504445000805\ 2671 | 239140119539877318368599930961260715705768612554159776190114958532016770639568\ 2672 | 001641129452539918228196509546926056613756276158660363597278340862705926178688\ 2673 | 633087364217529195133059680242343826530228759081359760534149483676807294952750\ 2674 | 699146045714649399993128913985069777384293737572883819682754314184879883880345\ 2675 | 7199 + $CellContext`x], 2676 | Editable->False]], "Print", 2677 | CellChangeTimes->{ 2678 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2679 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2680 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2681 | 3.500541206834858*^9}], 2682 | 2683 | Cell[BoxData[ 2684 | InterpretationBox[ 2685 | RowBox[{"\<\"D: \"\>", "\[InvisibleSpace]", "1"}], 2686 | SequenceForm["D: ", 1], 2687 | Editable->False]], "Print", 2688 | CellChangeTimes->{ 2689 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2690 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2691 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2692 | 3.500541206922072*^9}], 2693 | 2694 | Cell[BoxData["\<\"plain\"\>"], "Print", 2695 | CellChangeTimes->{ 2696 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2697 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2698 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2699 | 3.500541206999955*^9}], 2700 | 2701 | Cell[BoxData[ 2702 | InterpretationBox[ 2703 | RowBox[{"\<\"r = \"\>", "\[InvisibleSpace]", "1"}], 2704 | SequenceForm["r = ", 1], 2705 | Editable->False]], "Print", 2706 | CellChangeTimes->{ 2707 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2708 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2709 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2710 | 3.500541207065185*^9}], 2711 | 2712 | Cell[BoxData[ 2713 | InterpretationBox[ 2714 | RowBox[{"\<\"z = \"\>", "\[InvisibleSpace]", 2715 | RowBox[{ 2716 | "18606277901293954094967235807851381974585543962199228364315247640705777977\ 2717 | 846731060809310234821892869492661676611193880457204490086144293816471825116519\ 2718 | 778066972221698309970728708911262314000421163766373540757231958840263073313595\ 2719 | 877059483645859597604226057923740637544601310063157884412946828244993674124956\ 2720 | 894072765359397550896136545270858917546751663320746891548761478740746590528028\ 2721 | 098516839245860427500465258891970463066997294689323653222057859273299016088729\ 2722 | 1618029952125777546281129058747438249093325539650014503703725563379178804441", 2723 | "+", 2724 | RowBox[{ 2725 | "5226327022929097450725371071230664800663376035693727463872482241849486981\ 2726 | 025697183808643876399166459108595827055632297682888350954685739702964732667654\ 2727 | 680426672143377695087782385606290830095591216352493984543750775473884882347664\ 2728 | 658639176769541408251155320138810499041362318590255229572967504523769339517587\ 2729 | 955503786987604714089563809915968551562912169620648752952992555833686219106045\ 2730 | 404808466584354972086492019489586693126893562719424459060349924302679708159515\ 2731 | 661558153704853684534557795273461443628570815675726619818869107359331158720610\ 2732 | ", " ", "x"}], "-", 2733 | RowBox[{ 2734 | "1276958183898153407320930097025061447024642241678252900264415928564274191\ 2735 | 749885985637458189093544688885688494995421695342731067966633830667067327814776\ 2736 | 350993897890989191704163378736267693426369611459110145092864196288053623434707\ 2737 | 437972567893880619926797000499470186418918611368826501890825583498563497541987\ 2738 | 826768938922597774542870931142426551666846639355897443259574251862857734810325\ 2739 | 404916825574898236967592522925473212710798426416940556338848128193009622656796\ 2740 | 21807436811639381408080371899482277099052541508325732708158304209307929887618"\ 2741 | , " ", 2742 | SuperscriptBox["x", "2"]}], "+", 2743 | RowBox[{ 2744 | "1279140774044535520588356722336911362329937275125295386386456287075068315\ 2745 | 787934320063895513879501161699916331640810261793471653750066212527185837631905\ 2746 | 752951947633176828381382445164244618380142093320523557973508137326615021044523\ 2747 | 030886523597694420560855229585285734524160525989311824439885875916207843051148\ 2748 | 466060492717793254390727452155820955718053642045817365062957512959559310723520\ 2749 | 230283568329412529555649446948027100203171233990487082898157737802650367320199\ 2750 | 948687433872965427809790557291309439495678884346790648360856688602403320212706\ 2751 | ", " ", 2752 | SuperscriptBox["x", "3"]}], "+", 2753 | RowBox[{ 2754 | "1841187558967382245529602280158092396593685544335197736057295029610868955\ 2755 | 903638095593678824552496739929044891416557956537827280260304353088663419417772\ 2756 | 586511002227533190714530728605974211978153853793864525820950480828280133484779\ 2757 | 879877260296511644852472980915949398555763680829374670586326801675655980297848\ 2758 | 969031137389689964037435618633829699481932802081919799460840152110462353198007\ 2759 | 164342404017056534862295910716547319420279941259180152235808248241490607489425\ 2760 | 487249046277055420534857448793211975015478744341510786978089846968886748623796\ 2761 | ", " ", 2762 | SuperscriptBox["x", "4"]}], "-", 2763 | RowBox[{ 2764 | "2989092974096134699287522750082344754609866140656208285316451996390729985\ 2765 | 332198087341902801002908378397341331681305604393325636216732139611602513574071\ 2766 | 212710180247989007537275720299680214541513555156443351223657235715866090574404\ 2767 | 171292626014774807647096057243577664085569522360116456424005461142782974069152\ 2768 | 308312588253749877293323469834249191610820022433363958791965218912990353524401\ 2769 | 878531549484174332860378888221788134380023574375102123631809781741847094824416\ 2770 | 060975498899520408035220936832180170135947065885169913441452353003768292104490\ 2771 | ", " ", 2772 | SuperscriptBox["x", "5"]}], "-", 2773 | RowBox[{ 2774 | "4745803675609975726334924098366778553262509506813188847334189126116312172\ 2775 | 784533438532241438299568698432185966059542515730948751872866753991530908505421\ 2776 | 307892117301291481459611000386437900221514674561922853619079096997398799357961\ 2777 | 653702030020896548289731061034315416127956249775670049451144753226608313439487\ 2778 | 230011244414779331651139625264054545631265793913486154792734464878948160590880\ 2779 | 891697789870204940747617076549461998446927424854267569807790356103505647468972\ 2780 | 671732286003494667371191144779906574138873782526988650783945907989972359536946\ 2781 | ", " ", 2782 | SuperscriptBox["x", "6"]}], "-", 2783 | RowBox[{ 2784 | "5133420937600038603489259476011606252066677953720367518041455376376185998\ 2785 | 365530640224459261563304241469999019829003668071923519161608611453267766873490\ 2786 | 529480812776445854736485494905996894458507269040043252670837280834389406881608\ 2787 | 568996263484724107462548499691801680145960552308163264283957571014571654085668\ 2788 | 040036059441318049226353161523166866263235317607739917303814748835788520041389\ 2789 | 767388998068178736216191036307229045293074800391318866063233231735664266718410\ 2790 | 47088289979390628319559087137188806425140170443657532347057390215827542358854"\ 2791 | , " ", 2792 | SuperscriptBox["x", "7"]}]}]}], 2793 | SequenceForm[ 2794 | "z = ", 18606277901293954094967235807851381974585543962199228364315247640705\ 2795 | 777977846731060809310234821892869492661676611193880457204490086144293816471825\ 2796 | 116519778066972221698309970728708911262314000421163766373540757231958840263073\ 2797 | 313595877059483645859597604226057923740637544601310063157884412946828244993674\ 2798 | 124956894072765359397550896136545270858917546751663320746891548761478740746590\ 2799 | 528028098516839245860427500465258891970463066997294689323653222057859273299016\ 2800 | 088729161802995212577754628112905874743824909332553965001450370372556337917880\ 2801 | 4441 + 52263270229290974507253710712306648006633760356937274638724822418494869\ 2802 | 810256971838086438763991664591085958270556322976828883509546857397029647326676\ 2803 | 546804266721433776950877823856062908300955912163524939845437507754738848823476\ 2804 | 646586391767695414082511553201388104990413623185902552295729675045237693395175\ 2805 | 879555037869876047140895638099159685515629121696206487529529925558336862191060\ 2806 | 454048084665843549720864920194895866931268935627194244590603499243026797081595\ 2807 | 156615581537048536845345577952734614436285708156757266198188691073593311587206\ 2808 | 10 $CellContext`x - 2809 | 127695818389815340732093009702506144702464224167825290026441592856427419174\ 2810 | 988598563745818909354468888568849499542169534273106796663383066706732781477635\ 2811 | 099389789098919170416337873626769342636961145911014509286419628805362343470743\ 2812 | 797256789388061992679700049947018641891861136882650189082558349856349754198782\ 2813 | 676893892259777454287093114242655166684663935589744325957425186285773481032540\ 2814 | 491682557489823696759252292547321271079842641694055633884812819300962265679621\ 2815 | 807436811639381408080371899482277099052541508325732708158304209307929887618 \ 2816 | $CellContext`x^2 + 2817 | 127914077404453552058835672233691136232993727512529538638645628707506831578\ 2818 | 793432006389551387950116169991633164081026179347165375006621252718583763190575\ 2819 | 295194763317682838138244516424461838014209332052355797350813732661502104452303\ 2820 | 088652359769442056085522958528573452416052598931182443988587591620784305114846\ 2821 | 606049271779325439072745215582095571805364204581736506295751295955931072352023\ 2822 | 028356832941252955564944694802710020317123399048708289815773780265036732019994\ 2823 | 8687433872965427809790557291309439495678884346790648360856688602403320212706 \ 2824 | $CellContext`x^3 + 2825 | 184118755896738224552960228015809239659368554433519773605729502961086895590\ 2826 | 363809559367882455249673992904489141655795653782728026030435308866341941777258\ 2827 | 651100222753319071453072860597421197815385379386452582095048082828013348477987\ 2828 | 987726029651164485247298091594939855576368082937467058632680167565598029784896\ 2829 | 903113738968996403743561863382969948193280208191979946084015211046235319800716\ 2830 | 434240401705653486229591071654731942027994125918015223580824824149060748942548\ 2831 | 7249046277055420534857448793211975015478744341510786978089846968886748623796 \ 2832 | $CellContext`x^4 - 2833 | 298909297409613469928752275008234475460986614065620828531645199639072998533\ 2834 | 219808734190280100290837839734133168130560439332563621673213961160251357407121\ 2835 | 271018024798900753727572029968021454151355515644335122365723571586609057440417\ 2836 | 129262601477480764709605724357766408556952236011645642400546114278297406915230\ 2837 | 831258825374987729332346983424919161082002243336395879196521891299035352440187\ 2838 | 853154948417433286037888822178813438002357437510212363180978174184709482441606\ 2839 | 0975498899520408035220936832180170135947065885169913441452353003768292104490 \ 2840 | $CellContext`x^5 - 2841 | 474580367560997572633492409836677855326250950681318884733418912611631217278\ 2842 | 453343853224143829956869843218596605954251573094875187286675399153090850542130\ 2843 | 789211730129148145961100038643790022151467456192285361907909699739879935796165\ 2844 | 370203002089654828973106103431541612795624977567004945114475322660831343948723\ 2845 | 001124441477933165113962526405454563126579391348615479273446487894816059088089\ 2846 | 169778987020494074761707654946199844692742485426756980779035610350564746897267\ 2847 | 1732286003494667371191144779906574138873782526988650783945907989972359536946 \ 2848 | $CellContext`x^6 - 2849 | 513342093760003860348925947601160625206667795372036751804145537637618599836\ 2850 | 553064022445926156330424146999901982900366807192351916160861145326776687349052\ 2851 | 948081277644585473648549490599689445850726904004325267083728083438940688160856\ 2852 | 899626348472410746254849969180168014596055230816326428395757101457165408566804\ 2853 | 003605944131804922635316152316686626323531760773991730381474883578852004138976\ 2854 | 738899806817873621619103630722904529307480039131886606323323173566426671841047\ 2855 | 088289979390628319559087137188806425140170443657532347057390215827542358854 \ 2856 | $CellContext`x^7], 2857 | Editable->False]], "Print", 2858 | CellChangeTimes->{ 2859 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2860 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2861 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2862 | 3.500541207136034*^9}], 2863 | 2864 | Cell[BoxData["\<\"bruch\"\>"], "Print", 2865 | CellChangeTimes->{ 2866 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2867 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2868 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2869 | 3.5005412071948643`*^9}], 2870 | 2871 | Cell[BoxData[ 2872 | InterpretationBox[ 2873 | RowBox[{"\<\"r = \"\>", "\[InvisibleSpace]", "1"}], 2874 | SequenceForm["r = ", 1], 2875 | Editable->False]], "Print", 2876 | CellChangeTimes->{ 2877 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 2878 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 2879 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 2880 | 3.500541207262576*^9}], 2881 | 2882 | Cell[BoxData[ 2883 | InterpretationBox[ 2884 | RowBox[{"\<\"z = \"\>", "\[InvisibleSpace]", 2885 | RowBox[{ 2886 | "18606277901293954094967235807851381974585543962199228364315247640705777977\ 2887 | 846731060809310234821892869492661676611193880457204490086144293816471825116519\ 2888 | 778066972221698309970728708911262314000421163766373540757231958840263073313595\ 2889 | 877059483645859597604226057923740637544601310063157884412946828244993674124956\ 2890 | 894072765359397550896136545270858917546751663320746891548761478740746590528028\ 2891 | 098516839245860427500465258891970463066997294689323653222057859273299016088729\ 2892 | 1618029952125777546281129058747438249093325539650014503703725563379178804441", 2893 | "+", 2894 | RowBox[{ 2895 | "5226327022929097450725371071230664800663376035693727463872482241849486981\ 2896 | 025697183808643876399166459108595827055632297682888350954685739702964732667654\ 2897 | 680426672143377695087782385606290830095591216352493984543750775473884882347664\ 2898 | 658639176769541408251155320138810499041362318590255229572967504523769339517587\ 2899 | 955503786987604714089563809915968551562912169620648752952992555833686219106045\ 2900 | 404808466584354972086492019489586693126893562719424459060349924302679708159515\ 2901 | 661558153704853684534557795273461443628570815675726619818869107359331158720610\ 2902 | ", " ", "x"}], "-", 2903 | RowBox[{ 2904 | "1276958183898153407320930097025061447024642241678252900264415928564274191\ 2905 | 749885985637458189093544688885688494995421695342731067966633830667067327814776\ 2906 | 350993897890989191704163378736267693426369611459110145092864196288053623434707\ 2907 | 437972567893880619926797000499470186418918611368826501890825583498563497541987\ 2908 | 826768938922597774542870931142426551666846639355897443259574251862857734810325\ 2909 | 404916825574898236967592522925473212710798426416940556338848128193009622656796\ 2910 | 21807436811639381408080371899482277099052541508325732708158304209307929887618"\ 2911 | , " ", 2912 | SuperscriptBox["x", "2"]}], "+", 2913 | RowBox[{ 2914 | "1279140774044535520588356722336911362329937275125295386386456287075068315\ 2915 | 787934320063895513879501161699916331640810261793471653750066212527185837631905\ 2916 | 752951947633176828381382445164244618380142093320523557973508137326615021044523\ 2917 | 030886523597694420560855229585285734524160525989311824439885875916207843051148\ 2918 | 466060492717793254390727452155820955718053642045817365062957512959559310723520\ 2919 | 230283568329412529555649446948027100203171233990487082898157737802650367320199\ 2920 | 948687433872965427809790557291309439495678884346790648360856688602403320212706\ 2921 | ", " ", 2922 | SuperscriptBox["x", "3"]}], "+", 2923 | RowBox[{ 2924 | "1841187558967382245529602280158092396593685544335197736057295029610868955\ 2925 | 903638095593678824552496739929044891416557956537827280260304353088663419417772\ 2926 | 586511002227533190714530728605974211978153853793864525820950480828280133484779\ 2927 | 879877260296511644852472980915949398555763680829374670586326801675655980297848\ 2928 | 969031137389689964037435618633829699481932802081919799460840152110462353198007\ 2929 | 164342404017056534862295910716547319420279941259180152235808248241490607489425\ 2930 | 487249046277055420534857448793211975015478744341510786978089846968886748623796\ 2931 | ", " ", 2932 | SuperscriptBox["x", "4"]}], "-", 2933 | RowBox[{ 2934 | "2989092974096134699287522750082344754609866140656208285316451996390729985\ 2935 | 332198087341902801002908378397341331681305604393325636216732139611602513574071\ 2936 | 212710180247989007537275720299680214541513555156443351223657235715866090574404\ 2937 | 171292626014774807647096057243577664085569522360116456424005461142782974069152\ 2938 | 308312588253749877293323469834249191610820022433363958791965218912990353524401\ 2939 | 878531549484174332860378888221788134380023574375102123631809781741847094824416\ 2940 | 060975498899520408035220936832180170135947065885169913441452353003768292104490\ 2941 | ", " ", 2942 | SuperscriptBox["x", "5"]}], "-", 2943 | RowBox[{ 2944 | "4745803675609975726334924098366778553262509506813188847334189126116312172\ 2945 | 784533438532241438299568698432185966059542515730948751872866753991530908505421\ 2946 | 307892117301291481459611000386437900221514674561922853619079096997398799357961\ 2947 | 653702030020896548289731061034315416127956249775670049451144753226608313439487\ 2948 | 230011244414779331651139625264054545631265793913486154792734464878948160590880\ 2949 | 891697789870204940747617076549461998446927424854267569807790356103505647468972\ 2950 | 671732286003494667371191144779906574138873782526988650783945907989972359536946\ 2951 | ", " ", 2952 | SuperscriptBox["x", "6"]}], "-", 2953 | RowBox[{ 2954 | "5133420937600038603489259476011606252066677953720367518041455376376185998\ 2955 | 365530640224459261563304241469999019829003668071923519161608611453267766873490\ 2956 | 529480812776445854736485494905996894458507269040043252670837280834389406881608\ 2957 | 568996263484724107462548499691801680145960552308163264283957571014571654085668\ 2958 | 040036059441318049226353161523166866263235317607739917303814748835788520041389\ 2959 | 767388998068178736216191036307229045293074800391318866063233231735664266718410\ 2960 | 47088289979390628319559087137188806425140170443657532347057390215827542358854"\ 2961 | , " ", 2962 | SuperscriptBox["x", "7"]}]}]}], 2963 | SequenceForm[ 2964 | "z = ", 18606277901293954094967235807851381974585543962199228364315247640705\ 2965 | 777977846731060809310234821892869492661676611193880457204490086144293816471825\ 2966 | 116519778066972221698309970728708911262314000421163766373540757231958840263073\ 2967 | 313595877059483645859597604226057923740637544601310063157884412946828244993674\ 2968 | 124956894072765359397550896136545270858917546751663320746891548761478740746590\ 2969 | 528028098516839245860427500465258891970463066997294689323653222057859273299016\ 2970 | 088729161802995212577754628112905874743824909332553965001450370372556337917880\ 2971 | 4441 + 52263270229290974507253710712306648006633760356937274638724822418494869\ 2972 | 810256971838086438763991664591085958270556322976828883509546857397029647326676\ 2973 | 546804266721433776950877823856062908300955912163524939845437507754738848823476\ 2974 | 646586391767695414082511553201388104990413623185902552295729675045237693395175\ 2975 | 879555037869876047140895638099159685515629121696206487529529925558336862191060\ 2976 | 454048084665843549720864920194895866931268935627194244590603499243026797081595\ 2977 | 156615581537048536845345577952734614436285708156757266198188691073593311587206\ 2978 | 10 $CellContext`x - 2979 | 127695818389815340732093009702506144702464224167825290026441592856427419174\ 2980 | 988598563745818909354468888568849499542169534273106796663383066706732781477635\ 2981 | 099389789098919170416337873626769342636961145911014509286419628805362343470743\ 2982 | 797256789388061992679700049947018641891861136882650189082558349856349754198782\ 2983 | 676893892259777454287093114242655166684663935589744325957425186285773481032540\ 2984 | 491682557489823696759252292547321271079842641694055633884812819300962265679621\ 2985 | 807436811639381408080371899482277099052541508325732708158304209307929887618 \ 2986 | $CellContext`x^2 + 2987 | 127914077404453552058835672233691136232993727512529538638645628707506831578\ 2988 | 793432006389551387950116169991633164081026179347165375006621252718583763190575\ 2989 | 295194763317682838138244516424461838014209332052355797350813732661502104452303\ 2990 | 088652359769442056085522958528573452416052598931182443988587591620784305114846\ 2991 | 606049271779325439072745215582095571805364204581736506295751295955931072352023\ 2992 | 028356832941252955564944694802710020317123399048708289815773780265036732019994\ 2993 | 8687433872965427809790557291309439495678884346790648360856688602403320212706 \ 2994 | $CellContext`x^3 + 2995 | 184118755896738224552960228015809239659368554433519773605729502961086895590\ 2996 | 363809559367882455249673992904489141655795653782728026030435308866341941777258\ 2997 | 651100222753319071453072860597421197815385379386452582095048082828013348477987\ 2998 | 987726029651164485247298091594939855576368082937467058632680167565598029784896\ 2999 | 903113738968996403743561863382969948193280208191979946084015211046235319800716\ 3000 | 434240401705653486229591071654731942027994125918015223580824824149060748942548\ 3001 | 7249046277055420534857448793211975015478744341510786978089846968886748623796 \ 3002 | $CellContext`x^4 - 3003 | 298909297409613469928752275008234475460986614065620828531645199639072998533\ 3004 | 219808734190280100290837839734133168130560439332563621673213961160251357407121\ 3005 | 271018024798900753727572029968021454151355515644335122365723571586609057440417\ 3006 | 129262601477480764709605724357766408556952236011645642400546114278297406915230\ 3007 | 831258825374987729332346983424919161082002243336395879196521891299035352440187\ 3008 | 853154948417433286037888822178813438002357437510212363180978174184709482441606\ 3009 | 0975498899520408035220936832180170135947065885169913441452353003768292104490 \ 3010 | $CellContext`x^5 - 3011 | 474580367560997572633492409836677855326250950681318884733418912611631217278\ 3012 | 453343853224143829956869843218596605954251573094875187286675399153090850542130\ 3013 | 789211730129148145961100038643790022151467456192285361907909699739879935796165\ 3014 | 370203002089654828973106103431541612795624977567004945114475322660831343948723\ 3015 | 001124441477933165113962526405454563126579391348615479273446487894816059088089\ 3016 | 169778987020494074761707654946199844692742485426756980779035610350564746897267\ 3017 | 1732286003494667371191144779906574138873782526988650783945907989972359536946 \ 3018 | $CellContext`x^6 - 3019 | 513342093760003860348925947601160625206667795372036751804145537637618599836\ 3020 | 553064022445926156330424146999901982900366807192351916160861145326776687349052\ 3021 | 948081277644585473648549490599689445850726904004325267083728083438940688160856\ 3022 | 899626348472410746254849969180168014596055230816326428395757101457165408566804\ 3023 | 003605944131804922635316152316686626323531760773991730381474883578852004138976\ 3024 | 738899806817873621619103630722904529307480039131886606323323173566426671841047\ 3025 | 088289979390628319559087137188806425140170443657532347057390215827542358854 \ 3026 | $CellContext`x^7], 3027 | Editable->False]], "Print", 3028 | CellChangeTimes->{ 3029 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 3030 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 3031 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 3032 | 3.5005412073332767`*^9}], 3033 | 3034 | Cell[BoxData[ 3035 | InterpretationBox[ 3036 | RowBox[{"\<\"G/p: \"\>", "\[InvisibleSpace]", 3037 | RowBox[{ 3038 | RowBox[{"(", 3039 | RowBox[{ 3040 | RowBox[{ 3041 | "-", "107493382441220578583068405534777301375107883635956109177596665099\ 3042 | 458901227695"}], "+", 3043 | RowBox[{ 3044 | "31810837069535115646009361831136028582740027235500413973792200468412115\ 3045 | 177870", " ", "x"}], "+", 3046 | RowBox[{ 3047 | "71065913259136879899311556577208324788924955300858900251035742041123349\ 3048 | 716346", " ", 3049 | SuperscriptBox["x", "2"]}], "+", 3050 | RowBox[{ 3051 | "72688652456327974496755954258563870359449131720646191060199575414348797\ 3052 | 668558", " ", 3053 | SuperscriptBox["x", "3"]}], "+", 3054 | RowBox[{ 3055 | "71429375151620777497704783504066309427036088980352534392789761689602887\ 3056 | 40348", " ", 3057 | SuperscriptBox["x", "4"]}], "-", 3058 | RowBox[{ 3059 | "11299280524528604605960672870828375886757487436723748613088956021972184\ 3060 | 3913462", " ", 3061 | SuperscriptBox["x", "5"]}], "+", 3062 | RowBox[{ 3063 | "32565686091734612263107365726690080715567822978529262411068294166474106\ 3064 | 623498", " ", 3065 | SuperscriptBox["x", "6"]}], "-", 3066 | RowBox[{ 3067 | "10420229012670635888325400009497157785486432866507031315805054688086377\ 3068 | 3827642", " ", 3069 | SuperscriptBox["x", "7"]}]}], ")"}], "/", 3070 | "1231003300305270537067062428503061694116823921725847525986787482316038415\ 3071 | 803511484470857413004091186247621369576387526271921897136843416838879890078358\ 3072 | 139917392729457152365812854453190896388919514975602601092704698606103324527587\ 3073 | 914520623059981626907369071722278607243935201409676852119503548921535303053967\ 3074 | 473633615900032374774136045835832601751925671953291571409211286875721070369254\ 3075 | 312932526091178899240811583386050533342849190516462545039133603597851465115909\ 3076 | 436968438785504390959970456245524633772275342566512584842955003830821323505427\ 3077 | 989527454756799044898773585305778377574958277881195844180596507531084561788769\ 3078 | "}]}], 3079 | SequenceForm[ 3080 | "G/p: ", 3081 | Rational[1, 3082 | 1231003300305270537067062428503061694116823921725847525986787482316038415\ 3083 | 803511484470857413004091186247621369576387526271921897136843416838879890078358\ 3084 | 139917392729457152365812854453190896388919514975602601092704698606103324527587\ 3085 | 914520623059981626907369071722278607243935201409676852119503548921535303053967\ 3086 | 473633615900032374774136045835832601751925671953291571409211286875721070369254\ 3087 | 312932526091178899240811583386050533342849190516462545039133603597851465115909\ 3088 | 436968438785504390959970456245524633772275342566512584842955003830821323505427\ 3089 | 989527454756799044898773585305778377574958277881195844180596507531084561788769\ 3090 | ] (-10749338244122057858306840553477730137510788363595610917759666509945890122\ 3091 | 7695 + 31810837069535115646009361831136028582740027235500413973792200468412115\ 3092 | 177870 $CellContext`x + 3093 | 71065913259136879899311556577208324788924955300858900251035742041123349716\ 3094 | 346 $CellContext`x^2 + 3095 | 72688652456327974496755954258563870359449131720646191060199575414348797668\ 3096 | 558 $CellContext`x^3 + 3097 | 71429375151620777497704783504066309427036088980352534392789761689602887403\ 3098 | 48 $CellContext`x^4 - 3099 | 11299280524528604605960672870828375886757487436723748613088956021972184391\ 3100 | 3462 $CellContext`x^5 + 3101 | 32565686091734612263107365726690080715567822978529262411068294166474106623\ 3102 | 498 $CellContext`x^6 - 3103 | 10420229012670635888325400009497157785486432866507031315805054688086377382\ 3104 | 7642 $CellContext`x^7)], 3105 | Editable->False]], "Print", 3106 | CellChangeTimes->{ 3107 | 3.497598026184266*^9, 3.4996814924279222`*^9, {3.5005384041545277`*^9, 3108 | 3.500538425779643*^9}, 3.5005386974045973`*^9, 3.500540155284587*^9, 3109 | 3.5005409627397413`*^9, 3.500541060793895*^9, 3.500541139445302*^9, 3110 | 3.500541207420681*^9}] 3111 | }, Open ]] 3112 | }, Open ]], 3113 | 3114 | Cell[BoxData["PolynomialExtendedGCD"], "Input", 3115 | CellChangeTimes->{{3.500542777827376*^9, 3.500542782382269*^9}}] 3116 | }, 3117 | WindowToolbars->{}, 3118 | WindowSize->{864, 1152}, 3119 | WindowMargins->{{0, Automatic}, {Automatic, 0}}, 3120 | FrontEndVersion->"7.0 for Mac OS X x86 (32-bit) (November 10, 2008)", 3121 | StyleDefinitions->"Default.nb" 3122 | ] 3123 | (* End of Notebook Content *) 3124 | 3125 | (* Internal cache information *) 3126 | (*CellTagsOutline 3127 | CellTagsIndex->{} 3128 | *) 3129 | (*CellTagsIndex 3130 | CellTagsIndex->{} 3131 | *) 3132 | (*NotebookFileOutline 3133 | Notebook[{ 3134 | Cell[545, 20, 668, 15, 118, "Input"], 3135 | Cell[1216, 37, 95516, 2183, 5765, "Input"], 3136 | Cell[CellGroupData[{ 3137 | Cell[96757, 2224, 141, 3, 27, "Input"], 3138 | Cell[CellGroupData[{ 3139 | Cell[96923, 2231, 1682, 27, 126, "Print"], 3140 | Cell[98608, 2260, 13225, 214, 1082, "Print"], 3141 | Cell[111836, 2476, 11432, 174, 865, "Print"], 3142 | Cell[123271, 2652, 1723, 28, 126, "Print"], 3143 | Cell[124997, 2682, 407, 9, 20, "Print"], 3144 | Cell[125407, 2693, 304, 5, 20, "Print"], 3145 | Cell[125714, 2700, 409, 9, 20, "Print"], 3146 | Cell[126126, 2711, 9902, 150, 869, "Print"], 3147 | Cell[136031, 2863, 306, 5, 20, "Print"], 3148 | Cell[136340, 2870, 409, 9, 20, "Print"], 3149 | Cell[136752, 2881, 9904, 150, 869, "Print"], 3150 | Cell[146659, 3033, 3718, 76, 258, "Print"] 3151 | }, Open ]] 3152 | }, Open ]], 3153 | Cell[150404, 3113, 113, 1, 27, "Input"] 3154 | } 3155 | ] 3156 | *) 3157 | 3158 | (* End of internal cache information *) 3159 | -------------------------------------------------------------------------------- /libScarab1.0.0/integer-fhe.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hcrypt-project/libScarab/2c277089aa1e824f1b7d93d7282e2bb4f0b0a4ab/libScarab1.0.0/integer-fhe.o -------------------------------------------------------------------------------- /libScarab1.0.0/main.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | 6 | #include "test.h" 7 | 8 | int main(int argc, char **argv) 9 | { 10 | test_suite(); 11 | 12 | exit(0); 13 | } 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /libScarab1.0.0/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hcrypt-project/libScarab/2c277089aa1e824f1b7d93d7282e2bb4f0b0a4ab/libScarab1.0.0/main.o -------------------------------------------------------------------------------- /libScarab1.0.0/parameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * parameters.h 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 25.11.10. 6 | * Copyright 2010 Henning Perl. All rights reserved. 7 | * 8 | */ 9 | 10 | #pragma once 11 | #ifndef PARAMETERS_H 12 | #define PARAMETERS_H 13 | 14 | #define N 8 15 | #define MU 4 16 | //#define NU 2**256; 17 | #define LOG_NU 384 18 | #define S1 8 19 | #define S2 5 20 | #define T 5 // Ceiling[Log[2, S2]] + 2 21 | #define S 3 // Floor[Log[2, s2]] + 1 22 | 23 | #endif -------------------------------------------------------------------------------- /libScarab1.0.0/test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * test.c 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 17.12.10. 6 | * 7 | */ 8 | 9 | #include "test.h" 10 | 11 | #define ASSERT_HALFADD(__a,__b,__sum,__carry) \ 12 | fhe_halfadd(sum, carry, __a, __b, pk); \ 13 | assert(fhe_decrypt(sum, sk) == __sum); \ 14 | assert(fhe_decrypt(carry, sk) == __carry); 15 | 16 | #define ASSERT_FULLADD(__a,__b,__c,__sum,__carry) \ 17 | fhe_fulladd(sum, carry, __a, __b, __c, pk); \ 18 | assert(fhe_decrypt(sum, sk) == __sum); \ 19 | assert(fhe_decrypt(carry, sk) == __carry); 20 | 21 | #define ASSERT_HOMMUL(__a, __b, __check) \ 22 | fhe_mul(temp, __a, __b, pk); \ 23 | assert(fhe_decrypt(temp, sk) == __check); 24 | 25 | #define ASSERT_HOMADD(__a, __b, __check) \ 26 | fhe_add(temp, __a, __b, pk); \ 27 | assert(fhe_decrypt(temp, sk) == __check); 28 | 29 | void 30 | test_suite() 31 | { 32 | test_fully_homomorphic(); 33 | test_homomorphic(); 34 | test_recrypt(); 35 | test_encryt_decrypt(); 36 | test_halfadd(); 37 | test_fulladd(); 38 | } 39 | 40 | void 41 | test_encryt_decrypt() 42 | { 43 | printf("ENCRYPT/DECRYPT\n"); 44 | int m0, m1; 45 | mpz_t c0, c1; 46 | 47 | mpz_init(c0); 48 | mpz_init(c1); 49 | 50 | fhe_pk_t pk; 51 | fhe_sk_t sk; 52 | fhe_pk_init(pk); 53 | fhe_sk_init(sk); 54 | 55 | for (int i = 0; i < KEYRUNS; i++) { 56 | fhe_keygen(pk, sk); 57 | 58 | for (int j = 0; j < RUNS; j++) { 59 | fhe_encrypt(c0, pk, 0); 60 | m0 = fhe_decrypt(c0, sk); 61 | fhe_encrypt(c1, pk, 1); 62 | m1 = fhe_decrypt(c1, sk); 63 | 64 | assert(m0 == 0); 65 | assert(m1 == 1); 66 | printf("."); 67 | fflush(stdout); 68 | } 69 | printf("\n"); 70 | } 71 | fhe_pk_clear(pk); 72 | fhe_sk_clear(sk); 73 | mpz_clear(c0); 74 | mpz_clear(c1); 75 | printf("PASSED.\n"); 76 | } 77 | 78 | 79 | void 80 | test_halfadd() 81 | { 82 | printf("HALFADD\n"); 83 | mpz_t c0, c1; 84 | mpz_t sum, carry; 85 | 86 | mpz_init(c0); 87 | mpz_init(c1); 88 | mpz_init(sum); 89 | mpz_init(carry); 90 | 91 | fhe_pk_t pk; 92 | fhe_sk_t sk; 93 | fhe_pk_init(pk); 94 | fhe_sk_init(sk); 95 | 96 | for (int i = 0; i < KEYRUNS; i++) { 97 | fhe_keygen(pk, sk); 98 | 99 | fhe_encrypt(c0, pk, 0); 100 | fhe_encrypt(c1, pk, 1); 101 | 102 | ASSERT_HALFADD(c0,c0,0,0); 103 | ASSERT_HALFADD(c1,c0,1,0); 104 | ASSERT_HALFADD(c0,c1,1,0); 105 | ASSERT_HALFADD(c1,c1,0,1); 106 | printf("."); 107 | fflush(stdout); 108 | } 109 | fhe_pk_clear(pk); 110 | fhe_sk_clear(sk); 111 | mpz_clear(sum); 112 | mpz_clear(carry); 113 | mpz_clear(c0); 114 | mpz_clear(c1); 115 | printf(" PASSED.\n"); 116 | } 117 | 118 | 119 | void 120 | test_fulladd() 121 | { 122 | printf("FULLADD\n"); 123 | mpz_t c0, c1; 124 | mpz_t sum, carry; 125 | 126 | mpz_init(c0); 127 | mpz_init(c1); 128 | mpz_init(sum); 129 | mpz_init(carry); 130 | 131 | fhe_pk_t pk; 132 | fhe_sk_t sk; 133 | fhe_pk_init(pk); 134 | fhe_sk_init(sk); 135 | 136 | for (int i = 0; i < KEYRUNS; i++) { 137 | fhe_keygen(pk, sk); 138 | 139 | fhe_encrypt(c0, pk, 0); 140 | fhe_encrypt(c1, pk, 1); 141 | 142 | ASSERT_FULLADD(c0,c0,c0,0,0); 143 | ASSERT_FULLADD(c1,c0,c0,1,0); 144 | ASSERT_FULLADD(c0,c1,c0,1,0); 145 | ASSERT_FULLADD(c1,c1,c0,0,1); 146 | ASSERT_FULLADD(c0,c0,c1,1,0); 147 | ASSERT_FULLADD(c1,c0,c1,0,1); 148 | ASSERT_FULLADD(c0,c1,c1,0,1); 149 | ASSERT_FULLADD(c1,c1,c1,1,1); 150 | printf("."); 151 | fflush(stdout); 152 | } 153 | fhe_pk_clear(pk); 154 | fhe_sk_clear(sk); 155 | mpz_clear(sum); 156 | mpz_clear(carry); 157 | mpz_clear(c0); 158 | mpz_clear(c1); 159 | printf(" PASSED.\n"); 160 | } 161 | 162 | 163 | void 164 | test_recrypt() 165 | { 166 | printf("RECRYPT\n"); 167 | 168 | mpz_t c0, c1; 169 | 170 | mpz_init(c0); 171 | mpz_init(c1); 172 | 173 | fhe_pk_t pk; 174 | fhe_sk_t sk; 175 | fhe_pk_init(pk); 176 | fhe_sk_init(sk); 177 | 178 | for (int i = 0; i < KEYRUNS; i++) { 179 | fhe_keygen(pk, sk); 180 | 181 | for (int j = 0; j < RUNS; j++) { 182 | fhe_encrypt(c0, pk, 0); 183 | fhe_encrypt(c1, pk, 1); 184 | 185 | fhe_recrypt(c0, pk); 186 | assert(fhe_decrypt(c0, sk) == 0); 187 | 188 | fhe_recrypt(c1, pk); 189 | assert(fhe_decrypt(c1, sk) == 1); 190 | 191 | printf("."); 192 | fflush(stdout); 193 | } 194 | printf("\n"); 195 | } 196 | fhe_pk_clear(pk); 197 | fhe_sk_clear(sk); 198 | mpz_clear(c0); 199 | mpz_clear(c1); 200 | printf("PASSED.\n"); 201 | } 202 | 203 | 204 | void 205 | test_homomorphic() 206 | { 207 | printf("HOMOMORPHIC (w/o recrypt)\n"); 208 | 209 | int m; 210 | mpz_t c0, c1, temp; 211 | 212 | mpz_init(c0); 213 | mpz_init(c1); 214 | mpz_init(temp); 215 | 216 | fhe_pk_t pk; 217 | fhe_sk_t sk; 218 | fhe_pk_init(pk); 219 | fhe_sk_init(sk); 220 | 221 | for (int i = 0; i < KEYRUNS; i++) { 222 | mpz_t c0, c1; 223 | 224 | mpz_init(c0); 225 | mpz_init(c1); 226 | 227 | fhe_pk_t pk; 228 | fhe_sk_t sk; 229 | fhe_pk_init(pk); 230 | fhe_sk_init(sk); 231 | 232 | fhe_keygen(pk, sk); 233 | fhe_encrypt(c0, pk, 0); 234 | printf("\nadd-chain: "); 235 | for (int j = 0; j < RUNS*RUNS; j++) { 236 | fhe_add(c0, c0, c0, pk); 237 | m = fhe_decrypt(c0, sk); 238 | printf("%i", m); 239 | fflush(stdout); 240 | } 241 | fhe_encrypt(c1, pk, 1); 242 | printf("\nmul-chain: "); 243 | for (int j = 0; j < RUNS*RUNS; j++) { 244 | fhe_mul(c1, c1, c1, pk); 245 | m = fhe_decrypt(c1, sk); 246 | printf("%i", m); 247 | fflush(stdout); 248 | } 249 | printf("\n"); 250 | } 251 | 252 | fhe_pk_clear(pk); 253 | fhe_sk_clear(sk); 254 | mpz_clear(c0); 255 | mpz_clear(c1); 256 | mpz_clear(temp); 257 | 258 | printf("PASSED.\n"); 259 | } 260 | 261 | void 262 | test_fully_homomorphic() 263 | { 264 | printf("FULLY HOMOMORPHIC (with recrypt)\n"); 265 | 266 | int m; 267 | mpz_t c0, c1, temp; 268 | 269 | mpz_init(c0); 270 | mpz_init(c1); 271 | mpz_init(temp); 272 | 273 | fhe_pk_t pk; 274 | fhe_sk_t sk; 275 | fhe_pk_init(pk); 276 | fhe_sk_init(sk); 277 | 278 | for (int i = 0; i < KEYRUNS; i++) { 279 | mpz_t c0, c1; 280 | 281 | mpz_init(c0); 282 | mpz_init(c1); 283 | 284 | fhe_pk_t pk; 285 | fhe_sk_t sk; 286 | fhe_pk_init(pk); 287 | fhe_sk_init(sk); 288 | 289 | fhe_keygen(pk, sk); 290 | fhe_encrypt(c0, pk, 0); 291 | printf("\nadd-chain: "); 292 | for (int j = 0; j < RUNS*RUNS; j++) { 293 | fhe_add(c0, c0, c0, pk); 294 | fhe_recrypt(c0, pk); 295 | m = fhe_decrypt(c0, sk); 296 | printf("%i", m); 297 | fflush(stdout); 298 | } 299 | fhe_encrypt(c1, pk, 1); 300 | printf("\nmul-chain: "); 301 | for (int j = 0; j < RUNS*RUNS; j++) { 302 | fhe_mul(c1, c1, c1, pk); 303 | fhe_recrypt(c1, pk); 304 | m = fhe_decrypt(c1, sk); 305 | printf("%i", m); 306 | fflush(stdout); 307 | } 308 | printf("\n"); 309 | } 310 | 311 | fhe_pk_clear(pk); 312 | fhe_sk_clear(sk); 313 | mpz_clear(c0); 314 | mpz_clear(c1); 315 | mpz_clear(temp); 316 | 317 | printf("PASSED.\n"); 318 | } -------------------------------------------------------------------------------- /libScarab1.0.0/test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * test.h 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 17.12.10. 6 | * 7 | */ 8 | 9 | #pragma once 10 | #ifndef TEST_H 11 | #define TEST_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include "integer-fhe.h" 17 | 18 | #define RUNS 50 19 | #define KEYRUNS 10 20 | 21 | void test_encryt_decrypt(); 22 | 23 | void test_halfadd(); 24 | 25 | void test_fulladd(); 26 | 27 | void test_recrypt(); 28 | 29 | void test_homomorphic(); 30 | 31 | void test_fully_homomorphic(); 32 | 33 | void test_suite(); 34 | 35 | #endif -------------------------------------------------------------------------------- /libScarab1.0.0/test.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hcrypt-project/libScarab/2c277089aa1e824f1b7d93d7282e2bb4f0b0a4ab/libScarab1.0.0/test.o -------------------------------------------------------------------------------- /libScarab1.0.0/types.c: -------------------------------------------------------------------------------- 1 | /* 2 | * types.c 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 25.11.10. 6 | * Copyright 2010 Henning Perl. All rights reserved. 7 | * 8 | */ 9 | 10 | #include "types.h" 11 | 12 | 13 | /** memory management **/ 14 | 15 | void fhe_pk_init(fhe_pk_t pk) 16 | { 17 | mpz_init(pk->p); 18 | mpz_init(pk->alpha); 19 | for (int i = 0; i < S1; i++) { 20 | mpz_init(pk->B[i]); 21 | mpz_init(pk->c[i]); 22 | } 23 | } 24 | 25 | 26 | void fhe_pk_clear(fhe_pk_t pk) 27 | { 28 | mpz_clear(pk->p); 29 | mpz_clear(pk->alpha); 30 | for (int i = 0; i < S1; i++) { 31 | mpz_clear(pk->B[i]); 32 | mpz_clear(pk->c[i]); 33 | } 34 | } 35 | 36 | 37 | void fhe_sk_init(fhe_sk_t sk) 38 | { 39 | mpz_init(sk->p); 40 | mpz_init(sk->B); 41 | } 42 | 43 | 44 | void fhe_sk_clear(fhe_sk_t sk) 45 | { 46 | mpz_clear(sk->p); 47 | mpz_clear(sk->B); 48 | } 49 | 50 | /** output **/ 51 | 52 | void fhe_pk_print(fhe_pk_t pk) 53 | { 54 | printf("public key:\n"); 55 | gmp_printf("\tp =\t%Zd\n", pk->p); 56 | gmp_printf("\tα =\t%Zd\n", pk->alpha); 57 | printf("\tc[i]\tB[i]\n"); 58 | for (int i = 0; i < S1; i++) { 59 | gmp_printf("\t%Zd\n\t\t%Zd\n", pk->c[i], pk->B[i]); 60 | } 61 | } 62 | 63 | void fhe_pk_print_mathematica(fhe_pk_t pk) 64 | { 65 | printf("public key:\n"); 66 | gmp_printf("{%Zd, %Zd, %i, %i, {{", pk->p, pk->alpha, S1, S2); 67 | for (int i = 0; i < S1; i++) { 68 | gmp_printf("%Zd", pk->c[i]); 69 | if (i < S1-1) { 70 | printf(", "); 71 | } 72 | } 73 | printf("}, {"); 74 | for (int i = 0; i < S1; i++) { 75 | gmp_printf("%Zd", pk->B[i]); 76 | if (i < S1-1) { 77 | printf(", "); 78 | } } 79 | printf("}}}\n"); 80 | } 81 | 82 | void fhe_sk_print(fhe_sk_t sk) 83 | { 84 | printf("secret key:\n"); 85 | gmp_printf("\tp =\t%Zd\n", sk->p); 86 | gmp_printf("\tB =\t%Zd\n", sk->B); 87 | } 88 | 89 | void fhe_sk_print_mathematica(fhe_sk_t sk) 90 | { 91 | printf("secret key:\n"); 92 | gmp_printf("{%Zd, %Zd}\n", sk->p, sk->B); 93 | } 94 | -------------------------------------------------------------------------------- /libScarab1.0.0/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * types.h 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 25.11.10. 6 | * Copyright 2010 Henning Perl. All rights reserved. 7 | * 8 | */ 9 | 10 | #pragma once 11 | #ifndef TYPES_H 12 | #define TYPES_H 13 | 14 | #include 15 | #include 16 | #include "parameters.h" 17 | 18 | /** type defs **/ 19 | typedef struct { 20 | mpz_t p, alpha; 21 | mpz_t c[S1], B[S1]; 22 | } _fhe_pk; 23 | typedef _fhe_pk fhe_pk_t[1]; 24 | 25 | typedef struct { 26 | mpz_t p, B; 27 | } _fhe_sk; 28 | typedef _fhe_sk fhe_sk_t[1]; 29 | 30 | /** memory management **/ 31 | 32 | void fhe_pk_init(fhe_pk_t pk); 33 | 34 | void fhe_pk_clear(fhe_pk_t pk); 35 | 36 | void fhe_sk_init(fhe_sk_t sk); 37 | 38 | void fhe_sk_clear(fhe_sk_t sk); 39 | 40 | /** output **/ 41 | 42 | void fhe_pk_print(fhe_pk_t pk); 43 | 44 | void fhe_sk_print(fhe_sk_t sk); 45 | 46 | #endif -------------------------------------------------------------------------------- /libScarab1.0.0/types.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hcrypt-project/libScarab/2c277089aa1e824f1b7d93d7282e2bb4f0b0a4ab/libScarab1.0.0/types.o -------------------------------------------------------------------------------- /libScarab1.0.0/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * util.c 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 27.11.10. 6 | * Copyright 2010 Henning Perl. All rights reserved. 7 | * 8 | */ 9 | 10 | #include "util.h" 11 | 12 | int 13 | min(int a, int b) 14 | { 15 | return (alength == 0) 77 | { 78 | if (poly2->length == 0) 79 | F_mpz_mod_poly_zero(res); 80 | else F_mpz_mod_poly_make_monic(res, poly2); 81 | return; 82 | } 83 | 84 | if (poly2->length == 0) 85 | { 86 | F_mpz_mod_poly_make_monic(res, poly1); 87 | return; 88 | } 89 | 90 | if ((poly1->length == 1) || (poly2->length == 1)) 91 | { 92 | _F_mpz_poly_attach_F_mpz_mod_poly(r, res); 93 | F_mpz_poly_set_coeff_ui(r, 0, 1L); 94 | _F_mpz_mod_poly_attach_F_mpz_poly(res, r); 95 | _F_mpz_mod_poly_normalise(res); 96 | return; 97 | } 98 | 99 | F_mpz_t P; 100 | F_mpz_init(P); 101 | F_mpz_set(P, poly1->P); 102 | 103 | F_mpz_mod_poly_init(R, P); 104 | 105 | if (poly1->length > poly2->length) 106 | { 107 | _F_mpz_mod_poly_attach(A, poly1); 108 | _F_mpz_mod_poly_attach(B, poly2); 109 | } else 110 | { 111 | _F_mpz_mod_poly_attach(A, poly2); 112 | _F_mpz_mod_poly_attach(B, poly1); 113 | } 114 | 115 | F_mpz_mod_poly_rem(R, A, B); 116 | 117 | F_mpz_mod_poly_swap(A, B); 118 | F_mpz_mod_poly_swap(B, R); 119 | F_mpz_mod_poly_init(R, P); 120 | 121 | if (B->length > 1) 122 | { 123 | F_mpz_mod_poly_rem(R, A, B); 124 | F_mpz_mod_poly_swap(A, B); 125 | F_mpz_mod_poly_swap(B, R); 126 | F_mpz_mod_poly_init(R, P); 127 | steps = 1; 128 | } 129 | 130 | while (B->length > 1) 131 | { 132 | F_mpz_mod_poly_rem(A, A, B); 133 | F_mpz_mod_poly_swap(A, B); 134 | } 135 | 136 | if (B->length == 1) 137 | { 138 | _F_mpz_poly_attach_F_mpz_mod_poly(r, res); 139 | F_mpz_poly_set_coeff_ui(r, 0, 1L); 140 | _F_mpz_mod_poly_attach_F_mpz_poly(res, r); 141 | res->length = 1; 142 | } 143 | else F_mpz_mod_poly_make_monic(res, A); 144 | 145 | if (steps) 146 | { 147 | F_mpz_mod_poly_clear(A); 148 | } 149 | 150 | F_mpz_mod_poly_clear(B); 151 | F_mpz_mod_poly_clear(R); 152 | } 153 | 154 | 155 | void F_mpz_mod_poly_make_monic(F_mpz_mod_poly_t output, F_mpz_mod_poly_t pol) 156 | { 157 | if (!pol->length) 158 | { 159 | output->length = 0; 160 | return; 161 | } 162 | 163 | F_mpz_t *lead_coeff = (F_mpz_t *)&pol->coeffs[pol->length-1]; 164 | 165 | if (F_mpz_is_one(*lead_coeff)) 166 | { 167 | F_mpz_mod_poly_set(output, pol); 168 | return; 169 | } 170 | F_mpz_t lead_inv; 171 | F_mpz_init(lead_inv); 172 | 173 | F_mpz_invert(lead_inv, *lead_coeff, pol->P); 174 | F_mpz_mod_poly_scalar_mul(output, pol, lead_inv); 175 | } -------------------------------------------------------------------------------- /libScarab1.0.0/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * util.h 3 | * integer-fhe 4 | * 5 | * Created by Henning Perl on 27.11.10. 6 | * Copyright 2010 Henning Perl. All rights reserved. 7 | * 8 | */ 9 | 10 | #pragma once 11 | #ifndef UTIL_H 12 | #define UTIL_H 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | int min(int a, int b); 19 | 20 | void fmpz_poly_to_F_mpz_mod_poly(F_mpz_mod_poly_t out, fmpz_poly_t in); 21 | 22 | void fmpz_poly_rand_coeff_even(fmpz_poly_t poly, int n, ulong length, gmp_randstate_t* state); 23 | 24 | int fmpz_probab_prime_p(fmpz_t n, int reps); 25 | 26 | void F_mpz_mod_poly_gcd_euclidean(F_mpz_mod_poly_t res, F_mpz_mod_poly_t poly1, F_mpz_mod_poly_t poly2); 27 | 28 | static inline 29 | void _F_mpz_mod_poly_attach(F_mpz_mod_poly_t out, const F_mpz_mod_poly_t in) 30 | { 31 | out->coeffs = in->coeffs; 32 | out->length = in->length; 33 | out->alloc = in->alloc; 34 | *(out->P) = *(in->P); 35 | } 36 | 37 | void F_mpz_mod_poly_make_monic(F_mpz_mod_poly_t output, F_mpz_mod_poly_t pol); 38 | 39 | #endif -------------------------------------------------------------------------------- /libScarab1.0.0/util.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hcrypt-project/libScarab/2c277089aa1e824f1b7d93d7282e2bb4f0b0a4ab/libScarab1.0.0/util.o --------------------------------------------------------------------------------