Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PolynomialMod2 Class Reference

Polynomial with Coefficients in GF(2). More...

#include <gf2n.h>

List of all members.

ENUMS, EXCEPTIONS, and TYPEDEFS

typedef unsigned int RandomizationParameter

CREATORS

 PolynomialMod2 ()
 creates the zero polynomial. More...

 PolynomialMod2 (const PolynomialMod2 &t)
 copy constructor. More...

 PolynomialMod2 (word value,unsigned int bitLength=WORD_BITS)
 convert from word. More...

 PolynomialMod2 (const byte *encodedPoly,unsigned int byteCount)
 convert from big-endian byte array. More...

 PolynomialMod2 (BufferedTransformation &encodedPoly,unsigned int byteCount)
 convert from big-endian form stored in a BufferedTransformation. More...

 PolynomialMod2 (RandomNumberGenerator &rng,unsigned int bitcount)
 create a random polynomial uniformly distributed over all polynomials with degree less than bitcount. More...

PolynomialMod2 Monomial (unsigned i)
 return x^i. More...

PolynomialMod2 Trinomial (unsigned t0,unsigned t1,unsigned t2)
 return x^t0 + x^t1 + x^t2. More...

PolynomialMod2 Pentanomial (unsigned t0,unsigned t1,unsigned t2,unsigned int t3,unsigned int t4)
 return x^t0 + x^t1 + x^t2 + x^t3 + x^t4. More...

PolynomialMod2 AllOnes (unsigned n)
 return x^(n-1) + ... + x + 1. More...

const PolynomialMod2& Zero ()
const PolynomialMod2& One ()

ENCODE/DECODE

unsigned int MinEncodedSize ()const
 minimum number of bytes to encode this polynomial. More...

unsigned int Encode (byte *output,unsigned int outputLen)const
 encode in big-endian format. More...

unsigned int Encode (BufferedTransformation &bt,unsigned int outputLen)const
void Decode (const byte *input,unsigned int inputLen)
void Decode (BufferedTransformation &bt,unsigned int inputLen)
void DEREncodeAsOctetString (BufferedTransformation &bt,unsigned int length)const
 encode value as big-endian octet string. More...

void BERDecodeAsOctetString (BufferedTransformation &bt,unsigned int length)
 decode value as big-endian octet string. More...


ACCESSORS

unsigned int BitCount ()const
 number of significant bits = Degree() + 1. More...

unsigned int ByteCount ()const
 number of significant bytes = ceiling(BitCount()/8). More...

unsigned int WordCount ()const
 number of significant words = ceiling(ByteCount()/sizeof(word)). More...

bool GetBit (unsigned int n)const
 return the n-th bit, n=0 being the least significant bit. More...

byte GetByte (unsigned int n)const
 return the n-th byte. More...

signed int Degree ()const
 the zero polynomial will return a degree of -1. More...

unsigned int CoefficientCount ()const
 degree + 1. More...

int GetCoefficient (unsigned int i)const
 return coefficient for x^i. More...

int operator[] (unsigned int i)const
 return coefficient for x^i. More...

bool IsZero ()const
bool Equals (const PolynomialMod2 &rhs)const

MANIPULATORS

PolynomialMod2& operator= (const PolynomialMod2 &t)
PolynomialMod2& operator &= (const PolynomialMod2 &t)
PolynomialMod2& operator^= (const PolynomialMod2 &t)
PolynomialMod2& operator+= (const PolynomialMod2 &t)
PolynomialMod2& operator-= (const PolynomialMod2 &t)
PolynomialMod2& operator *= (const PolynomialMod2 &t)
PolynomialMod2& operator/= (const PolynomialMod2 &t)
PolynomialMod2& operator%= (const PolynomialMod2 &t)
PolynomialMod2& operator<<= (unsigned int)
PolynomialMod2& operator>>= (unsigned int)
void Randomize (RandomNumberGenerator &rng,unsigned int bitcount)
void SetBit (unsigned int i,int value=1)
void SetByte (unsigned int n,byte value)
 set the n-th byte to value. More...

void SetCoefficient (unsigned int i,int value)
void swap (PolynomialMod2 &a)

UNARY OPERATORS

bool operator! ()const
PolynomialMod2 operator+ ()const
PolynomialMod2 operator- ()const

BINARY OPERATORS

PolynomialMod2 And (const PolynomialMod2 &b)const
PolynomialMod2 Xor (const PolynomialMod2 &b)const
PolynomialMod2 Plus (const PolynomialMod2 &b)const
PolynomialMod2 Minus (const PolynomialMod2 &b)const
PolynomialMod2 Times (const PolynomialMod2 &b)const
PolynomialMod2 DividedBy (const PolynomialMod2 &b)const
PolynomialMod2 Modulo (const PolynomialMod2 &b)const
PolynomialMod2 operator>> (unsigned int n)const
PolynomialMod2 operator<< (unsigned int n)const

OTHER ARITHMETIC FUNCTIONS

unsigned int Parity ()const
 sum modulo 2 of all coefficients. More...

bool IsIrreducible ()const
 check for irreducibility. More...

PolynomialMod2 Doubled ()const
 is always zero since we're working modulo 2. More...

PolynomialMod2 Squared ()const
bool IsUnit ()const
 only 1 is a unit. More...

PolynomialMod2 MultiplicativeInverse ()const
 return inverse if *this is a unit, otherwise return 0. More...

PolynomialMod2 InverseMod (const PolynomialMod2 &)const
 calculate multiplicative inverse of *this mod n.

PolynomialMod2 Gcd (const PolynomialMod2 &a,const PolynomialMod2 &n)
 greatest common divisor. More...

void Divide (PolynomialMod2 &r,PolynomialMod2 &q,const PolynomialMod2 &a,const PolynomialMod2 &d)
 calculate r and q such that (a == d*q + r) && (deg(r) < deg(d)). More...


INPUT/OUTPUT

class  operator<<

Friends

class  GF2NT


Detailed Description

Polynomial with Coefficients in GF(2).

Definition at line 16 of file gf2n.h.


Member Typedef Documentation

typedef unsigned int PolynomialMod2::RandomizationParameter
 

Definition at line 28 of file gf2n.h.


Constructor & Destructor Documentation

PolynomialMod2::PolynomialMod2 ( )
 

creates the zero polynomial.

Definition at line 17 of file gf2n.cpp.

PolynomialMod2::PolynomialMod2 ( const PolynomialMod2 & t )
 

copy constructor.

Definition at line 33 of file gf2n.cpp.

PolynomialMod2::PolynomialMod2 ( word value,
unsigned int bitLength = WORD_BITS )
 

convert from word.

value should be encoded with the least significant bit as coefficient to x^0 and most significant bit as coefficient to x^(WORD_BITS-1) bitLength denotes how much memory to allocate initially

Definition at line 21 of file gf2n.cpp.

PolynomialMod2::PolynomialMod2 ( const byte * encodedPoly,
unsigned int byteCount ) [inline]
 

convert from big-endian byte array.

Definition at line 46 of file gf2n.h.

PolynomialMod2::PolynomialMod2 ( BufferedTransformation & encodedPoly,
unsigned int byteCount ) [inline]
 

convert from big-endian form stored in a BufferedTransformation.

Definition at line 50 of file gf2n.h.

PolynomialMod2::PolynomialMod2 ( RandomNumberGenerator & rng,
unsigned int bitcount ) [inline]
 

create a random polynomial uniformly distributed over all polynomials with degree less than bitcount.

Definition at line 54 of file gf2n.h.


Member Function Documentation

PolynomialMod2 PolynomialMod2::AllOnes ( unsigned n ) [static]
 

return x^(n-1) + ... + x + 1.

Definition at line 48 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::And ( const PolynomialMod2 & b ) const
 

Definition at line 235 of file gf2n.cpp.

void PolynomialMod2::BERDecodeAsOctetString ( BufferedTransformation & bt,
unsigned int length )
 

decode value as big-endian octet string.

Definition at line 163 of file gf2n.cpp.

unsigned int PolynomialMod2::BitCount ( ) const
 

number of significant bits = Degree() + 1.

Definition at line 186 of file gf2n.cpp.

Referenced by CoefficientCount(), Degree(), and Divide().

unsigned int PolynomialMod2::ByteCount ( ) const
 

number of significant bytes = ceiling(BitCount()/8).

Definition at line 177 of file gf2n.cpp.

Referenced by MinEncodedSize().

unsigned int PolynomialMod2::CoefficientCount ( ) const [inline]
 

degree + 1.

Definition at line 115 of file gf2n.h.

void PolynomialMod2::DEREncodeAsOctetString ( BufferedTransformation & bt,
unsigned int length ) const
 

encode value as big-endian octet string.

Definition at line 156 of file gf2n.cpp.

void PolynomialMod2::Decode ( BufferedTransformation & bt,
unsigned int inputLen )
 

Definition at line 137 of file gf2n.cpp.

void PolynomialMod2::Decode ( const byte * input,
unsigned int inputLen )
 

Definition at line 125 of file gf2n.cpp.

signed int PolynomialMod2::Degree ( ) const [inline]
 

the zero polynomial will return a degree of -1.

Definition at line 113 of file gf2n.h.

Referenced by Divide(), and IsIrreducible().

void PolynomialMod2::Divide ( PolynomialMod2 & r,
PolynomialMod2 & q,
const PolynomialMod2 & a,
const PolynomialMod2 & d ) [static]
 

calculate r and q such that (a == d*q + r) && (deg(r) < deg(d)).

Definition at line 275 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::DividedBy ( const PolynomialMod2 & b ) const
 

Definition at line 300 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::Doubled ( ) const [inline]
 

is always zero since we're working modulo 2.

Definition at line 208 of file gf2n.h.

unsigned int PolynomialMod2::Encode ( BufferedTransformation & bt,
unsigned int outputLen ) const
 

Definition at line 149 of file gf2n.cpp.

unsigned int PolynomialMod2::Encode ( byte * output,
unsigned int outputLen ) const
 

encode in big-endian format.

if outputLen < MinEncodedSize, the most significant bytes will be dropped if outputLen > MinEncodedSize, the most significant bytes will be padded

Definition at line 131 of file gf2n.cpp.

Referenced by DEREncodeAsOctetString().

bool PolynomialMod2::Equals ( const PolynomialMod2 & rhs ) const
 

Definition at line 433 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::Gcd ( const PolynomialMod2 & a,
const PolynomialMod2 & n ) [static]
 

greatest common divisor.

Definition at line 498 of file gf2n.cpp.

Referenced by IsIrreducible().

bool PolynomialMod2::GetBit ( unsigned int n ) const [inline]
 

return the n-th bit, n=0 being the least significant bit.

Definition at line 108 of file gf2n.h.

byte PolynomialMod2::GetByte ( unsigned int n ) const
 

return the n-th byte.

Definition at line 71 of file gf2n.cpp.

int PolynomialMod2::GetCoefficient ( unsigned int i ) const [inline]
 

return coefficient for x^i.

Definition at line 117 of file gf2n.h.

Referenced by GetBit(), and operator[]().

bool PolynomialMod2::IsIrreducible ( ) const
 

check for irreducibility.

Definition at line 503 of file gf2n.cpp.

bool PolynomialMod2::IsUnit ( ) const [inline]
 

only 1 is a unit.

Definition at line 213 of file gf2n.h.

Referenced by IsIrreducible(), and MultiplicativeInverse().

bool PolynomialMod2::IsZero ( ) const [inline]
 

Definition at line 123 of file gf2n.h.

unsigned int PolynomialMod2::MinEncodedSize ( ) const [inline]
 

minimum number of bytes to encode this polynomial.

MinEncodedSize of 0 is 1

Definition at line 76 of file gf2n.h.

PolynomialMod2 PolynomialMod2::Minus ( const PolynomialMod2 & b ) const [inline]
 

Definition at line 185 of file gf2n.h.

PolynomialMod2 PolynomialMod2::Modulo ( const PolynomialMod2 & b ) const
 

Definition at line 307 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::Monomial ( unsigned i ) [static]
 

return x^i.

Definition at line 86 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::MultiplicativeInverse ( ) const [inline]
 

return inverse if *this is a unit, otherwise return 0.

Definition at line 215 of file gf2n.h.

const PolynomialMod2 & PolynomialMod2::One ( ) [static]
 

Definition at line 119 of file gf2n.cpp.

unsigned int PolynomialMod2::Parity ( ) const
 

sum modulo 2 of all coefficients.

Definition at line 195 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::Pentanomial ( unsigned t0,
unsigned t1,
unsigned t2,
unsigned int t3,
unsigned int t4 ) [static]
 

return x^t0 + x^t1 + x^t2 + x^t3 + x^t4.

Definition at line 102 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::Plus ( const PolynomialMod2 & b ) const [inline]
 

Definition at line 183 of file gf2n.h.

void PolynomialMod2::Randomize ( RandomNumberGenerator & rng,
unsigned int bitcount )
 

Definition at line 39 of file gf2n.cpp.

void PolynomialMod2::SetBit ( unsigned int i,
int value = 1 )
 

Definition at line 57 of file gf2n.cpp.

void PolynomialMod2::SetByte ( unsigned int n,
byte value )
 

set the n-th byte to value.

Definition at line 79 of file gf2n.cpp.

void PolynomialMod2::SetCoefficient ( unsigned int i,
int value ) [inline]
 

Definition at line 160 of file gf2n.h.

PolynomialMod2 PolynomialMod2::Squared ( ) const
 

Definition at line 255 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::Times ( const PolynomialMod2 & b ) const
 

Definition at line 242 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::Trinomial ( unsigned t0,
unsigned t1,
unsigned t2 ) [static]
 

return x^t0 + x^t1 + x^t2.

Definition at line 93 of file gf2n.cpp.

unsigned int PolynomialMod2::WordCount ( ) const
 

number of significant words = ceiling(ByteCount()/sizeof(word)).

Definition at line 172 of file gf2n.cpp.

Referenced by BitCount(), and ByteCount().

PolynomialMod2 PolynomialMod2::Xor ( const PolynomialMod2 & b ) const
 

Definition at line 217 of file gf2n.cpp.

const PolynomialMod2 & PolynomialMod2::Zero ( ) [static]
 

Definition at line 113 of file gf2n.cpp.

bool PolynomialMod2::operator! ( ) const
 

Definition at line 426 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::operator+ ( ) const [inline]
 

Definition at line 171 of file gf2n.h.

PolynomialMod2 & PolynomialMod2::operator+= ( const PolynomialMod2 & t ) [inline]
 

Definition at line 137 of file gf2n.h.

PolynomialMod2 PolynomialMod2::operator- ( ) const [inline]
 

Definition at line 173 of file gf2n.h.

PolynomialMod2 & PolynomialMod2::operator-= ( const PolynomialMod2 & t ) [inline]
 

Definition at line 139 of file gf2n.h.

PolynomialMod2 PolynomialMod2::operator<< ( unsigned int n ) const
 

Definition at line 414 of file gf2n.cpp.

PolynomialMod2 & PolynomialMod2::operator<<= ( unsigned int n )
 

Definition at line 314 of file gf2n.cpp.

PolynomialMod2 & PolynomialMod2::operator= ( const PolynomialMod2 & t )
 

Definition at line 204 of file gf2n.cpp.

PolynomialMod2 PolynomialMod2::operator>> ( unsigned int n ) const
 

Definition at line 420 of file gf2n.cpp.

PolynomialMod2 & PolynomialMod2::operator>>= ( unsigned int n )
 

Definition at line 378 of file gf2n.cpp.

int PolynomialMod2::operator[] ( unsigned int i ) const [inline]
 

return coefficient for x^i.

Definition at line 120 of file gf2n.h.

PolynomialMod2 & PolynomialMod2::operator^= ( const PolynomialMod2 & t )
 

Definition at line 210 of file gf2n.cpp.

void PolynomialMod2::swap ( PolynomialMod2 & a ) [inline]
 

Definition at line 163 of file gf2n.h.


Friends And Related Function Documentation

class GF2NT [friend]
 

Definition at line 233 of file gf2n.h.

ostream & operator<< ( ::ostream & out,
const PolynomialMod2 & a ) [friend]
 

Definition at line 449 of file gf2n.cpp.


The documentation for this class was generated from the following files:
Generated at Mon Jan 15 01:16:59 2001 for Crypto++ by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000