A formally verified, portable SPARK 2014 implementation of the NaCl cryptographic library with constant-time algorithms.
SPARKNaCl is a cryptographic library that reimplements the TweetNaCl API using the SPARK 2014 programming language. It provides authenticated encryption, digital signatures, and hashing with the added guarantee of formal verification for type safety and correctness. The project solves the need for high-assurance cryptography that is both portable and resistant to timing attacks.
Developers and organizations requiring formally verified cryptographic implementations for safety-critical systems, embedded devices, or high-security applications where proof of correctness is essential.
Developers choose SPARKNaCl for its unique combination of automated formal verification, constant-time algorithms, and zero-footprint portability, offering higher assurance than typical C-based cryptographic libraries while maintaining compatibility with the NaCl API.
SPARK 2014 re-implementation of the TweetNaCl crypto library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The entire library has an automated static proof of type safety and correctness using SPARK 2014 tools, ensuring no buffer overflows, numeric overflows, or runtime errors as confirmed in the README's proof results.
Retains timing-attack-resistant implementations from NaCl, with code structured to avoid conditional statements on sensitive data, maintaining security against side-channel attacks.
Compatible with the GNAT Zero Footprint runtime, enabling deployment on bare-metal embedded systems up to servers without runtime dependencies, as highlighted in the Goals section.
Includes ChaCha20, SHA-256, HMAC, HKDF, and AEAD algorithms beyond the original NaCl specification, moving towards TLS 1.3 support as noted in the June 2022 updates.
Features extensive explanatory comments and contracts, making it more understandable than minimal implementations like TweetNaCl, as emphasized in the README's philosophy.
Written in SPARK/Ada, which has a smaller community and tooling; a C API wrapper is a known TBD item, complicating integration with non-Ada projects.
Requires specific GNAT and SPARK tools for development and verification, adding setup complexity and limiting use in environments without these tools.
Performance optimization for Salsa20 and some primitives is still on the 'to be done' list, and performance can vary significantly with compiler optimization levels (e.g., slower at -O0).
The PRNG package was removed for portability, forcing clients to supply their own secure random number generator, increasing implementation effort as noted in the March 2021 updates.