x/pep
Abstract
The document specifies the pep module of fairyring.
The pep module is responsible for decrypting, decoding and processing encrypted transactions from users.
For a guide on encrypting transactions, please read this guide.
State
The x/pep module keeps state of the following primary objects:
- Aggregated keyshares
- Encrypted transactions
- General encrypted transactions
- Pep nonce
- Active & queued public keys
- Latest processed height
- General decryption key requests
- Private decryption key requests
- Wasm contract addresses for callback
Params
proto/fairyring/pep/params.proto
message Params {
option (amino.name) = "fairyring/x/pep/Params";
// option (gogoproto.equal) = true;
string keyshare_channel_id = 1 [(gogoproto.moretags) = "yaml:\"keyshare_channel_id\""];
bool is_source_chain = 2 [(gogoproto.moretags) = "yaml:\"is_source_chain\""];
repeated TrustedCounterParty trusted_counter_parties = 3;
repeated string trusted_addresses = 4 [(gogoproto.moretags) = "yaml:\"trusted_addresses\""];
cosmos.base.v1beta1.Coin min_gas_price = 5 [(gogoproto.moretags) = "yaml:\"min_gas_price\""];
cosmos.base.v1beta1.Coin private_decryption_key_price = 6 [(gogoproto.moretags) = "yaml:\"private_decryption_key_price\""];
}
message TrustedCounterParty {
string client_id = 1;
string connection_id = 2;
string channel_id = 3;
}
Messages
MsgSubmitEncryptedTx
Submit encrypted transaction
proto/fairyring/pep/tx.proto
message MsgSubmitEncryptedTx {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
string data = 2;
uint64 target_block_height = 3;
}
The message will fail under the following conditions:
- Target block height is lower than or equal to the latest height
- Target block height is higher than public key expiry height
- Sender does not have enough tokens for fee
- Active public key not found
MsgSubmitGeneralEncryptedTx
Submit general encrypted transaction
proto/fairyring/pep/tx.proto
message MsgSubmitGeneralEncryptedTx {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
string data = 2;
string req_id = 3;
}
The message will fail under the following conditions:
- Entry for the given request id not found
- Sender does not have enough tokens for fee
MsgSubmitDecryptionKey
Submit decryption key
proto/fairyring/pep/tx.proto
message MsgSubmitDecryptionKey {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
uint64 height = 2;
string data = 3;
}
The message will fail under the following conditions:
- Active public key does not exist
- Aggregated keyshare is invalid
- Sender is not trusted
MsgRequestGeneralIdentity
Request a general identity
proto/fairyring/pep/tx.proto
message MsgRequestGeneralIdentity {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
google.protobuf.Duration estimated_delay = 2 [(gogoproto.stdduration) = true];
string req_id = 3;
}
The message will fail under the following conditions:
- Request ID from the sender already exists
- Estimated delay is empty
MsgRequestGeneralDecryptionKey
Request general decryption key
proto/fairyring/pep/tx.proto
message MsgRequestGeneralDecryptionKey {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
string identity = 2;
}
The message will fail under the following conditions:
- Entry for the given identity not found
- Sender is not the creator of the given identity
MsgRequestPrivateIdentity
Request a private identity
proto/fairyring/pep/tx.proto
message MsgRequestPrivateIdentity {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
string req_id = 2;
}
The message will fail under the following conditions:
- Request ID from the sender already exists
MsgRequestPrivateDecryptionKey
Request private decryption key
proto/fairyring/pep/tx.proto
message MsgRequestPrivateDecryptionKey {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
string identity = 2;
string secp_pubkey = 3;
}
The message will fail under the following conditions:
- Given identity & active public key not found
- Sender does not have enough tokens for fee
MsgRegisterContract
Register a WASM contract for callback
proto/fairyring/pep/tx.proto
message MsgRegisterContract {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
string contract_address = 2;
string identity = 3;
}
The message will fail under the following conditions:
- Contract address is invalid
- Contract info not found for the given address
- Sender is not the admin / creator of the given contract
- Contract already registered for the given identity
MsgUnregisterContract
Unregister a WASM contract
proto/fairyring/pep/tx.proto
message MsgUnregisterContract {
option (cosmos.msg.v1.signer) = "creator";
string creator = 1;
string contract_address = 2;
string identity = 3;
}
The message will fail under the following conditions:
- Contract address is invalid
- Contract info not found for the given address
- Sender is not the admin / creator of the given contract
- Entry for the given identity not found
- The given contract is not in the registered contracts
Events
The pep module emits the following events:
Message Events
MsgSubmitEncryptedTx
| Type | Attribute Key | Attribute Value |
|---|---|---|
new-encrypted-tx-submitted | creator | creatorAddress |
new-encrypted-tx-submitted | target-height | height |
new-encrypted-tx-submitted | index | txIndex |
new-encrypted-tx-submitted | data | txData |
MsgSubmitGeneralEncryptedTx
| Type | Attribute Key | Attribute Value |
|---|---|---|
new-general-encrypted-tx-submitted | creator | creatorAddress |
new-general-encrypted-tx-submitted | identity | identity |
new-general-encrypted-tx-submitted | index | txIndex |
new-general-encrypted-tx-submitted | data | txData |
MsgCreateAggregatedKeyshare
The following events will be emitted when the aggregated keyshare is invalid:
| Type | Attribute Key | Attribute Value |
|---|---|---|
decryption-key-verification | creator | creatorAddress |
decryption-key-verification | height | height |
decryption-key-verification | reason | failReason |
Block Events
The following events will be emitted when processing an encrypted transaction in BeginBlock:
When the encrypted transaction is reverted:
| Type | Attribute Key | Attribute Value |
|---|---|---|
reverted-encrypted-tx | creator | creatorAddress |
reverted-encrypted-tx | height | height |
reverted-encrypted-tx | index | txIndex |
reverted-encrypted-tx | reason | revertReason |
When the general encrypted transaction is reverted:
| Type | Attribute Key | Attribute Value |
|---|---|---|
reverted-encrypted-tx | creator | creatorAddress |
reverted-encrypted-tx | index | txIndex |
reverted-encrypted-tx | identity | identity |
reverted-encrypted-tx | reason | revertReason |
When the encrypted transaction is executed successfully:
| Type | Attribute Key | Attribute Value |
|---|---|---|
executed-encrypted-tx | creator | creatorAddress |
executed-encrypted-tx | index | txIndex |
executed-encrypted-tx | data | txData |
executed-encrypted-tx | memo | txMemo |
executed-encrypted-tx | events | underlyingEvents |
When an encrypted tx is discarded:
| Type | Attribute Key | Attribute Value |
|---|---|---|
discarded-encrypted-tx | height | height |
discarded-encrypted-tx | index | txIndex |