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.
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
Finalize ADR-028 #8398
Finalize ADR-028 #8398
Changes from 16 commits
7b8173b
8643cae
6038410
aecb45b
9a4e078
bbfb1b7
8129844
2724c7b
8c44486
1557ef5
aaf471b
c230c68
9b21ec5
9550d11
c0a9b20
84f57b8
c8fa6cb
3d29aff
e407672
889b9c5
ab4b9d1
834d997
3ceb0f2
274efce
461c703
201a19e
5093022
6fb8701
eb23aa6
963b093
c79c796
eae740c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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.
why you want to have a
moduleName
as a type? I think it make more sense to put is a key.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 reason, why I think it makes more sense to put a variable moduleName / moduleID as a
key
argument is the design intuition:ed25519
,schnorr2of4
, ....).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.
So here you're trying to hedge against the possibility of the module name as the schema description causing weird side effects?
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.
moduleName
is not a schema type - so passing it as a first argument there doesn't match our definition.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.
Well it is sort of a schema type in that all of the
group
addresses orcosmwasm
addresses define their own sub-address format.Are there any pros/cons from a security perspective of
address.Hash(moduleName, moduleSubKey)
vsaddress.Hash("module", moduleName + moduleSubKey)
?address.Hash(moduleName, moduleSubKey)
was the original design and still makes sense to me for simplicity's sake...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 issue would be if a user is in control of
moduleName
. He is not - only an app developer is.So we need to be careful to not have a moduleName same as any scheme name (eg:
ed25519
).I don't see any security concern for
address.Hash("module", moduleName + moduleSubKey)
except the weird conflicts on concatenation (same as in multisig example) - which is solveable with length prefixing.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.
Ah, yes... So what about
address.Hash("module:" + moduleName, moduleSubKey)
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.
Insecure modules (either explicit or negligent) is a much larger independent discussion. Objectively I don't see the value in the "module" prefix given the context here (module name + module provided sub-keys as components of the address, sourced from the module).
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 created a new section for module sub-accounts.
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.
Please remove this section and consider reverting to the previous multisig format. As we discussed live generalizing multisig keys to composed addresses is a nice idea but doesn't work because there are too many specifics like threshold which isn't here.
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 reverted and merged the Multisig Addresses section here. My motivation here is to show a generic function to compose pubkeys, and use multisig as an example. I think it's better to make this abstraction, rather than re-implement it in other account types.
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.
Well even so, I don't think this is actually correct, the concatenated addresses each need to be length prefixed because they can be variable length. But otherwise, maybe it works...
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.
That's why we use
.Address()
function for all sub addresses - it will have the required logic.Compose
is a one way function, there is nothing to decode.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 my comment wasn't clear but we need to length prefix before concatenation because otherwise the boundary between addresses isn't clear
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.
Let me give more context. The motivation to have this section is to:
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 think that's okay, I'm not there's another use case but it looks okay.
This is what I was trying to say: https://github.com/cosmos/cosmos-sdk/pull/8398/files#r566337924
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.
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.
Without length prefixing each address here you don't know the boundary. The addresses could be 20 or 32 bytes or some other number of users choose. So you can't successfully compose without that. Otherwise, there could be some weird collisions however unlikely.
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.
Composed
is a one-way function - once hashed, we can't go back. We don't need to know boundaries - finding a collision with length prefixing is as hard as finding a collision without them. We can mapLengthPrefixAddress
to all sub addresses, but I don't see any justification for that. Meaning it obfuscates the code but it doesn't enhance the security.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.
Practically speaking, the only way we could get a collision is when we have two sequences of addresses which concatenate to the same string:
So, the question is not about the hash collision, but key construction. Specifically: is it harder to find 2 different list of addresses (as != bs) for having a match in A or in B?
so, lets think...
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.
Each problem can be solved by a construction: we map and concatenate. Then for constructing
bs
we try to slice the concatenate sequence just before some1
bits.Specifically, for problem
B
, here is an example of conflicting addresses in binary form: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 more about it. Since the length prefix is always 1 byte, then we can't construct conflicting address sequences unless the individual addresses are the same - so the
lenpref
in this case will work.Other solution I had in mind was to hash each subaddress before concatenation - this way all parts have exactly same length.
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.
Yeah, the collision risk may be small but length-prefixing is cheap and ensures zero collisions in the pre-image.
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.
@aaronc , yes, in OP, when you wrote about collision I thought you are writing about hash collision ;) In the (updated) text I use conflict instead of collision.