Skip to Content
oxcrypto

Balloon

Create and verify Balloon or Balloon-M password records over SHA-2 or SHA-3.

from oxcrypto.password.balloon import BALLOON

algorithm = BALLOON.BALLOON_M
encoded = algorithm.hash(b"example password")
assert algorithm.verify(b"example password", encoded)

Both variants return one digest-sized result from derive(password, salt=..., space_cost=..., time_cost=..., parallelism=...). Space cost counts digest blocks. Set parallelism to 1 for BALLOON.BALLOON.

hash takes keyword-only space_cost, time_cost and parallelism (defaults 1024, 3, 1). hash, verify and derive take a digest:

digestOutput length
"sha256" (default)32 bytes
"sha384", "sha3-384"48 bytes
"sha512", "sha3-512"64 bytes
"sha3-256"32 bytes

The output length is the digest size: balloon-hash 0.5.0 has no variable-length output, so pick a digest for the length you need. The PHC record does not name the digest, so pass the same digest to verify.

encoded = algorithm.hash(b"example password", space_cost=4096, digest="sha3-512")
assert algorithm.verify(b"example password", encoded, digest="sha3-512")

Balloon hashing is from Boneh, Corrigan-Gibbs and Schechter, "Balloon Hashing" (ASIACRYPT 2016), an academic design without RFC or NIST status. The implementation is the RustCrypto balloon-hash crate 0.5.0, a stable release with no published audit, with sha2 0.11 and sha3 0.12. SHA-256 tests use the crate's own vectors; no published vectors exist for the other digests, so their tests check output size, digest separation and round trips.