keyshare module is responsible for collecting all the keyshares from validators and aggregating it to one derived private key every block.
State
Thex/keyshare module keeps state of the following primary objects:
- Validator information
- Submitted keyshares
- Aggregated keyshares
- Active & queued public key
- Authorized address
- Submit general keyshares
- Submit encrypted keyshares
- Keyshares encrypted with the validator’s public key
Params
proto/fairyring/keyshare/params.proto
Messages
MsgRegisterValidator
Register as a validator in thex/keyshare module validator set.
proto/fairyring/keyshare/tx.proto
- Creator address staked token is less than minimum requirement
- Creator address already registered as a validator in
x/keysharemodule
MsgDeRegisterValidator
Deregisters a validator from thex/keyshare module validator set.
proto/fairyring/keyshare/tx.proto
- Creator address is not a registered validator in the keyshare module
MsgSendKeyshare
Submit keyshare for target heightproto/fairyring/keyshare/tx.proto
- Sender is not a registered validator in the validator set
- Sender is not an authorized address
- Block height does not equal the current block height
- Keyshare index is incorrect
- Keyshare is incorrect
MsgCreateLatestPubkey
Create master public key used for encrypting transactions.proto/fairyring/keyshare/tx.proto
- Sender is not a trusted address
- A queued public key already exists
- Commitments array is empty
- encrypted keyshare array is empty
- numberOfValidators is 0
MsgOverrideLatestPubkey
Override the latest master public key used for encrypting transactions.proto/fairyring/keyshare/tx.proto
- Sender is not a trusted address
- A queued public key already exists
- Commitments array is empty
- encrypted keyshare array is empty
- numberOfValidators is 0
MsgCreateAuthorizedAddress
Authorize the target address to submit keyshares for the sender address.proto/fairyring/keyshare/tx.proto
- Target address is invalid
- Creator is not a validator in the
x/keysharevalidator set - Target address is already authorized
- Target address is the same as sender address
- Creator already authorized another address
MsgUpdateAuthorizedAddress
Update the status of the target authorized addressproto/fairyring/keyshare/tx.proto
- Target is not authorized
- Target is not authorized by the sender
- Target address is the same as sender address
MsgDeleteAuthorizedAddress
Delete authorized addressproto/fairyring/keyshare/tx.proto
- Target is not authorized
- Sender is not the creator of the target authorized address and the authorized address itself
MsgSubmitGeneralKeyshare
Submit general keyshareproto/fairyring/keyshare/tx.proto
- Sender is not a validator in the validator set
- Sender is not an authorized address
- Keyshare is incorrect
- ID type is not supported
- Decryption Key Request (ID Value) not found
MsgSubmitEncryptedKeyshare
Submit encrypted keyshareproto/fairyring/keyshare/tx.proto
- Sender is not a validator in the validator set
- Sender is not an authorized address
- Encrypted keyshare is incorrect
- Private Decryption Key Request (Identity) not found
Events
The keyshare module emits the following events:Message Events
MsgRegisterValidator
| Type | Attribute Key | Attribute Value |
|---|---|---|
new-validator-registered | creator | creatorAddress |
MsgDeRegisterValidator
| Type | Attribute Key | Attribute Value |
|---|---|---|
validator-deregistered | creator | creatorAddress |
MsgSendKeyshare
When a valid keyshare is received:| Type | Attribute Key | Attribute Value |
|---|---|---|
keyshare-sent | validator | validatorAddress |
keyshare-sent | keyshare-height | height |
keyshare-sent | received-height | height |
keyshare-sent | message | keyshareInHex |
keyshare-sent | index | keyshareIndex |
| Type | Attribute Key | Attribute Value |
|---|---|---|
keyshare-aggregated | height | height |
keyshare-aggregated | data | aggregatedKeyshareInHex |
keyshare-aggregated | pubkey | pubkeyForTheAggregatedKey |
MsgCreateGeneralKeyshare
When a valid general keyshare is received:| Type | Attribute Key | Attribute Value |
|---|---|---|
keyshare-sent | validator | validatorAddress |
keyshare-sent | received-height | height |
keyshare-sent | message | keyshareInHex |
keyshare-sent | index | keyshareIndex |
keyshare-sent | id-type | keyshareIdType |
keyshare-sent | id-value | keyshareIdValue |
| Type | Attribute Key | Attribute Value |
|---|---|---|
general-keyshare-aggregated | data | aggregatedKeyshareInHex |
general-keyshare-aggregated | pubkey | pubkeyForTheAggregatedKey |
general-keyshare-aggregated | id-value | aggregatedKeyshareIdValue |
general-keyshare-aggregated | id-type | aggregatedKeyshareIdType |
MsgSubmitEncryptedKeyshare
When a valid encrypted keyshare is received:| Type | Attribute Key | Attribute Value |
|---|---|---|
encrypted-keyshare-sent | validator | validatorAddress |
encrypted-keyshare-sent | received-height | height |
encrypted-keyshare-sent | message | keyshareInHex |
encrypted-keyshare-sent | index | keyshareIndex |
encrypted-keyshare-sent | id-value | keyshareIdValue |
MsgCreateLatestPubkey
| Type | Attribute Key | Attribute Value |
|---|---|---|
queued-pubkey-created | active-pubkey-expiry-height | activePubkeyExpiryHeight |
queued-pubkey-created | expiry-height | height |
queued-pubkey-created | creator | creatorAddress |
queued-pubkey-created | pubkey | pubkeyCreated |
queued-pubkey-created | number-of-validators | numberOfValidators |
queued-pubkey-created | encrypted-shares | encryptedKeysharesArray |
MsgOverrideLatestPubkey
| Type | Attribute Key | Attribute Value |
|---|---|---|
pubkey-overrode | active-pubkey-expiry-height | activePubkeyExpiryHeight |
pubkey-overrode | expiry-height | height |
pubkey-overrode | creator | creatorAddress |
pubkey-overrode | pubkey | pubkeyCreated |
pubkey-overrode | number-of-validators | numberOfValidators |
pubkey-overrode | encrypted-shares | encryptedKeysharesArray |
Client
CLI
User can query and interact with thekeyshare module using the CLI.
Queries
Thequery commands allows users to query keyshare state.
fairyringd query keyshare --help
list-decryption-keys
Thelist-decryption-keys command allows users to query all the decryption keys.
fairyringd query keyshare list-decryption-keys [flags]
Example:
fairyringd query keyshare list-decryption-keys
Example Output:
list-authorized-address
Thelist-authorized-address command allows users to query all the authorized addresses.
fairyringd query keyshare list-authorized-address [flags]
Example:
fairyringd query keyshare list-authorized-address
Example Output:
list-keyshares
Thelist-key-share command allows users to query all the keyshare submitted by validators.
fairyringd query keyshare list-keyshares [flags]
Example:
fairyringd query keyshare list-keyshares
Example Output:
list-general-keyshares
Thelist-general-keyshares command allow users to query all the general keyshare submitted by validators.
fairyringd query keyshare list-general-keyshares [flags]
Example:
fairyringd query keyshare list-general-keyshares
Example Output:
list-validator-set
Thelist-validator-set command allows users to query all the validators in the validator set.
fairyringd query keyshare list-validator-set [flags]
Example:
fairyringd query keyshare list-validator-set
Example Output:
params
Theparams command allows users to query current params of the keyshare module.
fairyringd query keyshare params [flags]
Example:
fairyringd query keyshare params
Example Output:
show-active-pub-key
Theshow-active-pub-key command allows users to query current active & queued public keys and encrypted key shares.
fairyringd query keyshare show-active-pub-key [flags]
Example:
fairyringd query keyshare show-active-pub-key
Example Output:
show-decryption-key
Theshow-decryption-key command allows users to query decryption key of the target height.
fairyringd query keyshare show-decryption-key [height] [flags]
Example:
fairyringd query keyshare show-decryption-key 100000
Example Output:
show-authorized-address
Theshow-authorized-address command allows users to check if the target address is authorized.
fairyringd query keyshare show-authorized-address [target] [flags]
Example:
fairyringd query keyshare show-authorized-address fairy1...
Example Output:
show-commitments
Theshow-commitments command allows users to query all the active & queued commitments.
fairyringd query keyshare show-commitments [flags]
Example:
fairyringd query keyshare show-commitments
Example Output:
show-keyshare
Theshow-keyshare command allows users to query the keyshare submitted by the target validator on a particular height.
fairyringd query show-keyshare [validator] [block-height] [flags]
Example:
fairyringd query keyshare show-keyshare fairy14qekdkj3mnmveb5ugh0n112a3pud23y8tcf9bb 100000
Example Output:
show-general-keyshare
Theshow-general-keyshare command allow users to query the target general keyshare submitted by its validator, id type and id value.
fairyringd query show-general-keyshare [validator] [id-type] [id-value] [flags]
Example:
fairyringd query keyshare show-general-keyshare fairy14qekdkj3mnmveb5ugh0n112a3pud23y8tcf9bb private-gov-identity "1/rq"
Example Output:
show-validator-set
Theshow-validator-set command allows users to check if the target address is in validator set.
index is the target validator address.
fairyringd query show-validator-set [index] [flags]
Example:
fairyringd query show-validator-set fairy14qekdkj3mnmveb5ugh0n112a3pud23y8tcf9bb
Example Output:
Transactions
Thetx commands allows users to interact with the keyshare module.
fairyringd tx keyshare --help
create-authorized-address
Thecreate-authorized-address command allow validators to authorize another address to submit keyshare for them.
fairyringd tx keyshare create-authorized-address [target] [flags]
Example:
fairyringd tx keyshare create-authorized-address fairy1...
update-authorized-address
Theupdate-authorized-address command allow validators to update the status of the authorized address.
fairyringd tx keyshare update-authorized-address [target] [is-authorized] [flags]
Example:
fairyringd tx keyshare update-authorized-address fairy1... false
delete-authorized-address
Thedelete-authorized-address command allow validators / the authorized address itself to delete the authorized address.
fairyringd tx keyshare delete-authorized-address [target] [flags]
Example:
fairyringd tx keyshare delete-authorized-address fairy1...
create-latest-pubkey
Thecreate-latest-pubkey command allow trusted addresses to submit public key, commitments and encrypted key shares.
fairyringd tx keyshare create-latest-pubkey [public-key] [commitments] [number-of-validators] [encrypted-key-shares] [flags]
Example:
fairyringd tx keyshare create-latest-pubkey "856ec61e4a6adc43f76262afbe503276e3798b35d7a329548322eac342f819f42466d92b81e7861e341326668f4f9a09" "856ec61e4a6adc43f76262afbe503276e3798b35d7a329548322eac342f819f42466d92b81e7861e341326668f4f9a09,a6f02f598d3b89c524792889b0b115cd229ba60aeb568c228de7db1e8c182fd07bb473fab5258564c26fe5164e287e35" 1 '[{"data": "XaMhXRlQ/wLVzXsQn4K/vwLKACBPV90koTC452UXPjgq1sSakgr33jLBNGFpzc71p7niKwAgfWc5Yd9ZupN3pcz9aC7EBG+Q2/ocxZerPR2rpbkq5NNAAnTY/yN7+xA7HcSm61fBFcv/ZPhthtvA8Qg+QYHfnQI8PouunWpHXjlOtWNY8g5GGFSqFSEkyHtaHOcC9OApPeosvv1o3Mrp+HenxURUqw==", "validator": "fairy18hl5c9xn5dze2g50uaw0l2mr02ew57zkynp0td"}]'
register-validator
Theregister-validator command allow validators to register as a validator in x/keyshare module validator set.
fairyringd tx keyshare register-validator [flags]
Example:
fairyringd tx keyshare register-validator
deregister-validator
Thederegister-validator command allow validators to deregister in x/keyshare module validator set.
fairyringd tx keyshare deregister-validator [flags]
Example:
fairyringd tx keyshare deregister-validator
send-keyshare
Thesend-keyshare command allow validators to submit their keyshare for specific block height.
fairyringd tx keyshare send-keyshare [message] [keyshare-index] [block-height] [flags]
Example:
fairyringd tx keyshare send-keyshare a7348fb8cf57c1adf655f8d27c79086a5fd356285a6f00c9aea05ea6d2a8da63e08ea27d10d91b83be0778fc652d9c920ed18690f5e776ec3fb57e2504949bbe31deef8648c488263d871f040d5d2781068a3c2f78b057fef57397310367fb7d 1 100000
gRPC
Users can query thekeyshare module using gRPC endpoints.
Commitments
TheCommitments endpoint allows users to query the active & queued commitments.
fairyring.keyshare.Query/Commitments
Example:
grpcurl -plaintext localhost:9090 fairyring.keyshare.Query/Commitments
Example Output:
Params
TheParams endpoint allows users to query x/keyshare module params.
fairyring.keyshare.Query/Params
Example:
grpcurl -plaintext localhost:9090 fairyring.keyshare.Query/Params
Example Output:
ValidatorSet
TheValidatorSet endpoint allows users to query if the target address is in the validator set.
fairyring.keyshare.Query/ValidatorSet
Example:
ValidatorSetAll
TheValidatorSetAll endpoint allows users to query all validators in the validator set.
fairyring.keyshare.Query/ValidatorSetAll
Example:
grpcurl -plaintext localhost:9090 fairyring.keyshare.Query/ValidatorSetAll
Example Output:
Keyshare
TheKeyshare endpoint allows users to query the keyshare submitted by target validator on particular block height.
fairyring.keyshare.Query/Keyshare
Example:
KeyshareAll
TheKeyshareAll endpoint allows users to query all the submitted keyshares.
fairyring.keyshare.Query/KeyshareAll
Example:
grpcurl -plaintext localhost:9090 fairyring.keyshare.Query/KeyshareAll
Example Output:
DecryptionKey
TheDecryptionKey endpoint allows users to query the decryption key on a particular height.
fairyring.keyshare.Query/DecryptionKey
Example:
DecryptionKeyAll
TheDecryptionKeyAll endpoint allows users to query all decryption keys.
fairyring.keyshare.Query/DecryptionKeyAll
Example:
grpcurl -plaintext localhost:9090 fairyring.keyshare.Query/DecryptionKeyAll
Example Output:
Pubkey
ThePubkey endpoint allows users to query active & queued public keys and encrypted key shares.
fairyring.keyshare.Query/Pubkey
Example:
grpcurl -plaintext localhost:9090 fairyring.keyshare.Query/Pubkey
Example Output:
AuthorizedAddress
TheAuthorizedAddress endpoint allows users to query target authorized address.
fairyring.keyshare.Query/AuthorizedAddress
Example:
AuthorizedAddressAll
TheAuthorizedAddressAll endpoint allows users to query all authorized addresses.
fairyring.keyshare.Query/AuthorizedAddressAll
Example:
grpcurl -plaintext localhost:9090 fairyring.keyshare.Query/AuthorizedAddressAll
Example Output: