Documentation ¶
Index ¶
Constants ¶
const KeyLength = 32
KeyLength is the length of keys (in bytes).
const NonceLength = 24
NonceLength is the the length of nonces (in bytes).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Challenge ¶
Challenge represents something that can be solved and solutions can be checked against.
type Nonce ¶
type Nonce *[NonceLength]byte
Nonce represents a nonce.
func GenerateNonce ¶ added in v1.4.48
GenerateNonce generates a fixed number of random bytes.
func SolveChallenge ¶ added in v1.4.48
func SolveChallenge(challenge []byte, nonce Nonce, peersPublicKey *PublicKey, privateKey *PrivateKey) ([]byte, Nonce, error)
SolveChallenge attempts to solve a challenge with a given private key.
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey represents a private key.
func GenerateKey ¶ added in v1.4.49
func GenerateKey() (*PrivateKey, error)
GenerateKey generates a new PrivateKey.
func ParsePrivateKey ¶ added in v1.4.49
func ParsePrivateKey(raw []byte) (*PrivateKey, error)
ParsePrivateKey parses raw bytes onto a PrivateKey.
func ParsePrivateKeyB64 ¶ added in v1.4.49
func ParsePrivateKeyB64(b64 string) (*PrivateKey, error)
ParsePrivateKeyB64 parses base64-encoded bytes onto a PrivateKey.
func (*PrivateKey) B64 ¶ added in v1.4.51
func (p *PrivateKey) B64() string
B64 returns the base64-encoded private key bytes.
func (*PrivateKey) Public ¶ added in v1.4.49
func (p *PrivateKey) Public() *PublicKey
Public returns the public key corresponding to the private key.
func (*PrivateKey) Raw ¶ added in v1.4.49
func (p *PrivateKey) Raw() *[KeyLength]byte
Raw returns the address of the raw private key bytes.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey represents a public key.
func MustParsePublicKey ¶ added in v1.4.58
MustParsePublicKey parses raw bytes onto a PublicKey or panics on error.
func ParsePublicKey ¶ added in v1.4.49
ParsePublicKey parses raw bytes onto a PublicKey.
func ParsePublicKeyB64 ¶ added in v1.4.49
ParsePublicKeyB64 parses base64-encoded bytes onto a PublicKey.
type Service ¶
type Service interface { PrivateKey() *PrivateKey NewChallengeForPeer(*PublicKey) (Challenge, error) }
Service represents an entity capable of issuing challenges for others to solve.
func New ¶
func New(privateKey *PrivateKey) (Service, error)
New returns a newly initialized, default Service implementation.