Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Ada/SPARK
  3. spark-nacl

spark-nacl

BSD-3-ClauseAda

A formally verified, portable SPARK 2014 implementation of the NaCl cryptographic library with constant-time algorithms.

GitHubGitHub
136 stars14 forks0 contributors

What is spark-nacl?

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.

Target Audience

Developers and organizations requiring formally verified cryptographic implementations for safety-critical systems, embedded devices, or high-security applications where proof of correctness is essential.

Value Proposition

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.

Overview

SPARK 2014 re-implementation of the TweetNaCl crypto library

Use Cases

Best For

  • Building high-assurance systems requiring formally verified cryptography
  • Embedded and bare-metal applications needing zero-footprint cryptographic libraries
  • Implementing timing-attack-resistant cryptographic operations
  • Educational projects exploring formal methods in security-critical code
  • Extending cryptographic support with verified ChaCha20 and SHA-256 implementations
  • Porting NaCl-based cryptography to platforms without C runtime dependencies

Not Ideal For

  • Projects in languages other than Ada or C without willingness to interface with SPARK tooling
  • Rapid prototyping or applications where the overhead of formal verification is unnecessary
  • Teams needing a broad range of cryptographic algorithms beyond NaCl's core and its ChaCha20/SHA-256 extensions
  • Environments without access to or familiarity with GNAT and SPARK verification tools

Pros & Cons

Pros

Automated Formal Verification

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.

Constant-Time Algorithms

Retains timing-attack-resistant implementations from NaCl, with code structured to avoid conditional statements on sensitive data, maintaining security against side-channel attacks.

Portability and Zero Footprint

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.

Extended Cryptography Support

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.

Readable and Documented Code

Features extensive explanatory comments and contracts, making it more understandable than minimal implementations like TweetNaCl, as emphasized in the README's philosophy.

Cons

Limited Language Ecosystem

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.

Toolchain Dependence

Requires specific GNAT and SPARK tools for development and verification, adding setup complexity and limiting use in environments without these tools.

Incomplete Performance Analysis

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).

No Built-in PRNG

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.

Frequently Asked Questions

Quick Stats

Stars136
Forks14
Contributors0
Open Issues3
Last commit4 months ago
CreatedSince 2019

Tags

#spark-2014#ada#constant-time#security-library#high-assurance#cryptography#public-key-cryptography#nacl#formal-verification

Built With

C
CVC4
Z
Z3
G
GNATprove
G
GNAT
A
Ada
S
SPARK 2014

Included in

Ada/SPARK821
Auto-fetched 20 hours ago

Related Projects

ada-crypto-libraryada-crypto-library

This project is obsolete is no longer developed, maintained or serviced!

Stars86
Forks20
Last commit8 years ago
libkeccaklibkeccak

SHA-3 and other Keccak related algorithms in SPARK/Ada.

Stars40
Forks3
Last commit1 month ago
libsparkcryptolibsparkcrypto

A cryptographic library in SPARK 2014

Stars29
Forks3
Last commit5 years ago
libsodium-adalibsodium-ada

libsodium for Ada - A secure cryptographic library

Stars12
Forks1
Last commit10 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub