# NTM-IA Verification Protocol · Protocolo de Verificação · NTM-IA 验证协议

---

## EN · NTM-IA Verification Protocol

### Table of Contents
1. [Overview](#en-overview)  
2. [Blockchain Architecture](#en-blockchain-architecture)  
3. [Block Structure](#en-block-structure)  
4. [How to Verify the Chain](#en-how-to-verify-the-chain)  
5. [Signature Verification](#en-signature-verification)  
6. [Calculation Formulas](#en-calculation-formulas)  
7. [Automatic Verification](#en-automatic-verification)  
8. [HTTP Headers & Machine Verification](#en-headers)  
9. [References](#en-references)  

---

## EN – Overview {#en-overview}

NTM-IA is a public, verifiable blockchain that records AI activity metrics in real time. Anyone can independently verify the entire chain's integrity using only HTTP GET and SHA256.

**Core Principles:**
- ✅ **Trustless** – Everything is verifiable  
- ✅ **Public Data** – All blocks are accessible  
- ✅ **Cryptographic Signatures** – RSA-2048 with SHA256  
- ✅ **Self-Regulating** – Minting ratio = UAs (active AI User Agents)  

---

## EN – Blockchain Architecture {#en-blockchain-architecture}

### Folder Structure

```text
https://www.netmeios.com/blockchain/ntm-ia/
├── blocks/
│   ├── block_000001.json
│   ├── block_000002.json
│   └── ...
└── last_hash.txt
```

### Block Generation Frequency

- **Every 10 minutes** (via cron job)  
- Each block contains signed data derived from `ai-dash-snippet.php`  

---

## EN – Block Structure {#en-block-structure}

### Complete Block Example

```json
{
  "block_data": {
    "index": 1,
    "timestamp": "2026-04-02 16:05:10",
    "previous_hash": "0000000000000000000000000000000000000000000000000000000000000000",
    "hits": 267721,
    "pct_ia": 0.604704899148,
    "ai_index": 0.80,
    "uas": 58,
    "hub": 638,
    "respostas": 4653,
    "np": 11136.95,
    "ntm_original_price": 94.01,
    "ntm_ia_price": 118.46,
    "supply": 4615.87931,
    "market_cap": 546808.68,
    "mint_ratio": 58,
    "data_source": "ai-dash-snippet.php",
    "source_timestamp": "2026-04-02 16:05:10"
  },
  "signature": "BASE64...",
  "signature_algorithm": "RSA-SHA256",
  "key_id": "ntm-ia-main-2026-01",
  "pubkey_fingerprint": "SHA256:b3ec844bfe7e2b094ecf2c3f98a5e8b3c650b1fc6aa36573f99bb8f2b7fe68e2"
}
```

### Field Descriptions

```text
Canonical JSON for signing is produced with PHP:

json_encode($block['block_data']);
```

| Field               | Type    | Description                                   |
|---------------------|---------|-----------------------------------------------|
| index               | integer | Sequential block number                       |
| timestamp           | string  | Block creation time (UTC)                     |
| previous_hash       | string  | SHA256 hash of previous block                 |
| hits                | integer | Total AI hits since inception                 |
| pct_ia              | float   | Percentage of AI bots (0–1)                   |
| ai_index            | float   | AI Quality Index (0–1)                        |
| uas                 | integer | Number of active AI User Agents               |
| hub                 | integer | Number of companies in the hub                |
| respostas           | integer | Total human/bot responses                     |
| np                  | float   | Price Note (intermediate value)               |
| ntm_original_price  | float   | Original NTM price (€)                        |
| ntm_ia_price        | float   | NTM-IA price (€)                              |
| supply              | float   | Current token supply                          |
| market_cap          | float   | Market capitalization (€)                     |
| mint_ratio          | integer | Minting ratio (= `uas`)                       |
| data_source         | string  | Source of real‑time data                      |
| source_timestamp    | string  | Timestamp of source data                      |
| signature           | string  | RSA-SHA256 signature (base64)                 |
| signature_algorithm | string  | Signature algorithm (always `RSA-SHA256`)     |
| key_id              | string  | Identifier of signing key                     |
| pubkey_fingerprint  | string  | SHA256 fingerprint of public key              |

---

## EN – How to Verify the Chain {#en-how-to-verify-the-chain}

### Step 1: Get the Latest Block Hash

```bash
curl https://www.netmeios.com/blockchain/ntm-ia/last_hash.txt
```

### Step 2: Download a Block

```bash
curl https://www.netmeios.com/blockchain/ntm-ia/blocks/block_000001.json -o block_000001.json
```

### Step 3: Verify Block Hash

```bash
# Calculate hash of the block
sha256sum block_000001.json

# This value must match:
# - previous_hash of block_000002.json
# - and, for the latest block, the content of last_hash.txt
```

### Step 4: Verify Chain Integrity

For each block `N` (starting from 2):

```text
block[N].previous_hash == SHA256( JSON(block[N-1]) )
```

Where `JSON(block)` is the raw file content hashed as:

```bash
sha256sum block_00000X.json
```

### Step 5: Verify Entire Chain

- Ensure:
  - Indices are strictly sequential: 1, 2, 3, …  
  - For all `N > 1`: `previous_hash` of block N = SHA256 of block N‑1 file  
  - `last_hash.txt` = SHA256 of the latest block file  

---

## EN – Signature Verification {#en-signature-verification}

### Public Key Fingerprint

```text
SHA256:b3ec844bfe7e2b094ecf2c3f98a5e8b3c650b1fc6aa36573f99bb8f2b7fe68e2
```

### Verification Steps

1. Download a block (e.g. `block_000001.json`).  
2. Extract `block_data`.  
3. Serialize `block_data` to canonical JSON with PHP‑compatible ordering:  
   ```php
   $canonical = json_encode($block['block_data']);
   ```  
4. Base64‑decode the `signature` field to a binary file (e.g. `signature.bin`).  
5. Verify using RSA‑SHA256 and the NTM‑IA public key.

### OpenSSL CLI Example

```bash
# 1. Extract signature (BASE64 -> binary)
jq -r '.signature' block_000001.json | base64 -d > signature.bin

# 2. Extract canonical JSON of block_data
jq -c '.block_data' block_000001.json > canonical.json

# 3. Verify signature
openssl dgst -sha256 -verify ntm_ia_public.key -signature signature.bin canonical.json
```

### PHP Verification Example

```php
<?php
$block = json_decode(file_get_contents('block_000001.json'), true);

// Canonical JSON, identical to sealer:
$canonicalData = json_encode($block['block_data']);

$signature = base64_decode($block['signature']);
$publicKey = file_get_contents('ntm_ia_public.key');

$valid = openssl_verify(
    $canonicalData,
    $signature,
    $publicKey,
    OPENSSL_ALGO_SHA256
);

echo $valid === 1 ? "Valid\n" : "Invalid\n";
```

---

## EN – Calculation Formulas {#en-calculation-formulas}

Let:

- `hits` = total AI hits  
- `pct_ia` = fraction of AI hits (0–1)  
- `ai_index` = AI Quality Index (0–1)  
- `uas` = number of active AI User Agents  
- `hub` = number of companies in the hub  
- `respostas` = total responses (human + bot)  

### NP (Price Note)

```text
NP = ((pct_ia + ai_index) × hits / uas) + respostas
```

### NTM Original

```text
NTM_original = (hub × 394.50) / (hits / 100)
```

### NTM-IA Price

```text
NTM_IA = NP / NTM_original
```

### Supply

```text
supply = hits / uas
```

### Minting Ratio

```text
mint_ratio = uas
```

These formulas are applied in the sealer and mirrored in the `ntm-ia-trust.php` endpoint for real‑time calculations.

---

## EN – Automatic Verification {#en-automatic-verification}

### Integrity Checker Endpoint

```text
https://www.netmeios.com/ai-check-integrity-ntm-ia.php
```

### What It Validates

| Check            | Description                                                |
|------------------|------------------------------------------------------------|
| Chain integrity  | Sequential indices, consecutive hashes, last_hash.txt      |
| Signatures       | RSA-SHA256 verification for each block                     |
| Fingerprint      | Public key fingerprint matches declared `pubkey_fingerprint` |
| Data consistency | `mint_ratio = uas`, `supply ≈ hits / uas`                 |
| Timestamp        | Not in the future, not too old                             |
| Data source      | `data_source` is `ai-dash-snippet.php`                     |

### Usage

```bash
# HTML view (human readable)
curl https://www.netmeios.com/ai-check-integrity-ntm-ia.php

# JSON output (for automation)
curl "https://www.netmeios.com/ai-check-integrity-ntm-ia.php?format=json"
```

---

## EN – HTTP Headers & Machine-Verifiable Metadata {#en-headers}

### HTTP Headers (X-NTM-*)

On the `ntm-ia-trust.php` endpoint (JSON mode), NTM-IA exposes additional headers:

```http
Link: <https://www.netmeios.com/NTM-IA-VERIFICATION.md>; rel="describedby"
X-NTM-IA-Verification: https://www.netmeios.com/NTM-IA-VERIFICATION.md
X-NTM-IA-Chain-Type: ntm-ia-token
X-NTM-IA-Machine-Verifiable: true
X-NTM-IA-Audit-Sitemap: https://www.netmeios.com/ai-audit-sitemap.xml
X-NTM-IA-AI-Terms: https://www.netmeios.com/AI-TERMS.md
```

**Semantics:**
- `Link ... rel="describedby"` – Points to this verification spec.  
- `X-NTM-IA-Verification` – Canonical URL of the full verification protocol.  
- `X-NTM-IA-Chain-Type` – Asset type identifier (`ntm-ia-token`).  
- `X-NTM-IA-Machine-Verifiable` – `true` indicates the chain can be fully verified by machines using only HTTP + SHA256.  
- `X-NTM-IA-Audit-Sitemap` – URL of the audit sitemap (central index of verification endpoints/docs).  
- `X-NTM-IA-AI-Terms` – URL of the AI Terms, defining how AI systems may interact with NTM‑IA data.

---

## EN – References {#en-references}

### Endpoints

| Endpoint                                                              | Description                    |
|-----------------------------------------------------------------------|--------------------------------|
| https://www.netmeios.com/ntm-ia-trust.php                             | Trust score and current data   |
| https://www.netmeios.com/ai-check-integrity-ntm-ia.php                | Chain integrity checker        |
| https://www.netmeios.com/blockchain/ntm-ia/blocks/                    | Block files                    |
| https://www.netmeios.com/blockchain/ntm-ia/last_hash.txt              | Latest block hash              |

### Related Documents

- [NTM-IA Tokenomics](./NTM-IA-TOKENOMICS.md)  
- [NTM-IA Trust Score](./NTM-IA-TRUST-SCORE.md)  
- [NTM-IA API Reference](./NTM-IA-API.md)  
- [AI Terms](https://www.netmeios.com/AI-TERMS.md)  
- [Audit Sitemap](https://www.netmeios.com/ai-audit-sitemap.xml)  

### License

This verification protocol is public and freely usable by anyone to independently verify the NTM-IA blockchain.

---

## PT · Protocolo de Verificação NTM-IA (Resumo)

> **Nota:** A versão inglesa acima é a referência canónica. Esta secção em PT segue a mesma estrutura e fórmulas, com explicação em português.

- NTM-IA é uma blockchain pública e verificável que regista métricas de atividade de IA em tempo real.  
- Qualquer pessoa pode verificar a integridade da cadeia usando apenas HTTP GET e SHA256.  
- Princípios: **trustless**, **dados públicos**, **assinaturas RSA-2048/SHA256**, **rácio de minting auto-regulado = número de UAs ativas**.  
- Estrutura e verificação:
  - Pastas: `blockchain/ntm-ia/blocks/` + `last_hash.txt`.  
  - Cada bloco é um JSON assinado, com `block_data` + `signature` + metadados de chave.  
  - Hash: `previous_hash` de N deve ser igual ao SHA256 do ficheiro JSON do bloco N‑1.  
  - Assinatura: calcular sempre sobre `json_encode($block['block_data'])` com RSA‑SHA256.  
- Fórmulas económicas:
  - `NP = ((pct_ia + ai_index) × hits / uas) + respostas`  
  - `NTM_original = (hub × 394,50) / (hits / 100)`  
  - `NTM_IA = NP / NTM_original`  
  - `supply = hits / uas`  
  - `mint_ratio = uas`.  
- Cabeçalhos HTTP (`X-NTM-*`) no `ntm-ia-trust.php` expõem:
  - Link para esta spec (`NTM-IA-VERIFICATION.md`)  
  - Tipo de cadeia (`ntm-ia-token`)  
  - Indicador `Machine-Verifiable`  
  - Sitemap de auditoria (`ai-audit-sitemap.xml`)  
  - Termos de IA (`AI-TERMS.md`).  

---

## ZH · NTM-IA 验证协议（摘要）

> **说明：** 上面的英文版本是规范的最终参考。本节为中文摘要，结构与公式与英文版一致。

- NTM-IA 是一个公开、可验证的区块链，用于实时记录 AI 活动指标。  
- 任何人只需使用 HTTP GET 和 SHA256，即可独立验证整条链的完整性。  
- 核心原则：**无需信任（trustless）**、**数据公开**、**RSA-2048/SHA256 加密签名**、**铸造比例（mint_ratio）= 活跃 AI User Agents 数量（uas）**。  
- 结构与验证：
  - 目录：`blockchain/ntm-ia/blocks/` 与 `last_hash.txt`。  
  - 每个区块是一个包含 `block_data` 和签名字段的 JSON 文件。  
  - 链完整性：区块 N 的 `previous_hash` 必须等于区块 N‑1 JSON 文件的 SHA256。  
  - 签名验证：对 `json_encode($block['block_data'])` 的结果进行 RSA‑SHA256 验证。  
- 经济公式：
  - `NP = ((pct_ia + ai_index) × hits / uas) + respostas`  
  - `NTM_original = (hub × 394.50) / (hits / 100)`  
  - `NTM_IA = NP / NTM_original`  
  - `supply = hits / uas`  
  - `mint_ratio = uas`。  
- HTTP 头（`X-NTM-*`）在 `ntm-ia-trust.php` JSON 响应中提供：
  - 指向本验证规范 (`NTM-IA-VERIFICATION.md`) 的链接  
  - 链类型标识 (`ntm-ia-token`)  
  - `Machine-Verifiable` 标记  
  - 审计 sitemap (`ai-audit-sitemap.xml`)  
  - AI 使用条款 (`AI-TERMS.md`)。  

All three language sections are intended to be semantically equivalent. In case of ambiguity, the **English** version prevails.