Documentation ¶
Index ¶
- Constants
- func GenerateKeypair() (*SecretKey, *PublicKey, error)
- func MnemonicToEntropy(mnemonic string) ([]byte, error)
- func NewRandomElement() (*r255.Element, error)
- func NewRandomScalar() (*r255.Scalar, error)
- func NewSigningContext(context, msg []byte) *merlin.Transcript
- func ScalarFromBytes(b [32]byte) (*r255.Scalar, error)
- func SeedFromMnemonic(mnemonic string, password string) ([64]byte, error)
- func TranscriptWithMalleabilityAddressed(t *merlin.Transcript, pk *PublicKey) *merlin.Transcript
- type DerivableKey
- type ExtendedKey
- type MiniSecretKey
- type PublicKey
- func (p *PublicKey) Compress() [32]byte
- func (p *PublicKey) Decode(in [32]byte) error
- func (pk *PublicKey) DeriveKey(t *merlin.Transcript, cc [ChainCodeLength]byte) (*ExtendedKey, error)
- func (pk *PublicKey) DeriveScalarAndChaincode(t *merlin.Transcript, cc [ChainCodeLength]byte) (*r255.Scalar, [ChainCodeLength]byte)
- func (p *PublicKey) Encode() [32]byte
- func (p *PublicKey) Verify(s *Signature, t *merlin.Transcript) bool
- func (pk *PublicKey) VrfVerify(t *merlin.Transcript, inout *VrfInOut, proof *VrfProof) (bool, error)
- type SecretKey
- func (s *SecretKey) Decode(in [32]byte) error
- func (sk *SecretKey) DeriveKey(t *merlin.Transcript, cc [ChainCodeLength]byte) (*ExtendedKey, error)
- func (s *SecretKey) Encode() [32]byte
- func (s *SecretKey) Public() (*PublicKey, error)
- func (sk *SecretKey) Sign(t *merlin.Transcript) (*Signature, error)
- func (sk *SecretKey) VrfSign(t *merlin.Transcript) (*VrfInOut, *VrfProof, error)
- type Signature
- type VrfInOut
- type VrfOutput
- type VrfProof
Constants ¶
const ChainCodeLength = 32
Variables ¶
This section is empty.
Functions ¶
func GenerateKeypair ¶
GenerateKeypair generates a new schnorrkel secret key and public key
func MnemonicToEntropy ¶
MnemonicToEntropy takes a mnemonic string and reverses it to the entropy An error is returned if the mnemonic is invalid.
func NewRandomElement ¶
NewRandomElement returns a random ristretto element
func NewRandomScalar ¶
NewRandomScalar returns a random ristretto scalar
func NewSigningContext ¶
func NewSigningContext(context, msg []byte) *merlin.Transcript
NewSigningContext returns a new transcript initialized with the context for the signature .see: https://github.com/w3f/schnorrkel/blob/db61369a6e77f8074eb3247f9040ccde55697f20/src/context.rs#L183
func ScalarFromBytes ¶
ScalarFromBytes returns a ristretto scalar from the input bytes performs input mod l where l is the group order
func SeedFromMnemonic ¶
SeedFromMnemonic returns a 64-byte seed from a bip39 mnemonic
func TranscriptWithMalleabilityAddressed ¶
func TranscriptWithMalleabilityAddressed(t *merlin.Transcript, pk *PublicKey) *merlin.Transcript
TranscriptWithMalleabilityAddressed returns the input transcript with the public key commited to it, addressing VRF output malleability.
Types ¶
type DerivableKey ¶
type DerivableKey interface { Encode() [32]byte Decode([32]byte) error DeriveKey(*merlin.Transcript, [ChainCodeLength]byte) (*ExtendedKey, error) }
DerivableKey implements DeriveKey
type ExtendedKey ¶
type ExtendedKey struct {
// contains filtered or unexported fields
}
ExtendedKey consists of a DerivableKey which can be a schnorrkel public or private key as well as chain code
func DeriveKeySimple ¶
func DeriveKeySimple(key DerivableKey, i []byte, cc [ChainCodeLength]byte) (*ExtendedKey, error)
DeriveKeySimple derives a subkey identified by byte array i and chain code.
func NewExtendedKey ¶
func NewExtendedKey(k DerivableKey, cc [ChainCodeLength]byte) *ExtendedKey
NewExtendedKey creates an ExtendedKey given a DerivableKey and chain code
func (*ExtendedKey) ChainCode ¶
func (ek *ExtendedKey) ChainCode() [ChainCodeLength]byte
ChainCode returns the chain code underlying the ExtendedKey
func (*ExtendedKey) DeriveKey ¶
func (ek *ExtendedKey) DeriveKey(t *merlin.Transcript) (*ExtendedKey, error)
DeriveKey derives an extended key from an extended key
func (*ExtendedKey) Key ¶
func (ek *ExtendedKey) Key() DerivableKey
Key returns the schnorrkel key underlying the ExtendedKey
func (*ExtendedKey) Public ¶
func (ek *ExtendedKey) Public() (*PublicKey, error)
Public returns the PublicKey underlying the ExtendedKey
func (*ExtendedKey) Secret ¶
func (ek *ExtendedKey) Secret() (*SecretKey, error)
Secret returns the SecretKey underlying the ExtendedKey if it's not a secret key, it returns an error
type MiniSecretKey ¶
type MiniSecretKey struct {
// contains filtered or unexported fields
}
MiniSecretKey is a secret scalar
func GenerateMiniSecretKey ¶
func GenerateMiniSecretKey() (*MiniSecretKey, error)
GenerateMiniSecretKey generates a mini secret key from random
func MiniSecretFromMnemonic ¶
func MiniSecretFromMnemonic(mnemonic string, password string) (*MiniSecretKey, error)
MiniSecretFromMnemonic returns a go-schnorrkel MiniSecretKey from a bip39 mnemonic
func NewMiniSecretKey ¶
func NewMiniSecretKey(b [64]byte) *MiniSecretKey
NewMiniSecretKey derives a mini secret key from a byte array
func NewMiniSecretKeyFromRaw ¶
func NewMiniSecretKeyFromRaw(b [32]byte) (*MiniSecretKey, error)
NewMiniSecretKeyFromRaw derives a mini secret key from little-endian encoded raw bytes.
func (*MiniSecretKey) Decode ¶
func (s *MiniSecretKey) Decode(in [32]byte) (err error)
func (*MiniSecretKey) Encode ¶
func (s *MiniSecretKey) Encode() [32]byte
func (*MiniSecretKey) ExpandEd25519 ¶
func (s *MiniSecretKey) ExpandEd25519() *SecretKey
ExpandEd25519 expands a mini secret key into a secret key https://github.com/w3f/schnorrkel/blob/43f7fc00724edd1ef53d5ae13d82d240ed6202d5/src/keys.rs#L196
func (*MiniSecretKey) ExpandUniform ¶
func (s *MiniSecretKey) ExpandUniform() *SecretKey
ExpandUniform
func (*MiniSecretKey) Public ¶
func (s *MiniSecretKey) Public() *PublicKey
Public gets the public key corresponding to this mini secret key
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is a member
func NewPublicKey ¶
NewPublicKey creates a new public key from input bytes
func (*PublicKey) DeriveKey ¶
func (pk *PublicKey) DeriveKey(t *merlin.Transcript, cc [ChainCodeLength]byte) (*ExtendedKey, error)
func (*PublicKey) DeriveScalarAndChaincode ¶
func (pk *PublicKey) DeriveScalarAndChaincode(t *merlin.Transcript, cc [ChainCodeLength]byte) (*r255.Scalar, [ChainCodeLength]byte)
DeriveScalarAndChaincode derives a new scalar and chain code from an existing public key and chain code
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
SecretKey consists of a secret scalar and a signing nonce
func NewSecretKey ¶
NewSecretKey creates a new secret key from input bytes
func (*SecretKey) DeriveKey ¶
func (sk *SecretKey) DeriveKey(t *merlin.Transcript, cc [ChainCodeLength]byte) (*ExtendedKey, error)
DeriveKey derives a new secret key and chain code from an existing secret key and chain code
func (*SecretKey) Sign ¶
func (sk *SecretKey) Sign(t *merlin.Transcript) (*Signature, error)
Sign uses the schnorr signature algorithm to sign a message See the following for the transcript message https://github.com/w3f/schnorrkel/blob/db61369a6e77f8074eb3247f9040ccde55697f20/src/sign.rs#L158 Schnorr w/ transcript, secret key x: 1. choose random r from group 2. R = gr 3. k = scalar(transcript.extract_bytes()) 4. s = kx + r signature: (R, s) public key used for verification: y = g^x
type Signature ¶
Signature holds a schnorrkel signature
func (*Signature) Decode ¶
Decode sets a Signature from bytes see: https://github.com/w3f/schnorrkel/blob/db61369a6e77f8074eb3247f9040ccde55697f20/src/sign.rs#L100
func (*Signature) Encode ¶
Encode turns a signature into a byte array see: https://github.com/w3f/schnorrkel/blob/db61369a6e77f8074eb3247f9040ccde55697f20/src/sign.rs#L77
type VrfInOut ¶
type VrfInOut struct {
// contains filtered or unexported fields
}
type VrfOutput ¶
type VrfOutput struct {
// contains filtered or unexported fields
}
func (*VrfOutput) AttachInput ¶
func (out *VrfOutput) AttachInput(pub *PublicKey, t *merlin.Transcript) *VrfInOut
AttachInput returns a VrfInOut pair from an output