auth

package
v0.0.0-...-7fba91e Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package auth 提供客户端认证相关功能

Index

Constants

View Source
const (
	// PrivateKeyPEMType PEM 类型标识
	PrivateKeyPEMType = "PRIVATE KEY"
	// PublicKeyPEMType PEM 类型标识
	PublicKeyPEMType = "PUBLIC KEY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyPair

type KeyPair struct {
	PublicKey  ed25519.PublicKey
	PrivateKey ed25519.PrivateKey
}

KeyPair Ed25519 密钥对

func Generate

func Generate() (*KeyPair, error)

Generate 生成新的 Ed25519 密钥对

func Load

func Load() (*KeyPair, error)

Load 从 ~/.charline/id_ed25519 加载密钥对

func (*KeyPair) PubKeyBase64

func (kp *KeyPair) PubKeyBase64() string

PubKeyBase64 返回 Base64 编码的公钥(用于发送给 server)

func (*KeyPair) PubKeyBytes

func (kp *KeyPair) PubKeyBytes() []byte

PubKeyBytes 返回公钥字节数组

func (*KeyPair) Save

func (kp *KeyPair) Save() error

Save 保存密钥对到 ~/.charline/ 私钥权限: 600 公钥权限: 644

func (*KeyPair) Sign

func (kp *KeyPair) Sign(message []byte) string

Sign 使用私钥对消息进行签名 返回 Base64 编码的签名

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer 签名器

func NewSigner

func NewSigner(kp *KeyPair) *Signer

NewSigner 创建签名器

func (*Signer) PublicKeyHex

func (s *Signer) PublicKeyHex() string

PublicKeyHex 返回公钥的十六进制编码

func (*Signer) Sign

func (s *Signer) Sign(nonce string) (string, error)

Sign 对 nonce 进行签名 返回 hex 编码的签名

Jump to

Keyboard shortcuts

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