c4e_poly.h File Reference
(Version 551)
Polynomial arithmetic with coefficients from .
More...
#include "c4e_elements.h"
Go to the source code of this file.
Functions |
C4eElemCmp | c4e_poly_cmp (C4E_CONST C4eElement *a, C4E_CONST C4eElement *b) |
| Compares two (may be denormalized) binary polynomials.
|
void | c4e_poly_add (C4E_CONST C4eElement *a, C4E_CONST C4eElement *b, C4eElement *c) |
| Addition of two binary polynomials (with coefficients in ).
|
void | c4e_poly_addshl (C4E_CONST C4eElement *a, C4E_CONST C4eElement *b, C4eArchSize shift, C4eElement *c) |
| Addition of a binary polynomial with a (bit-wise) left-shifted binary polynomial.
|
void | c4e_poly_mul (C4E_CONST C4eElement *C4E_RESTRICT a, C4E_CONST C4eElement *C4E_RESTRICT b, C4eElement *C4E_RESTRICT c) |
| Multiplication of two binary polynomials (with coefficients in ).
|
void | c4e_poly_sqr (C4E_CONST C4eElement *a, C4eElement *c) |
| Square of a binary polynomial (with coefficients in ).
|
void | c4e_poly_mod (C4E_CONST C4eElement *C4E_RESTRICT a, C4E_CONST C4eElement *C4E_RESTRICT b, C4E_CONST C4eElement *C4E_RESTRICT m, C4eElement *C4E_RESTRICT c) |
| Modulo-division of two binary polynomials (reduction), with optional pre-multiplication by a third polynomial.
|
void | c4e_poly_gcd (C4eElemTriple *a, C4eElemTriple *b) |
| Greatest Common Divisor of two binary polynomials over . It calculates the GCD of a->x and b->x together with the Bezout cofactors and in equation .
|
Detailed Description
Polynomial arithmetic with coefficients from .
- Note:
- This interface is the counterpart to c4e_bigint.h.
- Author:
- Copyright (C) 2013-2015 Ralf Hoppe <ralf.hoppe@ieee.org>
- Version:
- Id
- c4e_poly.h 551 2015-03-01 12:37:45Z ralf
Definition in file c4e_poly.h.
Function Documentation
Compares two (may be denormalized) binary polynomials.
- Parameters:
-
[in] | a | First polynomial. |
[in] | b | Second polynomial. |
- Returns:
- The function returns:
- Return values:
-
Addition of two binary polynomials (with coefficients in ).
- Note:
- The parameters
a
and b
have not to be normalized, except for performance reasons.
- Parameters:
-
[in] | a | First polynomial. |
[in] | b | Second polynomial. |
[out] | c | Result , not normalized. It is allowed to set c pointing to a or b . |
Addition of a binary polynomial with a (bit-wise) left-shifted binary polynomial.
- Note:
- It is allowed to set
c
pointing to a
or b
.
- Precondition:
- The required digits space (in units of C4eArchDigit) for
c
is: max(b->size
+ ceil(shift
/ C4E_SYS_DIGIT_BITS), a->size
)
- Parameters:
-
[in] | a | Pointer to first binary polynomial. |
[in] | b | Pointer to second binary polynomial. |
[in] | shift | Number of bits to shift each digit in b before xor'ing with a . |
[out] | c | Result c = a ^ (b << shift ), normalized. |
- See also:
- C4eElement, C4E_ELEM_ASGN_MEM()
Multiplication of two binary polynomials (with coefficients in ).
- Note:
- Because this function implements a kind of classical school book algorithm, it's complexity is O(
a->size
* b->size
).
-
The parameters
a
and b
have not to be normalized, except for performance reasons.
- Precondition:
c->digits
must point to pre-allocated memory space for at least (a->size
+ b->size
) digits.
-
Use of restrict qualifier indicates that aliasing
a
or b
with c
or aliasing a->digits
or b->digits
with c->digits
is not allowed.
- Bibliography:
- Peterson, W. Wesley und E. J. Weldon, Jr.: Error-Correcting Codes. MIT Press, 1972.
- Bibliography:
- Berlekamp, Elwyn R.: Algebraic Coding Theory. Aegean Park Press, 1984.
- Parameters:
-
[in] | a | First multiplier (polynomial). |
[in] | b | Second multiplier (polynomial). |
[out] | c | Result , not normalized. |
- See also:
- C4eElement, C4E_ELEM_ASGN_MEM()
Modulo-division of two binary polynomials (reduction), with optional pre-multiplication by a third polynomial.
- Note:
- This function combines the multiplication algorithm in c4e_poly_mul() with a Linear Feedback Shift Register (LFSR) based division, according to [Peterson], figure 7.6. The algorithm is illustrated in [Peterson], figure 7.8.
-
The parameters
a
and b
have not to be normalized, except for performance reasons.
- Precondition:
- The modulus
m
must be normalized, e.g. by using function c4e_elem_norm().
-
Divide by zero is not supported - catch this situation in advance (e.g. using macro C4E_ELEM_IS_ZERO(
m
)).
-
If factor
b
is used, then it's size must be less/equal m->size
(in best-case it is also reduced to m
).
-
c->digits
must point to pre-allocated memory space for at least m->size
digits.
-
Use of restrict qualifier indicates that aliasing
a
or b
with c
or aliasing a->digits
or b->digits
with c->digits
is not allowed.
- Bibliography:
- Peterson, W. Wesley und E. J. Weldon, Jr.: Error-Correcting Codes. MIT Press, 1972.
- Bibliography:
- Berlekamp, Elwyn R.: Algebraic Coding Theory. Aegean Park Press, 1984.
- Parameters:
-
[in] | a | First multiplier in dividend . |
[in] | b | Second multiplier in . If it is NULL, then is assumed. In the other case b is allowed to point to a or b->digits point to a->digits . |
[in] | m | Divisor polynomial (modulus). |
[out] | c | Result , normalized. |
- See also:
- C4eElement, C4E_ELEM_ASGN_MEM()
Greatest Common Divisor of two binary polynomials over . It calculates the GCD of a->x
and b->x
together with the Bezout cofactors and in equation .
- Note:
- The asymptotic complexity of the algorithm is O(
a->x.size
* b->x.size
).
-
If the algorithm computes in
a->y
and returns a->x
in a->z
, b->x
in b->z
.
-
Members
a->attr
and b->attr
have no meaning (will be destroyed).
- Precondition:
- The polynomials
a->x
and b->x
must be normalized, e.g. by using function c4e_elem_norm().
-
It is not allowed that both polynomials
a->x
and b->x
are both zero (C4E_ELEM_IS_ZERO()).
-
The required digits space (in units of C4eArchDigit) for all polynomials is the maximum size of the two input values
a->x
and b->x
+ 1U.
- Bibliography:
- Menezes, Alfred J., P. C. van Oorschot und Scott A. Vanstone: Handbook of applied cryptography. CRC Press Series on Discrete Mathematics and Its Application. CRC Press, 2. Edition, 1992.
- Bibliography:
- Hankerson, Darrel, Alfred Menezes und Scott Vanstone: Guide to Elliptic Curve Cryptography. Springer, New York, 2004.
- Bibliography:
- Crandall, Richard und Carl Pomerance: Prime Numbers. A Computational Perspective. Springer, 2. Auflage, 2005.
- Bibliography:
- Berlekamp, Elwyn R.: Algebraic Coding Theory, Revised 1984 Edition. Aegean Park Press, Laguna Hills, CA, 1984.
- Parameters:
-
[in,out] | a | As an input parameter a->x holds the polynomial, for which the GCD with b->x is calculated. As an output it returns:
- zero in
a->x ;
- the coprime part of
a->x in a->z ;
- Bezout cofactor in
a->y .
|
[in,out] | b | As an input parameter b->x holds the polynomial, for which the GCD with a->x is calculated. As an output it returns:
- the in
b->x ;
- the coprime part of
b->x in b->z ;
- Bezout cofactor in
b->y .
|
- See also:
- C4eElemTriple, c4e_elem_norm(), C4E_ELEM_IS_ZERO(), C4eElement, C4E_ELEM_ASGN_MEM()