common

package
v0.0.0-...-24e5678 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AddressLength is the expected length of the address
	AddressLength = common.AddressLength
)

Lengths of hashes and addresses in bytes.

View Source
const MinSignatureSize = 65

SignatureSize is 67 bytes r 32 s 32 v 1 => v 3 const SignatureSize = 67

View Source
const PublicKeySize = 65

PublicKeySize is 65 bytes

Variables

View Source
var (
	ErrInvalidAddressFormat   = errors.New("invalid address format")
	ErrInvalidAddressCheckSum = errors.New("invalid address checksum")
	ErrInvalidSignatureFormat = errors.New("invalid signature format")
	ErrInvalidSignature       = errors.New("invalid signature")
	ErrInvalidPublicKey       = errors.New("invalid public key")
	ErrInvalidPublicKeyFormat = errors.New("invalid public key format")
	ErrInsufficientSignature  = errors.New("insufficient signature")
	ErrDuplicatedSignature    = errors.New("duplicated signature")
)

common errors

View Source
var ZeroAddr = Address{}

Functions

func GetChainCap

func GetChainCap(ChainID *big.Int) *big.Int

func IsHexAddress

func IsHexAddress(s string) bool

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

func ParseAddress

func ParseAddress(s string) (common.Address, error)

ParseAddress is parse address

func Sizeof

func Sizeof(t reflect.Type) int

reflect.TypeOf(packetHeader)

func ValidateSignaturesMajority

func ValidateSignaturesMajority(chainID *big.Int, signedHash hash.Hash256, sigs []Signature, KeyMap map[PublicKey]bool) error

ValidateSignaturesMajority validates signatures with the signed hash and checks majority

func VerifySignature

func VerifySignature(pubkey PublicKey, h hash.Hash256, sig Signature) error

VerifySignature checks the signature with the public key and the hash value

Types

type Address

type Address = common.Address

func BigToAddress

func BigToAddress(b *big.Int) Address

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

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.

type Causer

type Causer interface {
	Cause() error
}

type PacketHeader

type PacketHeader struct {
	N1 int32 // sizeof에서 사용할 때 int로 하면 안 됨
	N2 int16
	N3 int64
}

type PublicKey

type PublicKey [PublicKeySize]byte

PublicKey is the [PublicKeySize]byte with methods

func MustParsePublicKey

func MustParsePublicKey(str string) PublicKey

MustParsePublicKey panic when error occurred

func ParsePublicKey

func ParsePublicKey(str string) (PublicKey, error)

ParsePublicKey parse the public hash from the string

func RecoverPubkey

func RecoverPubkey(chainid *big.Int, h hash.Hash256, s Signature) (PublicKey, error)

RecoverPubkey recover the public key using the hash value and the signature

func (PublicKey) Address

func (pubkey PublicKey) Address() Address

String returns the hex string of the public key

func (PublicKey) Clone

func (pubkey PublicKey) Clone() PublicKey

Clone returns the clonend value of it

func (PublicKey) MarshalJSON

func (pubkey PublicKey) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (PublicKey) String

func (pubkey PublicKey) String() string

String returns the hex string of the public key

func (*PublicKey) UnmarshalJSON

func (pubkey *PublicKey) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

type Signature

type Signature []byte

Signature is the [SignatureSize]byte with methods

func MustParseSignature

func MustParseSignature(str string) Signature

MustParseSignature panic when error occurred

func ParseSignature

func ParseSignature(str string) (Signature, error)

ParseSignature parse the public hash from the string

func (Signature) Clone

func (sig Signature) Clone() Signature

Clone returns the clonend value of it

func (Signature) MarshalJSON

func (sig Signature) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (Signature) String

func (sig Signature) String() string

String returns the hex string of the signature

func (*Signature) UnmarshalJSON

func (sig *Signature) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

type SyncChan

type SyncChan struct {
	Chan chan interface{}
	// contains filtered or unexported fields
}

func NewSyncChan

func NewSyncChan() *SyncChan

func (*SyncChan) Close

func (t *SyncChan) Close()

func (*SyncChan) Send

func (t *SyncChan) Send(v interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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