wirev1

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DomainAuth          = "UGE-APP-MINING-WIRE-V1"
	DomainCandidate     = "UGE-APP-MINING-CANDIDATE-WIRE-V1"
	DomainEntitlementID = "UGE-APP-MINING-CANDIDATE-V1"
)
View Source
const CandidateSchemaVersion = "uge-app-mining-candidate-0.1"
View Source
const DomainAssessment = "UGE-APP-MINING-ASSESSMENT-V1"
View Source
const (
	// Secp256k1SigLength is r(32)||s(32)||v(1) for EIP-191 personal_sign.
	Secp256k1SigLength = 65
)

Variables

View Source
var AssessmentFieldOrder = []string{
	"credential_version",
	"app_id",
	"pool_id",
	"pav_id",
	"evidence_root",
	"gas_evidence_root",
	"amount",
	"denom",
	"gas_used",
	"qualified_tx_count",
	"rule_version",
	"issued_at",
	"expires_at",
	"credential_id",
	"signer_key_id",
}

AssessmentFieldOrder is the frozen UGE AssessmentCredential frame order (§3).

View Source
var CandidateFields = []string{
	"schema_version", "entitlement_id", "app_id", "epoch", "amount", "denom",
	"gas_used", "qualified_tx_count", "pav_id", "evidence_root", "gas_evidence_root", "rule_version",
}

CandidateFields is the fixed order for UGE-APP-MINING-CANDIDATE-WIRE-V1.

View Source
var CommonFields = []string{
	"protocol_version", "operation", "role", "chain_id", "pool_id", "key_id", "nonce", "expires_at",
}

Common authorization envelope fields (fixed order before op-specific fields).

View Source
var OpFields = map[string][]string{
	"PUBLISH": {"entitlement_id", "app_id", "candidate_hash", "rule_version"},
	"RESOLVE": {"challenge_id", "candidate_id", "outcome", "rationale_digest"},
	"APPROVE": {"entitlement_id", "app_id", "candidate_hash", "challenge_resolution_hash", "amount", "denom", "rule_version"},
	"FREEZE":  {"entitlement_id", "evidence_type", "evidence_digest", "freeze_until"},
	"REVOKE":  {"entitlement_id", "evidence_type", "evidence_digest", "rationale_digest"},
}

OpFields maps operation -> ordered business fields (after CommonFields).

Functions

func AssessmentBytes

func AssessmentBytes(record map[string]string) ([]byte, error)

AssessmentBytes returns the canonical assessment frame bytes (all fields as given).

func AssessmentCredentialID

func AssessmentCredentialID(record map[string]string) (string, error)

AssessmentCredentialID returns SHA-256 hex of the assessment frame with credential_id forced empty. This avoids the self-referential fixed-point while still covering every other committed field (UGE §3 intent).

func AuthorizationBytes

func AuthorizationBytes(record map[string]string) ([]byte, error)

AuthorizationBytes returns canonical wire bytes for an authorization record.

func AuthorizationDigest

func AuthorizationDigest(record map[string]string) (string, error)

AuthorizationDigest returns SHA-256 hex of AuthorizationBytes.

func CandidateHash

func CandidateHash(c Candidate) (string, error)

CandidateHash returns SHA-256 hex of the candidate wire frame.

func EntitlementIDOf

func EntitlementIDOf(c Candidate) string

EntitlementIDOf recomputes candidate identity (UGE-APP-MINING-CANDIDATE-V1). Fields: app_id, epoch, pav_id, evidence_root, gas_evidence_root, gas_used, rule_version, denom, amount.

func RequireCredentialIDBound

func RequireCredentialIDBound(record map[string]string) error

RequireCredentialIDBound ensures record["credential_id"] equals AssessmentCredentialID.

func VerifyAssessment

func VerifyAssessment(record map[string]string, signatureB64 string, pubkey []byte) bool

VerifyAssessment checks Ed25519 signature over AssessmentBytes (with filled credential_id).

func VerifyAuthorization

func VerifyAuthorization(record map[string]string, signatureB64 string, pubkey []byte) bool

VerifyAuthorization checks an Ed25519 signature (raw 64-byte, standard base64) over AuthorizationBytes. pubkey must be raw 32-byte Ed25519 public key.

func VerifyAuthorizationSecp256k1

func VerifyAuthorizationSecp256k1(record map[string]string, signatureB64 string, expectedAddr []byte) string

VerifyAuthorizationSecp256k1 verifies an EIP-191 personal_sign over the wire frame bytes. expectedAddr must be a raw 20-byte EVM address. signatureBase64 decodes to 65 bytes with v in {27,28}; high-s is rejected.

Returns "" on success; otherwise a stable reason token:

"sig_length" | "high_s" | "recover" | "mismatch" | "frame"

Types

type Candidate

type Candidate struct {
	SchemaVersion    string
	EntitlementID    string
	AppID            string
	Epoch            string
	Amount           string
	Denom            string
	GasUsed          string
	QualifiedTxCount string
	PavID            string
	EvidenceRoot     string
	GasEvidenceRoot  string
	RuleVersion      string
}

Candidate is the full candidate commitment record (all values as strings).

Jump to

Keyboard shortcuts

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