Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Package = amino.NewPackage( "github.com/gnolang/gno/tm2/pkg/crypto/mock", "tm", amino.GetCallersDirname(), ).WithDependencies().WithTypes( PubKeyMock{}, "PubKeyMock", PrivKeyMock{}, "PrivKeyMock", )
Package is deliberately not registered with the global amino codec here, the way every other crypto package registers itself. Use UnsafeRegisterAminoPackage, and read its docs first.
Functions ¶
func UnsafeRegisterAminoPackage ¶
func UnsafeRegisterAminoPackage()
UnsafeRegisterAminoPackage registers PubKeyMock and PrivKeyMock with the global amino codec, so that they can be encoded to and decoded from amino bytes anywhere in the process. It is idempotent.
Do NOT call this on any production path. These types stand in for real crypto, and PubKeyMock in particular verifies any signature that can be derived from the message and the public key alone — which is to say, by anyone. Registering it lets an caller-chosen type URL in untrusted bytes resolve to PubKeyMock, so any crypto.PubKey decoded from the wire may hold a key whose signatures are forgeable. That reaches further than it first looks: a key type needs only to be accepted somewhere a crypto.PubKey is decoded, such as a constituent key of a multisig.PubKeyMultisigThreshold, for its forgeable signatures to stand in for a real one.
Registration is kept out of this package's init so that importing the package cannot enable that decoding as a side effect, and so that enabling it is greppable. Call it from an init() in a _test.go file: the global codec seals itself the first time it is used, and registering after that panics with "codec sealed".
Types ¶
type PrivKeyMock ¶
type PrivKeyMock []byte
PrivKeyMock implements crypto.PrivKey.
func GenPrivKey ¶
func GenPrivKey() PrivKeyMock
func (PrivKeyMock) Bytes ¶
func (privKey PrivKeyMock) Bytes() []byte
Bytes marshals the privkey using amino encoding w/ type information.
func (PrivKeyMock) PubKey ¶
func (privKey PrivKeyMock) PubKey() crypto.PubKey
type PubKeyMock ¶
type PubKeyMock []byte
func (PubKeyMock) Address ¶
func (pubKey PubKeyMock) Address() crypto.Address
Returns address w/ pubkey as suffix (for debugging).
func (PubKeyMock) Bytes ¶
func (pubKey PubKeyMock) Bytes() []byte
Bytes marshals the PubKey using amino encoding.
func (PubKeyMock) String ¶
func (pubKey PubKeyMock) String() string
func (PubKeyMock) VerifyBytes ¶
func (pubKey PubKeyMock) VerifyBytes(msg []byte, sig []byte) bool