{"id":27688629,"url":"https://github.com/openfheorg/openfhe-boolean-circuit-evaluator","last_synced_at":"2026-03-13T20:27:59.957Z","repository":{"id":104797432,"uuid":"558021915","full_name":"openfheorg/openfhe-boolean-circuit-evaluator","owner":"openfheorg","description":"  Encrypted Digital Circuit Evaluator using OpenFHE's FHEW/TFHE to execute digital circuits described in various formats. ","archived":false,"fork":false,"pushed_at":"2023-10-26T18:18:52.000Z","size":13767,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-10-26T19:30:43.865Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openfheorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"Contributing.md","funding":null,"license":"LICENSE","code_of_conduct":"Code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-10-26T18:45:39.000Z","updated_at":"2023-04-20T22:39:54.000Z","dependencies_parsed_at":"2023-05-29T23:45:20.529Z","dependency_job_id":"9db42ff7-552e-4d1f-a3db-fc8a1f22063b","html_url":"https://github.com/openfheorg/openfhe-boolean-circuit-evaluator","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfheorg%2Fopenfhe-boolean-circuit-evaluator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfheorg%2Fopenfhe-boolean-circuit-evaluator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfheorg%2Fopenfhe-boolean-circuit-evaluator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfheorg%2Fopenfhe-boolean-circuit-evaluator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openfheorg","download_url":"https://codeload.github.com/openfheorg/openfhe-boolean-circuit-evaluator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250796312,"owners_count":21488706,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-25T10:01:38.620Z","updated_at":"2026-03-13T20:27:59.835Z","avatar_url":"https://github.com/openfheorg.png","language":"C++","funding_links":[],"categories":["Applications"],"sub_categories":[],"readme":"Encrypted Boolean Circuit Evaluator\n==================================\n\n![OpenFHE_logo](logo.png \"OpenFHE\")\n\nThis is a demonstration application using OPENFHE's binfhe module for\nencrypted boolean logic.\n\nThe demonstration programs here read in boolean circuits using\nmultiple formats and will execute them in encrypted form. In general\neach example program performs the following steps:\n\n- Step 1 analyze input file for I/O and other infomation (depth etc)\n\n- Step 2 translate the input to an intermediate \"assembler\" file description \n\n- Step 3 tests the function using C++ equivalent to generate test\n  vectors, or use known test vectors if supplied\n\n- Step 4 run the file in a Plaintext circuit evaluation mode and verify output\n\n- Step 5 repeats with an Encrypted Circuit Evaluation. A flag can be\n  thrown that allows gate by gate verification (it does a parallel\n  plaintext circuit evaluation). If therre is an error, the error is\n  corrected. -- Note this was added for us to debug OPENFHE's\n  implementations.\n\n\nNote that steps 1 and 2 only need be done once, the output is stored\nin a file. This can speed up working with big circuits.\n\nInput formats supported\n-----------------------\n\nCurrently only the old bristol fashion input file is supported\nhttps://homes.esat.kuleuven.be/~nsmart/MPC/old-circuits.html\n\nThese inputs are in `examples/old_bristol_ckts`.\n\nNewer bristol fashion circuits are planned to be supported soon. Some might work already.\n\nSee the Todo list at the bottom of the file.\n\nCURRENT STATUS\n--------------\nThis code is rewrite of old Matlab code originally built by BBN/NJIT for the \nDARPA Proceed program. The port implements a different approach to circuit emulation\nthat allows parallel execution of encrypted gates, and dynamic memory allocation for circuit nodes (wires / registers). \n\n### Status as of 8/12/2020\n\nExecution of gates now parallelized. Circuit management not\nparallelized and algorithm is now a choke point (is still single thread\nthat generates execution tasks, and does many searches). However, for encrypted circuits the overhead is small (less than a few percent). \nAdd FF and clocked circuits\n\n### Status as of 11/2/2022\n\nMigrated to OpenFHE.\n\nTodo:\n-----\n\n* Note: code to analyze reuse of registers/nodes is broken. so is code\n  to compute ciruit depth, as it is not needed for FHEW. may want to\n  rewrite analysis/assembler/circuit code.\n\n* Add and test new bristol fashion format\n\u003chttps://homes.esat.kuleuven.be/~nsmart/MPC/\u003e\nthese inputs are in `examples/new_bristol_ckts`.\n\nand the Goldfeder circutis\n\u003chttp://stevengoldfeder.com/projects/circuits/sha2circuit.html\u003e\n\nalso we need to eventually check out \n\u003chttps://pypi.org/project/bfcl/\u003e\n\n\n* Add parser for other input file formats. \n\n* generalize input and output to multiple registers of arbitrary bitwidths\n\n* allow encrypted I/O (i.e. do not decrypt by default)\n\n* Speed up circuit management representation, possibly with linked list\n\n* add command line flags for other parameter sets afforded by OpenFHE\n\n* split TB_crypto into md5 and sha256 test benches, since the combined code takes extremely long\nto run\n\nBuilding the system\n-------------------\n\n### Build instructions for Ubuntu\n\nPlease note that we have not tried installing this on windows or\nmacOS. If anyone does try this, please update this file with\ninstructions.  It's recommended to use at least Ubuntu 18.04, and gnu g++ 7 or greater.\n\n\n1. Install pre-requisites (if not already installed):\n`g++`, `cmake`, `make`, `autoconf`, `boost`. Sample commands using `apt-get` are listed below. It is possible that these are already installed on your system.\n\n```bash\n$ sudo apt-get install build-essential #this already includes g++`\n$ sudo apt-get install autoconf\n$ sudo apt-get install make\n$ sudo apt-get install cmake\n$ sudo apt-get install libboost-all-dev\n```\n\n\u003e Note that `sudo apt-get install g++-\u003cversion\u003e` can be used to\ninstall a specific version of the compiler. You can use `g++\n--version` to check the version of `g++` that is the current system\ndefault.\n\n2. Install OPENFHE on your system. This code was tested with\n   pre-release 1.10.3. Note we have not tested the circuit emulator\n   with the 32 bit build of OPENFHE, though it should run fine for `STD128_OPT`.\n\nFull instructions for this are to be found in the `README.md` file in\nthe [OPENFHE repo](https://github.com/openfheorg/openfhe-development).\n\nRun `make install` at the end to install the system to the default\nlocation (you can change this location, but then you will have to\nchange the Makefile in this repo to reflect the new location with \n\n`$  cmake -DCMAKE_INSTALL_PREFIX=[insert your install directory] ..`\n\n3. Clone this repo onto your system.\n\n4. Create the build directory\n\n```bash\n$ mkdir build\n```\n\n5. Build the system using make\n\n```bash\ncd build\ncmake ..\nmake\n```\n\nAll the examples will be in the `build/bin` directory. All input files, and resulting assembler outputs will be in various subdirectories under `build/examples`.\n\nRunning Simple Examples\n=======================\n\nThere are two simple examples:\n\n- `TB_adder_2bit` - runs a simple 2 bit adder. 4 bits in , 3 bits out\n- `TB_parity` - runs a circuit twice to generate and then check parity for 8 bit input. \n\t\t\t\t\nThe assembled circuit descriptions for these examples were generated by\nhand and are in `examples/simple_ckts/adder/adder_2bit.out` and\n`examples/simple_ckts/parity/parity.out`\n\nNote the following command line flags are valid (defaults shown in [ ].\n\n```\n-a assemble flag (false) note, if true then analyze must be true\n-f fanout generation flag (false)\n-z analyze flag (false)\n-c # test cases [4]\n-n # test loops [10]\n-s parameter set (TOY|STD128_OPT) [STD128_OPT]\n-m method (AP|GINX) [GINX] \n-v verbose flag (false)\n\nh prints this message\n\n```\n\n\u003e Note that for these two simple examples the `-a -f -z -c` flags, while listed, have no effect.\n\nIt is easiest to run from your `build` directory as follows:\n` cd build`\n\n`bin/TB_adder_2bit -s STD128_OPT -m GINX -v`\n\n\nAlso note that OpenFHE supports other settings for parameter set,\nwhich will be added in later releases.\n\nRunning Complicated Examples\n============================\nThere are currently four more complex examples in order of increasing run time.\n\n- `TB_comparators` - tests old bristol style comparator circuits\n- `TB_adders` - tests old bristol style adder circuits\n- `TB_multipliers` -  tests old bristol style adder circuits\n- `TB_md5` - tests old bristol style md5 circuit\n- `TB_SHA256` - tests old bristol style sha256 circuits\n- `TB_aes` - tests old bristol style AES expanded and non-expanded circuits\n\n\nFor all examples you should run the program once with the `-a -z`\nflags set in order to generate assembler output. The assembler output\nfor input case `foo.txt` will be `foo_FHE.out`. The FHE is to indicate\nthat there is no impled circuit depth limit, i.e. no explicit\nbootstrapping will be needed. This is a holdover from an older SHE\nsystem design. Note the output files are stored in the\n`build\\examples` directory tree.\n\nNote that the `-s TOY` setting can be used when assembling the\ncircuit, as the result is indepenent of the crypto parameter\nused. `TOY` is only good for debugging and verifying functional\ncorrectness -- it has *NO* security!\n\nOnce these files are generated you can run that demo case with\ndifferent settings, without the `-a -z` flags set. \n\nMore details on each demo:\n--------------------------\n\n`TB_comparators` runs the following test cases: \n\n- `comparator_32bit_unsigned_lteq.txt` \n- `comparator_32bit_unsigned_lt.txt`\n- `comparator_32bit_signed_lteq.txt`\n- `comparator_32bit_signed_lt.txt`\n\nThese are combinations of 32 bit unsigned and unsigned less-than or\nless-than-or-equal comparisons.\n\n`TB_adders` runs the `adder_32bit.txt` and   `adder_64bit.txt` test cases. \n\n`TB_multipliers` runs the single `mult_32x32.txt` test case.\n\n`TB_md5` runs the `md5.txt` test case from the crypto directory. Note:\nthis takes a long time to run typically.\n\n`TB_sha256` runs the `sha-256.txt` test case from the crypto\ndirectory. Note: this takes a long time to run typically.\n\n`TB_aes` runs the `AES-expanded.txt` and `AES-non-expanded.txt` test\ncases. Note these take a VERY long time to run typically.\n\n\nNote that while other crypto curciuts are in the\n`examples/old_bristol_ckts/crypto` directory, we currently do not have\ntest vectors for any of them, so we did not build any test bench\nprograms.\n\nWe suggest that for these larger cases, you run on a multicore machine\nwith at least 8 GB ram. The encrypted circuit evaluator will evaluate\nexcrypted gates in parallel, up to the number of OMP threads specified\nthrough the environment variable (the default is usually the number of\ncpus on the system).\n\nAlso note that the current netlist generator is not very efficient, so\nthat large circuits such as the crypto circuits take a very long time\nto set up. This is something on the list of things to optimize.\n\nAcknowledgements: \n-----------------\n\nThis system has been developed with support from the DARPA MARSHALL\nprogram. Portions of the code were based on MATLAB code previously\ndeveloped for the DARPA PROCEED program.\n\nThe port of this system to OpenFHE was funded by Duality Technologies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenfheorg%2Fopenfhe-boolean-circuit-evaluator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenfheorg%2Fopenfhe-boolean-circuit-evaluator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenfheorg%2Fopenfhe-boolean-circuit-evaluator/lists"}