types

package
v0.0.0-...-270a13f Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PubKeySize is is the size, in bytes, of public keys as used in this package.
	PubKeySize = 32
	// PrivateKeySize is the size, in bytes, of private keys as used in this package.
	PrivateKeySize = 64
	// Size of an Edwards25519 signature. Namely the size of a compressed
	// Edwards25519 point, and a field element. Both of which are 32 bytes.
	SignatureSize = 64
	// SeedSize is the size, in bytes, of private key seeds. These are the
	// private key representations used by RFC 8032.
	SeedSize = 32

	KeyType = "ed25519"
)
View Source
const (
	RAW_TRANSACTION_SALT           = "APTOS::RawTransaction"
	RAW_TRANSACTION_WITH_DATA_SALT = "APTOS::RawTransactionWithData"
)
View Source
const (
	AddressLength = 32
)

Variables

This section is empty.

Functions

func EncodeBCS

func EncodeBCS[T bool | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string | Uint128](t T) []byte

func FromHex

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func IsHexAddress

func IsHexAddress(s string) bool

IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.

func ReverseBytes

func ReverseBytes(b []byte)

Types

type Address

type Address [AddressLength]byte

Address represents the 32 byte address of an account .

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.

func HexToAddress

func HexToAddress(s string) Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes gets the string representation of the underlying address.

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b. If b is larger than len(a), b will be cropped from the left.

func (Address) String

func (a Address) String() string

String implements fmt.Stringer.

type BatchVerifier

type BatchVerifier struct {
	*ed25519.BatchVerifier
}

BatchVerifier implements batch verification for ed25519.

func NewBatchVerifier

func NewBatchVerifier() *BatchVerifier

func (*BatchVerifier) Add

func (b *BatchVerifier) Add(key PubKey, msg, signature []byte) error

func (*BatchVerifier) Verify

func (b *BatchVerifier) Verify() (bool, []bool)

type InnerTransaction

type InnerTransaction struct {
	Sender                  string             `json:"sender"`
	SequenceNumber          string             `json:"sequence_number"`
	MaxGasAmount            string             `json:"max_gas_amount"`
	GasUnitPrice            string             `json:"gas_unit_price"`
	ExpirationTimestampSecs string             `json:"expiration_timestamp_secs"`
	Payload                 TransactionPayload `json:"payload"`
}

type Module

type Module struct {
	Code []byte `lcs:"code"`
}

type ModuleID

type ModuleID struct {
	Address Address `lcs:"address"`
	Name    string  `lcs:"name"`
}

func ParseModuleAndFunctionName

func ParseModuleAndFunctionName(function string) (*ModuleID, string, error)

type PrivKey

type PrivKey []byte

PrivKey implements crypto.PrivKey.

func GenPrivKey

func GenPrivKey() PrivKey

GenPrivKey generates a new ed25519 private key. It uses OS randomness in conjunction with the current global random seed in tendermint/libs/common to generate the private key.

func GenPrivKeyFromHex

func GenPrivKeyFromHex(key string) (pk PrivKey, err error)

GenPrivKeyFromHex generates a ed25519 private key from hex format private key.

func GenPrivKeyFromSecret

func GenPrivKeyFromSecret(secret []byte) PrivKey

GenPrivKeyFromSecret hashes the secret with SHA2, and uses that 32 byte output to create the private key. NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.

func GenPrivKeyFromSeed

func GenPrivKeyFromSeed(seed []byte) PrivKey

GenPrivKey generates a new ed25519 private key. From a 32 bytes seed

func (PrivKey) Bytes

func (privKey PrivKey) Bytes() []byte

Bytes returns the privkey byte format.

func (PrivKey) Equals

func (privKey PrivKey) Equals(other PrivKey) bool

Equals - you probably don't need to use this. Runs in constant time based on length of the keys.

func (PrivKey) PubKey

func (privKey PrivKey) PubKey() PubKey

PubKey gets the corresponding public key from the private key.

Panics if the private key is not initialized.

func (PrivKey) Sign

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

Sign produces a signature on the provided message. This assumes the privkey is wellformed in the golang format. The first 32 bytes should be random, corresponding to the normal ed25519 private key. The latter 32 bytes should be the compressed public key. If these conditions aren't met, Sign will panic or produce an incorrect signature.

func (PrivKey) String

func (privKey PrivKey) String() string

func (PrivKey) Type

func (privKey PrivKey) Type() string

type PubKey

type PubKey []byte

PubKeyEd25519 implements crypto.PubKey for the Ed25519 signature scheme.

func (PubKey) Address

func (pubKey PubKey) Address() Address

Address is the SHA256 of the raw pubkey bytes.

func (PubKey) Bytes

func (pubKey PubKey) Bytes() []byte

Bytes returns the PubKey byte format.

func (PubKey) Equals

func (pubKey PubKey) Equals(other PubKey) bool

func (PubKey) String

func (pubKey PubKey) String() string

func (PubKey) Type

func (pubKey PubKey) Type() string

func (PubKey) VerifySignature

func (pubKey PubKey) VerifySignature(msg []byte, sig []byte) bool

type RawRawTransactionWithData

type RawRawTransactionWithData interface{}

type RawTransaction

type RawTransaction struct {
	Sender                  Address               `lcs:"sender"`
	SequenceNumber          uint64                `lcs:"sequence_number"`
	Payload                 RawTransactionPayload `lcs:"payload"`
	MaxGasAmount            uint64                `lcs:"max_gas_amount"`
	GasUnitPrice            uint64                `lcs:"gas_unit_price"`
	ExpirationTimestampSecs uint64                `lcs:"expiration_timestamp_secs"`
	ChainID                 uint8                 `lcs:"chain_id"`
}

type RawTransactionArgument

type RawTransactionArgument interface{}

type RawTransactionArgumentAddress

type RawTransactionArgumentAddress struct {
	Value Address `lcs:"value"`
}

type RawTransactionArgumentBool

type RawTransactionArgumentBool struct {
	Value bool `lcs:"value"`
}

type RawTransactionArgumentU128

type RawTransactionArgumentU128 struct {
	Value Uint128 `lcs:"value"`
}

type RawTransactionArgumentU64

type RawTransactionArgumentU64 struct {
	Value uint64 `lcs:"value"`
}

type RawTransactionArgumentU8

type RawTransactionArgumentU8 struct {
	Value uint8 `lcs:"value"`
}

type RawTransactionArgumentU8Vector

type RawTransactionArgumentU8Vector struct {
	Value []uint8 `lcs:"value"`
}

type RawTransactionPayload

type RawTransactionPayload interface{}

type RawTransactionPayloadEntryFunction

type RawTransactionPayloadEntryFunction struct {
	ModuleName   ModuleID  `lcs:"module_name"`
	FunctionName string    `lcs:"function_name"`
	TyArgs       []TypeTag `lcs:"ty_args"`
	Args         [][]byte  `lcs:"args"`
}

type RawTransactionPayloadModuleBundle

type RawTransactionPayloadModuleBundle struct{}

type RawTransactionPayloadScript

type RawTransactionPayloadScript struct {
	Code   []byte                   `lcs:"code"`
	TyArgs []TypeTag                `lcs:"ty_args"`
	Args   []RawTransactionArgument `lcs:"args"`
}

type Transaction

type Transaction struct {
	InnerTransaction
	Signature        *TransactionSignature `json:"signature"`
	SecondarySigners *[]string             `json:"secondary_signers,omitempty"`
}

func (*Transaction) EncodeToBCS

func (tx *Transaction) EncodeToBCS(payload RawTransactionPayload) (data []byte, err error)

func (*Transaction) ToRawTransaction

func (tx *Transaction) ToRawTransaction(payload RawTransactionPayload) *RawTransaction

type TransactionPayload

type TransactionPayload struct {
	Type          string        `json:"type"`
	Function      string        `json:"function"`
	TypeArguments []string      `json:"type_arguments"`
	Arguments     []interface{} `json:"arguments"`
}

type TransactionSignature

type TransactionSignature struct {
	Type      string `json:"type"`
	PublicKey string `json:"public_key"`
	Signature string `json:"signature"`
}

type TypeTag

type TypeTag interface{}

type TypeTagAddress

type TypeTagAddress struct{}

type TypeTagBool

type TypeTagBool struct{}

type TypeTagSigner

type TypeTagSigner struct{}

type TypeTagStruct

type TypeTagStruct struct {
	Address    Address   `lcs:"address"`
	ModuleName string    `lcs:"module_name"`
	Name       string    `lcs:"name"`
	TypeArgs   []TypeTag `lcs:"type_args"`
}

func NewTypeTagStructFromString

func NewTypeTagStructFromString(tag string) (*TypeTagStruct, error)

type TypeTagU128

type TypeTagU128 struct{}

type TypeTagU64

type TypeTagU64 struct{}

type TypeTagU8

type TypeTagU8 struct{}

type TypeTagVector

type TypeTagVector struct {
	Value TypeTag `lcs:"value"`
}

type Uint128

type Uint128 struct{ *big.Int }

func (Uint128) MarshalLCS

func (u Uint128) MarshalLCS(e *lcs.Encoder) error

func (*Uint128) UnmarshalLCS

func (u *Uint128) UnmarshalLCS(d *lcs.Decoder) error

Jump to

Keyboard shortcuts

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