cheatfate / nimcrypto

Nim cryptographic library
MIT License
190 stars 23 forks source link

Trouble using scrypt #51

Closed deeuu closed 3 years ago

deeuu commented 3 years ago

Hi,

I'm trying to import and use scrypt, but am having issues when trying to run an example based on the test suite:

import nimcrypto / [scrypt]

func myscrypt[T, M](password: openArray[T], salt: openArray[M],
                   N, r, p, keyLen: static[int]): array[keyLen, byte] =
  let (xyvLen, bLen) = scryptCalc(N, r, p)
  var xyv = newSeq[uint32](xyvLen)
  var b = newSeq[byte](bLen)
  discard scrypt(password, salt, N, r, p, xyv, b, result)

discard myscrypt(password = "", salt = "", N = 16, r = 1, p = 1, keyLen = 64)
nim c -r main.nim                                                                                                                                                                                                                                                                                                           
Hint: used config file '/home/deeuu/.choosenim/toolchains/nim-1.4.2/config/nim.cfg' [Conf]
Hint: used config file '/home/deeuu/.choosenim/toolchains/nim-1.4.2/config/config.nims' [Conf]
..............
/home/deeuu/git/nimcrypto/main.nim(10, 17) template/generic instantiation of `myscrypt` from here
/home/deeuu/git/nimcrypto/main.nim(8, 17) template/generic instantiation of `scrypt` from here
/home/deeuu/git/nimcrypto/nimcrypto/hmac.nim(89, 25) Error: undeclared field: 'hmacSizeBlock'

It looks like I have to import hmac to get around it, i.e.

import nimcrypto / [scrypt, hmac]

Any help is much appreciated!

cheatfate commented 3 years ago

Fixed in https://github.com/cheatfate/nimcrypto/commit/cd6899010324006216962fc35b44c0aa8698aded