You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, @oli-obk You asked for use cases so this is on you ;)
I think that being able to hash in a const fn is a needed use case in production.
Domain separation between hashing different messages is good practice in cryptography [0],[1],[2]
so I'd want to do something along these lines: const TaggedHashAppA: Sha256 = Sha256::new().input(b"AppA")
or even:
Hi,
@oli-obk You asked for use cases so this is on you ;)
I think that being able to hash in a const fn is a needed use case in production.
Domain separation between hashing different messages is good practice in cryptography [0],[1],[2]
so I'd want to do something along these lines:
const TaggedHashAppA: Sha256 = Sha256::new().input(b"AppA")
or even:
you'll then use it like that:
This is a naive implementation that manages to do everything under const eval (you can search for "Replacement" to see stuff I had to replace to make it work) except the
input
function on line 60https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=2a3be44298313834597b0e834a6050af
Had to replace:
W[..16].copy_from_slice(&block);
with:
And unroll a couple of loops.
[0] https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-05#section-2.2.5
[1] https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf Section 2.3 "Domain Separation"
[2] https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki "Tagged Hashes"
The text was updated successfully, but these errors were encountered: