identity

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package identity holds Phase 3 delegation proofs (master → operational key).

Index

Constants

View Source
const ScopeNetworkOps uint8 = 1

ScopeNetworkOps is the only delegation scope in Phase 3 (QUIC/DHT signing).

Variables

View Source
var (

	// ErrInvalidDelegation is returned when structure, signature, or key binding fails.
	ErrInvalidDelegation = errors.New("a2al/identity: invalid delegation proof")
)

Functions

func BuildEthereumDelegationMessage

func BuildEthereumDelegationMessage(opPub ed25519.PublicKey, aid a2al.Address, issuedAt, expiresAt uint64, scope uint8) string

BuildEthereumDelegationMessage returns the exact UTF-8 string for EIP-191 personal_sign (spec §6.3.1).

func BuildParalismDelegationMessage

func BuildParalismDelegationMessage(opPub ed25519.PublicKey, aid a2al.Address, issuedAt, expiresAt uint64, scope uint8) string

BuildParalismDelegationMessage returns the exact UTF-8 string for Bitcoin-style message signing (Phase 4 §6.5).

func EncodeDelegationProof

func EncodeDelegationProof(p DelegationProof) ([]byte, error)

EncodeDelegationProof encodes the full proof (including signature) to canonical CBOR.

func VerifyDelegation

func VerifyDelegation(p DelegationProof, nowUnix uint64, opPriv ed25519.PrivateKey) error

VerifyDelegation checks the proof (Ed25519 master or Ethereum EIP-191) and optional op key binding.

Types

type DelegationMessageFields

type DelegationMessageFields struct {
	OpKeyHex string
	Agent    string
	Scope    uint8
	IssuedAt uint64
	Expires  uint64
}

DelegationMessageFields are the structured key:value fields shared by all chain delegation messages.

func ParseDelegationMessageFields

func ParseDelegationMessageFields(msg string) (DelegationMessageFields, error)

ParseDelegationMessageFields parses key:value lines from a delegation message body.

type DelegationProof

type DelegationProof struct {
	MasterPub []byte `cbor:"1,keyasint,omitempty"`
	OpPub     []byte `cbor:"2,keyasint"`
	AgentAddr []byte `cbor:"3,keyasint"`
	IssuedAt  uint64 `cbor:"4,keyasint"`
	ExpiresAt uint64 `cbor:"5,keyasint"`
	Scope     uint8  `cbor:"6,keyasint"`
	Signature []byte `cbor:"7,keyasint"`
	Message   string `cbor:"8,keyasint,omitempty"`
}

DelegationProof is the full CBOR object including signature (key 7). Ethereum (and other blockchain) proofs omit MasterPub (key 1) and set Message (key 8).

func GenerateEthereumIdentity

func GenerateEthereumIdentity() (ethPriv *secp256k1.PrivateKey, opPriv ed25519.PrivateKey, proof DelegationProof, err error)

GenerateEthereumIdentity creates a random secp256k1 owner key, a new Ed25519 op key, and a DelegationProof (expiresAt=0).

func GenerateParalismIdentity

func GenerateParalismIdentity() (btcPriv *secp256k1.PrivateKey, opPriv ed25519.PrivateKey, proof DelegationProof, err error)

GenerateParalismIdentity creates random secp256k1 + Ed25519 op key and DelegationProof (expiresAt=0).

func ImportBlockchainDelegation

func ImportBlockchainDelegation(sig []byte, message string, opPub ed25519.PublicKey, aid a2al.Address, issuedAt, expiresAt uint64, scope uint8) (DelegationProof, error)

ImportBlockchainDelegation builds a proof from an external wallet EIP-191 signature (65-byte r||s||v).

func ImportParalismDelegation

func ImportParalismDelegation(sig []byte, message string, opPub ed25519.PublicKey, aid a2al.Address, issuedAt, expiresAt uint64, scope uint8) (DelegationProof, error)

ImportParalismDelegation builds a proof from an external Bitcoin-style message signature (65-byte compact).

func ParseDelegationProof

func ParseDelegationProof(b []byte) (DelegationProof, error)

ParseDelegationProof decodes CBOR bytes into DelegationProof.

func SignDelegation

func SignDelegation(masterPriv ed25519.PrivateKey, opPub ed25519.PublicKey, aid a2al.Address, issuedAt, expiresAt uint64, scope uint8) (DelegationProof, error)

SignDelegation builds a proof: master authorizes op key for AID and scope. expiresAt 0 means no expiry. issuedAt is Unix seconds.

func SignEthDelegation

func SignEthDelegation(ethPriv *secp256k1.PrivateKey, opPub ed25519.PublicKey, aid a2al.Address, issuedAt, expiresAt uint64, scope uint8) (DelegationProof, error)

SignEthDelegation builds an Ethereum DelegationProof (CLI/tests; production wallets sign externally).

func SignParalismDelegation

func SignParalismDelegation(btcPriv *secp256k1.PrivateKey, opPub ed25519.PublicKey, aid a2al.Address, issuedAt, expiresAt uint64, scope uint8) (DelegationProof, error)

SignParalismDelegation builds a Paralism DelegationProof (local key; compressed pubkey address).

func (DelegationProof) AgentAID

func (p DelegationProof) AgentAID() (a2al.Address, error)

AgentAID returns the AID (master identity) embedded in the proof.

Jump to

Keyboard shortcuts

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