Sample BAT: CLAUS++ version 1

CLAUS++ (ColLaboratively Agreed User Secret), version 1, is an example of a secret-sharing BAT. It defines C++ functions for a user to generate a new public key and to compute a shared secret from another user's public key. It follows the eBATS secret-sharing API so that it is benchmarkable by the eBATS tools.

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++.

Core files

The CLAUS++ package contains several files. One file, claus++-1/sizes.h, states that there are 256 bytes in a secret key, 128 bytes in a public key, and 128 bytes in a shared secret:
     #define SECRETKEY_BYTES 256
     #define PUBLICKEY_BYTES 128
     #define SHAREDSECRET_BYTES 128
A 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:

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.

Add-on files

Another file, claus++-1/extra.cpp, defines several optional functions that document extra features of CLAUS++: These features are recorded in the eBATS database along with the time/space benchmarks.

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.


This is version 2006.11.22 of the eBATS claus++-1.html web page. This web page is in the public domain.