Link to this headingScrypt
- resistant to dictionary attacks, GPU attacks and ASIC attacks
- Uses a lot of memory biased on the options
- Memory required = 128 * N * r * p bytes
- Uses a lot of memory biased on the options
- Uses the Salsa key schedule algorithm as a Mixer
- Uses single rounds of pbkdf2-sha256 to initialize the internal buffer
- Options
- N – iterations count (affects memory and CPU usage), e.g. 16384 or 2048
- r – block size (affects memory and CPU usage), e.g. 8
- p – parallelism factor (threads to run in parallel - affects the memory, CPU usage), usually 1
- password – the input password (8-10 chars minimal length is recommended)
- salt – securely-generated random bytes (64 bits minimum, 128 bits recommended)
- derived-key-length - how many bytes to generate as output, e.g. 32 bytes (256 bits)
Link to this headingUsage
#Scrypt(password, salt, itteration_count, block_size, parallel, output_size)
= b
= b
= 2048
= 8
= 1
= 32
=
#Derived key: e813a6f6ccc4e9110193bf9efb7c0a489d76655f9e36629dccbeaf2a73bc0c6f
Link to this headingImplementation
"""docstring for Scrypt"""
#Check that memory factor * parallel factor is not greater than 2^30
=
=
#Check if Itterations is not a power of 2 greater than 2^0
=
=
#Initalize other temp buffers
= *
= *
= << 5
=
#Populate the Memory buffer from the input buffer
=
#print(self.memory_buffer)
#Mix the memory buffer and update the itteration buffer
= *
=
#Do a Block mix
=
#
= &
^=
#Do a Block mix
=
#print(self.memory_buffer)
=
return
= << 4
=
^=
#Salsa round
=
#Choose to replace in buffer
= +
=
#Copy Blocks arround
= << 5
= << 4
=
= + 16
= << 4
=
return
=
=
=
#???
=
=
#smix rounds
=
=
return
=
=
#8dc98cddcf52dd725d52b913f7bf8386fa44e1406795aa661487f434007dff1680be6baddd724659316f7ff4663174a7a4ead1c95d5175cf284ac9ae8703e1fb
=
=
#77053f0f354002c0f2a240ce9c7b17625fb1440f87a714451217e901f7d03d748411b0bc8e4c150a573f40b98dfa816cf12bb6b01a7567970f1448d7d2a1367a
=
=
#cc93bb017c38aaf54901146bdc5d21c21be2314ea63ec0a4466ea44af50c8a5c87b5cd567b8205f69f601fc8ed66e4108c5b8f12474e06520de57b8fdcc484bc
=
=
#e3e97ec22c635ca626a6e977ae90c69845ee4c716b57e9c00757e508822fedd83d1d0539d2de1c241b830d4ce59d0bcba72d482217f193af07a125eb1c67455f