crypto

package
v0.0.0-...-a856406 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const AddressLength = 21

Variables

View Source
var AddressPrefix = byte(0x41)

AddressPrefix is the byte prefix of the address used in TRON addresses. It's supposed to be '0xa0' for testnet, and '0x41' for mainnet. But the Shasta mainteiners don't use the testnet params. So the default value is 41. You may change it directly, or use the SetAddressPrefix/UseMainnet/UseTestnet methods.

Functions

func GenerateKey

func GenerateKey() (*ecdsa.PrivateKey, error)

func GetPrivateKeyByHexString

func GetPrivateKeyByHexString(privateKeyHexString string) (*ecdsa.PrivateKey,
	error)

func SetAddressPrefix

func SetAddressPrefix(p byte)

SetAddressPrefix sets the prefix to the provided byte.

func Sign

func Sign(hash []byte, privateKey *ecdsa.PrivateKey) ([]byte, error)

func UseMainnet

func UseMainnet()

UseMainnet sets the address prefix used for the main net.

func UseTestnet

func UseTestnet()

UseTestnet sets the address prefix used for the test net.

func VerifySignature

func VerifySignature(publicKey, hash, signature []byte) bool

Types

type Address

type Address [AddressLength]byte

func BytesToAddress

func BytesToAddress(b []byte) Address

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) Address

func (Address) Bytes

func (a Address) Bytes() []byte

func (*Address) SetBytes

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

Jump to

Keyboard shortcuts

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