6

I am working on my project of Elliptic Curve Cryptography which requires programming on binary fields. It includes basic operations like addition, multiplication, inversion etc w.r.t. an irreducible binary polynomial.

I am searching for a way by which these binary polynomials can be stored in a program. I am working on C and C++ programming language (with gmp library) so the first thought came to my mind was to use structures and bit-fields. But they are not dynamic and can't hold arbitrarily long polynomials. Using C++ Vector STL is possible but it won't be efficient, as it stores a single bit in a single word of 8 or more bits.

Is there any way of representation which is efficient?

Gaurav
  • 398
  • 8
  • 23

1 Answers1

0

It is NOT effectiv to store informations bitwise in an array. If I were you I would store the Bit-Informations in a big UNSIGNED LONG INTEGER and write a function that can get and put the bits in and out of this cluster of integer value. This way of storing the bit-information would speed up your solution up to 64 times!

  • You are right. But that won't be dynamic and restrict data size to just 64 bits. – Gaurav Dec 14 '15 at 08:53
  • 1
    Use a dynamic array of integers as underlying storage. The access function would cover this. The add/remove functions would grow and shrink the array using `realloc()`. @Gaurav – alk Dec 14 '15 at 09:12
  • @Gaurav - It's my understanding that the irreducible binary polynomial is fixed in size, and it's only the data that is variable length, and assuming this is true, then most of the time you're working with fixed length variables, which could be arrays of 32 or 64 bit unsigned integers. – rcgldr Dec 14 '15 at 13:37