{"id":39289285,"url":"https://github.com/meelgroup/bosphorus","last_synced_at":"2026-01-18T01:15:27.809Z","repository":{"id":41196344,"uuid":"161556331","full_name":"meelgroup/bosphorus","owner":"meelgroup","description":"Bosphorus, ANF simplifier and solver, and ANF-to-CNF converter","archived":false,"fork":false,"pushed_at":"2025-04-06T12:43:47.000Z","size":635,"stargazers_count":76,"open_issues_count":7,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-12-26T12:56:07.604Z","etag":null,"topics":["anf","anf-simplifications","cnf","cryptoanalysis","dimacs","sat"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meelgroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-12T23:09:05.000Z","updated_at":"2025-09-22T23:32:49.000Z","dependencies_parsed_at":"2024-01-27T05:23:36.917Z","dependency_job_id":"9d25f190-3d0d-48dc-b859-b828b0b06232","html_url":"https://github.com/meelgroup/bosphorus","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/meelgroup/bosphorus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fbosphorus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fbosphorus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fbosphorus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fbosphorus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meelgroup","download_url":"https://codeload.github.com/meelgroup/bosphorus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meelgroup%2Fbosphorus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28525947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"ssl_error","status_checked_at":"2026-01-18T00:39:39.467Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["anf","anf-simplifications","cnf","cryptoanalysis","dimacs","sat"],"created_at":"2026-01-18T01:15:26.422Z","updated_at":"2026-01-18T01:15:27.804Z","avatar_url":"https://github.com/meelgroup.png","language":"C++","readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Docker Hub](https://img.shields.io/badge/docker-latest-blue.svg)](https://hub.docker.com/r/msoos/bosphorus/)\n\nBosphorus is an ANF simplification and solving tool. It takes as input an ANF\nover GF(2) and can simplify and solve it. It uses many different algorithms,\nincluding XL, SAT, Brickenstein's ANF-to-CNF conversion, Gauss-Jordan\nelimination, etc. to simplify and solve ANFs.\n\nThe main use of the system is to simplify and solve ANF problems. It should\ngive you highly optimised ANFs and CNFs that it can solve. Its ANF\nsimplifications should be useful is many areas, not just direct ANF-to-SAT\nsolving. For example, it could be useful for helping to break [post-quantum\ncryptograpy\nproblems](https://csrc.nist.gov/projects/post-quantum-cryptography).\n\nThis work was done by Davin Choo and Kian Ming A. Chai from DSO National\nLaboratories Singapore, and Mate Soos and Kuldeep Meel from the National\nUniversity of Singapore (NUS). If you use Bosphorus, please cite our\n[paper](https://www.cs.toronto.edu/~meel/Papers/date-cscm19.pdf)\n([bibtex](https://www.cs.toronto.edu/~meel/bib/CSCM19.bib)) published at DATE\n2019. Some of the code was generously donated by [Security Research Labs,\nBerlin](https://srlabs.de/).\n\n\n## ANF simplification and solving\nSuppose we have a system of two equations:\n```\nx1 ⊕ x2 ⊕ x3 = 0\nx1 * x2 ⊕ x2 * x3 + 1 = 0\n```\n\nPut this in the ANF file `test.anf`:\n```\n$ cat test.anf\nx1 + x2 + x3\nx1*x2 + x2*x3 + 1\n```\nor, you can use the more detailed description:\n```\n$ cat test-detail.anf\nx(1) + x(2) + x(3)\nx(1)*x(2) + x(2)*x(3) + 1\n```\n\nLet's simplify, output a simplified ANF, a simplified CNF, solve it and write\nout the solution:\n```\n$ ./bosphorus --anfread test.anf --anfwrite out.anf --cnfwrite out.cnf --solvewrite solution\n```\n\nThe simplified ANF is in `out.anf`:\n```\n$ cat out.anf\nc -------------\nc Fixed values\nc -------------\nx(2) + 1\nc -------------\nc Equivalences\nc -------------\nx(3) + x(1) + 1\nc UNSAT : false\n```\n\nThe simplified CNF is in `out.cnf`:\n```\n3 0\n2 4 0\n-2 -4 0\n```\nThis CNF represents all the solutions to the ANF, i.e. it's equivalent to the\nANF.\n\n\nA solution to the problem is in `solution`:\n```\n$ cat solution\nv -0 1 2 -3\n```\nThis means x0 is `false`, x1 is `true`, x2 is `true` and x3 is `false`.\n\nExplanation of simplifications performed:\n* The first linear polynomial rearranged to `x1 = x2 + x3` to eliminate x1 from the other equations\n* The second polynomial becomes `(x2 + x3) * x2 + x2 * x3 + 1 = 0`, which simplifies to `x2 + 1 = 0`\n* Substituting `x2 + 1 = 0` yields `x1 + x3 + 1 = 0`\n\n## List all solutions of an ANF\n\nTo find all solutions to `myfile.anf`:\n```\n./bosphorus \\\n    --anfread myfile.anf \\\n    --cnfwrite myfile.cnf \\\n    --solve --allsol\n[...]\ns ANF-SATISFIABLE\nv x(0) x(1)+1 x(2) x(3)\ns ANF-SATISFIABLE\nv x(0) x(1)+1 1+x(2) 1+x(3)\ns ANF-UNSATISFIABLE\nc Number of solutions found: 2\n```\n\nWhere `x(0)` means `x(0)` must be FALSE and `x(1)+1` means `x(1)` must be TRUE.\n\nTo convert `myfile.anf` to `myfile.cnf` with all the simplifications:\n\n## Counting solutions of an ANF\n\nSometimes, there are too many solutions to an ANF to list them all (e.g.\n2**40). You can count the number of solutions of an ANF in `test.anf` by using\nthe standard translation and taking advantage of the projection written inside\nthe CNF. This projection set is written as `c ind var1 var2 ... varn 0`. Many\ncounters, such as [ApproxMC](https://github.com/meelgroup/approxmc) are able to\nuse this format to count the solutions in the CNF. Here is how to do it with\nApproxMC:\n\n```\n./bosphorus --anfread test.anf --cnfwrite out.cnf\n./approxmc out.cnf\n[...]\nc [appmc] Number of solutions is: 256*2**6\ns mc 16384\n```\n\nIf the number of solutions is low (say, less than 1000) you can also use\nCryptoMiniSat to do the counting:\n\n```\n./bosphorus --anfread test.anf --cnfwrite out.cnf\n./cryptominisat --maxsol 100000 out.cnf\n[...]\nc Number of solutions found until now:    16384\ns UNSATISFIABLE\n```\n\n## CNF simplification\n\nThis usage of the tool is **EXPERIMENTAL**. Do not, under any circumstances,\nrely on its correctness or veracity. In general `--cnfread` is not\nwell-supported. If you are still interested, then Bosphorus can simplify and\nsolve CNF problems. When simplifying or solving CNF problems, the CNF is\n(extremely) naively translated to ANF, then simplifications are applied, and a\nsophisticated system then translates the ANF back to CNF. This CNF can then be\noptinally solved.\n\nLet's say you have the CNF:\n\n```\n$ cat test.cnf\n-2  3  4 0\n 2 -3 0\n 2  3 -4 0\n-2 -3 -4 0\n 1  5 0\n-1 -5 0\n```\n\nLet's simplify and get the ANF:\n```\n$ ./bosphorus --cnfread test.cnf --anfwrite out2.anf\n$ cat out2.anf\nx(1)*x(2)*x(3) + x(1)*x(2) + x(1)*x(3) + x(1)\nx(1)*x(2)*x(3) + x(1)*x(2) + x(2)*x(3) + x(2)\nx(1)*x(2) + x(1) + x(2) + 1\nx(1)*x(2)*x(3)\nx(1) + x(2) + x(3)\nc -------------\nc Equivalences\nc -------------\nx(4) + x(0) + 1\n\n```\n\nThe system recovered XOR `x(1) + x(2) + x(3)` using ElimLin from the top 4\nequations that encode the CNF's first 4 clauses. This resoution is in fact\nnon-trivial, and can lead to interesting facts that can then be re-injected\nback into the CNF. Note that the first 4 clauses encode an XOR because the 2nd\nclause can be extended to the weaker clause `2 -3 4 0`, giving the trivial\nencoding of `x(1) + x(2) + x(3)` in CNF.\n\n## Mapping solutions from CNF to ANF\n\nLet's take a simple ANF:\n\n```\n$ cat test.anf\nx(1) + x2 + x3\nx1*x2 + x2*x3 + 1\n```\n\nLet's simplify and it to CNF:\n\n```\n./bosphorus --anfread test.anf  --cnfwrite test.cnf --solmap solution_map\n```\n\nLet's solve with any SAT solver:\n\n```\nlingeling test.cnf \u003e cnf_solution\n```\n\nLet's map the CNF solution back to ANF using the python script under `utils/map_solution.py`:\n\n```\n./map_solution.py solution_map cnf_solution\nc solution below, with variables starting at 0, as per ANF convention.\ns ANF-SATISFIABLE\nv x(0) 1+x(1) 1+x(2) x(3)\n```\n\nThis means that `x(0)=FALSE`, `x(1)=TRUE`, `x(2)=TRUE`, and `x(3)=FALSE`.\n\nIf you want all solutions:\n\n```\n./cryptominisat x --maxsol 10000000 \u003e cnf_solutions\n```\n\nThen take the solutions from `cnf_solutions` individually, put them in a file,\nand call `map_solution` on it, as before.\n\n# Building, Testing, Installing\n\nI suggest checking out the [GitHub\naction](https://github.com/meelgroup/bosphorus/blob/master/.github/workflows/build.yml)\nto see how to build and test the system.\n\n## Fuzzing\nThe tool comes with a built-in ANF fuzzer. To use, install\n[cryptominisat](https://github.com/msoos/cryptominisat), then run:\n\n```\ngit clone --depth 1 https://github.com/meelgroup/bosphorus\ncd bosphorus\nmkdir build\ncd build\nln -s ../utils/* .\n./build_normal.sh\n./fuzz.sh /usr/bin/cryptominisat5\n```\n\nWhere the argument to `fuzz.sh` must be the location of the cryptominisat5 binary.\n\n## Known issues\n- PolyBoRi cannot handle ring of sizes over approx 1 million (1048574). Do not\n  run `bosphorus` on instances with over a million variables.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeelgroup%2Fbosphorus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeelgroup%2Fbosphorus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeelgroup%2Fbosphorus/lists"}