wire

package
v1.1.33 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonBodyRequiresOuterSignature

func JsonBodyRequiresOuterSignature(plan int64, plan2KeyBootstrap bool) bool

JsonBodyRequiresOuterSignature 是否校验/生成 JsonBody.Valid(ML-DSA)。 plan2KeyBootstrap:WebSocket Plan2 /key 握手使用 p=0,但仍须 ML-DSA。

func PlanRequiresOuterSignature

func PlanRequiresOuterSignature(plan int64) bool

PlanRequiresOuterSignature Plan2 业务报文(p=2)需要 ML-DSA 外层签名。

Types

type AuthToken

type AuthToken struct {
	Token   string `json:"token"`
	Secret  string `json:"secret"`
	Expired int64  `json:"expired"`
}

type JsonBody

type JsonBody struct {
	// 16字节字段组 (3个string字段,48字节)
	Data   string `json:"d"` // 16字节 (8+8) - string字段
	Nonce  string `json:"n"` // 16字节 (8+8) - string字段
	Sign   string `json:"s"` // 16字节 (8+8) - string字段
	Valid  string `json:"e"` // 16字节 (8+8) - string字段
	Router string `json:"r"` // 16字节 (8+8) - string字段

	// 8字节字段组 (2个int64字段,16字节)
	Time int64 `json:"t"` // 8字节 - int64字段
	Plan int64 `json:"p"` // 8字节 - 0.默认(登录状态) 1.AES(登录状态) 2.Plan2(ML-KEM+ML-DSA匿名)
	User int64 `json:"u"` // 8字节 - 客户端ID
}

JsonBody 结构体 - 64字节 (5个字段,8字节对齐,无填充) 排列优化:string字段组在前(48字节),int64字段组在后(16字节)

func (*JsonBody) ParseData

func (self *JsonBody) ParseData(dst interface{}) error

func (*JsonBody) RawData

func (self *JsonBody) RawData() []byte

type JsonResp

type JsonResp struct {
	// 16字节字段组 (4个string字段,64字节)
	Message string `json:"m"` // 16字节 (8+8) - string字段
	Data    string `json:"d"` // 16字节 (8+8) - string字段
	Nonce   string `json:"n"` // 16字节 (8+8) - string字段
	Sign    string `json:"s"` // 16字节 (8+8) - string字段
	Valid   string `json:"e"` // 16字节 (8+8) - string字段
	Router  string `json:"r"` // 16字节 (8+8) - 路由字段,用于消息订阅

	// 8字节字段组 (3个字段:1个int+2个int64,24字节)
	Code int   `json:"c"` // 8字节 - int字段
	Time int64 `json:"t"` // 8字节 - int64字段
	Plan int64 `json:"p"` // 8字节 - int64字段
}

JsonResp 结构体 - 96字节 (7个字段,8字节对齐,无填充) 排列优化:string字段组在前(64字节),int和int64字段组在后(32字节)

type PrivateKey

type PrivateKey struct {
	Key string `json:"key"` // 私钥Base64编码格式
	Noc string `json:"noc"` // 随机数
}

type PublicKey

type PublicKey struct {
	Key string `json:"key"` // 服务端临时公钥
	Tag string `json:"tag"` // 客户端临时公钥
	Noc string `json:"noc"` // 随机数
	Sig string `json:"sig"` // 数据签名
	Exp int64  `json:"exp"` // 有效时间,单位秒
	Usr int64  `json:"usr"` // 客户端ID
}

Jump to

Keyboard shortcuts

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