identity

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package identity contains the byte-oriented identity rules shared by the Go and TypeScript SDKs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPrivateKey = errors.New("invalid secp256k1 private key")
	ErrInvalidPublicKey  = errors.New("invalid compressed secp256k1 public key")
	ErrInvalidPeerID     = errors.New("invalid peer id")
	ErrPeerIDMismatch    = errors.New("peer id does not match public key")
	ErrInvalidMultiaddr  = errors.New("invalid p2p multiaddr")
)

Functions

func Libp2pPublicKey

func Libp2pPublicKey(raw []byte) (libp2pcrypto.PubKey, error)

Libp2pPublicKey converts validated bytes into the native libp2p public-key object used by PeerId, Noise and Identify.

func ParsePrivateKeyHex

func ParsePrivateKeyHex(value string) ([]byte, error)

ParsePrivateKeyHex validates the configuration-only hexadecimal form.

func PeerIDFromPublicKey

func PeerIDFromPublicKey(raw []byte) (peer.ID, error)

PeerIDFromPublicKey uses the native libp2p key serialization and PeerId implementation. No protobuf, multihash or Base58 is assembled here.

func PrivateKeyBytes

func PrivateKeyBytes(raw []byte) error

PrivateKeyBytes is the only private-key input accepted by the identity package. It is intentionally not returned by any public identity helper.

func PublicKeyBytes

func PublicKeyBytes(raw []byte) ([]byte, error)

PublicKeyBytes validates a compressed SEC1 public key and returns a copy.

func PublicKeyFromPeerID

func PublicKeyFromPeerID(id peer.ID) ([]byte, error)

PublicKeyFromPeerID extracts the inline secp256k1 public key and checks the resulting identity. Hashed peer IDs deliberately fail closed because their public key cannot be authenticated from the ID alone.

func PublicKeyFromPrivateKey

func PublicKeyFromPrivateKey(raw []byte) ([]byte, error)

PublicKeyFromPrivateKey derives the canonical compressed public key. This helper is intended for a trusted local signer and test fixtures.

func PublicKeyHex

func PublicKeyHex(raw []byte) (string, error)

PublicKeyHex returns the configuration/logging representation of a public key. Bytes remain the identity truth inside the SDK.

func ValidateIdentity

func ValidateIdentity(publicKey []byte, id peer.ID, address string) error

ValidateIdentity checks the public-key/PeerId relationship and, when an address is supplied, its /p2p peer component as well.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址