vrpgo

package
v0.0.0-...-9c4f748 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressIDSize    = 20
	PublicKeyLength  = 32
	PrivateKeyLength = 32
	DigestLength     = 32
	SignatureLength  = 64

	DigestSize          = 32
	EthereumHashSize    = 32
	EthereumAddressSize = AddressIDSize
)

The lengths of basic crypto primitives.

Variables

This section is empty.

Functions

func AddressFromPublicKeyHash

func AddressFromPublicKeyHash(scheme byte, pubKeyHash []byte) eVESTXAddress

func DecodeFromHexString

func DecodeFromHexString(s string) ([]byte, error)

Types

type Address

type Address string

Address is a string representation of Vrp address in form of BASE58 string.

type AddressID

type AddressID [AddressIDSize]byte

type Bytes

type Bytes []byte

Bytes is a type alias for the slice of bytes.

type Digest

type Digest [DigestSize]byte

func SecureHashA

func SecureHashA(data []byte) (Digest, error)

type EthereumAddress

type EthereumAddress [EthereumAddressSize]byte

func EthereumAddressFromBytes

func EthereumAddressFromBytes(b []byte) EthereumAddress

type EthereumHash

type EthereumHash [EthereumHashSize]byte

type KeyPair

type KeyPair struct {
	PublicKey  PublicKey
	PrivateKey PrivateKey
}

KeyPair is an interface to a structure that holds corresponding private and public keys.

type PrivateKey

type PrivateKey string

PrivateKey is a string representation of a private key in form of BASE58 string.

type PublicKey

type PublicKey string

PublicKey is a string representation of a public key bytes in form of BASE58 string.

type Seed

type Seed string

Seed is a BIP39 seed phrase.

type VrpChainID

type VrpChainID byte

VrpChainID is a int64 to represent blockchain identification.

const (
	MainNet VrpChainID = 140
	TestNet VrpChainID = 139
)

Known chain IDs

type VrpCrypto

type VrpCrypto interface {
	Blake2b(input Bytes) Bytes // Blake2b produces the BLAKE2b-256 digest of the given `input`.
	Keccak(input Bytes) Bytes  // Keccak creates a new legacy Keccak-256 hash digest of the `input`.
	Sha256(input Bytes) Bytes  // Sha256 returns a new SHA256 checksum calculated from the `input`.

	Base58Encode(input Bytes) string // Base58Encode encodes the `input` into a BASE58 string.
	Base58Decode(input string) Bytes // Base58Decode decodes the `input` string to bytes.
	Base64Encode(input Bytes) string // Base64Encode returns a BASE64 string representation of the `input` bytes.
	Base64Decode(input string) Bytes // Base64Decode decodes the `input` BASE64 string to bytes.

	KeyPair(seed Seed) KeyPair       // KeyPair returns a pair of keys produced from the `seed`.
	PublicKey(seed Seed) PublicKey   // PublicKey returns a public key generated from the `seed`.
	PrivateKey(seed Seed) PrivateKey // PrivateKey generates a private key from the given `seed`.

	Address(publicKey PublicKey, chainID VrpChainID) Address // Address generates new Vrp address from the `publicKey` and `chainID`.
	AddressFromSeed(seed Seed, chainID VrpChainID) Address   // AddressFromSeed returns a new Vrp address produced from the `seed` and `chainID`.

	RandomSeed() Seed          // RandomSeed return a new randomly generated BIP39 seed phrase.
	VerifySeed(seed Seed) bool // Checks the seed parameters

	SignBytes(bytes Bytes, privateKey PrivateKey) Bytes // SignBytes produces a signature for the `bytes` by `privateKey`.
	SignBytesBySeed(bytes Bytes, seed Seed) Bytes       // SignBytesBySeed returns a signature for the `bytes` by a private keys generated from the `seed`.~“

	VerifySignature(publicKey PublicKey, bytes, signature Bytes) bool // VerifySignature returns true if `signature` is a valid signature of `bytes` by `publicKey`.

	VerifyAddress(address Address, chainID VrpChainID) bool      // VerifyAddress returns true if `address` is a valid Vrp address for the given `chainId`. Function calls the `VerifyAddressChecksum` function.
	VerifyAddressChecksum(address Address) bool                  // VerifyAddressChecksum calculates and compares the `address` checksum. Returns `true` if the checksum is correct.
	ToChainAddress(scheme byte, address []byte) eVESTXAddress    //Ethereum address to eVESTX Address
	EthereumAddressFromHexString(address string) EthereumAddress // eVESTX Address to ethereum address

}

VrpCrypto is a collection of functions to work with Vrp basic types and crypto primitives used by Vrp.

func NewVrpCrypto

func NewVrpCrypto() VrpCrypto

NewVrpCrypto returns a new instance of VrpCrypto interface.

Jump to

Keyboard shortcuts

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