cryptonote

package
v0.0.0-...-34c5cda Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cryptonote is for libraries to manage the keys and addresses used before Jamtis.

Index

Constants

View Source
const (
	// KeySize is the size, in bytes, of both public and private keys
	// used in cryptonote.
	KeySize = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	// contains filtered or unexported fields
}

Address represents a Monero address

func NewAddress

func NewAddress(addrStr string, net Network) (*Address, error)

NewAddress converts a string to a monero Address with validation.

func (*Address) Equal

func (a *Address) Equal(b *Address) bool

Equal returns true if the addresses are identical, otherwise false.

func (*Address) MarshalText

func (a *Address) MarshalText() ([]byte, error)

MarshalText serializes the Monero Address type with some extra validation.

func (*Address) Network

func (a *Address) Network() Network

Network returns the Monero network of the address

func (*Address) String

func (a *Address) String() string

func (*Address) Type

func (a *Address) Type() AddressType

Type returns the Address type

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(base58Input []byte) error

UnmarshalText converts a base58 encoded monero address to our Address type. The encoding, length and checksum are all validated, but not the network, as it is unknown by the JSON parser. Empty strings are not allowed. Use an address pointer in your serialized types if the Address is optional.

func (*Address) ValidateNet

func (a *Address) ValidateNet(net Network) error

ValidateNet validates that the monero network matches the passed network. This validation can't be performed when decoding JSON, as the environment is not known at that time.

type AddressType

type AddressType string

AddressType is the type of Monero address: Standard or Subaddress

const (
	Standard   AddressType = "standard"
	Subaddress AddressType = "subaddress"
)

Monero address types. We don't support Integrated.

type Network

type Network string

Network is the Monero network type

const (
	Mainnet  Network = "mainnet"
	Stagenet Network = "stagenet"
	Testnet  Network = "testnet"
)

Monero networks

type PrivateKeyPair

type PrivateKeyPair struct {
	// contains filtered or unexported fields
}

PrivateKeyPair represents a monero private spend and view key.

func GenerateKeys

func GenerateKeys() (*PrivateKeyPair, error)

GenerateKeys generates a private spend key and view key

func NewPrivateKeyPairFromBytes

func NewPrivateKeyPairFromBytes(skBytes, vkBytes []byte) (*PrivateKeyPair, error)

NewPrivateKeyPairFromBytes returns a new PrivateKeyPair given the canonical byte representation of a private spend and view key.

func (*PrivateKeyPair) PrivateViewKey

func (kp *PrivateKeyPair) PrivateViewKey() *PrivateViewKey

PrivateViewKey returns the key pair's private view key

func (*PrivateKeyPair) PublicKeyPair

func (kp *PrivateKeyPair) PublicKeyPair() *PublicKeyPair

PublicKeyPair returns the PublicKeyPair corresponding to the PrivateKeyPair

func (*PrivateKeyPair) SpendKey

func (kp *PrivateKeyPair) SpendKey() *PrivateSpendKey

SpendKey returns the key pair's private spend key

func (*PrivateKeyPair) SpendKeyBytes

func (kp *PrivateKeyPair) SpendKeyBytes() []byte

SpendKeyBytes returns the canonical byte encoding of the private spend key.

func (*PrivateKeyPair) SubAddrPubKeyPair

func (kp *PrivateKeyPair) SubAddrPubKeyPair(accountIndex uint32, subAddrIndex uint32) *PublicKeyPair

SubAddrPubKeyPair returns the PublicKeyPair of the requested subaddress.

type PrivateSpendKey

type PrivateSpendKey struct {
	// contains filtered or unexported fields
}

PrivateSpendKey represents a monero private spend key

func NewPrivateSpendKey

func NewPrivateSpendKey(b []byte) (*PrivateSpendKey, error)

NewPrivateSpendKey returns a new PrivateSpendKey from the given canonically-encoded scalar.

func (*PrivateSpendKey) AsPrivateKeyPair

func (k *PrivateSpendKey) AsPrivateKeyPair() (*PrivateKeyPair, error)

AsPrivateKeyPair returns the PrivateSpendKey as a PrivateKeyPair.

func (*PrivateSpendKey) Bytes

func (k *PrivateSpendKey) Bytes() []byte

Bytes returns the PrivateSpendKey as canonical bytes

func (*PrivateSpendKey) Hex

func (k *PrivateSpendKey) Hex() string

Hex formats the key as a hex string

func (*PrivateSpendKey) PrivateViewKey

func (k *PrivateSpendKey) PrivateViewKey() (*PrivateViewKey, error)

PrivateViewKey returns the private view key using the standard algorithm from the PrivateSpendKey. View keys do not not have to be derived from the spend key, but by doing it this way, you preserve compatibility with most wallets, some of which require it to be this way.

func (*PrivateSpendKey) Public

func (k *PrivateSpendKey) Public() *PublicKey

Public returns the public key corresponding to the private key.

func (*PrivateSpendKey) String

func (k *PrivateSpendKey) String() string

String formats the key as a 0x-prefixed hex string

type PrivateViewKey

type PrivateViewKey struct {
	// contains filtered or unexported fields
}

PrivateViewKey represents a monero private view key.

func (*PrivateViewKey) Bytes

func (k *PrivateViewKey) Bytes() []byte

Bytes returns the canonical 32-byte little-endian encoding of PrivateViewKey.

func (*PrivateViewKey) Hex

func (k *PrivateViewKey) Hex() string

Hex formats the key as a hex string

func (*PrivateViewKey) Public

func (k *PrivateViewKey) Public() *PublicKey

Public returns the PublicKey corresponding to this PrivateViewKey.

func (*PrivateViewKey) String

func (k *PrivateViewKey) String() string

String formats the key as a 0x-prefixed hex string

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents a monero public spend, view or subaddress key.

func (*PublicKey) Bytes

func (k *PublicKey) Bytes() []byte

Bytes returns the canonical 32-byte, little-endian encoding of PublicKey.

func (*PublicKey) Hex

func (k *PublicKey) Hex() string

Hex formats the key as a hex string

func (*PublicKey) String

func (k *PublicKey) String() string

String formats the key as a 0x-prefixed hex string

type PublicKeyPair

type PublicKeyPair struct {
	// contains filtered or unexported fields
}

PublicKeyPair contains a public SpendKey and ViewKey

func (*PublicKeyPair) Address

func (kp *PublicKeyPair) Address(net Network) *Address

Address returns the address as bytes for a PublicKeyPair with the given environment (ie. mainnet or stagenet)

func (*PublicKeyPair) SpendKey

func (kp *PublicKeyPair) SpendKey() *PublicKey

SpendKey returns the key pair's spend key.

func (*PublicKeyPair) ViewKey

func (kp *PublicKeyPair) ViewKey() *PublicKey

ViewKey returns the key pair's view key.

Jump to

Keyboard shortcuts

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