mock

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: UNKNOWN, Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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) Equals

func (privKey PrivKeyMock) Equals(other crypto.PrivKey) bool

func (PrivKeyMock) PubKey

func (privKey PrivKeyMock) PubKey() crypto.PubKey

func (PrivKeyMock) Sign

func (privKey PrivKeyMock) Sign(msg []byte) ([]byte, error)

Make a fake signature. Its length is variable.

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) Equals

func (pubKey PubKeyMock) Equals(other crypto.PubKey) bool

func (PubKeyMock) String

func (pubKey PubKeyMock) String() string

func (PubKeyMock) VerifyBytes

func (pubKey PubKeyMock) VerifyBytes(msg []byte, sig []byte) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL