Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aldantanneo/bigints
WIP constant time bigint implementation in SPARK
https://github.com/aldantanneo/bigints
ada bigint cryptography formal-verification spark
Last synced: 12 days ago
JSON representation
WIP constant time bigint implementation in SPARK
- Host: GitHub
- URL: https://github.com/aldantanneo/bigints
- Owner: AldanTanneo
- License: mit
- Created: 2024-11-25T13:42:02.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-01-24T14:43:36.000Z (18 days ago)
- Last Synced: 2025-01-24T15:30:56.840Z (18 days ago)
- Topics: ada, bigint, cryptography, formal-verification, spark
- Language: Ada
- Homepage:
- Size: 160 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Tests](https://github.com/AldanTanneo/bigints/actions/workflows/run_tests.yml/badge.svg)](https://github.com/AldanTanneo/bigints/actions/workflows/run_tests.yml)
# SPARK Constant Time Big Integer library
Implementation of a constant time big integer library, heavily inspired by [crypto-bigint](https://github.com/RustCrypto/crypto-bigint).
## Usage
The implementations are generic over the size of the integer
```ada
package U256 is new Bigints.Uint (256);
package U1024 is new Bigints.Uint (1024);
```There is also a generic package to deal with modular integers (ie, over a prime field)
```ada
P : U256 := ...-- a big prime, like 2^255 - 19
package GF_P is new Bigints.Modular (U256, P);
```All functions are implemented in constant time, except those with an explicit `_Vartime` suffix. Overloaded operators are also constant time.
> ⚠️ The constant time choice primitives like `Choice_From_Condition`, `Cond_Select`, `CSwap` rely on best-effort optimisation barriers.
## Tests
The library is formally checked using `gnatprove`. When contracts are respected, there cannot be any runtime errors.
Some functional contracts try to go a bit further and prove more advanced behaviours (WIP).
Tests are implemented in `./tests/src/`. Run them (UNIX only) with
```sh
cd tests
./run.sh
```