سؤال

Do you know of an implementation of Galois field arithmetic in C++? At least cases like GF(216) and GF(232) should be covered. Performance is a concern, so the implementation should have given some thought to optimizing its operations.

I'd prefer a common computational library or a small library dedicated to this task alone. Lacking these, I'd also welcome some readable source code.

هل كانت مفيدة؟

المحلول 2

Perhaps you can use the code that implements GCM Mode in crypto++ (in particular, gcm.cpp). Crypto++ is a free C++ library implementing many crypto schemes. Among them is GCM which uses Galois Field arithmetic.

According to the license, the library itself is copyrighted, while the individual source files are public domain.

نصائح أخرى

I found a link to a Galois Field Arithmetic Library by Arash Partow in the Wikipedia article on Finite field arithmetic.

At first glance, the code looks almost completely without comments, but written in a structured and therefore presumably understandable way. Performance doesn't appear to be an important design criterion, though: use of inlined functions is rather limited, and in general it appears like a direct notation of the theoretic math was deemed more important than expliting computational shortcuts. I list this here for completeness, so that you can have a look, form your own opinion, and can vote or comment accordingly.

There's a library called NTL: http://www.shoup.net/ntl/ . Though its source code ain't quite "readable".

Looking for algebraic numbers, I stumbled upon this answer which suggests Givaro. And looking at that, I found that it does GF(pk) arithmetic as well. The documentation is thin, but the sources show quite a bit of code and effort. Haven't dug into details yet, but I thought I'd include it in my list here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top