-
Notifications
You must be signed in to change notification settings - Fork 47
feat: add merkleization of DID documents #492
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
756ec48
wip
ntn-x2 40a0c28
wip pt. 2
ntn-x2 4d5212d
Code compiling
ntn-x2 67cd0ae
Wip for the proof generator function
ntn-x2 9d19e34
Test works!
ntn-x2 6180880
Complete DID Document Merkle proof failing
ntn-x2 b74e2cb
Fix buggy logic for proof generation
ntn-x2 dcde80f
Better tests
ntn-x2 7062b59
Runtime API implementation compiling!
ntn-x2 523cb82
clippy --all-targets
ntn-x2 1bde773
Wip on the XCM tests
ntn-x2 2033e22
WIP integration test on receiver chain
ntn-x2 2cd3360
Integration test completed
ntn-x2 94ee61e
Set spec_version of templates to 11000 to avoid type definitions mixups
ntn-x2 cd9bc0d
Replace BTreeSet input with Vec
ntn-x2 627a506
More changes
ntn-x2 fc5b4a1
Last fixes
ntn-x2 a99b836
Add some comments for easier understanding
ntn-x2 90d98db
Fix runtime-benchmarks feature
ntn-x2 34e4115
Remove MaxEncodedLen bound from DidPublicKey
ntn-x2 bba72a2
Reove imports from inside functions
ntn-x2 b33518c
Split up dip module into submodules
ntn-x2 ebe454d
Make VersionedIdentity* non_exhaustive
ntn-x2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,20 +16,17 @@ | |
|
|
||
| // If you feel like getting in touch with us, you can do so at [email protected] | ||
|
|
||
| use pallet_dip_receiver::traits::SuccessfulProofVerifier; | ||
| use runtime_common::dip::{receiver::DidMerkleProofVerifier, ProofLeaf}; | ||
| use sp_std::vec::Vec; | ||
|
|
||
| use crate::{DidIdentifier, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin}; | ||
| use crate::{BlockNumber, DidIdentifier, Hash, Hasher, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin}; | ||
|
|
||
| impl pallet_dip_receiver::Config for Runtime { | ||
| type BlindedValue = Vec<Vec<u8>>; | ||
| type Identifier = DidIdentifier; | ||
| // TODO: Change with right one | ||
| type ProofDigest = [u8; 32]; | ||
| // TODO: Change with right one | ||
| type ProofLeafKey = [u8; 4]; | ||
| // TODO: Change with right one | ||
| type ProofLeafValue = [u8; 4]; | ||
| // TODO: Change with right one | ||
| type ProofVerifier = SuccessfulProofVerifier<Self::ProofDigest, Self::ProofLeafKey, Self::ProofLeafValue>; | ||
| type ProofLeaf = ProofLeaf<Hash, BlockNumber>; | ||
| type ProofDigest = Hash; | ||
| type ProofVerifier = DidMerkleProofVerifier<Hash, BlockNumber, Hasher>; | ||
| type RuntimeCall = RuntimeCall; | ||
| type RuntimeEvent = RuntimeEvent; | ||
| type RuntimeOrigin = RuntimeOrigin; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,13 +17,13 @@ | |
| // If you feel like getting in touch with us, you can do so at [email protected] | ||
|
|
||
| use codec::{Decode, Encode}; | ||
| use did::did_details::DidDetails; | ||
| use dip_support::VersionedIdentityProofAction; | ||
| use pallet_dip_sender::traits::{ | ||
| DefaultIdentityProofGenerator, DefaultIdentityProvider, TxBuilder, XcmRouterDispatcher, | ||
| }; | ||
| use pallet_dip_sender::traits::{TxBuilder, XcmRouterDispatcher}; | ||
| use runtime_common::dip::sender::{DidIdentityProvider, DidMerkleRootGenerator}; | ||
| use xcm::{latest::MultiLocation, DoubleEncoded}; | ||
|
|
||
| use crate::{DidIdentifier, Runtime, RuntimeEvent, XcmRouter}; | ||
| use crate::{DidIdentifier, Hash, Runtime, RuntimeEvent, XcmRouter}; | ||
|
|
||
| #[derive(Encode, Decode)] | ||
| enum ReceiverParachainCalls { | ||
|
|
@@ -34,16 +34,16 @@ enum ReceiverParachainCalls { | |
| #[derive(Encode, Decode)] | ||
| enum ReceiverParachainDipReceiverCalls { | ||
| #[codec(index = 0)] | ||
| ProcessIdentityAction(VersionedIdentityProofAction<DidIdentifier, [u8; 32]>), | ||
| ProcessIdentityAction(VersionedIdentityProofAction<DidIdentifier, Hash>), | ||
| } | ||
|
|
||
| pub struct ReceiverParachainTxBuilder; | ||
| impl TxBuilder<DidIdentifier, [u8; 32]> for ReceiverParachainTxBuilder { | ||
| impl TxBuilder<DidIdentifier, Hash> for ReceiverParachainTxBuilder { | ||
| type Error = (); | ||
|
|
||
| fn build( | ||
| _dest: MultiLocation, | ||
| action: VersionedIdentityProofAction<DidIdentifier, [u8; 32]>, | ||
| action: VersionedIdentityProofAction<DidIdentifier, Hash>, | ||
| ) -> Result<DoubleEncoded<()>, Self::Error> { | ||
| let double_encoded: DoubleEncoded<()> = | ||
| ReceiverParachainCalls::DipReceiver(ReceiverParachainDipReceiverCalls::ProcessIdentityAction(action)) | ||
|
|
@@ -55,16 +55,11 @@ impl TxBuilder<DidIdentifier, [u8; 32]> for ReceiverParachainTxBuilder { | |
|
|
||
| impl pallet_dip_sender::Config for Runtime { | ||
| type Identifier = DidIdentifier; | ||
| // TODO: Change with right one | ||
| type Identity = u32; | ||
| // TODO: Change with right one | ||
| type IdentityProofDispatcher = XcmRouterDispatcher<XcmRouter, DidIdentifier, [u8; 32]>; | ||
| // TODO: Change with right one | ||
| type IdentityProofGenerator = DefaultIdentityProofGenerator; | ||
| // TODO: Change with right one | ||
| type IdentityProvider = DefaultIdentityProvider; | ||
| // TODO: Change with right one | ||
| type ProofOutput = [u8; 32]; | ||
| type Identity = DidDetails<Runtime>; | ||
| type IdentityProofDispatcher = XcmRouterDispatcher<XcmRouter, DidIdentifier, Hash>; | ||
| type IdentityProofGenerator = DidMerkleRootGenerator<Runtime>; | ||
| type IdentityProvider = DidIdentityProvider<Runtime>; | ||
| type ProofOutput = Hash; | ||
| type RuntimeEvent = RuntimeEvent; | ||
| type TxBuilder = ReceiverParachainTxBuilder; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this should be marked as
#[non_exhaustive]?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.
The idea is that consumers would try to convert their own version into this for message passing, and receivers would try to convert it back into a specific version. I took inspiration for how VersionedXcm works. Why do you think we need
non_exhaustive?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.
I was thinking how a new version would be introduced. What happens if a VersionedIdentityProof::v2 get's send to someone that only supports v1? at the moment that would result in a decoding error. Adding
non_exhaustivewouldn't change anything here.But if you use the
dipcrate as a dependency and use theVersionedIdentityProofhavingnon_exhaustivemakes a difference. IfVersionedIdentityProofis not marked asnon_exhaustive, adding a new version is a breaking change (sincematch VersionedIdentityProof {}doesn't cover this new case). Havingnon_exhaustivemakes adding new versions a non-breaking change since everyone is forced to already have code in place that covers new versions (and showing an error that this version is not supported).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.
I see. But isnt'a a compilation error what we actually want here? If you risk getting a versioned identity proof you don't support, you should probably return an error. Code won't need to be updated if you are using the old version, hence anything failing to decode will result in an error. Once you update the dependency, you should be at least aware that a new version could be around, and explicitly generate an error if it's not what you expect. Or am I still missing your point?
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.
The
non_exhaustiveis only for compile time. If we introduce a new version this would be a breaking change. Since it fails to compile.At runtime this doesn't change anything since if we talk to a newer version that we don't know, it fails to decode and won't reach any match statement where we check versions.
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.
343faf9. Let's see how this plays out 😄