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
- func VerifySignature(publicKey, signature, message []byte) error
- 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(keystr []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 is the expected public key length for sr25519. PublicKeyLength = 32 // SeedLength is the expected seed length for sr25519. SeedLength = 32 // PrivateKeyLength is the expected private key length for sr25519. PrivateKeyLength = 32 // SignatureLength is the expected signature length for sr25519. SignatureLength = 64 // VRFOutputLength is the expected VFR output length for sr25519. VRFOutputLength = 32 // VRFProofLength is the expected VFR proof length for sr25519. VRFProofLength = 64 )
Variables ¶
var SigningContext = []byte("substrate")
SigningContext is the context for signatures used or created with substrate
Functions ¶
func AttachInput ¶
func AttachInput(output [VRFOutputLength]byte, pub *PublicKey, t *merlin.Transcript) *sr25519.VrfInOut
AttachInput wraps schnorrkel *VrfOutput.AttachInput
func VerifySignature ¶
VerifySignature verifies a signature given a public key and a message
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 ¶
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 ¶
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 ¶
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