(Go: >> BACK << -|- >> HOME <<)

Lyra2: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
m Dating maintenance tags: {{Not in citation given}}
Lawvere (talk | contribs)
m Copy edits
(31 intermediate revisions by 22 users not shown)
Line 1:
{{Short description|Key derivative function}}
{{Multiple issues|
{{advert|date=October 2017}}<!-- self-promotion by one of the authors of the algo: most of the article is written by a single-purpose account "Erandrade" -->
{{primary sources|date=October 2017}}
{{refimprovemore citations needed|date=October 2017}}
}}
'''Lyra2''' is a [[Password hashing|password hashing scheme]] (PHS) that can also work as a [[key derivation function]] (KDF). It received a special recognition during the [[Password Hashing Competition]] in July 2015.,<ref>{{Cite web|url=https://password-hashing.net/|title=Password Hashing Competition|website=password-hashing.net|access-date=2016-03-22}}</ref>, which was won by [[Argon2]]. Besides being used for its original purposes, itIt is also used in the core of proof-of-work algorithms such as Lyra2REv2 ,<ref name="Lyra2REv2">{{Cite web|url=https://en.bitcoinwiki.org/wiki/Lyra2REv2|title=Lyra2REv2|website=eprint.iacr.org|access-date=2016-03-22}}</ref>, adopted by Vertcoin and<ref name="vertcoin">{{Cite web|url=http://vertcoin.org|title=Vertcoin|website=vertcoin.org|access-date=2019-10-08}}</ref>, MonaCoin ,<ref name="MonaCoin">{{Cite web|url=https://monacoin.org|title=MonaCoin|website=monacoin.org|access-date=2019-10-08}}</ref>, among other cryptocurrencies.<ref name="lyra2ToC">{{Cite conference|lastlast1=van Beirendonck|firstfirst1=M.|last2=Trudeau|first2=L.|last3=Giard|first3=P.|last4=Balatsoukas-Stimming|first4=A.|date=2019-05-29|title=A Lyra2 FPGA Core for Lyra2REv2-Based Cryptocurrencies|conference=IEEE International Symposium on Circuits and Systems (ISCAS)|location=Sapporo, Japan|publisher=IEEE|pages=1–5|doi=10.1109/ISCAS.2019.8702498|arxiv=1807.05764}}</ref>
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]] from [[Polytechnic School of the University of São Paulo|Escola Politécnica da Universidade de São Paulo]].<ref name=":0">{{Cite web|url=https://eprint.iacr.org/2015/136|title=Cryptology ePrint Archive: Report 2015/136|website=eprint.iacr.org|access-date=2016-03-22}}</ref>. It is an improvement over Lyra,<ref name=":1">{{Cite journal|lastlast1=Almeida|firstfirst1=Leonardo C.|last2=Andrade|first2=Ewerton R.|last3=Barreto|first3=Paulo S. L. M.|last4=Simplicio Jr|first4=Marcos A. |date=2014-01-04|title=Lyra: password-based key derivation with tunable memory and processing costs|journal=Journal of Cryptographic Engineering|language=en|volume=4|issue=2|pages=75–89|doi=10.1007/s13389-013-0063-5|issn=2190-8508|citeseerx=10.1.1.642.8519|s2cid=5245769 }}</ref><ref name=":8">{{Cite web|url=https://eprint.iacr.org/2014/030|title=Cryptology ePrint Archive: Report 2014/030|website=eprint.iacr.org|access-date=2016-03-22}}</ref> which was 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 ofto providing a high memory usage with a processing time similar to that obtained with [[scrypt]]. In addition, it also brings the following improvements when compared to its predecessor:<ref name="lyra2ToC2">{{Cite journal|lastlast1=Andrade|firstfirst1=E.|last2=Simplicio Jr|first2=M. |last3=Barreto|first3=P.|last4=Santos|first4=P.|date=2016-01-01|title=Lyra2: efficient password hashing with high security against time-memory trade-offs|journal=IEEE Transactions on Computers|volume=PP|issue=99|pages=3096–3108|doi=10.1109/TC.2016.2516011|s2cid=37232444 |issn=0018-9340}}</ref>
* it allows a higher security level against attack venues involving [[Time/memory/data tradeoff attack|time-memory trade-offs]]
* it allows [[Legitimate expectation|legitimate]] users to benefit more effectively from the [[Parallel computing|parallelism]] capabilities of their own platforms
* it includes tweaks for increasing the costs involved in the construction of [[Field-programmable gate array|dedicated hardware]] to attack the algorithm
* it balances resistance against [[side-channel attack|side-channel threats]] and attacks relying on cheaper (and, hence, slower) [[data storage device|storage devices]]
* Lyra2 is released under [[public domain]], and provides two main extensions:<ref name="lyra2RefGuide">{{Cite web|url=https://password-hashing.net/submissions/specs/Lyra2-v3.pdf|title=The Lyra2 reference guide|lastlast1=Simplicio Jr|firstfirst1=Marcos A.|last2=Almeida|first2=Leonardo C.|last3=Andrade|first3=Ewerton R.|last4=Santos|first4=Paulo C.|last5=Barreto|first5=Paulo S. L. M.|website=PHC|publisher=The Password Hashing Competition}}</ref>
* Lyra2-δ, gives the user better control over the algorithm's bandwidth usage
* Lyra2''p'', takes advantage of [[Parallel computing|parallelism]] capabilities on the legitimate user's platform
 
This algorithm enables parameterization in terms of:<ref name="lyra2RefGuide"/>
 
This algorithm enables parameterization in terms of:<ref name="lyra2RefGuide" />
* execution time (time cost <math>T</math>)
* memory required (number of rows <math>R</math>, and number of columns <math>C</math>)
Line 21 ⟶ 24:
* number of rounds performed for the underlying permutation function (<math>\rho</math>)
* number of bits to be used in rotations (<math>\omega</math>)
* output length (<math>\kappa</math>)
 
==Strengths ==
The core strengths of the algorithm are as follows:<ref name="lyra2ToC"/><ref name="lyra2RefGuide"/>
 
*High resistance against processing-memory tradeoffstrade-offs: estimated processing costs of [[Time/memory/data tradeofftrade-off attack|attacks with low memory usage]] involve a factor that grows exponentially with time cost due to recomputations.
According to <ref name="lyra2ToC"/><ref name="lyra2RefGuide"/>, the main strenghts of the algorithm are:
*Memory and time costs can be decoupled, allowing the resources'their usage to be fine-tuned.
 
*Fast due to use of reduced-round sponge function in the algorithm's core.
*High resistance against processing-memory tradeoffs: estimated processing costs of [[Time/memory/data tradeoff attack|attacks with low memory usage]] involve a factor that grows exponentially with time cost due to recomputations
*Can provide outputs of any desired length, behaving as a [[Keykey derivation function|Key Derivation Function]] (KDF).
*Memory and time costs can be decoupled, allowing the resources' usage to be fine-tuned
*Design combines resistance to [[side-channel attack]]s (during the whole Setup phase) and to attacks involving cheap (hence, low-speed) [[Computer data storage|memory devices]], aiming to balance such conflicting requirements.
*Fast due to use of reduced-round sponge function in the algorithm's core
*ConsidersIt considers a wide range of configurations for protecting against attacking platforms while optimizing execution on legitimate platform, such as:
*Can provide outputs of any desired length, behaving as a [[Key derivation function|Key Derivation Function]] (KDF)
**Support for parallelism, for [[Multimulti-core processor|multicoremulti-core platforms]], without giving much advantage to [[Graphicsgraphics processing unit|GPU]]-based attacks.
*Design combines resistance to [[side-channel attack]]s (during the whole Setup phase) and to attacks involving cheap (hence, low-speed) [[Computer data storage|memory devices]], aiming to balance such conflicting requirements
**Capability of using different underlying sponge functions depending on the target platform (e.g., [[BLAKE2|Blake2b]]b for software implementations; [[Keccak]] for hardware implementations; BlaMka for additional resistance against hardware platforms; etc.)
*Considers a wide range of configurations for protecting against attacking platforms while optimizing execution on legitimate platform, such as:
**Ability to raise the algorithm's memory bandwidth usage. (note: the original specification is expected to max out the bandwidth in current machines, but this feature may be useful for future hardware)
**Support for parallelism, for [[Multi-core processor|multicore platforms]], without giving much advantage to [[Graphics processing unit|GPU]]-based attacks
**Capability of using different underlying sponge functions depending on the target platform (e.g., [[BLAKE2|Blake2b]] for software implementations; [[Keccak]] 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 (cryptography)|salt]] and a [[password]], creating a [[pseudorandomness|pseudorandom]] output that can then be used as key material for cryptographic algorithms or as an [[authentication protocol|authentication]] string.<ref>{{Cite journal|url=http://csrc.nist.gov/publications/nistpubs/800-108/sp800-108.pdf|title=Recommendation for Key Derivation Using Pseudorandom Functions (Revised)|last=Chen|first=Lily|website=Computer Security|publisher=NIST|doi=10.6028/NIST.SP.800-108|year=2009|doi-access=free}}</ref>{{not in citationfailed givenverification|date=December 2019}}{{Citation needed|date=December 2019}}
 
Internally, the scheme's memory is organized as a matrix that is expected to remain in memory during the whole password hashing process:. sinceSince 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.<ref name="lyra2ToC"/>
 
The construction and visitation of the matrix is done using a stateful combination of the absorbing, squeezing and duplexing operations of the underlying [[Sponge function|sponge]] (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.<syntaxhighlight lang="python">
# ***=== Functions/symbols ***===
#; <code>||</code> : Concatenate two strings
#; {{code|^}} : Bitwise XOR
#; {{code|[+]}} : Wordwise add operation (i.e., ignoring carries between words)
#; {{code|%}} : Modulus
#; {{code|W}} : The target machine's word size (usually, 32 or 64)
#; {{code|omega}} : Number of bits to be used in rotations (recommended: a multiple of the machine's word size, W)
#; {{code|>>>}} : Right rotation
#; {{code|rho}} : Number of rounds for reduced squeeze or duplexing operations
#; {{code|blen}} : Sponge's block size in bytes
#; {{code|H or H_i}} : Sponge with block size blen (in bytes) and underlying permutation f
#; {{code|H.absorb(input)}} : Sponge's absorb operation on input
#; {{code|H.squeeze(len)}} : Sponge's squeeze operation of len bytes
#; {{code|H.squeeze_{rho}(len) }} : Sponge's squeeze operation of len bytes using rho rounds of f
#; {{code|H.duplexing(input,len)}} : Sponge's duplexing operation on input, producing len bytes
#; {{code|H.duplexing_{rho}(input,len) }}:Sponge's duplexing operation on input, using rho rounds of f, producing len bytes
#; {{code|pad(string)}} : Pads a string to a multiple of blen bytes (padding rule: 10*1)
#; {{code|lsw(input)}} : The least significant word of input
#; {{code|len(string)}} : Length of a string, in bytes
#; {{code|syncThreads()}} : Synchronize parallel threads
#; {{code|swap(input1,input2)}} : Swap the value of two inputs
#; {{code|C}} : Number of columns on the memory matrix (usually, 64, 128, 256, 512 or 1024)
#; {{code|P}} : Degree of parallelism ({{code|1=P >= 1}} and {{code|1=(m_cost/2) % P == 0}})
 
# ***=== Inputs ***===
#* {{mono|password}}
#* {{mono|salt}}
#* {{mono|t_cost}}
#* {{mono|m_cost}}
#* {{mono|outlen }}
 
# *** Algorithm without parallelism ***
 
# ** Bootstrapping phase: Initializes the sponge's state and local variables
 
# ***=== Algorithm without parallelism ***===
{{pre|1=<nowiki>
# ** 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
Line 95:
row1 = 1
prev1 = 0
</nowiki>
 
# ** Setup phase: Initializes a (m_cost x C) memory matrix, its cells having blen-byte cells
 
# Initializes M[0], M[1] and M[2]
Line 130:
sqrt = 2 * sqrt
# ** Wandering phase: Iteratively overwrites pseudorandom cells of the memory matrix
 
# Visitation Loop: (2 * m_cost * t_cost) rows revisited in pseudorandom fashion
Line 152:
prev1 = row1
 
# ** Wrap-up phase: output computation
 
# Absorbs a final column with a full-round sponge
Line 162:
# Provides outlen-long bitstring as output
return output
}}
 
# ***=== Algorithm with parallelism ***===
<pre>
 
for each i in [0,..P[]
# ** Bootstrapping phase: Initializes the sponge's state and local variables
# Byte representation of input parameters (others can be added)
Line 186 ⟶ 187:
prevP = 0
 
# ** Setup phase: Initializes a (m_cost x C) memory matrix, its cells having blen-byte cells
 
# Initializes M_i[0], M_i[1] and M_i[2]
Line 228 ⟶ 229:
syncThreads()
# ** Wandering phase: Iteratively overwrites pseudorandom cells of the memory matrix
 
wnd = m_cost / (2 * P)
Line 261 ⟶ 262:
syncThreads()
 
# ** Wrap-up phase: output computation
 
# Absorbs a final column with a full-round sponge
Line 271 ⟶ 272:
# Provides outlen-long bitstring as output
return output_0 ^ ... ^ output_{P-1}
</pre>
</syntaxhighlight>
 
==Security analysis==
Against Lyra2, the processing cost of attacks using <math>1/2^{n+2} </math> of the amount of memory employed by a legitimate user is expected to be between <math>O(2^{2nT}R^{3})</math> and <math>O(2^{2nT}R^{n+2})</math>, the latter being a better estimate for <math>n \gg 1</math>, instead of the <math>O(R)</math> achieved when the amount of memory is <math>O(R)</math>, where <math>T</math> is a user-defined parameter to define a processing time.
 
This compares well to [[scryptScrypt]], which displays a cost of <math>O(R^{2})</math> when the memory usage is high<math>O(1)</math>,<ref>{{Cite web|url=https://www.tarsnap.com/scrypt/scrypt.pdf|title=Stronger Key Derivation via Sequential Memory-Hard Functions|last=Percival|first=Colin|website=TARSNAP|publisher=The Technical BSD Conference}}</ref> and with other solutions in the literature, for which the results are usually <math>O(R^{T+1})</math>.<ref name=":1" /><ref>{{Cite web|url=https://eprint.iacr.org/2013/525|title=Cryptology ePrint Archive: Report 2013/525|website=eprint.iacr.org|access-date=2016-03-22}}</ref><ref>{{Cite web|url=https://www.uni-weimar.de/fileadmin/user/fak/medien/professuren/Mediensicherheit/Research/Theses/sascha-schmidt-master-thesis-catena.pdf|title=Implementation of the Catena Password-Scrambling Framework|last=Schmidt|first=Sascha|website=Bauhaus-Universität Weimar|publisher=Faculty of Media}}</ref><ref>{{Cite web|url=https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf|title=P-H-C/phc-winner-argon2|website=GitHub|access-date=2016-03-22}}</ref>
 
Nonetheless, in practice these solutions usually involve a value of <math>R</math> (memory usage) lower than those attained with the Lyra2 for the same processing time.<ref name=":3">{{Cite web|url=http://article.gmane.org/gmane.comp.security.phc/2237|title=Gmane -- Another PHC candidates mechanical tests|website=article.gmane.org|access-date=2016-03-22}}</ref><ref name=":4">{{Cite web|url=http://article.gmane.org/gmane.comp.security.phc/1992|title=Gmane -- A review per day Lyra2|website=article.gmane.org|access-date=2016-03-22}}</ref><ref name=":5">{{Cite web|url=http://article.gmane.org/gmane.comp.security.phc/1596|title=Gmane -- Lyra2 initial review|website=article.gmane.org|access-date=2016-03-22}}</ref><ref name=":6">{{Cite web|url=http://article.gmane.org/gmane.comp.security.phc/1849|title=Gmane -- Memory performance and ASIC attacks|website=article.gmane.org|access-date=2016-03-22}}</ref><ref name=":7">{{Cite web|url=http://article.gmane.org/gmane.comp.security.phc/1830|title=Gmane -- Quick analysis of Argon|website=article.gmane.org|access-date=2016-03-22}}</ref>
 
==Performance==
[[File:Lyra2-Bench.pdf|thumb|1050x1050px|center|Performance of SSE-enabled Lyra2, for C = 256, ρ = 1, p = 1, and different T and R settings, compared with SSE-enabled scrypt[[Scrypt]] and memory-hard PHC finalists with minimum parameters.]]
 
The processing time obtained with a SSE single-core implementation of Lyra2 are illustrated in the hereby shown figure. This figure was extracted from,<ref name=":2lyra2ToC2">{{Cite journal|last=Andrade|first=E.|last2=Simplicio Jr|first2=M. |last3=Barreto|first3=P.|last4=Santos|first4=P.|date=2016-01-01|title=Lyra2: efficient password hashing with high security against time-memory trade-offs|journal=IEEE Transactions on Computers|volume=PP|issue=99|pages=3096–3108|doi=10.1109/TC.2016.2516011|issn=0018-9340}}</ref> and is very similar ofto, third-party benchmarks performed during the PHC context.<ref name=":3" /><ref name=":4" /><ref name=":5" /><ref name=":6" /><ref name=":7" />
 
The results depicted correspond to the average execution time of Lyra2 configured with <math>C=256</math>, <math>\rho=1</math>, <math>b=768</math> bits (i.e., the inner state has 256 bits), and different <math>T</math> and <math>R</math> settings, giving an overall idea of possible combinations of parameters and the corresponding usage of resources.
Line 289 ⟶ 290:
As shown in this figure, Lyra2 is able to execute in: less than 1 s while using up to 400 MB (with <math>R = 2^{14}</math> and <math>T=5</math>) or up to 1 GB of memory (with <math>R \approx 4.2\cdot10^{4}</math> and <math>T=1</math>); or in less than 5 s with 1.6 GB (with <math>R = 2^{16}</math> and <math>T=6</math>).
 
All tests were performed on an [[List of Intel Xeon microprocessors|Intel Xeon E5-2430]] (2.20&nbsp;GHz with 12 Cores, 64 bits) equipped with 48 GB of [[Dynamic random-access memory|DRAM]], running [[Ubuntu (operating system)|Ubuntu]] 14.04 LTS 64 bits, and the source code was compiled using [[GNU Compiler Collection|gcc]] 4.9.2.<ref name=":2lyra2ToC2" />
 
==References==