{"id":13736702,"url":"https://github.com/status-im/nim-stint","last_synced_at":"2025-09-03T15:33:32.493Z","repository":{"id":29417361,"uuid":"121625672","full_name":"status-im/nim-stint","owner":"status-im","description":"Stack-based arbitrary-precision integers - Fast and portable with natural syntax for resource-restricted devices.","archived":false,"fork":false,"pushed_at":"2025-01-08T13:33:45.000Z","size":569,"stargazers_count":86,"open_issues_count":18,"forks_count":11,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-05T22:17:24.520Z","etag":null,"topics":["arbitrary-precision","arm","bigint","biginteger","bignum","bignumber","blockchain","cryptography","embedded","ethereum","math","mips","multi-precision","nim","number-theory","risc-v"],"latest_commit_sha":null,"homepage":"","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/status-im.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHEv2","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-02-15T12:09:55.000Z","updated_at":"2025-01-08T13:33:31.000Z","dependencies_parsed_at":"2024-01-06T11:59:38.103Z","dependency_job_id":"cd057272-7f34-49c8-bbd0-be933293abbb","html_url":"https://github.com/status-im/nim-stint","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/status-im%2Fnim-stint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/status-im%2Fnim-stint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/status-im%2Fnim-stint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/status-im%2Fnim-stint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/status-im","download_url":"https://codeload.github.com/status-im/nim-stint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427012,"owners_count":20937214,"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":["arbitrary-precision","arm","bigint","biginteger","bignum","bignumber","blockchain","cryptography","embedded","ethereum","math","mips","multi-precision","nim","number-theory","risc-v"],"created_at":"2024-08-03T03:01:26.843Z","updated_at":"2025-04-06T03:11:54.324Z","avatar_url":"https://github.com/status-im.png","language":"Nim","funding_links":[],"categories":["Algorithms"],"sub_categories":["Bigints"],"readme":"# Stint (Stack-based arbitrary precision integers)\n\n[![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg)\n![Github action](https://github.com/status-im/nim-stint/workflows/CI/badge.svg)\n\n`stint` provides efficient and convenient N-bit integers for Nim, for arbitrary\nsizes of `N` decided at compile time with an interface similar to to\n`int64`/`uint64`.\n\nIn addition to basic integer operations, `stint` also contains primtives for\nmodular arithmetic, endian conversion, basic I/O, bit twiddling etc.\n\n`stint` integers, like their `intXX`/`uintXX` counterpart in Nim are stack-based\nvalues, meaning that they are naturally allocation-free and have value-based\nsemantics.\n\n```nim\nimport stint\n\nfunc addmul(a, b, c: UInt256): UInt256 =\n  a * b + c\n\necho addmul(u256\"100000000000000000000000000000\", u256\"1\", u256\"2\")\n```\n\n## Priorities\n\n- Portability\n  - 32 and 64 bit\n  - ARM/x86/x86_64 extensively tested\n  - Additionally RISC-V and MIPS for open hardware and low power IoT devices.\n- Speed, library is carefully tuned to produce the best assembly given the current compilers.\n  However, the library itself does not require assembly for portability.\n- No heap/dynamic allocation\n- Ease of use:\n  - Use traditional `+`, `-`, `+=`, etc operators like on native types\n  - converting to and from raw byte BigInts (also called octet string in IETF specs)\n  - converting to and from Hex\n  - converting to and from decimal strings\n\nNon-priorities include:\n\n* constant-time operation (not suitable for certain kinds of cryptography out of the box)\n* runtime precision\n\n## See also\n\n* [constantine](https://github.com/mratsim/constantine) - modular arithmetic and elliptic curve operations focusing on cryptography and constant-time implementation\n* [N2472](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2472.pdf) - `_ExtInt(N)` - native arbitrary precision integers for C\n* [stew](https://github.com/status-im/nim-stew/) - helpers and utilities for ordinary Nim integers (`endians2`, `bitops2` etc)\n\n## License\n\nLicensed and distributed under either of\n\n* MIT license: [LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT\n\nor\n\n* Apache License, Version 2.0, ([LICENSE-APACHEv2](LICENSE-APACHEv2) or http://www.apache.org/licenses/LICENSE-2.0)\n\nat your option. This file may not be copied, modified, or distributed except according to those terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatus-im%2Fnim-stint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatus-im%2Fnim-stint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatus-im%2Fnim-stint/lists"}