{"id":16517824,"url":"https://github.com/erhant/polenta","last_synced_at":"2026-02-06T01:40:11.777Z","repository":{"id":257653784,"uuid":"821564885","full_name":"erhant/polenta","owner":"erhant","description":"A toy language to play around with polynomials over finite fields.","archived":false,"fork":false,"pushed_at":"2024-10-29T18:59:30.000Z","size":100,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T19:11:08.424Z","etag":null,"topics":["cryptography","lambdaworks","pest","polynomials","repl","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/polenta/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erhant.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":"2024-06-28T20:49:33.000Z","updated_at":"2025-01-28T07:54:49.000Z","dependencies_parsed_at":"2025-01-13T06:53:25.462Z","dependency_job_id":null,"html_url":"https://github.com/erhant/polenta","commit_stats":null,"previous_names":["erhant/polenta"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erhant/polenta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fpolenta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fpolenta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fpolenta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fpolenta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erhant","download_url":"https://codeload.github.com/erhant/polenta/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fpolenta/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276184489,"owners_count":25599343,"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","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cryptography","lambdaworks","pest","polynomials","repl","rust"],"created_at":"2024-10-11T16:33:51.494Z","updated_at":"2025-09-21T02:32:15.503Z","avatar_url":"https://github.com/erhant.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polenta\n\n![Crates.io Version](https://img.shields.io/crates/v/polenta)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/erhant/polenta/tests.yml?label=tests)\n![Crates.io License](https://img.shields.io/crates/l/polenta)\n\nPolenta is a toy polynomial arithmetic language, and **everything** is a polynomial. As such, it is more suited towards having fun instead of having performance.\n\n## Features\n\n- [x] Polynomial arithmetic using [lambdaworks](https://github.com/lambdaclass/lambdaworks)\n- [x] REPL to play around with\n- [x] `let` and `assert` expressions\n- [ ] `prove` and `commit` expressions\n- [ ] selecting fields\n\n\u003e The project mostly started to learn more about Pest, and it is a lovely project! See \u003chttps://pest.rs\u003e for more!\n\n## Installation\n\nYou can add the [crate](https://crates.io/crates/polenta) with:\n\n```sh\ncargo add polenta\n```\n\nYou can install the REPL with:\n\n```sh\ncargo install polenta --features=\"repl\"\n```\n\n## Usage\n\nIn this section we go over what can be done with Polenta.\n\n\u003e All code shown below are valid Polenta code. To follow along, you can use the REPL installed above!\n\n### Statements\n\nYou can use Polenta as a calculator-over-field.\n\n```rs\n\u003e 10 - 2^3 * 2;\n18446744069414584315\n```\n\nHowever, you should keep in mind that all operations are defined over the field, so division might not always work as you expect:\n\n```rs\n\u003e 1 / 2; // some number x such that 2*x = 1, not 0.5!\n9223372034707292161\n```\n\n\u003e Polenta supports single line comments using `//`, as shown above.\n\n### Creating a Polynomial\n\nA polynomial is created by specifying its terms.\n\n```rs\n\u003e let P(x) = 3*x^2 + 5;\n3*x^2 + 5\n```\n\nBehind the scenes all terms are considered a monomial, and they are composed together. As such, you can repeat a term with the same degree and the result will have them added up:\n\n```rs\n\u003e let P(x) = 3*x^2 + 2*x^2 + 1*x^2;\n6*x^2\n\u003e let Q(x) = 5*x - 5*x + 1;\n1\n```\n\nYou can also multiply polynomials:\n\n```rs\n\u003e let P(x) = (x + 1)*(x + 2)*(x + 4);\nx^3 + 7*x^2 + 14*x + 8\n```\n\nYou can create a polynomial from an existing one:\n\n```rs\n\u003e let P(x) = 3*x;\n3*x\n\u003e let Q(x) = P^2 + 2*P;\n9*x^2 + 6*x\n```\n\nShadowing is allowed:\n\n```rs\n\u003e let P(x) = 3*x;\n3*x\n\u003e let P(x) = 3*P + 5;\n9*x + 5\n```\n\nYou can use an identifier within a polynomial, but if the identifier has the same name as the term, it will be ignored.\n\n```rs\n\u003e let t = 2;\n\u003e let x = 5;\n\u003e let P(x) = x^t + 2*x;\nx^2 + 2*x\n```\n\n### Equality\n\nPolenta has `==` and `!=` operators that return either a 1 or 0 based on the equality.\n\n```rs\n\u003e 2 == 3\n0\n\u003e let P(x) = 2*x\n2*x\n\u003e let Q(x) = 3*x - x\n2*x\n\u003e P == Q\n1\n```\n\n### Evaluating a Polynomial\n\nEvaluation is achieved using a binary operation `@`, so that `P@2` means \"evaluate polynomial `P` at point `2`.\n\n```rs\n\u003e let P(x) = 3*x;\n3*x\n\u003e let z = P@3;\n9\n\u003e let Q(x) = x^z + z*x;\nx^9 + 9*x\n```\n\nRemember that everything is a polynomial in Polenta, so you could evaluate a number as well. Evaluation will not have an effect because a number is treated as a constant polynomial.\n\n```rs\n\u003e 4@2\n4\n```\n\nSince evaluation is a binary operation, you can chain them together:\n\n```rs\n\u003e let P(x) = 3*x + 1;\n3*x + 1\n\u003e let Q(x) = x/2;\n9223372034707292161*x\n\u003e Q@P@Q@P@3; // Q(P(Q(P(3))))\n8\n```\n\n### Assertions\n\nYou can make assertions within Polenta for safety, where a failed assertion throws an `AssertionError`.\nAn assertion fails if the expression that they are given is a zero polynomial.\n\n```rs\n\u003e assert 1\n1\n\u003e assert 0\n  × Assertion Failed\n\n\u003e assert 43\n43\n```\n\n### Errors in REPL\n\nWhile using REPL, if there is an error you will see it on screen with clear logs.\n\n```sh\n\u003e let x = idontexist;\n  × Unknown Identifier: idontexist\n\u003e 5/0;\n  × Division by Zero\n\u003e let a = ++syntaxerror--;\n  × Syntax Error\n   ╭─[input:1:9]\n 1 │ let a = ++syntaxerror--;\n   ·         ─\n   ╰────\n  help: Expected one of [expr], got []\n```\n\n## Testing\n\nRun all tests with:\n\n```sh\ncargo test\n```\n\n## License\n\nPolenta is MIT licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Fpolenta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferhant%2Fpolenta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Fpolenta/lists"}