Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

commitreveal source pure

Package commitreveal implements a minimal commit-reveal scheme.

Overview

Package commitreveal implements a minimal commit-reveal scheme.

A commitment is the hex-encoded SHA-256 of the exact byte string

Example
1salt + ":" + payload

The payload stays secret until the revealer publishes payload and salt; anyone can then recompute the commitment and check it matches the value that was committed earlier. The salt keeps short or guessable payloads from being brute-forced against a bare hash of the payload alone.

The package is pure and stateless: it is safe to import from any realm.

Functions 3

func Commit

1func Commit(payload string, salt string) string
source

Commit returns the commitment for payload under salt: the lowercase hex encoding of SHA-256(salt + ":" + payload).

func IsCommitment

1func IsCommitment(s string) bool
source

IsCommitment reports whether s has the canonical commitment format: exactly 64 lowercase hexadecimal characters.

func Verify

1func Verify(commitment string, payload string, salt string) bool
source

Verify reports whether commitment is well-formed and equals the commitment recomputed from payload and salt.

Dependencies

Imports 2

/p/g1gu8mdvjg8l5wj2ytknhs7pmyu0rmeclyvvlsd8/commitreveal

Imported by indexer

Source Files 3