Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

memba_quest_attestation_v1 source realm

Package memba\_quest\_attestation\_v1 is the on-chain quest/XP attestation realm for Memba (audit Q-05, Track A — "Mo...

Overview

Package memba_quest_attestation_v1 is the on-chain quest/XP attestation realm for Memba (audit Q-05, Track A — "Model B" offline-signed voucher).

WHY: Memba quest XP lives in a centralized backend DB; the chain holds no verifiable record. This realm makes a quest completion + its XP an independently verifiable on-chain fact, WITHOUT giving the backend a hot key that can write arbitrary state.

HOW (Model B — offline voucher):

  • The backend holds an OFFLINE ed25519 signing key; it NEVER broadcasts.
  • For a server-verified completion it issues a voucher (address, questId, xp, nonce) + ed25519 signature over the canonical message addr "|" questId "|" itoa(xp) "|" nonce (UTF-8 bytes)
  • The USER broadcasts RecordCompletion(...) with the voucher (they pay gas).
  • This realm verifies the signature against the configured signer pubkey, rejects reused nonces (replay), bounds xp, and records the completion + cumulative attested XP.

TRUST MODEL: the signature is the authority, NOT the caller — anyone may broadcast a valid voucher (it can only record the backend-attested fact). The only privileged action is rotating the signer pubkey (owner multisig).

The canonical message format is a CONTRACT with the backend signer — it MUST stay byte-identical on both sides. See canonicalMsg.

Constants 1

const MaxAttestXP, pubKeySize, sigSize, fieldSep

 1const (
 2
 3	// MaxAttestXP bounds the XP a single voucher can carry. This caps the blast
 4	// radius if the offline signer key ever leaks: a leaked key can still forge
 5	// vouchers, but cannot mint unbounded XP in one call. Generous vs the real
 6	// max single-quest XP (≤100).
 7	MaxAttestXP = 1000
 8
 9	pubKeySize = 32 // ed25519 public key length (gno crypto/ed25519 exposes no const)
10	sigSize    = 64 // ed25519 signature length
11	fieldSep   = "|"
12)
source

── Constants ────────────────────────────────────────────────

Functions 11

func AcceptOwnership

crossing Action
1func AcceptOwnership(cur realm)
source

AcceptOwnership completes the handoff. Only the staged pendingOwner may call it — including against the outgoing owner, so the two steps cannot be collapsed into one by the party giving up the role.

func CancelOwnershipTransfer

crossing Action
1func CancelOwnershipTransfer(cur realm)
source

CancelOwnershipTransfer clears a staged handoff. Owner only, so a proposal can be aborted without the proposed address cooperating.

func GetAttestedXP

Action
1func GetAttestedXP(addr string) int
source

GetAttestedXP returns addr's cumulative on-chain attested XP (0 if none).

func GetOwner

Action
1func GetOwner() string
source

GetOwner returns the address that currently holds ownership.

func GetRecordedCompletions

Action
1func GetRecordedCompletions(addr string) string
source

GetRecordedCompletions returns addr's attested quest IDs as a comma-separated list (empty string if none), in ascending key order.

func GetSigner

Action
1func GetSigner() string
source

GetSigner returns a copied canonical public-key string, or empty before setup.

func RecordCompletion

crossing Action
1func RecordCompletion(cur realm, addr, questId string, xp int, nonce, sigHex string)
source

RecordCompletion verifies a backend-signed voucher and records the completion + its XP on-chain. Idempotent per (addr, questId); replay-proof per nonce. Panics (reverting the tx) on any invalid/again-used/out-of-range voucher.

func Render

1func Render(path string) string
source

Render is the human/gnoweb view; the authoritative reads are the exported Get* funcs (queried via vm/qeval).

func SetSigner

crossing Action
1func SetSigner(cur realm, pubKeyHex string)
source

SetSigner installs/rotates the backend's offline signer PUBLIC key (32-byte hex). The current owner is authenticated using its live crossing frame.

func TransferOwnership

crossing Action
1func TransferOwnership(cur realm, newOwner address)
source

TransferOwnership stages a handoff. Owner only; it takes effect only once newOwner calls AcceptOwnership. Calling it again before acceptance replaces the staged address, which is how a mistyped proposal is corrected.

Imports 9

Source Files 4