crypto

package
v0.7.17-Pre4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 21 Imported by: 9

Documentation

Index

Constants

View Source
const (
	AddressLength = 21
	AddressPrefix = "41"
)

Variables

This section is empty.

Functions

func Decode58Check added in v0.5.5

func Decode58Check(input string) ([]byte, error)

Decode by base58 and check.

func Decrypt added in v0.1.7

func Decrypt(key, text []byte) ([]byte, error)

func EcdsaSign added in v0.5.6

func EcdsaSign(ecdsa *ecdsa.PrivateKey, bytes []byte) ([]byte, error)

func Encode58Check added in v0.5.5

func Encode58Check(input []byte) (string, error)

Encode by base58 and check.

func Encrypt added in v0.1.7

func Encrypt(key, text []byte) (string, error)

func FromHex added in v0.5.5

func FromHex(input string) ([]byte, error)

Decode hex string as bytes

func FromPrivKey added in v0.1.13

func FromPrivKey(privKey ic.PrivKey) (string, error)

func FromPubKey added in v0.1.13

func FromPubKey(pubKey ic.PubKey) (string, error)

func GenKeyPairs added in v0.1.7

func GenKeyPairs() (ic.PrivKey, ic.PubKey, error)

func GetPrivKeyFromHexOrBase64 added in v0.2.11

func GetPrivKeyFromHexOrBase64(raw string) (ic.PrivKey, error)

GetPrivKeyFromHexOrBase64 can decode a priv key from either hex or base64 format to satisfy different key storage encoding schemes

func GetPubKeyFromPeerId added in v0.1.8

func GetPubKeyFromPeerId(pid string) (ic.PubKey, error)

func GetRawFullFromPeerIdPretty added in v0.7.16

func GetRawFullFromPeerIdPretty(peerid string) ([]byte, error)

func GetTronPubKeyFromIcPubKey added in v0.7.16

func GetTronPubKeyFromIcPubKey(pubkey ic.PubKey) (*string, error)

func GetTronPubKeyFromPeerIdPretty added in v0.7.16

func GetTronPubKeyFromPeerIdPretty(peerId string) (*string, error)

func GetTronPubKeyFromPubkey added in v0.7.16

func GetTronPubKeyFromPubkey(pubkeyS string) (*string, error)

func Hash added in v0.5.5

func Hash(s []byte) ([]byte, error)

Package goLang sha256 hash algorithm.

func Hex64ToBase64 added in v0.2.11

func Hex64ToBase64(key string) (string, error)

func HexToECDSA added in v0.5.6

func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)

func Pad added in v0.1.7

func Pad(src []byte) []byte

pkcs7 padding

func Sign

func Sign(key ic.PrivKey, channelMessage proto.Message) ([]byte, error)

func ToPrivKey added in v0.1.4

func ToPrivKey(privKey string) (ic.PrivKey, error)

private key string to ic.PrivKey interface btfs config stores base64 of private key

func ToPrivKeyRaw added in v0.1.7

func ToPrivKeyRaw(privKey []byte) (ic.PrivKey, error)

Secp256k1 private key string to ic.PrivKey interface

func ToPubKey added in v0.1.4

func ToPubKey(pubKey string) (ic.PubKey, error)

public key string to ic.PubKey interface

func ToPubKeyRaw added in v0.1.7

func ToPubKeyRaw(pubKey []byte) (ic.PubKey, error)

public key string to ic.PubKey interface

func TronSign added in v0.7.16

func TronSign(privKey ic.PrivKey, msg proto.Message) ([]byte, error)

func TronSignRaw added in v0.7.16

func TronSignRaw(privKey ic.PrivKey, data []byte) ([]byte, error)

func Unpad added in v0.1.7

func Unpad(src []byte) ([]byte, error)

func Verify

func Verify(key ic.PubKey, channelMessage proto.Message, sig []byte) (bool, error)

Types

type Address added in v0.5.5

type Address [AddressLength]byte

func AddressLedgerToTron added in v0.5.5

func AddressLedgerToTron(ledgerAddress []byte) (Address, error)

Get Tron address from ledger address

func BytesToAddress added in v0.5.5

func BytesToAddress(b []byte) Address

func EcdsaPublicKeyToAddress added in v0.7.16

func EcdsaPublicKeyToAddress(p ecdsa.PublicKey) (Address, error)

func PublicKeyToAddress added in v0.5.5

func PublicKeyToAddress(p ecdsa.PublicKey) (Address, error)

ecdsa key to Tron address

func (*Address) Bytes added in v0.5.5

func (a *Address) Bytes() []byte

func (*Address) SetBytes added in v0.5.5

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

Convert byte to address.

type Keys added in v0.5.5

type Keys struct {
	Base58Address string
	HexAddress    string
	HexPrivateKey string
	HexPubKey     string
	Base64PubKey  string
}

func FromIcPrivateKey added in v0.5.6

func FromIcPrivateKey(privKey ic.PrivKey) (*Keys, error)

func FromPrivateKey added in v0.5.5

func FromPrivateKey(key string) (*Keys, error)

Jump to

Keyboard shortcuts

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