CLAUS++ is, cryptographically, a very simple form of the Diffie-Hellman secret-sharing system: it exponentiates modulo a fixed 1024-bit prime. CLAUS++ doesn't contain many lines of code: it relies on the popular GMP and NTL arithmetic libraries to generate keys and to compute shared secrets. Other BAT implementors may find CLAUS++ useful as an illustration of the ease of writing BATs.
CLAUS is a similar BAT written in C rather than C++.
#define SECRETKEY_BYTES 256 #define PUBLICKEY_BYTES 128 #define SHAREDSECRET_BYTES 128A single BAT can be parametrized and allow multiple key sizes; or it can be limited to a single key size, as illustrated by CLAUS++.
Another file, claus++-1/keypair.cpp, defines a keypair() function that generates a secret key and a public key:
int keypair( unsigned char *sk,unsigned long long *sklen, unsigned char *pk,unsigned long long *pklen ) { ... }
Another file, claus++-1/sharedsecret.cpp, defines a sharedsecret() function that generates a shared secret:
int sharedsecret( unsigned char *s,unsigned long long *slen, const unsigned char *sk,unsigned long long sklen, const unsigned char *pk,unsigned long long pklen ) { ... }
There's no special naming convention for the .cpp files and .h files other than sizes.h. All of the C++ functions could have been defined in one file or spread among any number of files. All of these files are automatically compiled together by the eBATS benchmarking tools.
At a lower level, keypair.cpp and sharedsecret.cpp can use the NTL library for arithmetic, but they instead use the GMP library for arithmetic if they're compiled with -DGMP, GMP and NTL are automatically made available to all BATs.
These two options are listed in another file, claus++-1/tunings:
-DTUNING="NTL" -DGMP -DTUNING="GMP"The benchmarking tools automatically try compiling with -DTUNING="NTL", and then try compiling with -DGMP -DTUNING="GMP"; whichever speed is better is reported. The TUNING macro is used as part of the report: either NTL or GMP appears in each CLAUS++ speed report in the eBATS database.
double multiplekeycdhchance(double e,double s,double k) { return dlchance(1024,e,s,k); }The underlying dlchance function is part of eBATS and didn't require any work by the CLAUS++ programmer.
One last file, claus++-1/documentation.pdf, contains references and other comments for cryptographers. This file isn't used in any way by the benchmarking tools but it's still an important part of a BAT.