crypto

package
v0.0.0-...-c37bcb2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: LGPL-3.0-or-later Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHashing is Hashing error
	ErrHashing = errors.New("Hashing error")
	// ErrEncrypting is Encoding error
	ErrEncrypting = errors.New("Encoding error")
	// ErrDecrypting is Decrypting error
	ErrDecrypting = errors.New("Decrypting error")
	// ErrUnknownProvider is Unknown provider error
	ErrUnknownProvider = errors.New("Unknown provider")
	// ErrHashingEmpty is Hashing empty value error
	ErrHashingEmpty = errors.New("Hashing empty value")
	// ErrEncryptingEmpty is Encrypting empty value error
	ErrEncryptingEmpty = errors.New("Encrypting empty value")
	// ErrDecryptingEmpty is Decrypting empty value error
	ErrDecryptingEmpty = errors.New("Decrypting empty value")
	// ErrSigningEmpty is Signing empty value error
	ErrSigningEmpty = errors.New("Signing empty value")
	// ErrCheckingSignEmpty is Checking sign of empty error
	ErrCheckingSignEmpty = errors.New("Cheking sign of empty")
	// ErrIncorrectSign is Incorrect sign
	ErrIncorrectSign = errors.New("Incorrect sign")
	// ErrUnsupportedCurveSize is Unsupported curve size error
	ErrUnsupportedCurveSize = errors.New("Unsupported curve size")
	// ErrIncorrectPrivKeyLength is Incorrect private key length error
	ErrIncorrectPrivKeyLength = errors.New("Incorrect private key length")
	// ErrIncorrectPubKeyLength is Incorrect public key length
	ErrIncorrectPubKeyLength = errors.New("Incorrect public key length")
)

Functions

func Address

func Address(pubKey []byte) int64

Address gets int64 EGGAS address from the public key

func CalcChecksum

func CalcChecksum(input []byte) (uint64, error)

CalcChecksum is calculates checksum

func CheckSign

func CheckSign(public []byte, data string, signature []byte) (bool, error)

CheckSign is checking sign

func Decrypt

func Decrypt(msg []byte, key []byte, iv []byte) ([]byte, error)

Decrypt is decrypting

func DoubleHash

func DoubleHash(msg []byte) ([]byte, error)

DoubleHash returns double hash of passed bytes

func Encrypt

func Encrypt(msg []byte, key []byte, iv []byte) ([]byte, error)

Encrypt is encrypting

func GenBytesKeys

func GenBytesKeys() ([]byte, []byte, error)

GenBytesKeys generates a random pair of ECDSA private and public binary keys.

func GenHexKeys

func GenHexKeys() (string, string, error)

GenHexKeys generates a random pair of ECDSA private and public hex keys.

func GetHMAC

func GetHMAC(secret string, message string) ([]byte, error)

GetHMAC returns HMAC hash

func GetHMACWithTimestamp

func GetHMACWithTimestamp(secret string, message string, timestamp string) ([]byte, error)

GetHMACWithTimestamp allows add timestamp

func GetWalletIDByPublicKey

func GetWalletIDByPublicKey(publicKey []byte) (int64, error)

GetWalletIDByPublicKey converts public key to wallet id

func Hash

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

Hash returns hash of passed bytes

func HashHex

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

func JSSignToBytes

func JSSignToBytes(in string) ([]byte, error)

JSSignToBytes converts hex signature which has got from the browser to []byte

func KeyToAddress

func KeyToAddress(pubKey []byte) string

KeyToAddress converts a public key to apla address XXXX-...-XXXX.

func NewHash

func NewHash() hash.Hash

func PrivateToPublic

func PrivateToPublic(key []byte) ([]byte, error)

PrivateToPublic returns the public key for the specified private key.

func RandInt

func RandInt(min int, max int) int

RandInt returns a random integer between min and max

func RandSeq

func RandSeq(n int) string

RandSeq is returning random string

func SharedEncrypt

func SharedEncrypt(public, text []byte) ([]byte, error)

SharedEncrypt creates a shared key and encrypts text. The first 32 characters are the created public key. The cipher text can be only decrypted with the original private key.

func Sign

func Sign(privateKey string, data string) ([]byte, error)

Sign in signing data with private key

Types

This section is empty.

Jump to

Keyboard shortcuts

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