Documentation
¶
Overview ¶
Package signing implements Hyperliquid L1 agent signing (sign_l1_action), ported from trade/src/app/features/perps/lib/hyperliquid{,Hash}.ts.
Only the mainnet "a" source is supported because the Oku backend hardcodes Hyperliquid mainnet (account/src/connectapi/perps/signing.go).
Index ¶
- func ActionHash(actionJSON string, vault string, nonce uint64) ([32]byte, error)
- func AddressOf(pub *secp256k1.PublicKey) string
- func AgentDigest(connectionID [32]byte) [32]byte
- func EncodeActionJSON(actionJSON string) ([]byte, error)
- func GenerateKey() ([]byte, error)
- func RecoverAddress(d [32]byte, sig Signature) (string, error)
- type KeySigner
- type Signature
- type SignedAction
- type Signer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionHash ¶
ActionHash returns keccak256(msgpack(action) || nonce_be64 || vaultFlag).
func AgentDigest ¶
AgentDigest returns the EIP-712 digest for Agent{source:"a", connectionId} in domain {name:"Exchange", version:"1", chainId:1337, verifyingContract:0x0}.
func EncodeActionJSON ¶
EncodeActionJSON msgpack-encodes a JSON document preserving object key order, matching @msgpack/msgpack encode(JSON.parse(actionJSON)) as used by trade/src/app/features/perps/lib/hyperliquidHash.ts. The JSON is walked token by token so key order is exactly the wire order; the msgpack wire primitives come from github.com/vmihailenco/msgpack/v5, the library the account backend uses for the same hash. Non-integer numbers are rejected (fail closed): no Oku action currently contains them and float encoding differs across SDKs.
Types ¶
type KeySigner ¶
type KeySigner struct {
// contains filtered or unexported fields
}
KeySigner signs with an in-memory secp256k1 key.
func NewKeySigner ¶
NewKeySigner builds a signer from 32 raw key bytes.
type SignedAction ¶
type SignedAction struct {
ActionJSON string `json:"actionJson"`
Nonce string `json:"nonce"` // int64 encoded as string per protojson
Signature Signature `json:"signature"`
}
SignedAction mirrors gfxcafe.oku.account.v2.SignedAction.
func SignAction ¶
func SignAction(s Signer, actionJSON string, nonce uint64) (SignedAction, error)
SignAction signs the exact actionJSON for the master account. Vault and subaccount routing is deliberately unsupported (v1 is master-only), so the vault flag is always 0x00.
func SignActionContext ¶
func SignActionContext(ctx context.Context, s Signer, actionJSON string, nonce uint64) (SignedAction, error)
SignActionContext propagates cancellation to remote signing implementations.