Documentation
¶
Overview ¶
Package fairdice implements commit-reveal dice between untrusting peers.
Neither player can be trusted to roll alone (there's no server — the relay is blind), so a roll is a three-message exchange:
- The roller generates random bytes RA and a salt, and broadcasts Commit = SHA-256(deterministic-CBOR(Reveal{RA, Salt})).
- The opponent broadcasts its own random RB (no commitment needed — it moves second and the roller is already bound).
- The roller broadcasts Reveal{RA, Salt}; everyone (spectators too) checks it against the commit and derives Dice(RA, RB).
The roller can't pick dice (bound before seeing RB); the opponent can't either (RA is fixed but unknown when choosing RB, so any RB yields uniformly distributed dice). A roller whose reveal doesn't match its commit is caught by every participant.
Extracted from https://github.com/richardwooding/kibitz
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dice ¶
Dice derives two dice from the combined randomness, uniformly via rejection sampling. Deterministic: every participant derives the same pair from the same (reveal, response).
Types ¶
type Response ¶
type Response [32]byte
Response is the opponent's contribution.
func NewResponse ¶
NewResponse is the opponent's random contribution.
type Reveal ¶
Reveal is what the roller discloses after the opponent responds. It is CBOR-encoded (deterministic mode, integer keys) before hashing, so the commitment preimage is unambiguous.
func (Reveal) Commitment ¶
Commitment computes the binding hash of a Reveal.