Add support of additional crypto types and hashing algorithms for Beefy#8707
Add support of additional crypto types and hashing algorithms for Beefy#8707Klapeyron wants to merge 28 commits intoparitytech:masterfrom
Conversation
|
User @Klapeyron, please sign the CLA here. |
f2c5ac1 to
22103b7
Compare
8a29ef3 to
5f4738d
Compare
| .keys(BEEFY_KEY_TYPE) | ||
| .map_err(|e| error::Error::Keystore(e.to_string()))? | ||
| .into_iter() | ||
| .filter_map(|pk| AuthorityId::try_from(pk.as_ref()).ok()) |
There was a problem hiding this comment.
I changed the behavior here, so in case in keystore were multiple keys for beefy with different schemes, then:
Before:
it was failing on first non-compatible key
After:
it is taking keys that can be converted to AuthorityId, ignoring non-compatible ones
There was a problem hiding this comment.
this doesn't look sound, it will result in duplicate authorities list if we have authorities registered with multiple types of crypto keys -- we would get an authority instance for each compatible crypto key -- which is breaking the old behavior and potentially breaking downstream assumptions
There was a problem hiding this comment.
Opened a PR that should make some things more generic and should address this also: #10763
| }, | ||
|
|
||
| _ => Err(error::Error::Keystore("key type is not supported by BEEFY Keystore".into()))?, | ||
| _ => store |
There was a problem hiding this comment.
I am not replacing previous 2 cases with this generic call, due they perform some additional hashing, which will be not done in case I will remove them
| sig_ref.to_vec() | ||
| }, | ||
|
|
||
| _ => Err(error::Error::Keystore("key type is not supported by BEEFY Keystore".into()))?, |
There was a problem hiding this comment.
I am not adding a case for bls381::CRYPTO_ID, due it does not need additional hashing as I understand, please correct me if I am wrong :). So it should fall in generic call.
aed7013 to
26e99a8
Compare
|
Any thoughts on this @drskalman ? |
0f3d74e to
56dac31
Compare
|
Not sure if it would make sense to allow Beefy to work with custom crypto types. @acatangiu @drskalman WDYT ? Also @Klapeyron could you give us more details about your use case please ? |
Sure. So we have more zero knowledge related scenario, we would like to use schnorr jubjub for that. So far we implemented the cryptography traits so we can use it among substrate code, but without changes in this PR, BEEFY will not make a call to a keystore for necessary keys, due custom cryptography is not on the list of supported types. Draft of the changes is here: input-output-hk/partner-chains#813 Also cryptography is not the only thing we would like to adjust, probably replacement of hardocded |
5577411 to
9719b43
Compare
|
I haven't the time now to review the code in detail. The reasoning behind this PR is good to me, maybe @drskalman and @serban300 can help with the code review. One high-level comment I have is that this is making breaking changes to BEEFY primitives, and BEEFY and MMR runtime pallets. It means that it needs |
|
@serban300 @acatangiu may as ask for your review of this changes? |
b69e08a to
579c7de
Compare
579c7de to
b69e08a
Compare
|
@serban300 @skunert please review |
This reverts commit 3e12fdc.
As a follow-up of the discussion #8707 (comment), I am extracting a missing forward call to a separate PR so we can deliver it independently. Context: When keystore is used by some component (like BEEFY) via Arc, then calls of `sign_with` function are forwarded to default trait implementation. It is not working, when custom keystore with custom `sign_with` implementation is used.
As a follow-up of the discussion paritytech#8707 (comment), I am extracting a missing forward call to a separate PR so we can deliver it independently. Context: When keystore is used by some component (like BEEFY) via Arc, then calls of `sign_with` function are forwarded to default trait implementation. It is not working, when custom keystore with custom `sign_with` implementation is used.
|
#10763 was merged in master. Please update this PR |
This PR: 1. makes some BEEFY keystore methods more generic: - `sign()` - `public_keys()` This is done by implementing the specific logic in the `BeefyAuthorityId`. 2. Removes the `BeefyAuthorityId::SignatureHasher` since for some algorithms it doesn't make sense to have a hasher. Also since now the `BeefyAuthorityId` implements both the signing and the verification logic, we should have better consistency. Related to paritytech#8707 (comment) --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
Thank you @serban300, we are now happy with current state of master with your recent changes, I will close this PR. If you will be interested in this remaining part of the PR (MMR hasher adjustment), I can rebase and narrow it to this scope of changes |
Nice, glad to hear that ! I'm good. Feel free to close. |
We would like to use BEEFY with our custom crypto type, in this PR we would like to extend
BeefyKeystorewith additional code, that makes an execution to underlying keystore.Also we added a testcases for additional crypto type that is already supported.
This PR also adds support for custom hashing.