{"id":16517832,"url":"https://github.com/erhant/fftype","last_synced_at":"2025-10-05T17:33:57.317Z","repository":{"id":172834918,"uuid":"640668194","full_name":"erhant/fftype","owner":"erhant","description":"Finite-field arithmetic within the type system.","archived":false,"fork":false,"pushed_at":"2023-06-05T19:23:22.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T19:49:25.054Z","etag":null,"topics":["cryptography","elliptic-curves","finite-fields","polynomials","types","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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":"2023-05-14T20:48:21.000Z","updated_at":"2023-06-05T19:15:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"5fe6962f-3642-4e06-a455-8566fc79db32","html_url":"https://github.com/erhant/fftype","commit_stats":null,"previous_names":["erhant/fftype"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erhant/fftype","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Ffftype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Ffftype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Ffftype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Ffftype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erhant","download_url":"https://codeload.github.com/erhant/fftype/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Ffftype/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278487576,"owners_count":25995211,"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-10-05T02:00:06.059Z","response_time":54,"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","elliptic-curves","finite-fields","polynomials","types","typescript"],"created_at":"2024-10-11T16:33:54.685Z","updated_at":"2025-10-05T17:33:57.302Z","avatar_url":"https://github.com/erhant.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\n    \u003ccode\u003efftype\u003c/code\u003e\n  \u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ccode\u003efinite-field arithmetic within the type system\u003c/code\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.typescriptlang.org/\" target=\"_blank\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/%E2%99%A5-3178C6?logo=typescript\u0026logoColor=white\" alt=\"TypeScript\" /\u003e\n    \u003ca\u003e\n    \u003ca href=\"./.github/workflows/types.yml\" target=\"_blank\"\u003e\n        \u003cimg alt=\"Workflow: types\" src=\"https://github.com/erhant/fftype/actions/workflows/types.yml/badge.svg?branch=main\"\u003e\n    \u003c/a\u003e\n    \n\u003c/p\u003e\n\nStart by installing dependencies with `yarn` or `npm i`. To run a function, assign its result to a type and simply \"hover over\" that type to see the results of \"running\" that function with some input.\n\n### Implementations\n\nWe have the following existing implementations:\n\n- [int4](./src/definitions/int4/): 4-Bit Non-Negative Integers\n- [int5](./src/definitions/int5/): 5-Bit Non-Negative Integers\n- [gf5](./src/definitions/gf5.d.ts): Galois Field of order 5\n- [gf13](./src/definitions/gf13.d.ts): Galois Field of order 13\n\nTo use an implementation, simply export them at [`source.d.ts`](./src/source.d.ts).\n\n### Writing an implementation\n\nWhen writing an implementation for a new field of order $p$, one must do the following:\n\n- Let $k$ be the minimum number of bits required to represent $p$.\n- Implement $k+1$ bits bitwise arithmetic.\n- Define the type of order in $k+1$ bits.\n- Define the type of field elements in $k+1$ bits.\n\nFor example, consider the Galois Field of order 5. The number 5 is representable with 3 bits as 101, so:\n\n- We must implement 4-bit arithmetic.\n- We define `type Ford = [0, 1, 0, 1]` which is 5 in bitwise representation.\n- We implement the field type `type Felt = [0, 1, 0, 0] | [0, 0, Bit, Bit]` which covers all bitwise representation of numbers `0, 1, 2, 3, 4`.\n\nAs another example, consider the Galois Field of order 13. The number 13 is representable with 4 bits as 1101, so:\n\n- We must implement 5-bit arithmetic.\n- We define `type Ford = [0, 1, 1, 0, 1]` which is 13 in bitwise representation.\n- We implement the field type `type Felt = [0, 1, 1, 0, 0] | [0, 1, 0, Bit, Bit] | [0, 0, Bit, Bit, Bit]` which covers all bitwise representation of numbers `0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12`.\n\n## Testing\n\nTests are done via [@type-challenges/utils](https://github.com/SamVerschueren/@type-challenges/utils), you can run them via `yarn test`. Note that testing is simply compiling everything and see if you get any errors.\n\n## Status\n\n- [x] Bitwise Operations\n  - [x] Addition\n  - [x] Subtraction\n  - [x] Rotations\n  - [x] Shifting\n  - [x] Fills\n  - [x] Logic\n- [ ] Finite Field Arithmetic\n  - [x] Addition\n  - [x] Additive Inverse\n  - [x] Multiplication\n  - [ ] Multiplicative Inverse\n  - [x] Subtraction via Additive Inverse\n  - [ ] Division via Multiplicative Inverse\n  - [x] Quotient\n  - [x] Modulus\n  - [x] Remainder\n  - [x] Comparators\n\nAny help is appreciated...\n\n## Resources\n\n- [Building Complex Types](https://medium.hexlabs.io/building-complex-types-in-typescript-804c973ce66f)\n- [Tail Recursion in TS](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#tail-recursion-elimination-on-conditional-types)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Ffftype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferhant%2Ffftype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Ffftype/lists"}