Documentation ¶
Index ¶
- Constants
- Variables
- func AttachInput(output [VrfOutputLength]byte, pub *PublicKey, t *merlin.Transcript) *sr25519.VrfInOut
- func MakeBytes(inout *sr25519.VrfInOut, size int, context []byte) []byte
- type Keypair
- func GenerateKeypair() (*Keypair, error)
- func NewKeypair(priv *sr25519.SecretKey) (*Keypair, error)
- func NewKeypairFromMnenomic(mnemonic, password string) (*Keypair, error)
- func NewKeypairFromPrivate(priv *PrivateKey) (*Keypair, error)
- func NewKeypairFromPrivateKeyBytes(in []byte) (*Keypair, error)
- func NewKeypairFromPrivateKeyString(in string) (*Keypair, error)
- func NewKeypairFromSeed(seed []byte) (*Keypair, error)
- type PrivateKey
- func (k *PrivateKey) Decode(in []byte) error
- func (k *PrivateKey) Encode() []byte
- func (k *PrivateKey) Hex() string
- func (k *PrivateKey) Public() (crypto.PublicKey, error)
- func (k *PrivateKey) Sign(msg []byte) ([]byte, error)
- func (k *PrivateKey) VrfSign(t *merlin.Transcript) ([VrfOutputLength]byte, [VrfProofLength]byte, error)
- type PublicKey
- func (k *PublicKey) Address() common.Address
- func (k *PublicKey) AsBytes() [PublicKeyLength]byte
- func (k *PublicKey) Decode(in []byte) error
- func (k *PublicKey) Encode() []byte
- func (k *PublicKey) Hex() string
- func (k *PublicKey) Verify(msg, sig []byte) (bool, error)
- func (k *PublicKey) VerifyDeprecated(msg, sig []byte) (bool, error)
- func (k *PublicKey) VrfVerify(t *merlin.Transcript, out [VrfOutputLength]byte, proof [VrfProofLength]byte) (bool, error)
Constants ¶
const ( PublicKeyLength int = 32 SeedLength int = 32 PrivateKeyLength int = 32 SignatureLength int = 64 VrfOutputLength int = 32 VrfProofLength int = 64 )
nolint
Variables ¶
var SigningContext = []byte("substrate")
SigningContext is the context for signatures used or created with substrate
Functions ¶
func AttachInput ¶ added in v0.3.0
func AttachInput(output [VrfOutputLength]byte, pub *PublicKey, t *merlin.Transcript) *sr25519.VrfInOut
AttachInput wraps schnorrkel *VrfOutput.AttachInput
Types ¶
type Keypair ¶
type Keypair struct {
// contains filtered or unexported fields
}
Keypair is a sr25519 public-private keypair
func GenerateKeypair ¶
GenerateKeypair returns a new sr25519 keypair
func NewKeypair ¶
NewKeypair returns a sr25519 Keypair given a schnorrkel secret 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 sr25519 Keypair given a *sr25519.PrivateKey
func NewKeypairFromPrivateKeyBytes ¶
NewKeypairFromPrivateKeyBytes returns a Keypair given a private key byte slice
func NewKeypairFromPrivateKeyString ¶
NewKeypairFromPrivateKeyString returns a Keypair given a 0x prefixed private key string
func NewKeypairFromSeed ¶
NewKeypairFromSeed returns a new sr25519 Keypair given a seed
func (*Keypair) Private ¶
func (kp *Keypair) Private() crypto.PrivateKey
Private returns the private key corresponding to this keypair
func (*Keypair) Sign ¶
Sign uses the keypair to sign the message using the sr25519 signature algorithm
func (*Keypair) VrfSign ¶
func (kp *Keypair) VrfSign(t *merlin.Transcript) ([VrfOutputLength]byte, [VrfProofLength]byte, error)
VrfSign creates a VRF output and proof from a message and private key
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey holds reference to a sr25519.SecretKey
func NewPrivateKey ¶
func NewPrivateKey(in []byte) (*PrivateKey, error)
NewPrivateKey creates a new private key using the input bytes
func (*PrivateKey) Decode ¶
func (k *PrivateKey) Decode(in []byte) error
Decode decodes the input bytes into a private key and sets the receiver the decoded key Input must be 32 bytes, or else this function will error
func (*PrivateKey) Encode ¶
func (k *PrivateKey) Encode() []byte
Encode returns the 32-byte encoding of the private key
func (*PrivateKey) Hex ¶
func (k *PrivateKey) Hex() string
Hex returns the private key as a '0x' prefixed hex string
func (*PrivateKey) Public ¶
func (k *PrivateKey) Public() (crypto.PublicKey, error)
Public returns the public key corresponding to this private key
func (*PrivateKey) Sign ¶
func (k *PrivateKey) Sign(msg []byte) ([]byte, error)
Sign uses the private key to sign the message using the sr25519 signature algorithm
func (*PrivateKey) VrfSign ¶
func (k *PrivateKey) VrfSign(t *merlin.Transcript) ([VrfOutputLength]byte, [VrfProofLength]byte, error)
VrfSign creates a VRF output and proof from a message and private key
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey holds reference to a sr25519.PublicKey
func NewPublicKey ¶
NewPublicKey returns a sr25519 public key from 32 byte input
func (*PublicKey) AsBytes ¶ added in v0.2.0
func (k *PublicKey) AsBytes() [PublicKeyLength]byte
AsBytes returns the key as a [PublicKeyLength]byte
func (*PublicKey) Decode ¶
Decode decodes the input bytes into a public key and sets the receiver the decoded key Input must be 32 bytes, or else this function will error
func (*PublicKey) Verify ¶
Verify uses the sr25519 signature algorithm to verify that the message was signed by this public key; it returns true if this key created the signature for the message, false otherwise
func (*PublicKey) VerifyDeprecated ¶ added in v0.3.0
VerifyDeprecated verifies that the public key signed the given message. Deprecated: this is used by ext_crypto_sr25519_verify_version_1 only and should not be used anywhere else. This method does not check that the signature is in fact a schnorrkel signature, and does not distinguish between sr25519 and ed25519 signatures.
func (*PublicKey) VrfVerify ¶
func (k *PublicKey) VrfVerify(t *merlin.Transcript, out [VrfOutputLength]byte, proof [VrfProofLength]byte) (bool, error)
VrfVerify confirms that the output and proof are valid given a message and public key