I just skimed your code and looks like std/random module is used for cryptographic purposes in randomSeed proc: https://github.com/C-NERD/nimAptos/blob/main/src/aptos/ed25519/ed25519.nim https://github.com/C-NERD/nimAptos/blob/main/src/aptos/accounts/aptos_account.nim
Please read: https://nim-lang.org/docs/random.html
You can use this module instead: https://nim-lang.org/docs/sysrand.html
randomSeed proc returns a 32 bytes value but random module can generate only 2^(16 * 8) - 1 values because Rand has only 16 bytes status.
I have replaced std/random with std/sysrand in the randomSeed proc of the ed25519 module. I also fixed some errors I noticed occured due to dependency version mistakes, Thanks once more for pointing out the improvement to make on the randomSeed proc.
Also I would love if more members of the community would participate in stress testing this library as it would help make it better. And that if anyone wishes to participate, the person should also try to post the issue on the github issue of the repo so that it will be easier for others to find in the future, Thanks
I'm not sure what your threat model is regarding cryptography but this is a big no-no:
https://github.com/C-NERD/nimAptos/blob/08b838a/src/aptos/ed25519/ed25519.nim#L60-L72
You're using the standard library hex parsing which is vulnerable to timing attacks and MUST NOT be used for cryptographic keys. Either use:
There are very unidiomatic blank lines and indents in your library after function declarations or var sections.
Thank you for this observation. I have pushed a fix to the devel branch at https://github.com/C-NERD/nimAptos/commit/6efcfda09cc7868ded304f4cf9cb8f89cfda7691 using libsodium procs bin2hex and hex2bin.
I'm not sure what your threat model is regarding cryptography but this is a big no-no
Currently I do not have a threat model, but I'll be sure to draft one in the coming days. Any tips on what to lookout for in terms of cryptographic security?
There are very unidiomatic blank lines and indents in your library after function declarations or var sections.
The blanklines are simply for aesthetics, I like how they look and it make code more readable to me.
Thanks again