Skip to content
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

Add blake2 as built in hash function and make HashingAlgorithm non-exhaustive #881

Merged
merged 5 commits into from
Jun 10, 2024

Conversation

ameba23
Copy link
Contributor

@ameba23 ameba23 commented Jun 7, 2024

Blake2 is used to hash ECDSA signer payloads on substrate / polkadot. So i think it makes sense to have it as one of our built in hash functions. This PR does that.

Ive also marked the HashingAlgorithm enum as non_exhaustive. This means we handle the case that it was some unknown variant and return a user error if it was. The idea is to future proof - meaning we can add extra variants without breaking validators who didn't yet update their software. There are probably arguments against doing this, so im willing to take it out if people think its a bad idea.

@ameba23 ameba23 changed the title Add blake2 as built in hash function and make HashingAlgorithm non-exaustive Add blake2 as built in hash function and make HashingAlgorithm non-exhaustive Jun 7, 2024
@@ -16,6 +16,7 @@ At the moment this project **does not** adhere to
- Add a way to change program modification account ([#843](https://github.com/entropyxyz/entropy-core/pull/843))
- Add support for `--mnemonic-file` and `THRESHOLD_SERVER_MNEMONIC` ([#864](https://github.com/entropyxyz/entropy-core/pull/864))
- Add validator helpers to cli ([#870](https://github.com/entropyxyz/entropy-core/pull/870))
- Add blake2 as built in hash function and make HashingAlgorithm non-exhaustive ([#881](https://github.com/entropyxyz/entropy-core/pull/881)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Im not sure if this counts as a breaking change. I think old JSON encoded signature requests will still work. But the shared type HashingAlgorithm has changed so strictly speaking this probably is breaking.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah this would be breaking for the entropy-shared crate since: a) we added a new field to a public enum and b) with the addition of non_exhaustive existing callers now need to handle the wildcard case.

We should also add this PR to the Added section.

@ameba23 ameba23 requested review from HCastano and JesseAbram June 7, 2024 09:52
Copy link
Collaborator

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

Cool cool.

Do you have any other docs supporting the use of Blake2 for ECDSA? I've found a couple places in the Substrate codebase (1, 2), but I was hoping to find a non-source code reference to this as well

@@ -16,6 +16,7 @@ At the moment this project **does not** adhere to
- Add a way to change program modification account ([#843](https://github.com/entropyxyz/entropy-core/pull/843))
- Add support for `--mnemonic-file` and `THRESHOLD_SERVER_MNEMONIC` ([#864](https://github.com/entropyxyz/entropy-core/pull/864))
- Add validator helpers to cli ([#870](https://github.com/entropyxyz/entropy-core/pull/870))
- Add blake2 as built in hash function and make HashingAlgorithm non-exhaustive ([#881](https://github.com/entropyxyz/entropy-core/pull/881)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah this would be breaking for the entropy-shared crate since: a) we added a new field to a public enum and b) with the addition of non_exhaustive existing callers now need to handle the wildcard case.

We should also add this PR to the Added section.

@ameba23
Copy link
Contributor Author

ameba23 commented Jun 7, 2024

Do you have any other docs supporting the use of Blake2 for ECDSA? I've found a couple places in the Substrate codebase (1, 2), but I was hoping to find a non-source code reference to this as well

No. It looks like the k256 crate which synedrion is based on uses sha256 by default, so i wouldn't say that blake2 is the standard for ecdsa/secp256k1 by any means: https://docs.rs/k256/0.13.1/src/k256/schnorr/signing.rs.html#216

@ameba23 ameba23 merged commit 1f608e5 into master Jun 10, 2024
1 of 3 checks passed
@ameba23 ameba23 deleted the peg/add-blake2 branch June 10, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants