{"id":22724647,"url":"https://github.com/mottla/go-r1cs-compiler","last_synced_at":"2025-04-13T19:07:00.097Z","repository":{"id":50151495,"uuid":"230733112","full_name":"mottla/go-R1CS-Compiler","owner":"mottla","description":"A compiler to turn GO code into a zkSNARK","archived":false,"fork":false,"pushed_at":"2021-07-19T06:25:56.000Z","size":1075,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T06:56:44.160Z","etag":null,"topics":["arithmetic-circuit","constraint","gates","golang","groth16","language","r1cs","snark","zk-snarks"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mottla.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}},"created_at":"2019-12-29T10:09:24.000Z","updated_at":"2024-04-08T18:19:06.000Z","dependencies_parsed_at":"2022-09-18T05:47:27.145Z","dependency_job_id":null,"html_url":"https://github.com/mottla/go-R1CS-Compiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mottla%2Fgo-R1CS-Compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mottla%2Fgo-R1CS-Compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mottla%2Fgo-R1CS-Compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mottla%2Fgo-R1CS-Compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mottla","download_url":"https://codeload.github.com/mottla/go-R1CS-Compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229082311,"owners_count":18017251,"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":["arithmetic-circuit","constraint","gates","golang","groth16","language","r1cs","snark","zk-snarks"],"created_at":"2024-12-10T15:07:29.771Z","updated_at":"2024-12-10T15:07:30.523Z","avatar_url":"https://github.com/mottla.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-R1CS Compiler\n\n**UNDER CONSTRUCTION**\n\n\n**Circuit Language**\nA subset of Golang (with slight modifications), suitable for the creation of Non-Interactive Succinct Arguments, such as zkSNARKs.\nThis projects goal is to provide a compiler that translates Go-code into R1CS, which is the compilation target\nand starting point for various zkSNARK constructions.\n\n-This compiler currently supports the creation of Groth16 zkSNARKs.\n\n-Comes with JS graph rendering support to visualize the generated arithmetic circuit if needed. \n\n# Language\n\n## main\n\nas in Go, every program starts with the function 'main'\n\n```\nfunc main(){\n#this is a comment\n}\n```\n\nmain can be fed with an arbitrary amount of single arguments and n-dimensional static size arrays of single values.\nMain does not support functions as inputs.\n\n```\nfunc main(a bool,b [2]uint32, c field, d uint64){\n\n}\n```\n\n## Declare public inputs\n\nIn order to declare, which of the Main-Function inputs will be part of the public statement of the SNARK, write\n\n```\nfunc main(a bool,b [2][3]uint32, c field, d uint64){\n    public{\n        a, \n        b[1][1],\n        c\n    }\n}\n```\n\n\n## variables\n\nVariable assignment and overloading follows the same logic as in Golang: \n\n```\n    var a = 42*17  # is now a field type element\n    # var a = x*x   -\u003e Error- variable a already declared\n    # a = true   -\u003e type missmatch. Field expected, got bool\n    var b = uint32(235)\n\n    #declare array\n    var c = [2]uint32{b,b+2}\n    \n    #declare function. Functions can return functions or take them as arguments\n    var d = func(x field, b func()(bool) , c [4]bool)( func()(field)) {\n               return 42\n            }\n\n}\n```\n\n\n## Function preloading\n\nAt this point we extended Go by this cool functionality.\nOne now can partially preload a function\n\n```\nfunc main(x field){\n    var multiply = func(a field,b field)(field){return a*b}\n    var multiplyBy5 = multiply(5)\n    multiplyBy5(x) #is now the same as multiply(5,x) \n}\n```\n\n## Operations\n\n| Operator   |      Description      |  Remark |\n|----------|:-------------:|------:|\n| + |  addition |  |\n| * |    multiplication   |   |\n| - | subtraction |     |\n| / | division|     |\n| ** | exponentiation |    *|\n| \u003c\u003c | left shift|   * |\n| \u0026gt;\u0026gt; | right-shift |    *  |\n| \u003c\u003c\u003c | rotate-left |   * |\n| \u0026gt;\u0026gt;\u0026gt; | rotate-right |    * |\n| \u0026 | bitwise-and |     |\n| \u0026#124; | bitwise-or |     |\n| ^ | bitwise-xor |     |\n| == | equality |     |\n| != | un-equality |     |\n\n*rhs must be fixed at compile-time\n\n\n## if-else if-else\n\nin order to create braching conditions, write:\n\n```\nif expression1{ \n    ...\n}else if expression2{\n    ...\n}else if expression3{\n    ...\n}else{\n    ...\n}\n```\n\nnote that we currently only support static decidable branching conditions\n\n## arrays\n\ntba.\n\n# SNARK stuff\n\n## euquality assertion gate\n\nin order to create an equality assertion constraint write\n\n```\nequal(expression1,expression2)\n```\n\nexample: in order to prove knowledge of a square root of some input y, write\n\n```\nfunc main(x field,y field){\n   public{y}\n   equal(x*x,y)\n}\n```\n\n## split\n\nto split a value into its bit representatives write\n\n```\nSPLIT(x)\n```\n\nnow the i'th bit of x can be accessed with x[i], where x[0] is the least significant bit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmottla%2Fgo-r1cs-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmottla%2Fgo-r1cs-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmottla%2Fgo-r1cs-compiler/lists"}