* WIP on protobuf keys * Use Type() and Bytes() in sr25519 pub key Equals * Add tests * Add few more tests * Update other pub/priv key types Equals * Fix PrivKey's Sign method * Rename variables in tests * Fix infinite recursive calls * Use tm ed25519 keys * Add Sign and VerifySignature tests * Remove ed25519 and sr25519 references * proto linting * Add proto crypto file * Implement some of the new multisig proto type methods * Add tests for MultisigThresholdPubKey * Add tests for pubkey pb/amino conversion functions * Move crypto types.go and register new proto pubkeys * Add missing pointer ref * Address review comments * panic in MultisigThresholdPubKey VerifySignature * Use internal crypto.PubKey in multisig * Add tests for MultisigThresholdPubKey VerifyMultisignature * Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys to v1 * Remove conversion functions and introduce internal PubKey type * Remove old secp256k1 PubKey and PrivKey * Uncomment test case * Fix linting issues * More linting * Revert tests keys values * Add Amino overrides to proto keys * Add pubkey test * Fix tests * Use threshold isntead of K * Standardize Type * Revert standardize types commit * Add comment * Simplify proto names * Add comment about multisig codec Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
67 lines
2.0 KiB
Go
67 lines
2.0 KiB
Go
package codec
|
|
|
|
import (
|
|
"github.com/gogo/protobuf/proto"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
|
)
|
|
|
|
type (
|
|
// Marshaler defines the interface module codecs must implement in order to support
|
|
// backwards compatibility with Amino while allowing custom Protobuf-based
|
|
// serialization. Note, Amino can still be used without any dependency on
|
|
// Protobuf. There are two typical implementations that fulfill this contract:
|
|
//
|
|
// 1. AminoCodec: Provides full Amino serialization compatibility.
|
|
// 2. ProtoCodec: Provides full Protobuf serialization compatibility.
|
|
Marshaler interface {
|
|
BinaryMarshaler
|
|
JSONMarshaler
|
|
}
|
|
|
|
BinaryMarshaler interface {
|
|
MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
|
|
MustMarshalBinaryBare(o ProtoMarshaler) []byte
|
|
|
|
MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
|
|
MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte
|
|
|
|
UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
|
|
MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)
|
|
|
|
UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
|
|
MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)
|
|
|
|
types.AnyUnpacker
|
|
}
|
|
|
|
JSONMarshaler interface {
|
|
MarshalJSON(o proto.Message) ([]byte, error)
|
|
MustMarshalJSON(o proto.Message) []byte
|
|
|
|
UnmarshalJSON(bz []byte, ptr proto.Message) error
|
|
MustUnmarshalJSON(bz []byte, ptr proto.Message)
|
|
}
|
|
|
|
// ProtoMarshaler defines an interface a type must implement as protocol buffer
|
|
// defined message.
|
|
ProtoMarshaler interface {
|
|
proto.Message // for JSON serialization
|
|
|
|
Marshal() ([]byte, error)
|
|
MarshalTo(data []byte) (n int, err error)
|
|
MarshalToSizedBuffer(dAtA []byte) (int, error)
|
|
Size() int
|
|
Unmarshal(data []byte) error
|
|
}
|
|
|
|
// AminoMarshaler defines an interface where Amino marshalling can be
|
|
// overridden by custom marshalling.
|
|
AminoMarshaler interface {
|
|
MarshalAmino() ([]byte, error)
|
|
UnmarshalAmino([]byte) error
|
|
MarshalAminoJSON() ([]byte, error)
|
|
UnmarshalAminoJSON([]byte) error
|
|
}
|
|
)
|