node-argon2 icon indicating copy to clipboard operation
node-argon2 copied to clipboard

How to hash without salt?

Open VityaSchel opened this issue 1 year ago • 2 comments

I really need to hash without salt (https://docs.oxen.io/oxen-docs/products-built-on-oxen/session/loki-name-system-for-session) and by that I mean salt that is equal to 0 bytes but when I try saltLength: 0 or salt: Buffer.alloc(0), argon2 throws [Error: Salt is too short]

VityaSchel avatar Jan 27 '24 02:01 VityaSchel

You can't, Argon2 does not support hashing without salt. The implementation of Argon2 expected in this document is not compliant with the reference one

ranisalt avatar Jan 27 '24 22:01 ranisalt

It seems the documentation you sent is incorrect. This product uses libsodium and that requires a fixed salt length of 16 bytes. They simply initialize it with a zeroed buffer.

https://github.com/oxen-io/oxen-core/blob/7bda65c5d2f615c317682ee82cd8251d35a60b69/src/cryptonote_core/oxen_name_system.cpp#L1725-L1740

You likely can achieve the same hashes by passing { salt: Buffer.alloc(16) } as the second param for hash

ranisalt avatar Jan 30 '24 15:01 ranisalt