-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
ADR034: Account Rekeying #7491
Merged
Merged
ADR034: Account Rekeying #7491
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
df6414d
adr
sunnya97 2affa79
adr 32 -> 34
sunnya97 30c13ea
Apply suggestions from code review
sunnya97 cb99dbd
Apply suggestions from code review
sunnya97 68ba564
Update adr-034-change-pubkey.md
sunnya97 091c835
Update adr-034-change-pubkey.md
sunnya97 c8c73a4
Apply suggestions from code review
sunnya97 2c58e18
Merge branch 'master' into sunny/change-pubkey-adr
sunnya97 2ace2a7
Update docs/architecture/adr-034-change-pubkey.md
sunnya97 6274240
Apply suggestions from code review
sunnya97 c4e5e29
Update and rename adr-034-change-pubkey.md to adr-034-account-rekeyin…
sunnya97 53108e7
Update adr-034-account-rekeying.md
sunnya97 20617d0
Update docs/architecture/adr-034-account-rekeying.md
sunnya97 045e787
Update adr-034-account-rekeying.md
sunnya97 101d62a
Add details about pruning
sunnya97 972095e
pruning info
sunnya97 fd6f07b
Merge branch 'master' into sunny/change-pubkey-adr
sunnya97 b5442e1
Update adr-034-account-rekeying.md
sunnya97 dc9d36b
Merge branch 'master' into sunny/change-pubkey-adr
sunnya97 a77eb25
Merge branch 'master' into sunny/change-pubkey-adr
sunnya97 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# ADR 032: Change PubKey | ||
|
||
## Changelog | ||
|
||
- 30-09-2020: Initial Draft | ||
|
||
## Status | ||
|
||
Proposed | ||
|
||
## Context | ||
|
||
Currently, in the Cosmos SDK, the address of an auth account is always based on the hash of the public key. Once an account is created, the public key for the account is set in stone, and cannot be changed. This can be a problem for users, as key rotation is a useful security practice, but is not possible currently. Furthermore, as multisigs are a type of pubkey, once a multisig for an account is set, it can not be updated. This is problematic, as multisigs are often used by organizations or companies, who may need to change their set of multisig signers for internal reasons. | ||
|
||
Transferring all the assets of an account to a new account with the updated pubkey is not sufficient, because some "engagements" of an account are not easily transferable. For example, in staking, to transfer bonded Atoms, an account would have to unbond all delegations and wait the three week unbonding period. Even more significantly, for validator operators, ownership over a validator is not transferrable at all, meaning that the operator key for a validator can never be updated, leading to poor operational security for validators. | ||
|
||
## Decision | ||
|
||
We propose the creation of a new feature called `changepubkey` that is an extension to `auth` that allows accounts to update the public key associated with their account, while keeping the address the same. | ||
|
||
This is possible because the Cosmos SDK `StdAccount` stores the public key for an account in state, instead of making the assumption that the public key is included in the transaction (whether explicitly or implicitly through the signature) as in other blockchains such as Bitcoin and Ethereum. Because the public key is stored on chain, it is okay for the public key to not hash to the address of an account, as the address is not pertinent to the signature checking process. | ||
|
||
To build this system, we design a new Msg type as follows: | ||
|
||
```protobuf | ||
message MsgChangePubKey { | ||
bytes address = 1 [ | ||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" | ||
]; | ||
bytes pub_key = 2 [ | ||
(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\"" | ||
]; | ||
} | ||
``` | ||
|
||
As an example, account pubkey change message can be defined as follows. | ||
|
||
```json | ||
{ | ||
"type": "cosmos-sdk/StdTx", | ||
"value": { | ||
"address": "cosmos1wf5h7meplxu3sc6rk2agavkdsmlsen7rgsasxk", | ||
"public_key": "cosmospub1addwnpepqdszcr95mrqqs8lw099aa9h8h906zmet22pmwe9vquzcgvnm93eqygufdlv" | ||
}, | ||
"signature": "a9n7pIqCUuYJTCm7ZBv1cqqlM3uYyX/7SnaSXA8zrG0CBWP6p55pTFFHYn39tVvFtRbGE7gXF1qCiaOilJ8NtQ==" | ||
} | ||
``` | ||
|
||
Here, the signature is signed for the public key thats current in-state for account `cosmos1wf5h7meplxu3sc6rk2agavkdsmlsen7rgsasxk`, as normally done in the ante-handler. | ||
|
||
Once, approved, the handler for this message type, which takes in the AccountKeeper, will update the in-state pubkey for the account and replace it with the pubkey from the Msg. | ||
|
||
Because an account can no longer be pruned from state once its pubkey has changed, we can charge an additional gas fee for this operation to compensate for this this externality (this bound gas amount is configured as parameter `PubKeyChangeCost`). The bonus gas is charged inside handler, using the `ConsumeGas` function. | ||
|
||
```go | ||
amount := ak.GetParams(ctx).PubKeyChangeCost | ||
ctx.GasMeter().ConsumeGas(amount, "pubkey change fee") | ||
``` | ||
|
||
|
||
## Consequences | ||
|
||
### Positive | ||
|
||
* Will allow users and validator operators to employ better operational security practices with key rotation. | ||
* Will allow organizations or groups to easily change and add/remove multisig signers. | ||
|
||
### Negative | ||
|
||
Breaks the current assumed relationship between address and pubkeys as H(pubkey) = address. This has a couple of consequences. | ||
|
||
* We cannot prune accounts with 0 balance that have had their pubkey changed (we currently do not currently do this anyways, but the reason we have account numbers is presumably for this purpose). | ||
* This makes wallets that support this feature more complicated. For example, if an address on chain was updated, the corresponding key in the CLI wallet also needs to be updated. | ||
|
||
### Neutral | ||
|
||
* While the purpose of this is intended to allow the owner of an account to update to a new pubkey they own, this could technically also be used to transfer ownership of an account to a new owner. For example, this could be use used to sell a staked position without unbonding or an account that has vesting tokens. However, the friction of this is very high as this would essentially have to be done as a very specific OTC trade. Furthermore, additional constraints could be added to prevent accouns with Vesting tokens to use this feature. | ||
* Will require that PubKeys for an account are included in the genesis exports. | ||
|
||
## References | ||
|
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.
We can still make it possible to prune accounts by introducing a new message:
MsgNukeAccount
. When an author will delete HIS account, then the deposit is released.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 implemented the "deposit" as an extra Gas charge rather than an actual monetary deposit. With a gas charge, we could provide a gasrefund when an account is nuked, but that could potentially turn into GasToken shenanigans like on Ethereum.