identity

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalCertificate

func MarshalCertificate(cert *x509.Certificate) []byte

MarshalCertificate exports the certificate in PEM format.

func MarshalPrivateKey

func MarshalPrivateKey(priv crypto.PrivateKey, passphrase string) ([]byte, error)

MarshalPrivateKey exports the private key in PEM format, optionally encrypted.

func UnmarshalCertificate

func UnmarshalCertificate(data []byte) (*x509.Certificate, error)

UnmarshalCertificate imports a certificate from PEM format.

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte, passphrase string) (crypto.PrivateKey, error)

UnmarshalPrivateKey imports a private key from PEM format.

func Verify

func Verify(cert *x509.Certificate, data []byte, signature []byte) error

Verify checks a signature against the given data and certificate.

func VerifyMessage

func VerifyMessage(cert *x509.Certificate, msg proto.Message, signature []byte) error

VerifyMessage verifies a protobuf message's signature. It clears the 'auth' field before verifying.

Types

type Identity

type Identity struct {
	Certificate *x509.Certificate
	PrivateKey  crypto.PrivateKey
}

Identity represents the cryptographic identity of an agent.

func Generate

func Generate(shortName string) (*Identity, error)

Generate creates a new self-signed X.509 certificate and ECDSA private key.

func (*Identity) AgentID

func (i *Identity) AgentID() string

AgentID derives a unique agent ID from the certificate's public key.

func (*Identity) Authenticate added in v1.7.0

func (i *Identity) Authenticate(msg proto.Message)

Authenticate signs the given message and sets its 'auth' field if it exists.

func (*Identity) Sign

func (i *Identity) Sign(data []byte) ([]byte, error)

Sign creates a signature for the given data using the private key.

func (*Identity) SignMessage

func (i *Identity) SignMessage(msg proto.Message) (signature []byte, certificate []byte, err error)

SignMessage signs a protobuf message. It clears the 'auth' field before signing.

Jump to

Keyboard shortcuts

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