Documentation ¶
Index ¶
- Constants
- func Verify(pub *PublicKey, msg, sig []byte) (bool, error)
- type Keypair
- func GenerateKeypair() (*Keypair, error)
- func NewKeypair(priv ed25519.PrivateKey) *Keypair
- func NewKeypairFromMnenomic(mnemonic, password string) (*Keypair, error)
- func NewKeypairFromPrivate(priv *PrivateKey) (*Keypair, error)
- func NewKeypairFromPrivateKeyString(in string) (*Keypair, error)
- func NewKeypairFromSeed(seed []byte) (*Keypair, error)
- type PrivateKey
- type PublicKey
- type PublicKeyBytes
- type SignatureBytes
Constants ¶
const PrivateKeyLength int = 64
PrivateKeyLength is the fixed Private Key Length
const PublicKeyLength int = 32
PublicKeyLength is the fixed Public Key Length
const SeedLength int = 32
SeedLength is the fixed Seed Length
const SignatureLength int = 64
SignatureLength is the fixed Signature Length
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Keypair ¶
type Keypair struct {
// contains filtered or unexported fields
}
Keypair is a ed25519 public-private keypair
func GenerateKeypair ¶
GenerateKeypair returns a new ed25519 keypair
func NewKeypair ¶
func NewKeypair(priv ed25519.PrivateKey) *Keypair
NewKeypair returns an Ed25519 keypair given a ed25519 private key
func NewKeypairFromMnenomic ¶ added in v0.3.1
NewKeypairFromMnenomic returns a new Keypair using the given mnemonic and password.
func NewKeypairFromPrivate ¶
func NewKeypairFromPrivate(priv *PrivateKey) (*Keypair, error)
NewKeypairFromPrivate returns a ed25519 Keypair given a *ed25519.PrivateKey
func NewKeypairFromPrivateKeyString ¶
NewKeypairFromPrivateKeyString returns a Keypair given a 0x prefixed private key string
func NewKeypairFromSeed ¶
NewKeypairFromSeed generates a new ed25519 keypair from a 32 byte seed
func (*Keypair) Private ¶
func (kp *Keypair) Private() crypto.PrivateKey
Private returns the keypair's private key
type PrivateKey ¶
type PrivateKey ed25519.PrivateKey
PrivateKey is the ed25519 Private Key
func NewPrivateKey ¶
func NewPrivateKey(in []byte) (*PrivateKey, error)
NewPrivateKey returns an ed25519 private key that consists of the input bytes Input length must be 64 bytes
func (*PrivateKey) Decode ¶
func (k *PrivateKey) Decode(in []byte) error
Decode turns the input bytes into a ed25519 PrivateKey the input must be 64 bytes, or the function will return an error
func (*PrivateKey) Encode ¶
func (k *PrivateKey) Encode() []byte
Encode returns the bytes underlying the ed25519 PrivateKey
type PublicKey ¶
PublicKey is the ed25519 Public Key
func NewPublicKey ¶
NewPublicKey returns an ed25519 public key that consists of the input bytes Input length must be 32 bytes
func (*PublicKey) AsBytes ¶
func (k *PublicKey) AsBytes() PublicKeyBytes
AsBytes returns the public key as PublicKeyBytes
func (*PublicKey) Decode ¶
Decode turns the input bytes into an ed25519 PublicKey the input must be 32 bytes, or the function will return and error
type PublicKeyBytes ¶
type PublicKeyBytes [PublicKeyLength]byte
PublicKeyBytes is an encoded ed25519 public key
func (PublicKeyBytes) Decode ¶ added in v0.2.0
func (b PublicKeyBytes) Decode(r io.Reader) ([PublicKeyLength]byte, error)
Decode returns the SCALE decoded PublicKeyBytes
func (PublicKeyBytes) Encode ¶ added in v0.2.0
func (b PublicKeyBytes) Encode() ([]byte, error)
Encode returns the SCALE encoding of PublicKeyBytes
func (PublicKeyBytes) String ¶ added in v0.2.0
func (b PublicKeyBytes) String() string
String returns the PublicKeyBytes formatted as a hex string
type SignatureBytes ¶
type SignatureBytes [SignatureLength]byte
SignatureBytes is a ed25519 signature
func NewSignatureBytes ¶
func NewSignatureBytes(in []byte) SignatureBytes
NewSignatureBytes returns a SignatureBytes given a byte array