New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: functionality to work with Hidden
types
#148
Conversation
Hidden
typesHidden
types
This should be checked by @jorgeantonio21 to see if it properly addresses the issues he had. |
hasher.update([0, 0, 0]); | ||
|
||
let mut output = GenericArray::<u8, <Blake256 as Digest>::OutputSize>::default(); | ||
hasher.finalize_into(&mut output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a new line with an assertion to compare the result of output with the same data, hashed using finalize
.
hasher.update([0, 0, 0]); | ||
|
||
let mut output = GenericArray::<u8, <Blake256 as Digest>::OutputSize>::default(); | ||
hasher.finalize_into_reset(&mut output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Will merge once there's an ACK |
ACK |
Work in
tari_utilities
PR 52 provides a newHidden
type for hidden data that supports safer handling of underlying data that supports theZeroize
trait. This is intended to handle things like passphrases, seed words, and derived key materials.Initial work by @jorgeantonio21 on migrating existing key derivation function (KDF) outputs to use
Hidden
found two issues pretty quickly:SecretKey
andPublicKey
traits do not enforceZeroize
, even though the Ristretto-based implementations in this crate do.The first issue is more of an annoyance, since it means a
Hidden
type containing a genericSecretKey
orPublicKey
needs to add additionalZeroize
trait bounds everywhere. This PR adds the trait bound to both. SinceRistrettoSecretKey
andRistrettoPublicKey
already implementZeroize
, this change is seamless. This addresses part of issue 147.The second issue is trickier. While we can't control what goes on inside the state of any underlying hash function (e.g.
Blake256
in thetari
crate), and while some hashing API use cases don't assume the output is sensitive, KDF use cases do. For these cases, we want to minimize non-zeroized copies of the output. This PR mitigates this by implementingFixedOutput
forDomainSeparatedHasher
, which adds in-place output support. The use of the requiredfinalize_into_reset
might be helpful in this case, since it doesn't consume the hasher but resets its internal state (albeit in a way that isn't clear to me).