Documentation
¶
Index ¶
- Constants
- Variables
- func AssessmentBytes(record map[string]string) ([]byte, error)
- func AssessmentCredentialID(record map[string]string) (string, error)
- func AuthorizationBytes(record map[string]string) ([]byte, error)
- func AuthorizationDigest(record map[string]string) (string, error)
- func CandidateHash(c Candidate) (string, error)
- func EntitlementIDOf(c Candidate) string
- func RequireCredentialIDBound(record map[string]string) error
- func VerifyAssessment(record map[string]string, signatureB64 string, pubkey []byte) bool
- func VerifyAuthorization(record map[string]string, signatureB64 string, pubkey []byte) bool
- func VerifyAuthorizationSecp256k1(record map[string]string, signatureB64 string, expectedAddr []byte) string
- type Candidate
Constants ¶
const ( DomainAuth = "UGE-APP-MINING-WIRE-V1" DomainCandidate = "UGE-APP-MINING-CANDIDATE-WIRE-V1" DomainEntitlementID = "UGE-APP-MINING-CANDIDATE-V1" )
const CandidateSchemaVersion = "uge-app-mining-candidate-0.1"
const DomainAssessment = "UGE-APP-MINING-ASSESSMENT-V1"
const (
// Secp256k1SigLength is r(32)||s(32)||v(1) for EIP-191 personal_sign.
Secp256k1SigLength = 65
)
Variables ¶
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).
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.
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).
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 ¶
AssessmentBytes returns the canonical assessment frame bytes (all fields as given).
func AssessmentCredentialID ¶
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 ¶
AuthorizationBytes returns canonical wire bytes for an authorization record.
func AuthorizationDigest ¶
AuthorizationDigest returns SHA-256 hex of AuthorizationBytes.
func CandidateHash ¶
CandidateHash returns SHA-256 hex of the candidate wire frame.
func EntitlementIDOf ¶
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 ¶
RequireCredentialIDBound ensures record["credential_id"] equals AssessmentCredentialID.
func VerifyAssessment ¶
VerifyAssessment checks Ed25519 signature over AssessmentBytes (with filled credential_id).
func VerifyAuthorization ¶
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).