common

package
v0.0.0-...-42ba967 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionLocks        = "locks"
	CollectionTransactions = "transactions"
	CollectionRefunds      = "refunds"
	CollectionMessages     = "messages"
	CollectionNodes        = "nodes"
)
View Source
const (
	AddressLength          = 20
	CosmosPublicKeyLength  = 33
	DefaultEntropySize     = 256
	DefaultBIP39Passphrase = ""
	DefaultCosmosHDPath    = "m/44'/118'/0'/0/0"
	DefaultETHHDPath       = "m/44'/60'/0'/0/0"
	ZeroAddress            = "0x0000000000000000000000000000000000000000"
)
View Source
const (
	HyperlaneVersion uint8 = 3
)

Variables

View Source
var ErrInvalidAddressLength = errors.New("invalid address length")
View Source
var (
	ErrInvalidPublicKeyLength = errors.New("invalid public key length")
)
View Source
var NewGCPKeyManagementClient = func(ctx context.Context) (GCPKeyManagementClient, error) {
	return kms.NewKeyManagementClient(ctx)
}

Functions

func AddressBytesFromBech32

func AddressBytesFromBech32(bech32Prefix string, address string) ([]byte, error)

func AddressHexFromBytes

func AddressHexFromBytes(address []byte) (string, error)

func Bech32FromBytes

func Bech32FromBytes(bech32Prefix string, bs []byte) (string, error)

func Bytes32FromAddressHex

func Bytes32FromAddressHex(addr string) ([]byte, error)

func BytesFromAddressHex

func BytesFromAddressHex(addr string) ([]byte, error)

func BytesFromBech32

func BytesFromBech32(bech32Prefix string, address string) (addr []byte, err error)

func BytesFromHex

func BytesFromHex(hexStr string) ([]byte, error)

func CosmosPrivateKeyFromMnemonic

func CosmosPrivateKeyFromMnemonic(mnemonic string) (crypto.PrivKey, error)

func CosmosPublicKeyFromHex

func CosmosPublicKeyFromHex(pubKeyHex string) (crypto.PubKey, error)

func CosmosPublicKeyFromMnemonic

func CosmosPublicKeyFromMnemonic(mnemonic string) (crypto.PubKey, error)

func CosmosPublicKeyHexFromMnemonic

func CosmosPublicKeyHexFromMnemonic(mnemonic string) (string, error)

func Ensure0xPrefix

func Ensure0xPrefix(str string) string

func EthereumAddressFromMnemonic

func EthereumAddressFromMnemonic(mnemonic string) (string, error)

func EthereumPrivateKeyFromMnemonic

func EthereumPrivateKeyFromMnemonic(mnemonic string) (*ecdsa.PrivateKey, error)

func EthereumPrivateKeyToAddressHex

func EthereumPrivateKeyToAddressHex(privateKey *ecdsa.PrivateKey) (string, error)

func HexFromBytes

func HexFromBytes(bytes []byte) string

func HexToAddress

func HexToAddress(hex string) ethcommon.Address

func IsValidAddressHex

func IsValidAddressHex(s string) bool

func IsValidBech32Address

func IsValidBech32Address(bech32Prefix string, address string) bool

func IsValidCosmosPublicKey

func IsValidCosmosPublicKey(s string) bool

func IsValidEthereumAddress

func IsValidEthereumAddress(s string) bool

func RemoveDuplicates

func RemoveDuplicates(elements []primitive.ObjectID) []primitive.ObjectID

Types

type GCPKeyManagementClient

type GCPKeyManagementClient interface {
	Close() error
	GetPublicKey(ctx context.Context, req *kmspb.GetPublicKeyRequest, opts ...gax.CallOption) (*kmspb.PublicKey, error)
	AsymmetricSign(ctx context.Context, req *kmspb.AsymmetricSignRequest, opts ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error)
	GetCryptoKeyVersion(ctx context.Context, req *kmspb.GetCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
}

type GcpKmsSigner

type GcpKmsSigner struct {
	// contains filtered or unexported fields
}

Struct Definition

func (*GcpKmsSigner) CosmosPublicKey

func (s *GcpKmsSigner) CosmosPublicKey() types.PubKey

func (*GcpKmsSigner) CosmosSign

func (s *GcpKmsSigner) CosmosSign(data []byte) ([]byte, error)

func (*GcpKmsSigner) Destroy

func (s *GcpKmsSigner) Destroy()

Destructor Function

func (*GcpKmsSigner) EthAddress

func (s *GcpKmsSigner) EthAddress() common.Address

func (*GcpKmsSigner) EthSign

func (s *GcpKmsSigner) EthSign(data []byte) ([]byte, error)

Method Implementations

type MnemonicSigner

type MnemonicSigner struct {
	// contains filtered or unexported fields
}

Struct Definition

func NewMnemonicSigner

func NewMnemonicSigner(mnemonic string) (*MnemonicSigner, error)

Constructor Function

func (*MnemonicSigner) CosmosPublicKey

func (s *MnemonicSigner) CosmosPublicKey() types.PubKey

func (*MnemonicSigner) CosmosSign

func (s *MnemonicSigner) CosmosSign(data []byte) ([]byte, error)

func (*MnemonicSigner) Destroy

func (s *MnemonicSigner) Destroy()

Destructor Function

func (*MnemonicSigner) EthAddress

func (s *MnemonicSigner) EthAddress() common.Address

func (*MnemonicSigner) EthSign

func (s *MnemonicSigner) EthSign(data []byte) ([]byte, error)

Method Implementations

type Signer

type Signer interface {
	EthSign(data []byte) ([]byte, error)
	CosmosSign(data []byte) ([]byte, error)
	EthAddress() common.Address
	CosmosPublicKey() types.PubKey
	Destroy()
}

Interface Definition

func NewGcpKmsSigner

func NewGcpKmsSigner(keyName string) (Signer, error)

Constructor Function

Jump to

Keyboard shortcuts

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