Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 6.42 KB

README.md

File metadata and controls

79 lines (57 loc) · 6.42 KB

LIGHTER-R

LIGHTER-R is a tool to (near-)optimally implement a given 4 × 4 SBox using logic gates from a reversible logic library (with an associated cost metric). This is an extension of the tool LIGHTER [hyperlinked original publication, archived publication, source codes]; which only works for 4 × 4 SBoxes the classical computing paradigm, namely for ASIC and CPU implementations.

The source code, hosted on GitHub, is a supporting component for the paper: LIGHTER-R: Optimized Reversible Circuit Implementation For SBoxes by Vishnu Asutosh Dasu, Anubhab Baksi, Sumanta Sarkar and Anupam Chattopadhyay [IEEE SoCC 2019/publication].

Please feel free to suggest/contribute new features or fix bugs or add documentation.

Command Line Usage

./non-lin-search [-v] [-w] [-u] [-q]
               [-l NUMBER] [-p NUMBER] [-r NUMBER]
               [-i SBOX] [-o SBOX]
               [-f FILE] [-s IMPLEMENTATION_ID]

-v : Verbose mode
-u : Expand only [-i] function (identity function by default)
-w : Write graph output in a file

-q : Enable all reversible gates (essential for LIGHTER-R)

-l <value> : Define an upper bound on the cost of the implementations generated
-p <value> : Define the number of threads used
-r <value> : Define an upper bound on the RAM used by the algorithm

-i <function> : Define start function
-o <function> : Define arrival function

-f <file> : Define the logic library with the associated cost metric

-s <string> : Define implementation information

Apart from -q and -s, rest of the options are adopted from the vanilla LIGHTER; and the -a option is omitted. The -q option is necessary for LIGHTER-R to work; and the -s option takes a string (such as the cipher name) and associates the string to the names of the C-like implementation files.

Implemented Reversible Logic Gates

Gate Library Quantum Cost Two-qubit Cost Gate Count Symbol
NOT (Tof1) NCT/ MCT 1 0 1 RNOT1
CNOT (Tof2) NCT/ MCT 1 1 1 CNOT1
CCNOT (Tof3) NCT/ MCT 5 5 1 CCNOT2
Tof4 MCT 13 5 1 CCCNOT2

Naming Convention

The number following the logic gate symbol denotes the number of primitive logic gates used to implement the gate. For example, CNOT1 uses 1 XOR gate in its implementation. In the case of Tof3 XOR and AND gates are used, hence CCNOT2.

TFC Support

Inside the /reversible-helper directory, the lighter_to_tfc.py file allows to convert a generated C file to the .tfc format. To use it, pass the source file in the command line. The output file will have the same name and will be generated in the same direcroty as the source file.

Notes

  1. The -a option should not be used while proceesing LIGHTER-R (i.e., together with -q).
  2. The Peres (Per3) gate is implemented in the peres branch, but this branch is not under active development.
  3. Apparently LIGHTER does not support logic gates with 0 cost. Through empirical tests, we observe that it does not work (basically, prints nothing) if the cost is less than 0.01. For this reason, the cost for the NOT (Tof1) gate has been substituted for 0.01 instead in all three (NCT, MCT and MCT+MCF) libraries.
  4. It is recommended to g++11 or later version.

Changes From Vanilla LIGHTER

  1. All basic functionalities are preserved — so the vanilla LIGHTER can be utilized (including the -a option)
  2. software.conf is renamed as CPU.conf and all the libraries (.conf files) are moved to the /libraries directory
  3. The description of the SBox (such as 0123456789ABCDEF) is used automatically in the names of the C-like implementation files when -s is not used
  4. Minor update is made in the Makefile to suppress a warning (utils.cpp:65:31: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result])