26
A Residue Approach to the Finite Field Arithmetics 1/23 A Residue Approach to the Finite Field Arithmetics JC Bajard LIRMM, CNRS UM2 161 rue Ada, 34392 Montpellier cedex 5, France CIRM 2009

A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 1/23

A Residue Approach to the Finite FieldArithmetics

JC Bajard

LIRMM, CNRS UM2161 rue Ada, 34392 Montpellier cedex 5, France

CIRM 2009

Page 2: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 2/23

Contents

Introduction to Residue Systems

Modular reduction in Residue Systems

Applications to Cryptography

Conclusion

Page 3: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 3/23

Introduction to Residue Systems

Introduction to Residue Systems

Page 4: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 4/23

Introduction to Residue Systems

Introduction to Residue Systems

I In some applications, like cryptography, we use finite fieldarithmetics on huge numbers or large polynomials.

I Residue systems are a way to distribute the calculus on smallarithmetic units.

I Are these systems suitable for finite field arithmetics?

Page 5: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 5/23

Introduction to Residue Systems

Residue Number Systems in Fp, p prime

I Modular arithmetic mod p, elements are considered asintegers.

I Residue Number SystemI RNS base: a set of coprime numbers (m1, ...,mk)I RNS representation: (a1, ..., ak) with ai = |A|mi

I Full parallel operations modM with M =∏k

i=1 mi

(|a1 ⊗ b1|m1, . . . , |an ⊗ bn|mn

)→ A⊗ B (mod M)

I Very fast product, but an extension of the base could benecessary and a reduction modulo p is needed.

Page 6: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 6/23

Introduction to Residue Systems

Residue Number Systems in Fp, p prime

I Φ(m) =∑p≤m

p prime

log p = log∏p≤m

p prime

p ∼ m

I If 2m−1 ≤ M < 2m then the size moduli is of order O(log m).

I In other words, if addition and multiplication havecomplexities of order Θ(f (m)) then in RNS the complexitiesbecome Θ(f (log m)).

Page 7: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 7/23

Introduction to Residue Systems

Lagrange representations in Fpk with p > 2k

I Arithmetic modulo I (X ), an irreducible Fp polynomial ofdegree k. Elements of Fpk are considered as Fp polynomialsof degree lower than k .

I Lagrange representationI is defined by k different points e1, ...ek in Fp. (k ≤ p.)I A polynomial A(X ) = α0 + α1X + ...+ αk−1X

k−1 over Fp isgiven in Lagrange representation by:

(a1 = A(e1), ..., ak = A(ek)).

I Remark: ai = A(ei ) = A(X ) mod (X − ei ). If we notemi (X ) = (X − ei ), we obtain a similar representation as RNS.

I Operations are made independently on each A(ei ) (like in FFTor Tom-Cook approaches). We need to extend to 2k pointsfor the product.

Page 8: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 8/23

Introduction to Residue Systems

Trinomial residue in F2n

I Arithmetic modulo I (X ), an irreducible F2 polynomial ofdegree n. Elements of F2n are considered as F2 polynomials ofdegree lower than n.

I Trinomial representationI is defined by a set of k coprime trinomials

mi (X ) = X d + X ti + 1, with k × d ≥ n,I an element A(X ) is represented by (a1(X ), ...ak(X )) with

ai (X ) = A(X ) mod mi (X ).I This representation is equivalent to RNS.

I Operations are made independently for each mi (X )

Page 9: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 9/23

Introduction to Residue Systems

Residue Systems

I Residue systems could be an issue for computing efficientlythe product.

I The main operation is now the modular reduction forconstructing the finite field elements.

I The choice of the residue system base is important, it givesthe complexity of the basic operations.

Page 10: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 10/23

Modular reduction in Residue Systems

Modular reduction in Residue Systems

Page 11: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 11/23

Modular reduction in Residue Systems

Reduction of Montgomery on Fp

I The most used reduction algorithm is due to Montgomery(1985)[9]

I For reducing A modulo p,one evaluates q = −(Ap−1) mod 2s ,then one constructs R = (A + qp)/2s .The obtained value satisfies: R ≡ A× 2−s (mod p) andR < 2p if A < p2s .We note Montg(A, 2s , p) = R.

I Montgomery notation: A′ = A× 2s mod pMontg(A′ × B ′, 2s , p) ≡ (A× B)× 2s (mod p)

Page 12: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 12/23

Modular reduction in Residue Systems

Residue version of Montgomery Reduction

I The residue base is such that p < M(or deg M(X ) ≥ deg I (X ))

I We use an auxiliary base such that p < M ′

(or deg M ′(X ) ≥ deg I (X )), M ′ and M coprime.(Exact product, and existence of M−1)

I Steps of the algorithm

1. Q = −(Ap−1) mod M (calculus in base M)2. Extension of the representation of Q to the base M ′

3. R = (A + Qp)×M−1 (calculus in base M ′)4. Extension of the representation of R to the base M

I The values are represented in the two bases.

Page 13: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 13/23

Modular reduction in Residue Systems

Extension of Residue System Bases (from M to M ′)

The extension comes from the Lagrange interpolation.If (a1, ..., ak) is the residue representation in the base M, then

A =k∑

i=1

∣∣∣∣∣ai ×[

M

mi

]−1

mi

∣∣∣∣∣mi

× M

mi− αM

The factor α can be, in certain cases, neglected or computed.[1]Another approach consists in the Newton interpolation where A iscorrectly reconstructed. [4]In the polynomial case, the term −αM vanishes.

Page 14: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 14/23

Modular reduction in Residue Systems

Extension for Q

By the CRT

Q̂ =n∑

i=1

∣∣∣qi |Mi |−1mi

∣∣∣mi

Mi = Q + αM

where 0 ≤ α < n.When Q̂ has been computed it is possible to compute R̂ as

R̂ = (AB + Q̂p)M−1 = (AB + Qp + αMp)M−1

= (AB + Qp)M−1 + αp

so that R̂ ≡ R ≡ ABM−1 (mod p), which is sufficient for ourpurpose. Also, assuming that AB < pM we find that R̂ < (n + 2)psince α < n.

Page 15: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 15/23

Modular reduction in Residue Systems

Extension R

Shenoy et Kumaresan (1989):

we have (n∑

i=1

Mi

∣∣∣|Mi |−1mi

ri

∣∣∣mi

) = R + α×M

α =

∣∣∣∣∣|M|−1mn+1

(n∑

i=1

∣∣∣∣Mi

∣∣∣|Mi |−1mi

ri

∣∣∣mi

∣∣∣∣mn+1

− |R|mn+1

)∣∣∣∣∣mn+1

r̃j =

∣∣∣∣∣n∑

i=1

∣∣∣∣Mi

∣∣∣|Mi |−1mi

ri

∣∣∣mi

∣∣∣∣fmj

− |αM|fmj

∣∣∣∣∣fmj

Page 16: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 16/23

Modular reduction in Residue Systems

Extension of Residue System Bases

We first translate in an intermediate representation (MRS):

ζ1 = a1

ζ2 = (a2 − ζ1) m−11 mod m2

ζ3 =((a3 − ζ1) m−1

1 − ζ2)

m−12 mod m3

...

ζn =(. . .((an − ζ1) m−1

1 − ζ2)

m−12 − · · · − ζn−1

)m−1

n−1 mod mn.

We evaluate A, with Horner’s rule, as

A = (. . . ((ζn mn−1 + ζn−1) mn−2 + · · ·+ ζ3) m2 + ζ2) m1 + ζ1.

Page 17: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 17/23

Modular reduction in Residue Systems

Features of the residue system

I Efficient multiplication, the cost being the cost of onemultiplication on one residue.

I Costly reduction: O(k1.6) for trinomials [4], 2k2 + 3k for RNS[1], O(k2) for Lagrange representation [5].

I If we take into account that most of the operations aremultiplications by a constant, the cost can be considerablysmaller.

Page 18: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 18/23

Applications to Cryptography

Applications to Cryptography

Page 19: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 19/23

Applications to Cryptography

Elliptic curve cryptography

I The main idea comes from the efficiency of the product andthe cost of the reduction in Residue Systems.

I We try to minimize the number of reductions. A reduction isnot necessary after each operation. Clearly, for a formula likeA× B + C × D, only one reduction is needed.

I Elliptic Curve Cryptography is based on points addition. Weuse appropriate forms (Hessian, Jacobi, Montgomery...) andcoordinates: projective, Jacobian or Chudnowski...

I For 512 bits values Residues Systems for curves defined over aprime field, are more efficient than classical representations.[2]

Page 20: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 20/23

Applications to Cryptography

Pairings

I To summarize we define a pairing as follows: let G1 and G2 betwo additive abelian groups of cardinal n and G3 amultiplicative group of cardinal n.

I A pairing is a function e : G1 × G2 → G3 which verifies thefollowing properties: Bilinearity, Non-degeneracy.

I For pairings defined on an elliptic curve E over a finite fieldFp, we have G1 ⊂ E (Fp), G2 ⊂ E (Fpk ) and G3 ⊂ Fpk , where

k is the smallest integer such that n divides pk − 1, k is calledthe embedded degree of the curve.

Page 21: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 21/23

Applications to Cryptography

Pairings

I The construction of the pairing involves values over Fp andFpk into the formulas. An approach with Residue Systems,similar to the one made on ECC could be interesting.[3]

I k is most of the time chosen as a small power of 2 and 3 foralgorithmic reasons. Residue arithmetics allow to pass overthis restriction.

I With pairings, we can also imagine two levels of ResidueSystems: one over Fp and one over Fpk .

Page 22: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 22/23

Conclusion

Conclusion on Residue Systems

Page 23: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 23/23

Conclusion

Conclusion

I If your number system is not efficient, then it remains to trythe residues.

Page 24: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 23/23

Conclusion

Bajard, J.C., Didier, L.S., Kornerup, P.: Modularmultiplication and base extension in residue number systems.15th IEEE Symposium on Computer Arithmetic, 2001 VailColorado USA pp. 59–65

Bajard, J.C., Duquesne, S., Ercegovac M. and Meloni N.:Residue systems efficiency for modular products summation:Application to Elliptic Curves Cryptography, in AdvancedSignal Processing Algorithms, Architectures, andImplementations XVI, SPIE 2006, San Diego, USA.

Bajard, J.C. and ElMrabet N.: Pairing in cryptography: anarithmetic point of view, Advanced Signal ProcessingAlgorithms, Architectures, and Implementations XVII, part ofthe SPIE Optics & Photonics 2007 Symposium. August 2007San Diego, USA.

Page 25: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 23/23

Conclusion

J.C. Bajard, L. Imbert, and G. A. Jullien: Parallel MontgomeryMultiplication in GF (2k) using Trinomial Residue Arithmetic,17th IEEE symposium on Computer Arithmetic, 2005, CapeCod, MA, USA.pp. 164-171

J.C. Bajard, L. Imbert et Ch. Negre, Arithmetic Operations inFinite Fields of Medium Prime Characteristic Using theLagrange Representation, journal IEEE Transactions onComputers, September 2006 (Vol. 55, No. 9) p p. 1167-1177

Bajard, J.C., Meloni, N., Plantard, T.: Efficient RNS bases forCryptography IMACS’05, Applied Mathematics andSimulation, (2005)

Garner, H.L.: The residue number system. IRE Transactionson Electronic Computers, EL 8:6 (1959) 140–147

Knuth, D.: Seminumerical Algorithms. The Art of ComputerProgramming, vol. 2. Addison-Wesley (1981)

Page 26: A Residue Approach to the Finite Field Arithmeticssteiner/num09/bajard.pdf · 2016-01-29 · A Residue Approach to the Finite Field Arithmetics 7/23 Introduction to Residue Systems

A Residue Approach to the Finite Field Arithmetics 23/23

Conclusion

Montgomery, P.L.: Modular multiplication without trialdivision. Math. Comp. 44:170 (1985) 519–521

Svoboda, A. and Valach, M.: Operational Circuits. Stroje naZpracovani Informaci, Sbornik III, Nakl. CSAV, Prague, 1955,pp.247-295.

Szabo, N.S., Tanaka, R.I.: Residue Arithmetic and itsApplications to Computer Technology. McGraw-Hill (1967)