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

v0 source pure

Package commit provides small, deterministic commitment helpers shared by the agent demos. On-chain realms store \*co...

Readme View source

p/moul/agents/commit/v0 — shared commitment helpers

A tiny pure package: the one place the agent demos agree on how a commitment is computed. On-chain realms should store commitments (hashes) to off-chain material — reports, patches, verdicts — not the material itself. When several realms do that, they need to compute hashes the same way, or they can't verify each other's commitments.

1commit.Hash(parts...)          // hex SHA-256, length-prefixed (no boundary collisions)
2commit.Verdict(vote, salt)     // canonical commit-reveal commitment for a hidden bool
3commit.Short(hexHash)          // abbreviate for display

Hash length-prefixes each part, so Hash("ab","c") != Hash("a","bc") — a small detail that matters the moment a commitment concatenates attacker-influenced fields.

Verdict is the scheme the jury demo uses for blind voting: commit Verdict(vote, salt) during the commit phase, then reveal (vote, salt) — anyone can recompute and confirm the vote wasn't changed after the fact.

Pure, deterministic, no realm state. Import it; don't reinvent the hashing.

1gno test .

Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.

Overview

Package commit provides small, deterministic commitment helpers shared by the agent demos. On-chain realms store *commitments* to off-chain data (reports, patches, verdicts) rather than the data itself; this package is the one place that defines how those commitments are computed, so several realms agree on the scheme.

Functions 3

func Hash

1func Hash(parts ...string) string
source

Hash returns the hex-encoded SHA-256 over its parts, length-prefixed so that Hash("ab","c") != Hash("a","bc"). Use it to commit to structured off-chain material without revealing it.

func Short

1func Short(h string) string
source

Short abbreviates a hex commitment for display.

func Verdict

1func Verdict(verdict bool, salt string) string
source

Verdict is the canonical commitment used by commit-reveal voting: a hidden boolean plus a salt. Reveal the same (verdict, salt) later and any observer can recompute this and confirm the vote was not changed after the fact.

Imports 2

  • crypto/sha256 stdlib
  • encoding/hex stdlib

Source Files 4