Involved Source Files Package key provides Ed25519 keys, signatures, and endpoint identifiers for
go-iroh.
A [SecretKey] signs messages and derives a [PublicKey]. Use [PublicKey] for
cryptographic operations and [EndpointID] for network-facing endpoint
identities. Keys and endpoint IDs render as lowercase hex by default;
[EndpointID.Z32] returns the z-base-32 form used in pkarr names.
The Go API is not stable before v1 and may change in any v0 release.key.gokey_core.go
PublicKey is a public Ed25519 key. It is verified to be a valid curve point
when created.
The zero value is not usable; construct a PublicKey with [NewPublicKey],
[ParsePublicKey], or [SecretKey.Public]. Bytes returns the public key as a 32-byte array. Compare returns -1, 0, or +1 comparing k and other by their raw bytes. It
gives PublicKey a total order suitable for sorting and map-free ordered use. Ed25519 returns the key as a crypto/ed25519 public key. The returned slice is
a copy and may be modified by the caller. EndpointID returns the endpoint identifier for k. Equal reports whether k and other are the same key. IsZero reports whether k is the unusable zero value. MarshalBinary implements encoding.BinaryMarshaler, producing the 32 raw bytes. MarshalText implements encoding.TextMarshaler, producing the hex form. Short returns a short, friendly hex string of the first 5 bytes of the key,
for logging. It is not a complete or parseable representation. String returns the lowercase-hex encoding of the key. It is the canonical
human-readable form and round-trips through [ParsePublicKey]. UnmarshalBinary implements encoding.BinaryUnmarshaler from 32 raw bytes. UnmarshalText implements encoding.TextUnmarshaler, parsing the hex or base32
form. Verify reports whether sig is a valid signature of message by k. It returns
nil on success and [ErrInvalidSignature] otherwise.
Verification uses crypto/ed25519 (cofactored, RFC 8032). The Rust reference
uses ed25519-dalek's verify_strict (cofactorless). The two agree for every
signature an honest iroh peer produces; they differ only for adversarially
malleable signatures, which iroh drops anyway. This divergence is benign for
iroh's drop-on-failure model (relay handshake, TLS raw-key, and pkarr packet
verification all reject on failure).
PublicKey : encoding.BinaryMarshaler
*PublicKey : encoding.BinaryUnmarshaler
PublicKey : encoding.TextMarshaler
*PublicKey : encoding.TextUnmarshaler
PublicKey : expvar.Var
PublicKey : fmt.Stringer
PublicKey : gopkg.in/yaml.v3.IsZeroer
func NewPublicKey(b [32]byte) (PublicKey, error)
func ParsePublicKey(s string) (PublicKey, error)
func PublicKeyFromEd25519(k ed25519.PublicKey) (PublicKey, error)
func PublicKeyFromSlice(b []byte) (PublicKey, error)
func EndpointID.PublicKey() PublicKey
func SecretKey.Public() PublicKey
func github.com/tmc/go-iroh/dns.(*SignedPacket).PublicKey() PublicKey
func github.com/tmc/go-iroh/internal/pkarr.(*SignedPacket).PublicKey() PublicKey
func PublicKey.Compare(other PublicKey) int
func PublicKey.Equal(other PublicKey) bool
func github.com/tmc/go-iroh/internal/pkarr.FromRelayPayload(pub PublicKey, payload []byte) (*pkarr.SignedPacket, error)
Signature is a signature produced by a [SecretKey]. Bytes returns the signature as a 64-byte array. Ed25519 returns the signature bytes used by crypto/ed25519. The returned
slice is a copy and may be modified by the caller. Equal reports whether s and other are the same signature. MarshalBinary implements encoding.BinaryMarshaler, producing the 64 raw
signature bytes. MarshalText implements encoding.TextMarshaler, producing the hex form. String returns the lowercase-hex encoding of the signature. UnmarshalBinary implements encoding.BinaryUnmarshaler from 64 raw bytes. UnmarshalText implements encoding.TextUnmarshaler, parsing the hex form.
Signature : encoding.BinaryMarshaler
*Signature : encoding.BinaryUnmarshaler
Signature : encoding.TextMarshaler
*Signature : encoding.TextUnmarshaler
Signature : expvar.Var
Signature : fmt.Stringer
func NewSignature(b [64]byte) Signature
func SignatureFromEd25519(sig []byte) (Signature, error)
func SignatureFromSlice(b []byte) (Signature, error)
func SecretKey.Sign(msg []byte) Signature
func github.com/tmc/go-iroh/internal/pkarr.(*SignedPacket).Signature() Signature
func PublicKey.Verify(message []byte, sig Signature) error
func Signature.Equal(other Signature) bool
Package-Level Functions (total 16)
EndpointIDFromSlice constructs an EndpointID from a byte slice.
GenerateSecretKey generates a new SecretKey using crypto/ed25519.
NewEndpointID constructs an EndpointID from a 32-byte array.
NewPublicKey constructs a PublicKey from a 32-byte array. It returns
[ErrInvalidKeyData] if the bytes do not decompress to a valid Ed25519 curve
point. It never fails for bytes returned from [PublicKey.Bytes].
NewSecretKey constructs a SecretKey from its 32-byte seed.
NewSignature constructs a Signature from its 64 raw bytes.
ParseEndpointID parses an EndpointID from its hex or base32 string form.
ParseEndpointIDZ32 parses an endpoint id from its z-base-32 encoding.
ParsePublicKey parses a PublicKey from its hex or base32 string form. A string
of exactly 64 characters is decoded as lowercase hex; otherwise it is decoded
as RFC 4648 base32 (no padding, case-insensitive). [PublicKey.String] always
produces the hex form.
ParseSecretKey parses a SecretKey from its hex or base32 string form, matching
the rules of [ParsePublicKey].
PublicKeyFromEd25519 constructs a PublicKey from a crypto/ed25519 public key.
PublicKeyFromSlice constructs a PublicKey from a byte slice. It returns
[ErrInvalidKeyLength] if the slice is not 32 bytes and [ErrInvalidKeyData] if
the bytes are not a valid curve point.
SecretKeyFromEd25519 constructs a SecretKey from a crypto/ed25519 private key.
The private key is copied.
SecretKeyFromSlice constructs a SecretKey from a 32-byte seed slice. It
returns [ErrInvalidKeyLength] if the slice is not 32 bytes.
SignatureFromEd25519 constructs a Signature from a crypto/ed25519 signature.
SignatureFromSlice constructs a Signature from a byte slice. It returns
[ErrInvalidSignatureParse] if the slice is not 64 bytes.
Package-Level Variables (total 6)
ErrDecodeBase32 is returned when a string cannot be decoded as base32.
ErrDecodeHex is returned when a string cannot be decoded as hex.
ErrInvalidKeyData is returned when bytes do not represent a valid
Ed25519 curve point.
ErrInvalidKeyLength is returned when key bytes have the wrong length.
ErrInvalidSignature is returned when signature verification fails.
ErrInvalidSignatureParse is returned when bytes cannot be parsed as an
Ed25519 signature.
Package-Level Constants (total 4)
PrivateKeySize is the size of an Ed25519 private key, in bytes.
PublicKeySize is the size of an Ed25519 public key, in bytes.
SeedSize is the size of an Ed25519 private key seed, in bytes.
SignatureSize is the size of an Ed25519 signature, in bytes.
The pages are generated with Goldsv0.8.4. (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.