Aqua ProtocolAqua Protocol
Aqua Protocol
Aqua ProtocolOpen-source cryptographic trust infrastructure for the AI era — verifiable identity, access control, and tamper-proof provenance.

Documentation

ConceptsAqua Protocol v3Schema ReferenceTooling & SDK

Documentation

ConceptsAqua Protocol v3Schema ReferenceTooling & SDK
Docs
Schema Reference

Schema Reference

Detailed schema specifications for Aqua Protocol v3 revisions

10 min read

Aqua Protocol v3 - Schema Reference

This document provides comprehensive technical specifications for all revision types in Aqua Protocol v3. Each revision type has specific fields and validation rules.

Version String Format

https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: {scalar|tree}

Components:

  • Protocol URL: https://aqua-protocol.org/docs/v3/schema_2
  • Hash Algorithm: SHA256
  • Canonicalization Method: scalar or tree

Common Fields

All revisions share these mandatory fields:

FieldTypeDescriptionValidation
previous_verification_hashstringHash of previous revisionEmpty string for genesis, otherwise 64-char hex with 0x prefix
local_timestampstringISO 8601 timestampValid ISO 8601 format: YYYY-MM-DDTHH:mm:ss
revision_typestringType of revisionOne of: "file", "form", "signature", "witness", "link"
versionstringProtocol version and methodMust match format above

File Revision

Represents a file with metadata and optional content.

Fields

FieldTypeRequiredDescription
previous_verification_hashstringYesPrevious revision hash (empty for genesis)
local_timestampstringYesISO 8601 timestamp
revision_typestringYesMust be "file"
versionstringYesProtocol version string
file_hashstringYesSHA256 hash of file content (hex with 0x)
file_noncestringYesRandom 16-byte nonce (hex with 0x)
contentstring/Uint8ArrayNoOptional file content
leavesstring[]ConditionalRequired if Method: tree, array of leaf hashes

Genesis File Revision (Scalar)

Code
json
1{
2 "previous_verification_hash": "",
3 "local_timestamp": "2024-01-01T12:00:00",
4 "revision_type": "file",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "file_hash": "0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
7 "file_nonce": "0x3fa8b1c2d3e4f5a67b8c9d0e1f2a3b4c"
8}

Genesis File Revision (Tree)

Code
json
1{
2 "previous_verification_hash": "",
3 "local_timestamp": "2024-01-01T12:00:00",
4 "revision_type": "file",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: tree",
6 "file_hash": "0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
7 "file_nonce": "0x3fa8b1c2d3e4f5a67b8c9d0e1f2a3b4c",
8 "leaves": [
9 "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
10 "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
11 ]
12}

With Content

Code
json
1{
2 "previous_verification_hash": "",
3 "local_timestamp": "2024-01-01T12:00:00",
4 "revision_type": "file",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "file_hash": "0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
7 "file_nonce": "0x3fa8b1c2d3e4f5a67b8c9d0e1f2a3b4c",
8 "content": "This is the file content as a string"
9}

Validation Rules

  1. file_hash must match SHA256 of file content
  2. file_nonce must be exactly 16 bytes (32 hex chars + 0x)
  3. If Method: tree, leaves array must be present
  4. If Method: scalar, leaves must be absent
  5. content is optional but if present, hash must match file_hash

Form Revision

Stores structured key-value data.

Fields

FieldTypeRequiredDescription
previous_verification_hashstringYesPrevious revision hash (empty for genesis)
local_timestampstringYesISO 8601 timestamp
revision_typestringYesMust be "form"
versionstringYesProtocol version string
file_hashstringYesSHA256 hash of form data
file_noncestringYesRandom 16-byte nonce
contentobjectYesForm data as key-value pairs
leavesstring[]ConditionalRequired if Method: tree

Example (Scalar)

Code
json
1{
2 "previous_verification_hash": "",
3 "local_timestamp": "2024-01-01T12:00:00",
4 "revision_type": "form",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "file_hash": "0xabc123def456...",
7 "file_nonce": "0x7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f",
8 "content": {
9 "name": "John Doe",
10 "email": "john@example.com",
11 "organization": "Example Corp",
12 "role": "Developer"
13 }
14}

Example (Tree)

Code
json
1{
2 "previous_verification_hash": "",
3 "local_timestamp": "2024-01-01T12:00:00",
4 "revision_type": "form",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: tree",
6 "file_hash": "0xabc123def456...",
7 "file_nonce": "0x7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f",
8 "content": {
9 "name": "John Doe",
10 "email": "john@example.com",
11 "organization": "Example Corp",
12 "role": "Developer"
13 },
14 "leaves": [
15 "0x...", // SHA256("name:John Doe")
16 "0x...", // SHA256("email:john@example.com")
17 "0x...", // SHA256("organization:Example Corp")
18 "0x..." // SHA256("role:Developer")
19 ]
20}

Leaf Computation (Tree Mode)

For each key-value pair in content:

Code
typescript
1leaf_hash = SHA256(`${key}:${value}`)

Validation Rules

  1. content must be a valid JSON object
  2. All values in content must be strings
  3. file_hash must match hash of canonicalized content
  4. If Method: tree, number of leaves must match number of keys in content

Signature Revision

Adds cryptographic signature to verify authenticity.

Common Fields

FieldTypeRequiredDescription
previous_verification_hashstringYesHash of revision being signed
local_timestampstringYesISO 8601 timestamp
revision_typestringYesMust be "signature"
versionstringYesProtocol version string
signature_typestringYesType: "cli", "metamask", "did", "p12", "inline"

CLI / MetaMask Signature

Additional Fields:

FieldTypeRequiredDescription
signaturestringYesHex-encoded signature (65 bytes for ECDSA)
signature_wallet_addressstringYesEthereum address (EIP-55 checksummed)

Example:

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:01:00",
4 "revision_type": "signature",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "signature_type": "cli",
7 "signature": "0x8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d1c",
8 "signature_wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb8"
9}

DID Signature

Additional Fields:

FieldTypeRequiredDescription
signatureobjectYesJWS (JSON Web Signature) object

Signature Object Structure:

Code
typescript
1{
2 payload: string; // Base64url-encoded payload
3 signatures: [{
4 protected: string; // Base64url-encoded protected header
5 signature: string; // Base64url-encoded signature
6 }]
7}

Example:

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:01:00",
4 "revision_type": "signature",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "signature_type": "did",
7 "signature": {
8 "payload": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19",
9 "signatures": [{
10 "protected": "eyJhbGciOiJFZERTQSJ9",
11 "signature": "kKvXJ_qjJRtGQFLpRvQlCdXMFD8sSE4DTlbMmLqg0BJ9FQKLHvX7y_z5Pr8u0xT8D2vCj9qL1KzN4rP2MzKfBQ"
12 }]
13 }
14}

P12 Certificate Signature

Additional Fields:

FieldTypeRequiredDescription
signaturestringYesHex-encoded signature
signature_public_keystringYesHex-encoded DER public key

Example:

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:01:00",
4 "revision_type": "signature",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "signature_type": "p12",
7 "signature": "0x...",
8 "signature_public_key": "0x308201a2300d06092a864886f70d01010105000382018f..."
9}

Inline Signature

Same as CLI/MetaMask but with pre-computed signature.

Validation Rules

  1. Signature must be verifiable using provided credentials
  2. For CLI/MetaMask: Address must be recoverable from signature
  3. For DID: JWS must be valid and verifiable
  4. For P12: Signature must verify with public key
  5. Signature must be computed over previous_verification_hash

Witness Revision

Anchors revision to blockchain or timestamping service.

Fields

FieldTypeRequiredDescription
previous_verification_hashstringYesHash being witnessed
local_timestampstringYesISO 8601 timestamp
revision_typestringYesMust be "witness"
versionstringYesProtocol version string
witness_merkle_rootstringYesRoot hash of Merkle tree
witness_timestampnumberYesUnix timestamp from witness service
witness_networkstringYesNetwork: "mainnet", "sepolia", "holesky", "tsa", "nostr"
witness_smart_contract_addressstringConditionalRequired for Ethereum
witness_transaction_hashstringYesTransaction or event hash
witness_sender_account_addressstringConditionalRequired for Ethereum
witness_merkle_proofstring[]YesMerkle proof (empty for single witness)

Ethereum Witness Example

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:02:00",
4 "revision_type": "witness",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "witness_merkle_root": "0xdef456...",
7 "witness_timestamp": 1704110520,
8 "witness_network": "sepolia",
9 "witness_smart_contract_address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
10 "witness_transaction_hash": "0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
11 "witness_sender_account_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb8",
12 "witness_merkle_proof": []
13}

Batched Witness Example

Multiple revisions witnessed in single transaction:

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:02:00",
4 "revision_type": "witness",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "witness_merkle_root": "0xroot...",
7 "witness_timestamp": 1704110520,
8 "witness_network": "mainnet",
9 "witness_smart_contract_address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
10 "witness_transaction_hash": "0x9f86d081...",
11 "witness_sender_account_address": "0x742d35Cc...",
12 "witness_merkle_proof": [
13 "0xsibling_hash_1",
14 "0xsibling_hash_2",
15 "0xsibling_hash_3"
16 ]
17}

Nostr Witness Example

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:02:00",
4 "revision_type": "witness",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "witness_merkle_root": "0xabc123...",
7 "witness_timestamp": 1704110520,
8 "witness_network": "nostr",
9 "witness_smart_contract_address": "",
10 "witness_transaction_hash": "nevent1qqsw...",
11 "witness_sender_account_address": "npub1...",
12 "witness_merkle_proof": []
13}

TSA Witness Example

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:02:00",
4 "revision_type": "witness",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "witness_merkle_root": "0xabc123...",
7 "witness_timestamp": 1704110520,
8 "witness_network": "tsa",
9 "witness_smart_contract_address": "https://timestamp.digicert.com",
10 "witness_transaction_hash": "base64_tsa_response",
11 "witness_sender_account_address": "",
12 "witness_merkle_proof": []
13}

Validation Rules

  1. For single witness: witness_merkle_proof must be empty array
  2. For single witness: witness_merkle_root equals previous_verification_hash
  3. For batched: Merkle proof must verify back to witness_merkle_root
  4. Transaction must exist and be confirmed on specified network
  5. witness_timestamp should match blockchain/service timestamp
  6. For Ethereum: Contract address and sender address required

Link Revision

Connects to other AquaTree chains.

Fields

FieldTypeRequiredDescription
previous_verification_hashstringYesPrevious revision in this chain
local_timestampstringYesISO 8601 timestamp
revision_typestringYesMust be "link"
versionstringYesProtocol version string
link_typestringNoApplication-specific link type
link_verification_hashesstring[]YesArray of hashes from other chains
link_file_hashesstring[]NoCorresponding file hashes

Example

Code
json
1{
2 "previous_verification_hash": "0xabc123...",
3 "local_timestamp": "2024-01-01T12:03:00",
4 "revision_type": "link",
5 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
6 "link_type": "dependencies",
7 "link_verification_hashes": [
8 "0x111222333444555666777888999000aaabbbcccdddeeefff000111222333444",
9 "0x222333444555666777888999000aaabbbcccdddeeefff000111222333444555",
10 "0x333444555666777888999000aaabbbcccdddeeefff000111222333444555666"
11 ],
12 "link_file_hashes": [
13 "0xfileHash1...",
14 "0xfileHash2...",
15 "0xfileHash3..."
16 ]
17}

Validation Rules

  1. link_verification_hashes must be non-empty array
  2. Each hash in array must be valid revision hash
  3. If link_file_hashes present, must have same length as link_verification_hashes
  4. Referenced revisions should exist (optional strict validation)

Hash Computation

Scalar Method

  1. Serialize revision as canonical JSON (sorted keys)
  2. Compute SHA256 hash of serialized string
  3. Prefix with 0x
Code
typescript
1const canonical = JSON.stringify(sortKeys(revision));
2const hash = "0x" + sha256(canonical).toString('hex');

Tree Method

  1. Extract leaves array from revision
  2. Build Merkle tree from leaves
  3. Root hash becomes verification hash
Code
typescript
1const leaves = revision.leaves;
2const tree = new MerkleTree(leaves, sha256);
3const hash = "0x" + tree.getRoot().toString('hex');

AquaTree Storage Format

Complete AquaTree structure for storage/transmission:

Code
json
1{
2 "revisions": {
3 "0xgenesis_hash": {
4 "previous_verification_hash": "",
5 "local_timestamp": "2024-01-01T12:00:00",
6 "revision_type": "file",
7 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
8 "file_hash": "0x...",
9 "file_nonce": "0x..."
10 },
11 "0xsignature_hash": {
12 "previous_verification_hash": "0xgenesis_hash",
13 "local_timestamp": "2024-01-01T12:01:00",
14 "revision_type": "signature",
15 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
16 "signature_type": "cli",
17 "signature": "0x...",
18 "signature_wallet_address": "0x..."
19 },
20 "0xwitness_hash": {
21 "previous_verification_hash": "0xsignature_hash",
22 "local_timestamp": "2024-01-01T12:02:00",
23 "revision_type": "witness",
24 "version": "https://aqua-protocol.org/docs/v3/schema_2 | SHA256 | Method: scalar",
25 "witness_merkle_root": "0x...",
26 "witness_timestamp": 1704110520,
27 "witness_network": "sepolia",
28 "witness_smart_contract_address": "0x...",
29 "witness_transaction_hash": "0x...",
30 "witness_sender_account_address": "0x...",
31 "witness_merkle_proof": []
32 }
33 },
34 "file_index": {
35 "0xfile_hash": "document.pdf"
36 },
37 "tree": {
38 "hash": "0xgenesis_hash",
39 "children": [
40 {
41 "hash": "0xsignature_hash",
42 "children": [
43 {
44 "hash": "0xwitness_hash",
45 "children": []
46 }
47 ]
48 }
49 ]
50 },
51 "treeMapping": {
52 "paths": {
53 "0xgenesis_hash": ["0xgenesis_hash"],
54 "0xsignature_hash": ["0xgenesis_hash", "0xsignature_hash"],
55 "0xwitness_hash": ["0xgenesis_hash", "0xsignature_hash", "0xwitness_hash"]
56 },
57 "latestHash": "0xwitness_hash"
58 }
59}

Field Constraints

Hashes

  • Format: Lowercase hexadecimal with 0x prefix
  • Length: 64 characters (32 bytes) + 2-char prefix = 66 total
  • Example: 0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08

Timestamps

  • Format: ISO 8601
  • Pattern: YYYY-MM-DDTHH:mm:ss
  • Example: 2024-01-01T12:00:00

Ethereum Addresses

  • Format: EIP-55 checksummed
  • Length: 42 characters (20 bytes + 0x)
  • Mixed case for checksum
  • Example: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb8

Nonces

  • Length: Exactly 16 bytes (32 hex chars + 0x)
  • Format: Lowercase hexadecimal with 0x prefix
  • Example: 0x3fa8b1c2d3e4f5a67b8c9d0e1f2a3b4c

Version Compatibility

  • v3.2.x: Current version, fully compatible
  • v3.1.x: Compatible, minor improvements
  • v3.0.x: Compatible, initial TypeScript release
  • v2.x: Not compatible, different schema

See Also

  • Introduction - Getting started
  • Concepts - Core concepts
  • Tooling - SDK API reference
Edit this pageReport an issue
Previous
Aqua Protocol v3
Next
Tooling & SDK

Documentation

  • Getting Started
  • API Reference

Community

  • GitHub

Copyright © 2026 Aqua. All rights reserved.

On this page

Version String FormatCommon FieldsFile RevisionFieldsGenesis File Revision (Scalar)Genesis File Revision (Tree)With ContentValidation RulesForm RevisionFieldsExample (Scalar)Example (Tree)Leaf Computation (Tree Mode)Validation RulesSignature RevisionCommon FieldsCLI / MetaMask SignatureDID SignatureP12 Certificate SignatureInline SignatureValidation RulesWitness RevisionFieldsEthereum Witness ExampleBatched Witness ExampleNostr Witness ExampleTSA Witness ExampleValidation RulesLink RevisionFieldsExampleValidation RulesHash ComputationScalar MethodTree MethodAquaTree Storage FormatField ConstraintsHashesTimestampsEthereum AddressesNoncesVersion CompatibilitySee Also