Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Tagged SHA256 hashes#42

Merged
apoelstra merged 4 commits intorust-bitcoin:masterfrom
stevenroose:sha256t
Feb 21, 2020
Merged

Tagged SHA256 hashes#42
apoelstra merged 4 commits intorust-bitcoin:masterfrom
stevenroose:sha256t

Conversation

@stevenroose
Copy link
Copy Markdown
Collaborator

@stevenroose stevenroose commented May 2, 2019

Introducing a new SHA256t hash type that works as a tagged hash. The idea of tagged hashes is to prevent collisions between hashes meant for different purposes. This type allows tagging these hashes using Rust's type system so that they are semantically different from each other and can't be confused.

It also enables seamless efficient calculation of these hashes.

The Tag::engine() method should return a HashEngine that is prefilled with data. Of course, it is supposed to have this data statically initialized instead of calculated on call.

Example usage: rust-bitcoin/rust-bitcoin#259

@stevenroose stevenroose changed the title WIP: [experiment] Tagged SHA256 hashes Tagged SHA256 hashes Sep 5, 2019
@stevenroose stevenroose force-pushed the sha256t branch 2 times, most recently from 47d6f6d to effe044 Compare September 6, 2019 11:09
@dr-orlovsky
Copy link
Copy Markdown
Contributor

Is there anything that prevents this from being merged?

@apoelstra
Copy link
Copy Markdown
Member

I'd prefer there be a real system out there (even a branch of elements where we can launch a regtest node) so we can test the API in the wild.

@dr-orlovsky
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work with the fix from stevenroose#3

@stevenroose
Copy link
Copy Markdown
Collaborator Author

Thanks, @dr-orlovsky! This PR should be good for review then!

@apoelstra
Copy link
Copy Markdown
Member

Can you add a unit test which actually implements this Tag trait so it's clear how to use it?

@stevenroose
Copy link
Copy Markdown
Collaborator Author

I added the tapleaf hash as an example.

Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! Ok, makes sense

@apoelstra apoelstra merged commit 108d17b into rust-bitcoin:master Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants