package nkeys
Import Path
github.com/nats-io/nkeys (on go.dev)
Dependency Relation
imports 10 packages, and imported by one package
Involved Source Files
crc16.go
creds_utils.go
errors.go
keypair.go
Package nkeys is an Ed25519 based public-key signature system that simplifies keys and seeds
and performs signing and verification.
It also supports encryption via x25519 keys and is compatible with https://pkg.go.dev/golang.org/x/crypto/nacl/box.
public.go
strkey.go
xkeys.go
Package-Level Type Names (total 2)
KeyPair provides the central interface to nkeys.
Open is only supported on CurveKey
( KeyPair) PrivateKey() ([]byte, error)
( KeyPair) PublicKey() (string, error)
Seal is only supported on CurveKeyPair
SealWithRand is only supported on CurveKeyPair
( KeyPair) Seed() ([]byte, error)
Sign is only supported on Non CurveKeyPairs
Verify is only supported on Non CurveKeyPairs
( KeyPair) Wipe()
func CreateAccount() (KeyPair, error)
func CreateCluster() (KeyPair, error)
func CreateCurveKeys() (KeyPair, error)
func CreateCurveKeysWithRand(rr io.Reader) (KeyPair, error)
func CreateOperator() (KeyPair, error)
func CreatePair(prefix PrefixByte) (KeyPair, error)
func CreatePairWithRand(prefix PrefixByte, rr io.Reader) (KeyPair, error)
func CreateServer() (KeyPair, error)
func CreateUser() (KeyPair, error)
func FromCurveSeed(seed []byte) (KeyPair, error)
func FromPublicKey(public string) (KeyPair, error)
func FromRawSeed(prefix PrefixByte, rawSeed []byte) (KeyPair, error)
func FromSeed(seed []byte) (KeyPair, error)
func ParseDecoratedNKey(contents []byte) (KeyPair, error)
func ParseDecoratedUserNKey(contents []byte) (KeyPair, error)
func CompatibleKeyPair(kp KeyPair, expected ...PrefixByte) error
PrefixByte is a lead byte representing the type.
( PrefixByte) String() string
PrefixByte : expvar.Var
PrefixByte : fmt.Stringer
func DecodeSeed(src []byte) (PrefixByte, []byte, error)
func Prefix(src string) PrefixByte
func CompatibleKeyPair(kp KeyPair, expected ...PrefixByte) error
func CreatePair(prefix PrefixByte) (KeyPair, error)
func CreatePairWithRand(prefix PrefixByte, rr io.Reader) (KeyPair, error)
func Decode(expectedPrefix PrefixByte, src []byte) ([]byte, error)
func Encode(prefix PrefixByte, src []byte) ([]byte, error)
func EncodeSeed(public PrefixByte, src []byte) ([]byte, error)
func FromRawSeed(prefix PrefixByte, rawSeed []byte) (KeyPair, error)
const PrefixByteAccount
const PrefixByteCluster
const PrefixByteCurve
const PrefixByteOperator
const PrefixBytePrivate
const PrefixByteSeed
const PrefixByteServer
const PrefixByteUnknown
const PrefixByteUser
Package-Level Functions (total 30)
CompatibleKeyPair returns an error if the KeyPair doesn't match expected PrefixByte(s)
CreateAccount will create an Account typed KeyPair.
CreateCluster will create a Cluster typed KeyPair.
CreateCurveKeys will create a Curve typed KeyPair.
CreateCurveKeysWithRand will create a Curve typed KeyPair
with specified rand source.
CreateOperator will create an Operator typed KeyPair.
CreatePair will create a KeyPair based on the rand entropy and a type/prefix byte.
CreatePair will create a KeyPair based on the rand reader and a type/prefix byte. rand can be nil.
CreateServer will create a Server typed KeyPair.
CreateUser will create a User typed KeyPair.
Decode will decode the base32 string and check crc16 and enforce the prefix is what is expected.
DecodeSeed will decode the base32 string and check crc16 and enforce the prefix is a seed
and the subsequent type is a valid type.
Encode will encode a raw key or seed with the prefix and crc16 and then base32 encoded.
EncodeSeed will encode a raw key with the prefix and then seed prefix and crc16 and then base32 encoded.
`src` must be 32 bytes long (ed25519.SeedSize).
Will create a curve key pair from seed.
FromPublicKey will create a KeyPair capable of verifying signatures.
FromRawSeed will create a KeyPair from the raw 32 byte seed for a given type.
FromSeed will create a KeyPair capable of signing and verifying signatures.
IsValidEncoding will tell you if the encoding is a valid key.
IsValidPublicAccountKey will decode and verify the string is a valid encoded Public Account Key.
IsValidPublicClusterKey will decode and verify the string is a valid encoded Public Cluster Key.
IsValidPublicCurveKey will decode and verify the string is a valid encoded Public Curve Key.
IsValidPublicKey will decode and verify that the string is a valid encoded public key.
IsValidPublicOperatorKey will decode and verify the string is a valid encoded Public Operator Key.
IsValidPublicServerKey will decode and verify the string is a valid encoded Public Server Key.
IsValidPublicUserKey will decode and verify the string is a valid encoded Public User Key.
ParseDecoratedJWT takes a creds file and returns the JWT portion.
ParseDecoratedNKey takes a creds file, finds the NKey portion and creates a
key pair from it.
ParseDecoratedUserNKey takes a creds file, finds the NKey portion and creates a
key pair from it. Similar to ParseDecoratedNKey but fails for non-user keys.
Prefix returns PrefixBytes of its input
Package-Level Constants (total 37)
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
Errors
PrefixByteAccount is the version byte used for encoded NATS Accounts
PrefixByteCluster is the version byte used for encoded NATS Clusters
PrefixByteCurve is the version byte used for encoded CurveKeys (X25519)
PrefixByteOperator is the version byte used for encoded NATS Operators
PrefixBytePrivate is the version byte used for encoded NATS Private keys
PrefixByteSeed is the version byte used for encoded NATS Seeds
PrefixByteServer is the version byte used for encoded NATS Servers
PrefixByteUnknown is for unknown prefixes.
PrefixByteUser is the version byte used for encoded NATS Users
Version is our current version
Only version for now, but could add in X3DH in the future, etc.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |