{"id":22283345,"url":"https://github.com/kilic/fp","last_synced_at":"2025-07-18T16:36:55.794Z","repository":{"id":144311505,"uuid":"199699827","full_name":"kilic/fp","owner":"kilic","description":"Nearly generic prime field implementation in Go","archived":false,"fork":false,"pushed_at":"2020-02-11T11:26:48.000Z","size":481,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-05T03:51:09.416Z","etag":null,"topics":["avo","prime-fields","x86-assembly"],"latest_commit_sha":null,"homepage":"","language":"Assembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kilic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-07-30T17:43:02.000Z","updated_at":"2025-03-30T00:45:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"15096fb6-1b64-456d-bd9e-a6cf78b1d3ec","html_url":"https://github.com/kilic/fp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kilic/fp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilic%2Ffp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilic%2Ffp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilic%2Ffp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilic%2Ffp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kilic","download_url":"https://codeload.github.com/kilic/fp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kilic%2Ffp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265793684,"owners_count":23829180,"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":["avo","prime-fields","x86-assembly"],"created_at":"2024-12-03T16:39:44.478Z","updated_at":"2025-07-18T16:36:55.770Z","avatar_url":"https://github.com/kilic.png","language":"Assembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"`fp` generates prime fields, field elements and x86 optimized, high speed field operations.\n\n## Generating Field\n\nExample commands to generate fields can be found [here](codegen/example.sh). \n\nThere are four generation modes.\n\n### A. Predefined Modulus\n\nGiven modulus input you get a field implementation with its precomputed constants.\n\n```sh\n# maybe you would like to generate a field for a BLS12-381 elliptic curve implementation\nMODULUS=0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab\ngo run . -output $GEN_DIR -bit 384 -opt A -modulus $MODULUS\n```\n\n### B. Random Field\n\nOption B helps to generate a random field with random prime modulus at desired bit length.\n\n### C. Arbitrary modulus\n\nWith this option you get a field implementation where you feed the modulus while construction of a field in runtime.\n\n### D. Generic\n\nIn generic case, field elements are `unsafe pointers`. This helps us to decide size of field element and its arithmetic functions in runtime. It also helps us to represent field element with single type independent from their size. [Generic field implementation](generic/field.go) is already generated.\n\n```go\ntype fieldElement = unsafe.Pointer\n\n// Given limb size returns field element filled with zero \nfunc newFieldElement(limbSize int) (fieldElement, error) {\n  switch limbSize {\n  case 1:\n    return unsafe.Pointer(\u0026[1]uint64{}), nil\n  case 2:\n   return unsafe.Pointer(\u0026[2]uint64{}), nil\n case 3:\n   return unsafe.Pointer(\u0026[3]uint64{}), nil\n  ...\n  case 12:\n    return unsafe.Pointer(\u0026[12]uint64{}), nil\n  ...\n  ...\n}\n```\n\nSimply provide a modulus in bytes to initialize a field.\n\n```go\npStr := \"0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001\"\npBytes, _ := hex.DecodeString(pStr[2:])\nfield := newField(pBytes)\n```\n\n## Benchmark\n\nBenchmarked on 2,7 GHz i5 machine\n\nTable below shows multiplication delays corresponding field sizes in bits.\n\n```\n128:  10.5 ns/op\n192:  15.8 ns/op\n256:  23.9 ns/op\n320:  33.3 ns/op\n384:  43.4 ns/op\n448:  59.2 ns/op\n512:  67.2 ns/op\n576:  81.9 ns/op\n640:  103 ns/op\n704:  130 ns/op\n768:  153 ns/op\n832:  177 ns/op\n896:  202 ns/op\n960:  228 ns/op\n1024: 256 ns/op\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilic%2Ffp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkilic%2Ffp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkilic%2Ffp/lists"}