ltonetwork / seasalt

NaCl compatible cryptography library using Bouncy Castle (Java)
Apache License 2.0
3 stars 1 forks source link

NaCL compatible seeding #17

Closed KaloyanTanev closed 2 years ago

KaloyanTanev commented 2 years ago

The problem: private key from seed in NaCL didn't correspond to the same private key in SeaSalt

The solution: BouncyCastle (the library used in SeaSalt) uses Java's SecureRandom which always provides different seed . There are some workarounds - https://stackoverflow.com/questions/27341294/get-deterministic-values-from-securerandom, but it's irrelevant to continue using SecureRandom. Instead of doing that, I moved to the NaCL's approach of doing SHA-256 over the given seed and providing this as private key parameter. Deriving the public key from it stays the same, however, I changed the private key to be 64-bytes long (same as in NaCL) which consists of the seed + public key.