# Fractal Social Hierarchy UTXO System with Universal Basic Income by Demurrage

A population register and a UTXO payment layer. The register is a social hierarchy: your superior attested your identity. Being registered gives you universal basic income, claimable as UTXO. All UTXO values decay at 20% per year — this decay is the UBI.

## Node

```
Node {
  key         pubkey
  children    []hash
  leaf        bool
  nonce       uint
  last_ubi    uint
  last_vote   uint        — timestamp of last vote claim
  tree_count  uint        — persons in subtree
  tree_ubi    uint        — unclaimed UBI in subtree (normalized)
}
```

A node is a person, a group of persons, or an organization. One key per node.

A person contributes 1 to tree_count. A group represents multiple persons as a single node (contributes N). An org is a non-person entity (contributes 0 — no UBI).

`tree_count` is the number of persons in the subtree, aggregated upward. Population = root.tree_count. A node's own person contribution is tree_count minus the sum of its children's tree_counts.

`last_ubi` is the timestamp of the node's last UBI claim.

`leaf` — if true, the node cannot have children. Set by the parent at creation.

## UTXO

```
Output {
  amount      uint
  time        uint
  owner       pubkey
}
```

Real value at time T: `amount × decay^(T − time)`.

Identified by `(tx_hash, index)` where `tx_hash` is the hash of the transaction that created it. Spent outputs are removed from the set.

## Decay

20% per year. Per-second factor at scale 10^16: `decay = 9999999929290076` (~0.8^(1/31557600)). Computed via binary exponentiation with floor rounding at every step, guaranteeing bit-reproducible results across implementations.

## UBI

Each person accrues UBI continuously. Claimable amount at time T:

```
claimable(T) = contribution × TOKEN × (1 − decay^(T − last_ubi))
```

TOKEN = 10^16 base units. `contribution` is the node's own person contribution (tree_count minus sum of children's tree_counts).

A person accrues up to 1 TOKEN. A group of 5 accrues up to 5. An org: nothing.

In equilibrium: total supply converges to population × TOKEN. Total decay across all UTXOs equals total UBI minted.

## Supply

Both the UTXO trie and the people tree normalize values to a shared reference time `norm_time`, periodically advanced from Unix time 0.

UTXO trie: each output's amount is normalized at insert: `normalized = amount / decay^(time − norm_time)`. Internal trie nodes sum their children. Total supply at time T: `root.sum × decay^(T − norm_time)`.

People tree: `tree_ubi` is normalized the same way. Unclaimed UBI at time T: `tree_count × TOKEN − root.tree_ubi × decay^(T − norm_time)`.

Invariant: `utxo_supply + unclaimed_ubi ≈ tree_count × TOKEN`. Verifiable from the two roots without traversal.

## Claim

```
Claim {
  key         pubkey
  outputs     []Output
  nonce       uint
  sig         sig
}
```

Mints UBI. `key` must exist in the tree with contribution > 0. Sum of output amounts must equal `claimable(T)`. Nonce matches the node's nonce. Signed by `key`.

Processing: create outputs with `time` = block time. Update `last_ubi` to block time. Increment nonce.

Outputs can be owned by any pubkey — not necessarily the claimer's tree key.

## Transfer

```
Transfer {
  inputs      []Outpoint
  outputs     []Output
  sigs        []sig           — one per input
}

Outpoint {
  tx          hash
  index       uint
}
```

Spends UTXOs and creates new ones. Each input is signed by its owner — different owners can participate in the same transaction.

Validation: each input exists and is unspent. Sum of output amounts ≤ sum of input real values at block time. Difference is the transaction fee, collected by the proposer. Recommended to split 50/50 with the validator.

Processing: remove spent inputs from the UTXO set. Create new outputs with `time` = block time.

## Tree Operations

### Add

```
Add {
  parent      pubkey
  child       pubkey
  hash        bytes[32]
  nonce       uint            — parent's nonce
  consent     sig             — child signs hash + nonce + parent pubkey
  sig         sig             — signed by parent
}
```

Parent adds child. Subtree verified by hash. `last_ubi` = block time for all nodes in the subtree. Increment parent's nonce. Recompute `tree_count` upward.

### Remove

```
Remove {
  parent      pubkey
  child       pubkey
  nonce       uint            — parent's nonce
  sig         sig             — signed by parent
}
```

Child and its entire subtree are deleted from the tree. Accrued UBI for each person in the subtree is automatically minted as UTXOs to their respective keys. Increment parent's nonce. Recompute `tree_count` upward.

### Rekey

```
Rekey {
  old         pubkey
  new         pubkey
  nonce       uint
  sig         sig             — signed by old key
}
```

Changes a node's key. Increment nonce.

### SetValidator

```
SetValidator {
  validator   pubkey
  nonce       uint
  sig         sig             — signed by root
}
```

Root sets the active validator. Increment root's nonce.

## Block Production

Block production is split into two roles: the validator signs every header, providing finality; the block proposer decides block contents and rotates between blocks. This separation makes the chain forkless (for the block proposer alternation — forking the hierarchy tree itself by starting a new root is always possible), which enables the simplest possible RNG for proposer rotation — a hash onion.

Each proposer pre-commits the top of a hash onion: `H^n(seed)`. Each block, the active proposer reveals the next layer. Verification: `H(revealed) == previous layer`. The revealed value is unpredictable until disclosed. Because the chain is forkless, each layer is revealed exactly once — never wasted on abandoned forks.

`rand = prev_rand XOR revealed`. Neither party can control the outcome alone — the onion was pre-committed and the previous rand was unknown at commit time.

The validator is expected to sign valid proposals. Refusal to sign is observable misbehavior.

## Election

Block proposer selection operates in fixed-length periods. Each period, vote tokens are claimed, mixed, and committed into `next_election`. At the end of the period, `next_election` becomes `election_trie` and a fresh `next_election` opens. One committed entry is selected each block — its candidate proposes that block.

### Election Trie

Each internal node carries the count of committed entries in its subtree. The root gives the total — the pool size for RNG selection. Committed entries count as 1, uncommitted as 0.

The election trie doubles as proposer registration and voting. Registering as a proposer costs a vote token — introducing a natural cost to prevent spam — while also counting as a vote for oneself.

### Entry

An entry in the election trie is either uncommitted or committed.

Uncommitted: `{amount, owner}`. Mixable.

Committed, amount=1, locked. Two variants:

**Encrypted vote:** `{H(candidate || nonce), owner?}`. The candidate's identity is hidden. The nonce is shared with the candidate in advance. `owner` is optional — a ledger may use it to share transaction fees with voters.

**Proposer registration:** `{key, onion}`. Plaintext. Registers the candidate with a hash onion commitment for block production.

### Transaction

One transaction type handles claiming, mixing, and committing.

Inputs: VoteClaims (mint new tokens) and/or existing uncommitted entries. One signature per input.

Outputs: uncommitted `{amount, owner}` and/or committed entries (encrypted vote or proposer registration). Committed outputs must have amount=1.

Constraint: sum of inputs = sum of outputs.

```
VoteClaim {
  key         pubkey
  nonce       uint
  sig         sig
}
```

A VoteClaim is a special input that mints vote tokens. `key` must exist in the tree with contribution > 0. Amount = contribution. Updates `last_vote` to block time. Increments nonce. Can be combined with other inputs and outputs in the same transaction — allowing immediate mixing or committing.

### Activation

Each period has two phases. In the first half, `next_election` is open — tokens can be claimed, mixed, and committed. At the midpoint, `next_election` locks. At the end of the period, `next_election` becomes the new `election_trie` and a fresh `next_election` opens.

The lock-to-activation gap ensures enough onion layers have been revealed that no one can predict which position the RNG will select.

### Selection

`rand mod total_committed` selects a position. The trie's cumulative sums enable traversal to the selected entry.

If the selected entry is a proposer registration and its `key` matches `header.proposer` — the proposer was selected directly. The proposer reveals the next onion layer from that entry.

If the selected entry is an encrypted vote — the proposer reveals `vote_nonce` in the header. Verification: `H(header.proposer || vote_nonce) == entry.commit`. The onion layer is revealed from the proposer's registration entry in the election trie, which is updated to the revealed layer.

## Validator

Root appoints the validator via SetValidator. The validator signs every header, providing finality. The chain is forkless — no competing headers can exist without the validator's signature. This enables the simplest possible RNG for proposer selection (see Block Production).

```
Header {
  seq           uint
  time          uint
  people_tree   hash
  utxo_trie     hash
  election_trie hash
  next_election hash
  prev          hash
  proposer      pubkey
  validator     pubkey
  rand          hash            — revealed onion layer
  vote_nonce    hash            — preimage nonce for encrypted vote
  prop_sig      sig             — signed by proposer
  val_sig       sig             — signed by validator
}
```

`people_tree` is the Merkle root of the node tree. `utxo_trie` is the root of the UTXO trie. `election_trie` is the active election trie (votes and proposer registrations).

## Hash

H(Node) = SHA-256(key || children || leaf || nonce || last_ubi || last_vote || tree_count || tree_ubi).

## Primitives

SHA-256, Ed25519. Amounts are unsigned 128-bit integers at scale 10^16 (1 TOKEN = 10^16 base units). All signatures include an opcode.

## Civil registration compatibility

The tree structure maps onto existing population registration infrastructure. A country, region, municipality, or village can be an org node with its citizens as children. The hierarchy does not prescribe a specific administrative structure — any nesting of individuals, groups, and organizations works.
