### D.12.3 crypto_lib

Library:
  crypto.lib
Purpose:
  Procedures for teaching cryptography
Authors:
  Gerhard Pfister, pfister@mathematik.uni-kl.de
  David Brittinger, dativ@gmx.net

Overview:
  The library contains procedures to compute the discrete logarithm, primality-tests, factorization included elliptic curves. The library is intended to be used for teaching purposes but not for serious computations. Sufficiently high printlevel allows to control each step, thus illustrating the algorithms at work.

Procedures:

> D.12.3.1 decimal |  | number corresponding to the hexadecimal number s
> D.12.3.2 eexgcdN |  | T with sum_i L[i]*T[i]=T[n+1]=gcd(L[1],...,L[n])
> D.12.3.3 lcmN |  | compute lcm(a,b)
> D.12.3.4 powerN |  | compute m^d mod n
> D.12.3.5 chineseRem |  | compute x such that x = T[i] mod L[i]
> D.12.3.6 Jacobi |  | the generalized Legendre symbol of a and n
> D.12.3.7 primList |  | the list of all primes <=n
> D.12.3.8 primL |  | first primes p_1,...,p_r such that q<p_1*...*p_r
> D.12.3.9 intPart |  | the integral part of a rational number
> D.12.3.10 intRoot |  | the integral part of the square root of m
> D.12.3.11 squareRoot |  | the square root of a in Z/p, p prime
> D.12.3.12 solutionsMod2 |  | basis solutions of Mx=0 over Z/2
> D.12.3.13 powerX |  | q-th power of the i-th variable modulo I
> D.12.3.14 babyGiant |  | discrete logarithm x: b^x=y mod p
> D.12.3.15 rho |  | discrete logarithm x: b^x=y mod p
> D.12.3.16 MillerRabin |  | probabilistic primaly-test of Miller-Rabin
> D.12.3.17 SolowayStrassen |  | probabilistic primaly-test of Soloway-Strassen
> D.12.3.18 PocklingtonLehmer |  | primaly-test of Pocklington-Lehmer
> D.12.3.19 PollardRho |  | Pollard's rho factorization
> D.12.3.20 pFactor |  | Pollard's p-factorization
> D.12.3.21 quadraticSieve |  | quadratic sieve factorization
> D.12.3.22 isOnCurve |  | P is on the curve y^2z=x^3+a*xz^2+b*z^3 over Z/N
> D.12.3.23 ellipticAdd |  | P+Q, addition on elliptic curves
> D.12.3.24 ellipticMult |  | k*P on elliptic curves
> D.12.3.25 ellipticRandomCurve |  | generates y^2z=x^3+a*xz^2+b*z^3 over Z/N randomly
> D.12.3.26 ellipticRandomPoint |  | random point on y^2z=x^3+a*xz^2+b*z^3 over Z/N
> D.12.3.27 countPoints |  | number of points of y^2=x^3+a*x+b over Z/N
> D.12.3.28 ellipticAllPoints |  | points of y^2=x^3+a*x+b over Z/N
> D.12.3.29 ShanksMestre |  | number of points of y^2=x^3+a*x+b over Z/N
> D.12.3.30 Schoof |  | number of points of y^2=x^3+a*x+b over Z/N
> D.12.3.31 generateG |  | m-th division polynomial of y^2=x^3+a*x+b over Z/N
> D.12.3.32 factorLenstraECM |  | Lenstra's factorization
> D.12.3.33 ECPP |  | primaly-test of Goldwasser-Kilian
> D.12.3.34 calculate_ordering |  | Calculates x so that primitive^x == num1 mod mod1
> D.12.3.35 is_primitive_root |  | Checks if primitive is a primitive root modulo mod1
> D.12.3.36 find_first_primitive_root |  | Returns the first primitive root modulo mod1, starting with 1
> D.12.3.37 binary_add |  | Adds a 1 to a binary encoded list
> D.12.3.38 inverse_modulus |  | Finds a t so that t*num = 1 mod mod1
> D.12.3.39 is_prime |  | Checks if n is prime proc find_biggest_index(a) Returns the index of the biggest element of a
> D.12.3.40 find_index |  | Returns the list index of element e in list a. Returns 0 if e is not in a
> D.12.3.41 subset_sum01 |  | solves the subset-sum-knapsack-problem by calculating all subsets and choosing the right solution
> D.12.3.42 subset_sum02 |  | solves the subset-sum-knapsack-problem with a naive greedy algorithm
> D.12.3.43 unbounded_knapsack |  | solves the unbounded_knapsack-problem, needing a list of knapsack weights, a list of profits and a capacity
> D.12.3.44 multidimensional_knapsack |  | solves the multidimensional_knapsack-problem by using the PECH algorithm, needing a weight matrix m, a list of capacities and a list of profits
> D.12.3.45 naccache_stern_generation |  | generates a hard knapsack for the Naccache-Stern Kryptosystem for given key and prime modulus
> D.12.3.46 naccache_stern_encryption |  | encrypts a message with the Naccache-Stern Kryptosystem, using a hard knapsack, a message encoded as binary list and a prime modulus
> D.12.3.47 naccache_stern_decryption |  | decrypts a message with the Naccache-Stern Kryptosystem, using the easy knapsack, the key, the prime modulus and the message encoded as integer
> D.12.3.48 m_merkle_hellman_transformation |  | generates a hard knapsack for the multiplicative Merkle-Hellman Kryptosystem for a given easy knapsack and a primitive root for a modulus mod1
> D.12.3.49 m_merkle_hellman_encryption |  | encrypts a message with the multiplicative Merkle-Hellman Kryptosystem, using a hard knapsack and a message encoded as binary list

> D.12.3.50 m_merkle_hellman_decryption

> decrypts a message with the multiplicative Merkle-Hellman Kryptosystem, using the easy knapsack, the key given by the primitive root, the modulus mod1 and the message encoded as integer merkle_hellman_transformation(list knapsack, int key, int mod1 generates a hard knapsack for the Merkle-Hellman Kryptosystem for a given easy knapsack , a multiplicator key and a modulus mod1

> D.12.3.51 merkle_hellman_encryption |  | encrypts a message with the Merkle-Hellman Kryptosystem, using a hard knapsack and a message encoded as binary list
> D.12.3.52 merkle_hellman_decryption |  | decrypts a message with the multiplicative Merkle-Hellman Kryptosystem, using the hard knapsack, the key, the modulus mod1 and the message encoded as integer
> D.12.3.53 super_increasing_knapsack |  | Creates the smallest super-increasing knapsack of given size ksize
> D.12.3.54 h_increasing_knapsack |  | Creates the smallest h-increasing knapsack of given size ksize and h
> D.12.3.55 injective_knapsack |  | Creates all list of all injective knapsacks of given size ksize and maximal element kmaxelement
> D.12.3.56 calculate_max_sum |  | Calculates the maximal sum of a given knapsack a
> D.12.3.57 set_is_injective |  | Checks if knapsack a is injective
> D.12.3.58 is_h_injective |  | Checks if knapsack a is h-injective
> D.12.3.59 is_fix_injective |  | Checks if knapsack a is fix-injective
> D.12.3.60 three_elements |  | Creates the smallest injective knapsack with a given injective_knapsack by using the three-elements-algorithm with a given number of iterations

User manual for Singular version 4-0-3, 2016, generated by texi2html.