SHA-256 Validation

TREF automatically detects if content has been tampered with.

Original (Valid)

The sky is blue due to Rayleigh scattering.

Content matches SHA-256 ID. Icon is normal.

Tampered (Invalid)

The sky is green due to Rayleigh scattering.

Content was changed but ID kept. Red X appears!

How It Works

  1. When a TREF block is created, the content is hashed with SHA-256
  2. This hash becomes the block's unique ID
  3. When displayed, TrefWrapper validates the hash automatically
  4. If the content was changed, the hash won't match
  5. Invalid blocks show a red X and warning message

API Usage:

// Automatic validation on display
wrapper.attachEvents(element);

// Manual validation
const result = await wrapper.validate();
if (!result.valid) {
  console.log('Tampered!', result.expected, result.actual);
}

// Standalone function
import { validateBlock } from 'tref-block';
const result = await validateBlock(block);