Documentation
¶
Overview ¶
Package cryptonote is for libraries to manage the keys and addresses used before Jamtis.
Index ¶
- Constants
- type Address
- func (a *Address) Equal(b *Address) bool
- func (a *Address) MarshalText() ([]byte, error)
- func (a *Address) Network() Network
- func (a *Address) String() string
- func (a *Address) Type() AddressType
- func (a *Address) UnmarshalText(base58Input []byte) error
- func (a *Address) ValidateNet(net Network) error
- type AddressType
- type Network
- type PrivateKeyPair
- func (kp *PrivateKeyPair) PrivateViewKey() *PrivateViewKey
- func (kp *PrivateKeyPair) PublicKeyPair() *PublicKeyPair
- func (kp *PrivateKeyPair) SpendKey() *PrivateSpendKey
- func (kp *PrivateKeyPair) SpendKeyBytes() []byte
- func (kp *PrivateKeyPair) SubAddrPubKeyPair(accountIndex uint32, subAddrIndex uint32) *PublicKeyPair
- type PrivateSpendKey
- func (k *PrivateSpendKey) AsPrivateKeyPair() (*PrivateKeyPair, error)
- func (k *PrivateSpendKey) Bytes() []byte
- func (k *PrivateSpendKey) Hex() string
- func (k *PrivateSpendKey) PrivateViewKey() (*PrivateViewKey, error)
- func (k *PrivateSpendKey) Public() *PublicKey
- func (k *PrivateSpendKey) String() string
- type PrivateViewKey
- type PublicKey
- type PublicKeyPair
Constants ¶
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 ¶
NewAddress converts a string to a monero Address with validation.
func (*Address) MarshalText ¶
MarshalText serializes the Monero Address type with some extra validation.
func (*Address) UnmarshalText ¶
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 ¶
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 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.
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.