Skip to content

stlxonline/python-balloon-hashing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Balloon Hashing

An implementation in Python of Balloon Hashing. All credit to Dan Boneh, Henry Corrigan-Gibbs, and Stuart Schechter. For more information see the research paper or their website for this project. All errors in the code are, of course, mine. Feel free to fix any mistakes.

Developer

Works on Python 3.

Background

Balloon Hashing is a new hashing function that, according to the paper, is:

  • Built from Standard Primitives: Builds on top of other common hashing functions.
  • Has Proven Memory-Hardness Properties: See paper.
  • Resistant to Cache Attacks: The idea is that an adversary who can observe the memory access patterns of the buffer in the algorithm (for example through cached side-channels) still can't figure out the password being cached.
  • Practical: Is as good as the best hashing functions used in production today.

Algorithm

The algorithm consists of three main parts, as explained in the paper. The first step is the expansion, in which the system fills up a buffer with pseudorandom bytes derived from the password and salt by computing repeatedly the hash function on a combination of the password and the previous hash. The second step is mixing, in which the system mixes time_cost number of times the pseudorandom bytes in the buffer. At each step in the for loop, it updates the nth block to be the hash of the n-1th block, the nth block, and delta other blocks chosen at random from the buffer. In the last step, the extraction, the system outputs as the hash the last element in the buffer.

Usage

An example will suffice to show how it works:

>>> import balloon as b
>>> password = "buildmeupbuttercup"
>>> salt = 'JqMcHqUcjinFhQKJ'
>>> print(b.balloon_hash(password, salt))
99c11d1d483d631783f46c235b81fac88e7d106ff304a5b1e6c7d55450e01583

# A slightly more advanced usage
>>> delta = 5
>>> time_cost = 18
>>> space_cost = 24
>>> bs = b.balloon(password, salt, space_cost, time_cost, delta=delta)
>>> print(bs.hex())
bf4d8bcd792a22ece165d996a2f1ee3af5ba92a19e79a335d191cd0840f178a6

About

Balloon Hashing implemented in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%