Hardware Implementation of

Finite-Field Arithmetic

 

Home
VHDL & ADA Codes
Table of contents
The Authors
Links & Material
Feedback

 

 

VHDL and ADA Models

 

Chapter 2: Mod m reduction

All examples of chapter 2

2.1.2. Non Restoring reducer. Ada model (nr_reducer.adb). VHDL model (nr_reducer.vhd). VHDL Testbench (test_nr_reducer.vhd)

2.1.3. SRT reducer. Ada model (srt_reducer.adb). VHDL model (srt_reducer.vhd). VHDL Testbench (test_srt_reducer.vhd)

2.2. Reduction mod 2K-a. Ada model (two_power_k_minus_a_reducer.adb). Ada Package (finite_fields.ads). VHDL model (tpkma_reducer.vhd). VHDL Testbench (test_tpkma_reducer.vhd)

2.3. Precomputation of 2i.k mod m. Ada model (precomputation_reducer.adb). Ada Package (finite_fields.ads; finite_fields.adb). VHDL model (precomputation_reducer.vhd). VHDL Testbench (test_precomp_reducer.vhd)

2.4. Barrett Reduction Algorithm m. Ada model (Barrett_reducer.adb). Ada Package (finite_fields.adb; finite_fields.ads). VHDL model (Barrett_reducer.vhd). VHDL Testbench (test_barret_reducer.vhd). A combinational VHDL implementation of Barret reducer and a testbench (Barrett_reducer_comb.vhd; test_barret_reducer_comb.vhd)

2.6. Specific Circuit. Mod 239 Reducer (mod_239_reducer.vhd)

2.6. Specific Circuit. Mod P192 Reducer. Two architectures are presented (mod_p192_reducer.vhd). VHDL Testbench (test_mod_p192_reducer.vhd).

 

Chapter 3: Mod m Operations (addition, subtraction, multiplication  and exponentiation)

All examples of chapter 3

3.1. Addition mod m. Ada model (binary_mod_m_addition.adb).

3.2. Subtraction mod m. Ada model (binary_mod_m_subtraction.adb).

3.3. Adder - Subtractor mod m.VHDL model (adder_subtractor.vhd). VHDL Testbench (test_add_sub.vhd). A simple modelsim script file (add_sub.do).

3.4.1 Multiply and Reduce. VHDL model (mod_239_multiplier.vhd; mod_239_reducer.vhd). VHDL Testbench (test_mod239_mult.vhd). A simple modelsim script file (mod_239_mult.do).

3.4.1 Multiply and Reduce, CSA Shift and Add multiplication. VHDL model (csa_mod_multiplier.vhd). VHDL Testbench (test_csa_mod_mult.vhd). A simple modelsim script file (csa_mod_mult.do).

3.4.2. Double, Add and Reduce (DAR) mod M Multiplier. Ada Model (dar_mod_multiplication.adb) VHDL model (dar_mod_multiplier.vhd). DAR Multiplier with carry-stored encoding (dar_csa_multiplier.vhd). A simple modelsim script file for K=8. (dar_mod_mult.do).

3.4.3 Montgomery Multiplication. Ada Model (Montgomery_product.adb). VHDL model (Montgomery_multiplier.vhd). A simple modelsim script file (Mont_mult.do).

3.5 Exponentiation mod M - MSB first. Ada Model for Most Significant Bit First Exponentiation (mod_m_exponentiation_msb.adb). Ada model for Montgomery MSB first (Montgomery_exponentiation_msb.adb); VHDL model for MSB first (Montgomery_exponentiator_msb.vhd). VHDL model of modified Montgomery Multiplier (Montgomery_multiplier_modif.vhd). A simple modelsim script file for K=8 (exponent_K8.do). Another simple modelsim script file for K=192 (exponent_K192.do).

3.5 Exponentiation mod M - LSB first. Ada Model for Least Significant Bit First Exponentiation (mod_m_exponentiation_lsb.adb). Ada model for Montgomery LSB first (Montgomery_exponentiation_lsb.adb); VHDL model for LSB first (Montgomery_exponentiator_lsb.vhd). VHDL model of modified Montgomery Multiplier (Montgomery_multiplier_modif.vhd). A simple modelsim script file for K=8 (exponent_K8.do). Another simple modelsim script file for K=192 (exponent_K192.do).

3.extra. Ada package containing some usefull functions (finite_fields.ads; finite_fields.adb)

 

Chapter 4: Division over GF(p)

All examples of chapter 4

4.1.1. Integer Division (non-restoring). Ada model (nr_divider.adb). VHDL model (nr_divider.vhd). VHDL Testbench (test_nr_divider.vhd). A simple modelsim script file for K=8 (nr_divider.do).

4.1.2. Multiplication and Subtraction. VHDL model (mult_subt.vhd). VHDL Testbench(test_mult_subt.vhd).

4.1.3. Euclidean algorithm for division mod p. Ada Model (euclidean_mod_p_division.adb). VHDL model (euclidean_divider.vhd). VHDL Testbench (test_euclidean_divider.vhd). A simple modelsim script file for K=8 (euclidean_divider.do).

4.2. Binary Algorithm for division mod p. Ada Model (binary_algorithm.adb). VHDL model (binary_algorithm.vhd). VHDL Testbench (test_binary_divider.vhd).

4.3. Plus-Minus Algorithm for division mod p. Ada Models (plus_minus_algorithm.adb; plus_minus_algorithm_2.adb). VHDL model (plus_minus.vhd). VHDL Testbench (test_plus-minus_divider.vhd).

4.4. Fermat´s Little Theorem based Algorithm for division mod p. Ada Model (fermat_division.adb;). VHDL model (Fermat_divider.vhd). VHDL Testbench (test_fermat_divider.vhd). A simple modelsim script file for K=8 (Fermat_divider.do).

4.extra. Ada package containing usefull functions for chapter 4 (finite_fields.ads; finite_fields.adb)

 

Chapter 5: Operations over Zp[x] / f(x)

All examples of chapter 5

5.1. Addition and Subtraction of Polynomials mod P. Ada model of Addition (addition_mod_f_poly.adb), Ada model for subtraction (subtraction_mod_f_poly.adb). VHDL model for Addition (adder_polynom.vhd). VHDL model for subtraction (subtractor_polynom.vhd). A testbench for addition and subtraction (test_adder_and_subtractor_polynom.vhd).

5.1.additional.  A VHDL code for an adder-subtractor(adder_subt_polynom.vhd). Testbench for the adder-subtractor(test_add_sub_polynom.vhd).

5.2.1 Two step Multiplication. Ada model (multiplication_mod_f_poly.adb)

5.2.2 Serial Multiplication. Ada model MSE-first Multiplier (MSEfirst.adb). Ada model LSE-first multiplier (LSEfirst.adb). VHDL model for MSE-first multiplier (MSE_first_mod_f_multipler.vhd).  VHDL model for MSE-first multiplier (LSE_first_mod_f_multipler.vhd). Testbench comparing results of MSE and LSE multipliers (test_mult_polynom.vhd). 

5.3. Exponentiation mod f(x). Ada model(Exp_mod_f.adb). VHDL model (exp_sq_mult.vhd). VHDL testbench (test_exp_polynom.vhd).

5.4. Optimal Extension Field. Ada model for OEF multiplication (OEF_mult_mod_f.adb). Ada model for MSE OEF multiplication (OEF_MSE_mult.adb).  Ada model for LSE OEF multiplication (OEF_LSE_mult.adb).  Ada model for OEF Exponentiation (OEF_exp.adb). The VHDL models 5.2 and 5.3 can be used for OEF, in fact the example uses OEF. 

5.extra. Basic ADA functions and definitions of chapter 5. (finite_fields_ch5.ads and finite_fields_ch5.adb; polynomials_ch5.ads and polynomials_ch5.adb).

 

Chapter 6: Operations over GF(pm)

All examples of chapter 6

6.1. Euclidean Algorithm. Ada model, first version(Euclidean_algorithm_polynomials.adb). Ada model for Euclidean Algorithm, second version (Euclidean_algorithm_polynomials2.adb). Ada model for Euclidean Algorithm, third version (pseudo_Euclidean_algorithm.adb). VHDL model for pseudo Euclidean divider (pseudo_Euclidean_divider.vhd). VHDL Testbench (test_pseudo_euclidean_div.vhd). For testbench a polynomial multiplier is necessary (LSE_first_mod_f_mult_test1.vhd).

6.2. Binary Algorithm. Ada model, first version (binary_polynomials.adb). Ada model for binary Algorithm, second version (binary_polynomials2.adb). VHDL model for bynary (binary_algorithm_polynomials.vhd) algorithm. VHDL Testbench (test_binary_divider.vhd). For testbench a polynomial multiplier is necessary (LSE_first_mod_f_mult_test2.vhd).

6.3. Reduction to multiplications over GF(pm) and inversion in Zp. Ada model (reduction_to_multiplications.adb). VHDL model (reduction_to_multiplications.vhd).VHDL Testbench (test_reduction_mult_divider.vhd). For testbench a polynomial multiplier is necessary (LSE_first_mod_f_mult_test3.vhd).

6.4. Optimal Extension Field (OEF). Ada model of version 1 (oef1.adb). Ada Model of version 2 (oef2.adb). VHDL model using LSE-first multiplier (oef.vhd). VHDL Testbench (test_OEF_divider.vhd). For testbench a polynomial multiplier is necessary (LSE_first_mod_f_mult_test4.vhd).  

6.extra. Basic ADA functions and definitions of chapter 5. (finite_fields.ads and polynomials.adb; polynomials.ads and polynomials.adb).

Chapter 7: Operations over GF(2m) – Polynomial Bases

All examples of chapter 7

7.1.1. Two step classic multiplication. Ada Model (classic_multiplication.adb). Poly Multiplication Model (classic_poly_multiplication.adb).  VHDL models (classic_multiplier.vhd). A simple testbench for M=8 (test_classic_mult.vhd and test_poly_mult.vhd). A do file for M=163 (test_mult_comb.do).

7.1.2. Interleaved Multiplication. MSB-first ADA model (MSBfirst.adb). LSB-first ADA model (LSBfirst.adb). VHDL model (interleaved_mult.vhd).  A simple testbench for M=8 (test_interleaved_mult.vhd). A do file for M=163 (test_mult_seq.do). An aditional VHDL model of interleaved multiplication with Polynomial F as input (interleaved_mult_F.vhd)

7.1.3. Matrix Vector Multiplier (Mastrovito product Matrix). Ada Model of P-Matrix computation (matrix_P.adb). Ada model Z-Matrix computation (mastrovito_matrix.adb). Ada model of Mastrovito Multiplication (mastrovito_multiplication.adb). VHDL model (mastrovito_multiplier.vhd).  A simple testbench for M=8 (test_mastrovito_mult.vhd). A do file for M=163 (test_mult_comb.do). Ada model Second Version of Mastrovito Multiplication (mastrovito_multiplication_v2.adb). VHDL model of seconf version (mastrovito_v2_multiplier.vhd).  A simple testbench for M=8 (test_mastrovito_mult.vhd).

7.1.4. Montgomery multiplication. Ada Model (bmult_montgomery.adb). A second version (bmult_montgomery_v2.adb). VHDL model, sequential implementation (montgomery_mult.vhd).  A simple testbench for M=8 (test_montg_mult.vhd). A do file for M=163 (test_mult_seq.do). VHDL model, combinational implementation (montg_comb_mult.vhd).

7.1.5. Karatsuba Multiplier. VHDL model for M even (Karatsuba_multiplier_even.vhd). General Karatsuba multiplier (Karatsuba_multiplier.vhd). Modified polynomial multiplier (poly_multiplier.vhd).

7.1.extra. A testbench including all multipliers and comparing the results (test_mult_by_Comparation.vhd)

7.2 Squaring. Ada model for Classic Squaring (classic_squaring.adb). Ada Model for LSB-first squaring (LSBfirst_squarer.adb). Ada model for Bit-Level Montgomery Squaring (bsquarer_montgomery.adb). Ada Model for Classic squaring second version (classic_squaring_v2.adb). Ada model for Bit Level Montgomey squating, second version (bsquarer_montgomery_v2.adb). Ada Model for LSB-first Squaring, second version (LSBfirst_squarer_v2.adb). VHDL model for classic multiplier (classic_squarer.vhd). VHDL model for montgomery squaring (montgomery_square.vhd). VHDL model for combinational montgomery squarer (montg_comb_squarer.vhd). LSB-first Squaring version 2 (LSB_first_squarer_V2.vhd). VHDL testbench instantiating all versions of squaring (test_square_by_comp.vhd).

7.3. Exponentiation. Ada model for Square and Multiply Exponentatiation (SQandMult_exp.adb). Ada Model for Bit-Level Montgomery Exponentiation (Exp_montgomery.adb). VHDL model for a general bynary Exponentiation (exponentiation_sq_mult.vhd). VHDL model for Montgomery Exponentiation (exponentiation_montgomery.vhd). VHDL model for Montgomery Exponentiation using a comb squarer (exponentiation_montgomery_adv.vhd). VHDL testbech instatitating exponentiation circuits (test_exponentiation.vhd).

7.4. Division. Ada model for modular division (binary_algorithm_polynomials.adb). Aditional Ada package for divider (polynomials.ads; polynomials.adb). VHDL model (binary_algorithm_polynomials.vhd). VHDL testbench (test_binary_division.vhd).

7.5. Inversion. Ada model for Extended Euclidean Algorithm (EEA) (EEA_inversion.adb). VHDL model for EEA (EEA_inversion.vhd). VHDL testbench (test_eea_inversion.vhd). Ada model for Modified Almost Inverse Algorithm (MAIA) (MAIA_inversion.adb). VHDL model for MAIA (test_maia_inversion.vhd). VHDL testbench (test_maia_inversion.vhd)

7.6. Important Irreductible Polynomials. Ada model for All-one Polinomials AOPs (mastrovito_multiplication_AOP.adb). VHDL model for AOPs (mastrovito_AOP_multiplier.vhd). Testbench for AOPs (test_mastrovitoAOPs.vhd). Ada model for Trinomials (mastrovito_multiplication_v2_trinomials.adb). VHDL model for Trinomials (mastrovito_trinom_multiplier.vhd). Testbench for Trinomials (test_mastrovito_trinom.vhd).Ada model for class 1 Pentanomials (mastrovito_multiplication_v2_pentanomials.adb). VHDL for class 1 Pentanomials (mastrovito_pentanom_multiplier.vhd). Testbench for class 1 Pentanomials(test_mastrovito_pentan.vhd). Testbenches instantiate an interleaved multiplier (nterleaved_mult_F.vhd) in order to compare results.

7.extra. Basic ADA functions and definitions of chapter 7. (GF2m.adb and GF2m.ads; finite_fields_gf2m.adb and finite_fields_GF2m.ads).

Chapter 8:  Operations over GF(2m) – Normal Bases

All examples of chapter 8

8.2. Normal Bases Squaring. Ada model (NB_sq.adb).

8.3. Normal Bases Multiplication. Ada model for Massey-Omura multiplication in GF(24) (NB_seqmult_GF2_4.adb). Ada model for Normal Bases Multiplier (NB_multiplier.adb). VHDL model for multiplication (NB_multiplier.vhd).

8.4. Exponentiation. Ada model for binary exponentiation (NB_exp.adb). VHDL model for exponentiation (NB_binary_exponentiation.vhd). A do file for GF(24) (test_NB_exp_GF4.do). A do file for GF(25) (test_NB_exp_GF5.do). Ada model for 2k-ary method for exponentiation (NB_2kary_exp.adb).

8.5. Inversion in Normal Bases. Ada model for Inversion in Normal Bases (NB_inversion.adb). VHDL model for Inversion (NB_inversion.vhd). A do file for GF(24) (test_NB_inv_GF4.do). A do file for GF(25) (test_NB_inv_GF5.do). Ada model for Itho-Tsuji Inversion Algorithm (NB_Itoh_Tsujii_inv.adb).

8.6. Type-1 Optimal normal Bases Multiplication with AOPs. Ada model (NB_T1_multiplier.adb). VHDL model (NB_T1_multiplier.vhd).

8.extra. Basic ADA functions and definitions of chapter 8. (GF2m.ads and GF2m.adb; finite_fields_gf2m.ads and finite_fields_gf2m.adb )

 

 

Chapter 10: An example of Application: elliptic curve cryptography

All examples of chapter 10

10.1. Point Multiplication. Ada model (frobenius_point_multiplication.adb). Ada model for version 3 (frobenius_point_multiplication3.adb). Aditional ADA package (Galois.ads and Galois.adb). VHDL models for K-163 (K163_point_multiplication.vhd, K163_addition.vhd, interleaved_mult.vhd,classic_squarer.vhd, binary_algorithm_polynomials.vhd). Simple do file (test_point_mult.do). A testbench for K-163 (test_simple_K163_point_mult.vhd). Zip file with VHDL descriptions for K-163 (K-163.zip). VHDL models for K-233 (K233_point_multiplication.vhd, K233_addition.vhd, interleaved_mult.vhd, classic_squarer.vhd, binary_algorithm_polynomials.vhd). Simple do file (test_point_mult.do). A testbench for K-233 (test_simple_K233_point_mult.vhd). Zip file with VHDL descriptions for K-233 (K-233.zip).

 

Home | VHDL & ADA Codes | Table of contents | The Authors | Links & Material | Feedback

This site was last updated 11/01/08