27 lines
1.1 KiB
Text
27 lines
1.1 KiB
Text
|
|
pragma cashscript ^0.13.0;
|
|||
|
|
|
|||
|
|
// CommitBox — the "commit" of a commit–reveal takeover
|
|||
|
|
// (Decentralized.DNS/DESIGN-covenant-registry.md §6.3).
|
|||
|
|
//
|
|||
|
|
// A taker creates one of these a block or more BEFORE taking a name over. Its
|
|||
|
|
// address reveals nothing: commitHash = hash256(name ‖ salt). The registry
|
|||
|
|
// covenant rebuilds this script from the taker's key hash and the revealed
|
|||
|
|
// salt, and requires input 1 of the takeover to be locked to it.
|
|||
|
|
//
|
|||
|
|
// The box enforces its own age (this.age), so a takeover cannot be assembled in
|
|||
|
|
// the same block as its commit, and it needs the taker's signature, so nobody
|
|||
|
|
// else can spend it out from under them.
|
|||
|
|
//
|
|||
|
|
// STATUS: chipnet draft, NOT REVIEWED — see name-registry.cash.
|
|||
|
|
contract CommitBox(bytes32 commitHash, bytes20 ownerPkh) {
|
|||
|
|
function spend(pubkey pk, sig s) {
|
|||
|
|
require(hash160(pk) == ownerPkh);
|
|||
|
|
require(checkSig(s, pk));
|
|||
|
|
require(this.age >= 1);
|
|||
|
|
// The commitment is data, not logic: it only has to be part of this
|
|||
|
|
// script so that it is part of the address. (The compiler rejects an
|
|||
|
|
// unused constructor argument.)
|
|||
|
|
require(commitHash.length == 32);
|
|||
|
|
}
|
|||
|
|
}
|