Lyra2
   HOME

TheInfoList



OR:

Lyra2 is a
password hashing scheme A password, sometimes called a passcode (for example in Apple devices), is secret data, typically a string of characters, usually used to confirm a user's identity. Traditionally, passwords were expected to be memorized, but the large number of ...
(PHS) that can also work as a
key derivation function In cryptography, a key derivation function (KDF) is a cryptographic algorithm that derives one or more secret keys from a secret value such as a master key, a password, or a passphrase using a pseudorandom function (which typically uses a crypto ...
(KDF). It received a special recognition during the
Password Hashing Competition The Password Hashing Competition was an open competition announced in 2013 to select one or more password hash functions that can be recognized as a recommended standard. It was modeled after the successful Advanced Encryption Standard process and ...
in July 2015, which was won by
Argon2 Argon2 is a key derivation function that was selected as the winner of the 2015 Password Hashing Competition. It was designed by Alex Biryukov, Daniel Dinu, and Dmitry Khovratovich from the University of Luxembourg. The reference implementation ...
. Besides being used for its original purposes, it is also in the core of proof-of-work algorithms such as Lyra2REv2, adopted by Vertcoin, MonaCoin, among other cryptocurrencies Lyra2 was designed by Marcos A. Simplicio Jr., Leonardo C. Almeida, Ewerton R. Andrade, Paulo C. F. dos Santos, and
Paulo S. L. M. Barreto Paulo S. L. M. Barreto (born 1965) is a Brazilian cryptographer and one of the designers of the Whirlpool (algorithm), Whirlpool cryptographic hash function, hash function and the block ciphers Anubis (cipher), Anubis and KHAZAD, together with Vin ...
from Escola Politécnica da Universidade de São Paulo. It is an improvement over Lyra, previously proposed by the same authors. Lyra2 preserves the security, efficiency and flexibility of its predecessor, including: (1) the ability to configure the desired amount of memory, processing time and parallelism to be used by the algorithm; and (2) the capacity of providing a high memory usage with a processing time similar to that obtained with
scrypt In cryptography, scrypt (pronounced "ess crypt") is a password-based key derivation function created by Colin Percival in March 2009, originally for the Tarsnap online backup service. The algorithm was specifically designed to make it costly ...
. In addition, it brings the following improvements when compared to its predecessor: * it allows a higher security level against attack venues involving time-memory trade-offs * it allows legitimate users to benefit more effectively from the parallelism capabilities of their own platforms * it includes tweaks for increasing the costs involved in the construction of dedicated hardware to attack the algorithm * it balances resistance against side-channel threats and attacks relying on cheaper (and, hence, slower) storage devices * Lyra2 is released under
public domain The public domain (PD) consists of all the creative work A creative work is a manifestation of creative effort including fine artwork (sculpture, paintings, drawing, sketching, performance art), dance, writing (literature), filmmaking, ...
, and provides two main extensions: * Lyra2-δ, gives the user better control over the algorithm's bandwidth usage * Lyra2''p'', takes advantage of parallelism capabilities on the legitimate user's platform This algorithm enables parameterization in terms of: * execution time (time cost T) * memory required (number of rows R, and number of columns C) * degree of parallelism (number of threads p) * underlying permutation function (can be seen as the main cryptographic primitive) * number of blocks used by the underlying permutation function (''bitrate'') * number of rounds performed for the underlying permutation function (\rho) * number of bits to be used in rotations (\omega) * output length (\kappa)


Strengths

The main strengths of the algorithm are: *High resistance against processing-memory tradeoffs: estimated processing costs of attacks with low memory usage involve a factor that grows exponentially with time cost due to recomputations *Memory and time costs can be decoupled, allowing the resources' usage to be fine-tuned *Fast due to use of reduced-round sponge function in the algorithm's core *Can provide outputs of any desired length, behaving as a
key derivation function In cryptography, a key derivation function (KDF) is a cryptographic algorithm that derives one or more secret keys from a secret value such as a master key, a password, or a passphrase using a pseudorandom function (which typically uses a crypto ...
(KDF) *Design combines resistance to
side-channel attack In computer security, a side-channel attack is any attack based on extra information that can be gathered because of the fundamental way a computer protocol or algorithm is implemented, rather than flaws in the design of the protocol or algorit ...
s (during the whole Setup phase) and to attacks involving cheap (hence, low-speed) memory devices, aiming to balance such conflicting requirements *Considers a wide range of configurations for protecting against attacking platforms while optimizing execution on legitimate platform, such as: **Support for parallelism, for multi-core platforms, without giving much advantage to
GPU A graphics processing unit (GPU) is a specialized electronic circuit designed to manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device. GPUs are used in embedded systems, mobi ...
-based attacks **Capability of using different underlying sponge functions depending on the target platform (e.g.,
BLAKE2 BLAKE is a cryptographic hash function based on Daniel J. Bernstein's ChaCha stream cipher, but a permuted copy of the input block, XORed with round constants, is added before each ChaCha round. Like SHA-2, there are two variants differing in t ...
b for software implementations;
Keccak SHA-3 (Secure Hash Algorithm 3) is the latest member of the Secure Hash Algorithm family of standards, released by NIST on August 5, 2015. Although part of the same series of standards, SHA-3 is internally different from the MD5-like struct ...
for hardware implementations; BlaMka for additional resistance against hardware platforms; etc.) **Ability to raise the algorithm's memory bandwidth usage (note: the original specification is expected to max out the bandwidth in current machines, but feature may be useful for future hardware)


Design

As any PHS, Lyra2 takes as input a
salt Salt is a mineral composed primarily of sodium chloride (NaCl), a chemical compound belonging to the larger class of salts; salt in the form of a natural crystalline mineral is known as rock salt or halite. Salt is present in vast quantitie ...
and a
password A password, sometimes called a passcode (for example in Apple devices), is secret data, typically a string of characters, usually used to confirm a user's identity. Traditionally, passwords were expected to be memorized, but the large number of ...
, creating a
pseudorandom A pseudorandom sequence of numbers is one that appears to be statistically random, despite having been produced by a completely deterministic Determinism is a philosophical view, where all events are determined completely by previously exi ...
output that can then be used as key material for cryptographic algorithms or as an
authentication Authentication (from ''authentikos'', "real, genuine", from αὐθέντης ''authentes'', "author") is the act of proving an assertion, such as the identity of a computer system user. In contrast with identification, the act of indicati ...
string. Internally, the scheme's memory is organized as a matrix that is expected to remain in memory during the whole password hashing process: since its cells are iteratively read and written, discarding a cell for saving memory leads to the need of recomputing it whenever it is accessed once again, until the point it was last modified. The construction and visitation of the matrix is done using a stateful combination of the absorbing, squeezing and duplexing operations of the underlying
sponge Sponges, the members of the phylum Porifera (; meaning 'pore bearer'), are a basal animal clade as a sister of the diploblasts. They are multicellular organisms that have bodies full of pores and channels allowing water to circulate through t ...
(i.e., its internal state is never reset to zero), ensuring the sequential nature of the whole process. Also, the number of times the matrix's cells are revisited after initialization is defined by the user, allowing Lyra2's execution time to be fine-tuned according to the target platform's resources.


Functions/symbols

, , 				Concatenate two strings
^				Bitwise XOR
 			Wordwise add operation (i.e., ignoring carries between words)
%				Modulus
W				The target machine's word size (usually, 32 or 64)
omega				Number of bits to be used in rotations (recommended: a multiple of the machine's word size, W)
>>>				Right rotation
rho				Number of rounds for reduced squeeze or duplexing operations
blen				Sponge's block size in bytes 
H or H_i			Sponge with block size blen (in bytes) and underlying permutation f
H.absorb(input)			Sponge's absorb operation on input
H.squeeze(len)			Sponge's squeeze operation of len bytes
H.squeeze_(len)		Sponge's squeeze operation of len bytes using rho rounds of f
H.duplexing(input,len)		Sponge's duplexing operation on input, producing len bytes
H.duplexing_(input,len)	Sponge's duplexing operation on input, using rho rounds of f, producing len bytes
pad(string)			Pads a string to a multiple of blen bytes (padding rule: 10*1)
lsw(input)			The least significant word of input
len(string)			Length of a string, in bytes
syncThreads()			Synchronize parallel threads
swap(input1,input2)		Swap the value of two inputs
C				Number of columns on the memory matrix (usually, 64, 128, 256, 512 or 1024)
P				Degree of parallelism (P >= 1 and (m_cost/2) % P = 0)


Inputs

* * * * *


Algorithm without parallelism


Algorithm with parallelism

for each i in  ..P	** Bootstrapping phase: Initializes the sponge's state and local variables
	
	# Byte representation of input parameters (others can be added)
	params =  outlen , ,  len(password) , ,  len(salt) , ,  t_cost , ,  m_cost , ,  C , ,  P , ,  i

	# Initializes the sponge's state (after that, password can be overwritten)
	H_i.absorb( pad(password , ,  salt , ,  params) )

	# Initializes visitation step, window and first rows that will feed 
	gap = 1
	stp = 1
	wnd = 2
	sqrt = 2
	sync = 4
	j = i

	prev0 = 2
	rowP = 1
	prevP = 0

	** Setup phase: Initializes a (m_cost x C) memory matrix, its cells having blen-byte cells

	# Initializes M_i  M_i and M_i 	for col = 0 to C-1
		M_i C-1-col] = H_i.squeeze_(blen)
	for col = 0 to C-1
		M_i C-1-col] = H_i.duplexing_( M_i col], blen)
	for col = 0 to C-1
		M_i C-1-col] = H_i.duplexing_( M_i col], blen)

	# Filling Loop: initializes remainder rows
	for row0 = 3 to ( (m_cost / P) - 1 )
		# Columns Loop: M_i ow0is initialized and M_j ow1is updated
		for col = 0 to C-1
			rand = H_i.duplexing_( M_j owPcol]  M_i rev0col]  M_j revPcol], blen)
			M_i ow0C-1-col] = M_i rev0col] ^ rand
			M_j owPcol] = M_j owPcol] ^ ( rand >>> omega )

		# Rows to be revisited in next loop
		prev0 = row0
		prevP = rowP
		rowP = (rowP + stp) % wnd

		# Window fully revisited
		if (rowP = 0)
			# Doubles window and adjusts step
			wnd = 2 * wnd
			stp = sqrt + gap
			gap = -gap
		
			# Doubles sqrt every other iteration
			if (gap = -1)
				sqrt = 2 * sqrt
		
		# Synchronize point
		if (row0 = sync)
			sync = sync + (sqrt / 2)
			j = (j + 1) % P
			syncThreads()

	syncThreads()
	
	** Wandering phase: Iteratively overwrites pseudorandom cells of the memory matrix

	wnd = m_cost / (2 * P)
	sync = sqrt
	off0 = 0
	offP = wnd

	# Visitation Loop: (2 * m_cost * t_cost / P) rows revisited in pseudorandom fashion
	for wCount = 0 to ( ( (m_cost * t_cost) / P) - 1)
		# Picks pseudorandom rows and slices (j)
		row0 = off0 + (lsw(rand) % wnd)
		rowP = offP + (lsw( rand >>> omega ) % wnd)
		j = lsw( ( rand >>> omega ) >>> omega ) % P

		# Columns Loop: update M_i ow0		for col = 0 to C-1
			# Picks pseudorandom column	
			col0 = lsw( ( ( rand >>> omega ) >>> omega ) >>> omega ) % C

			rand = H_i.duplexing_( M_i ow0col]  M_i rev0col0]  M_j owPcol], blen)
			M_i ow0col] = M_i ow0col] ^ rand

		# Next iteration revisits most recently updated rows
		prev0 = row0
		
		# Synchronize point
		if (wCount = sync)
			sync = sync + sqrt
			swap(off0,offP)
			syncThreads()

	syncThreads()

	** Wrap-up phase: output computation

	# Absorbs a final column with a full-round sponge
	H_i.absorb( M_i ow00] )

	# Squeezes outlen bits with a full-round sponge
	output_i = H_i.squeeze(outlen)

# Provides outlen-long bitstring as output
return output_0 ^ ... ^ output_


Security analysis

Against Lyra2, the processing cost of attacks using 1/2^ of the amount of memory employed by a legitimate user is expected to be between O(2^R^) and O(2^R^), the latter being a better estimate for n \gg 1, instead of the O(R) achieved when the amount of memory is O(R), where T is a user-defined parameter to define a processing time. This compares well to
scrypt In cryptography, scrypt (pronounced "ess crypt") is a password-based key derivation function created by Colin Percival in March 2009, originally for the Tarsnap online backup service. The algorithm was specifically designed to make it costly ...
, which displays a cost of O(R^) when the memory usage is O(1), and with other solutions in the literature, for which the results are usually O(R^). Nonetheless, in practice these solutions usually involve a value of R (memory usage) lower than those attained with the Lyra2 for the same processing time.


Performance

The processing time obtained with a SSE single-core implementation of Lyra2 are illustrated in the hereby shown figure. This figure was extracted from, and is very similar of third-party benchmarks performed during the PHC context. The results depicted correspond to the average execution time of Lyra2 configured with C=256, \rho=1, b=768 bits (i.e., the inner state has 256 bits), and different T and R settings, giving an overall idea of possible combinations of parameters and the corresponding usage of resources. As shown in this figure, Lyra2 is able to execute in: less than 1 s while using up to 400 MB (with R = 2^ and T=5) or up to 1 GB of memory (with R \approx 4.2\cdot10^ and T=1); or in less than 5 s with 1.6 GB (with R = 2^ and T=6). All tests were performed on an List of Intel Xeon microprocessors, Intel Xeon E5-2430 (2.20 GHz with 12 Cores, 64 bits) equipped with 48 GB of
DRAM Dynamic random-access memory (dynamic RAM or DRAM) is a type of random-access semiconductor memory that stores each bit of data in a memory cell, usually consisting of a tiny capacitor and a transistor, both typically based on metal-oxid ...
, running
Ubuntu Ubuntu ( ) is a Linux distribution based on Debian and composed mostly of free and open-source software. Ubuntu is officially released in three editions: ''Desktop'', ''Server'', and ''Core'' for Internet of things devices and robots. All the ...
14.04 LTS 64 bits, and the source code was compiled using gcc 4.9.2.


References


External links


Lyra2's websiteLyra2 source code repository on Github
{{Cryptography navbox , hash Key derivation functions