tari icon indicating copy to clipboard operation
tari copied to clipboard

Consider unifying domain-separated hashers

Open AaronFeickert opened this issue 1 year ago • 2 comments

Currently, there are two ways to create domain-separated hashers: DomainSeparatedHasher and DomainSeparatedConsensusHasher.

The former is part of tari-crypto, and is designed to safely chain input data to mitigate the risk of input collision while enforcing safe domain separation. This is done by prepending a fixed-sized input length encoding to each chained input.

The latter is part of tari and is designed to work more cleanly with serialization, but is defined separately.

The separate implementations mean that not all functionality is supported in both; for example, DomainSeparatedConsensusHasher does not support finalize_into, which can be useful for generating key-type data.

To ensure safety and reduce technical debt, it would be useful to do the following:

  • Ensure that the design of DomainSeparatedConsensusHasher mitigates the risk of input collision
  • Consider modifying one or both of the implementations to use a common design or wrapping

AaronFeickert avatar Aug 22 '23 16:08 AaronFeickert