Merge PR #6217: Add pub key proto definitions
This commit is contained in:
parent
49ae8800d1
commit
40082b823f
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,42 @@
|
|||
syntax = "proto3";
|
||||
package cosmos_sdk.crypto.v1;
|
||||
|
||||
//import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/crypto/types";
|
||||
|
||||
// PublicKey specifies a public key
|
||||
message PublicKey {
|
||||
// sum specifies which type of public key is wrapped
|
||||
oneof sum {
|
||||
bytes secp256k1 = 1;
|
||||
bytes ed25519 = 2;
|
||||
bytes sr25519 = 3;
|
||||
PubKeyMultisigThreshold multisig = 4;
|
||||
bytes secp256r1 = 5;
|
||||
|
||||
// any_pubkey can be used for any pubkey that an app may use which is
|
||||
// not explicitly defined in the oneof
|
||||
google.protobuf.Any any_pubkey = 15; // 15 is largest field that occupies one byte
|
||||
}
|
||||
}
|
||||
|
||||
// PubKeyMultisigThreshold specifies a public key type which nests multiple public
|
||||
// keys and a threshold
|
||||
message PubKeyMultisigThreshold {
|
||||
uint32 threshold = 1 [(gogoproto.customname) = "K", (gogoproto.moretags) = "yaml:\"threshold\""];
|
||||
repeated PublicKey pubkeys = 2 [(gogoproto.customname) = "PubKeys", (gogoproto.moretags) = "yaml:\"pubkeys\""];
|
||||
}
|
||||
|
||||
|
||||
// MultiSignature wraps the signatures from a PubKeyMultisigThreshold.
|
||||
// See cosmos_sdk.tx.v1.ModeInfo.Multi for how to specify which signers signed
|
||||
// and with which modes
|
||||
message MultiSignature {
|
||||
repeated bytes sigs = 1;
|
||||
}
|
||||
|
||||
// CompactBitArray is an implementation of a space efficient bit array.
|
||||
// This is used to ensure that the encoded data takes up a minimal amount of
|
||||
// space after proto encoding.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
- 2020 March 12: API Updates
|
||||
- 2020 April 13: Added details on interface `oneof` handling
|
||||
- 2020 April 30: Switch to `Any`
|
||||
- 2020 May 14: Describe public key encoding
|
||||
|
||||
## Status
|
||||
|
||||
|
@ -259,6 +260,32 @@ fields with bit 11 set
|
|||
This will likely need to be a custom protobuf parser pass that takes message bytes
|
||||
and `FileDescriptor`s and returns a boolean result.
|
||||
|
||||
### Public Key Encoding
|
||||
|
||||
Public keys in the Cosmos SDK implement Tendermint's `crypto.PubKey` interface,
|
||||
so a natural solution might be to use `Any` as we are doing for other interfaces.
|
||||
There are, however, a limited number of public keys in existence and new ones
|
||||
aren't created overnight. The proposed solution is to use a `oneof` that:
|
||||
|
||||
* attempts to catalog all known key types even if a given app can't use them all
|
||||
* has an `Any` member that can be used when a key type isn't present in the `oneof`
|
||||
|
||||
Ex:
|
||||
```proto
|
||||
message PublicKey {
|
||||
oneof sum {
|
||||
bytes secp256k1 = 1;
|
||||
bytes ed25519 = 2;
|
||||
...
|
||||
google.protobuf.Any any_pubkey = 15;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Apps should only attempt to handle a registered set of public keys that they
|
||||
have tested. The provided signature verification ante handler decorators will
|
||||
enforce this.
|
||||
|
||||
### CLI & REST
|
||||
|
||||
Currently, the REST and CLI handlers encode and decode types and txs via Amino
|
||||
|
|
Loading…
Reference in New Issue