Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidAddress(text string) bool
- type Address
- func (a Address) Bytes() []byte
- func (a Address) BytesPrefixed() []byte
- func (a *Address) Deserialize(reader *io.BinReader)
- func (a *Address) GetPublicKey() []byte
- func (a Address) IsNull() bool
- func (a Address) IsUser() bool
- func (a Address) Kind() AddressKind
- func (a *Address) Serialize(writer *io.BinWriter)
- func (a Address) String() string
- func (a Address) Text() string
- type AddressKind
- type Ed25519Signature
- type Hash
- type Hashable
- type KeyPair
- type PhantasmaKeys
- func (k PhantasmaKeys) Address() Address
- func (k PhantasmaKeys) ExpandedPrivateKey() []byte
- func (k PhantasmaKeys) PrivateKey() []byte
- func (k PhantasmaKeys) PublicKey() []byte
- func (k PhantasmaKeys) Sign(msg []byte) Signature
- func (k PhantasmaKeys) String() string
- func (k PhantasmaKeys) WIF() string
- type Signature
- type SignatureKind
Constants ¶
const HashLength = 32
HashLength const
const HexPrefix = "0x"
HexPrefix const
const Length = 34
Length is the length of data
const PrivateKeyLength = 32
PrivateKeyLength defines the length of a private key
Variables ¶
var Null []byte = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0}
Functions ¶
func IsValidAddress ¶
IsValidAddress verifies if a string is a valid address
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address struct
func FromString ¶
FromString creates an instance of an Address from a string
func (Address) BytesPrefixed ¶
BytesPrefixed returns the data representing an address, including prefix required for binary serialization
func (*Address) Deserialize ¶
Deserialize implements ther Serializable interface
func (*Address) GetPublicKey ¶
type AddressKind ¶
type AddressKind byte
AddressKind type
const ( // Invalid address Invalid AddressKind = 0x00 // User address User AddressKind = 0x01 // System address System AddressKind = 0x02 // Interop address Interop AddressKind = 0x03 )
type Ed25519Signature ¶
type Ed25519Signature struct {
// contains filtered or unexported fields
}
Ed25519Signature struct
func Generate ¶
func Generate(keyPair KeyPair, message []byte) Ed25519Signature
Generate a new signature
func NewEd25519Signature ¶
func NewEd25519Signature(bytes []byte) Ed25519Signature
NewEd25519Signature instatiates a new signature object
func (Ed25519Signature) Bytes ¶
func (sig Ed25519Signature) Bytes() []byte
Bytes returns the byte representation of the signature
func (Ed25519Signature) Deserialize ¶
func (sig Ed25519Signature) Deserialize(reader *io.BinReader)
Deserialize implements ther Serializable interface
func (Ed25519Signature) Kind ¶
func (sig Ed25519Signature) Kind() SignatureKind
Kind returns the type of the signature
func (Ed25519Signature) Serialize ¶
func (sig Ed25519Signature) Serialize(writer *io.BinWriter)
Serialize implements ther Serializable interface
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
Hash struct
func HashFromBytes ¶
HashFromBytes returns a Hash based on the passed in byte slice
func HashFromString ¶
HashFromString creates an instance of Hash from a string
func (*Hash) Deserialize ¶
Deserialize implements ther Serializable interface
func (Hash) FromUnpaddedHex ¶
FromUnpaddedHex creates an instance of Hash from an unpadded hex string
func (Hash) GetDifficulty ¶
GetDifficulty retrieves the current difficulty of the hash
type Hashable ¶
type Hashable interface {
Hash() Hash
}
Hashable represents an object which can be hashed. Usually these objects are io.Serializable and signable. They tend to cache the hash inside for effectiveness, providing this accessor method. Anything that can be identified with a hash can then be signed and verified.
type KeyPair ¶
type KeyPair interface { PrivateKey() []byte ExpandedPrivateKey() []byte PublicKey() []byte Address() Address Sign(msg []byte) Signature }
KeyPair a
type PhantasmaKeys ¶
type PhantasmaKeys struct {
// contains filtered or unexported fields
}
PhantasmaKeys is the struct that holds the information about keys for the phantasma blockchain
func FromWIF ¶
func FromWIF(wif string) (PhantasmaKeys, error)
FromWIF creates a new key pair based on the passed in WIF
func GeneratePhantasmaKeys ¶
func GeneratePhantasmaKeys() PhantasmaKeys
GeneratePhantasmaKeys creates a new phantasma keypair
func NewPhantasmaKeys ¶
func NewPhantasmaKeys(seed []byte) PhantasmaKeys
NewPhantasmaKeys instantiates a new PhantasmaKeys object based on the given seed
func (PhantasmaKeys) Address ¶
func (k PhantasmaKeys) Address() Address
Address returns the associated address
func (PhantasmaKeys) ExpandedPrivateKey ¶
func (k PhantasmaKeys) ExpandedPrivateKey() []byte
ExpandedPrivateKey returns the associated expanded private key
func (PhantasmaKeys) PrivateKey ¶
func (k PhantasmaKeys) PrivateKey() []byte
PrivateKey returns the associated private key
func (PhantasmaKeys) PublicKey ¶
func (k PhantasmaKeys) PublicKey() []byte
PublicKey returns the associated public key
func (PhantasmaKeys) Sign ¶
func (k PhantasmaKeys) Sign(msg []byte) Signature
Sign generates a signature for the passed in message
func (PhantasmaKeys) String ¶
func (k PhantasmaKeys) String() string
func (PhantasmaKeys) WIF ¶
func (k PhantasmaKeys) WIF() string
WIF returns the WIF based on the private key
type Signature ¶
type Signature interface { Kind() SignatureKind Verify(message []byte, addresses []Address) bool Serialize(*io.BinWriter) Deserialize(*io.BinReader) Bytes() []byte }
Signature a
type SignatureKind ¶
type SignatureKind uint
SignatureKind type
const ( // None Signature None SignatureKind = iota // Ed25519 Signature Ed25519 // ECDSA Signature ECDSA // Ring Signature Ring )