Smart Contracts & Workflows
How the IP declaration hash is made
Updated 26 Nov 2026
This page is the public rule for the check code (hash) of a DAO's IP declaration. Anyone can work it out again from the declaration file, without Kambria, and compare it with the one recorded on the Polygon network. The rule is the same as in KDF v1, so declarations recorded with v1 can still be checked.
The easy way: open the DAO's public IP page (ip-public.html?code=DAO-CODE) and tap Verify. The steps below are for people who want to check it themselves.
What is hashed
- The check code is made from one file: the DAO's declaration file (JSON text). It says what the DAO owns, who decides about it, and lists the attached documents.
- The declaration file is public. It is kept in Kambria's public file storage (Supabase Storage) and is never changed or deleted, because the record on the network points to it. Older v1 declarations live on IPFS and are read through public gateways.
- Attached documents (PDFs, images, Google Docs) are not in the file. Each one appears only by its title, a link and its own SHA-256 code (documents[].sha256: 64 characters, no 0x).
- Documents are private by default: only the DAO's members and Kambria Ops can open them. The public sees their names and SHA-256 codes; a document the DAO made public can be downloaded.
Step 1 · Sort the names
- In every group of fields (JSON object), sort the field names A → Z by character code (capital letters before small ones). Do this inside nested groups too.
- Lists (arrays) keep the order they were written in. Only the groups inside them are sorted.
Step 2 · One line, no spaces
- Write the JSON on one line: no spaces, no line breaks, no indentation. This is JavaScript JSON.stringify on the sorted value, or Python json.dumps(..., sort_keys=True, separators=(',', ':'), ensure_ascii=False).
- No line break at the very end, and no byte-order mark (BOM) at the start.
Step 3 · Letters and numbers
- Text is UTF-8. Letters such as Vietnamese ones stay real letters ("Tiếng Việt"), not \u codes.
- Kambria writes text in Unicode NFC when the declaration is made. When you check, hash the text exactly as it is in the file.
- Numbers are whole numbers only (declarationVersion: 1). Dates are text ("2026-11-19").
- A field set to null stays (for example "previousDeclarationHash": null in version 1). Do not drop, rename or add fields.
Step 4 · Make the code
declarationHash = keccak256( UTF-8 bytes of the one-line text )
- Use keccak256, not NIST SHA3-256 (Python hashlib.sha3_256 gives a different result) and not SHA-256.
- The result starts with 0x and has 64 more characters. Compare without caring about capital letters.
How to check (summary)
- On the public IP page, open Details → Open the declaration file and save it.
- Hash the exact saved file. If you have a pretty-printed copy, apply Steps 1–3 first.
- Compare with Check code (full) under Details.
If they differ, either the file is not the recorded one, or a rule was missed (spaces, line break at the end, BOM, unsorted names, SHA3-256 instead of keccak256).
Check an attached document
- Get the file: Download on the public page for a public document; a member opens a private one from the DAO's IP declaration page.
- Work out SHA-256 of the exact file bytes (for a Google Doc: of its PDF copy).
- Compare with documents[].sha256 in the declaration file.
Test example
DAO TECD, version 5 (a v1 test record). This exact text, with no line break at the end:
{"catalog":[],"coOwnership":{"basis":"DEP 3 IP Framework","reference":"https://kambria.io/docs/dep3/introduction/"},"daoId":"TECD","daoName":"Tech-powered Elderly Care DAO Beta","declarationVersion":5,"documents":[{"archiveUri":"ipfs://QmcNEnutajYqdYBVrMbW7grHiranYACfdUZk75d2ccR6yW","format":"pdf","sha256":"229defbb0cee6f02673a5cde290d0673e75a0dc31cec43989c8ab2a4eca7e1bb","title":"document v5","uri":"ipfs://QmcNEnutajYqdYBVrMbW7grHiranYACfdUZk75d2ccR6yW"}],"effectiveDate":"2026-11-19","exclusions":[],"governance":{"currentPhase":"admin-role","decisionProcess":"Decisions on IP use, licensing, or transfer follow DAO governance."},"previousDeclarationHash":"0x09f231a940cf8d203930bc9c896065a955296837641d0f2ccaa538047ce50d92","schema":"kambria-ip-declaration/v1","scope":{"categories":[{"description":"test","type":"brand"}],"summary":"test"}}
must give: 0x8e4136eff6aaaf0cb8fd4bd62061a5d692d3b0825aa08ae87606401972f7b7a8
Script (Python)
pip install pycryptodome, then: python check-ip.py declaration.json
import json, sys
from Crypto.Hash import keccak
text = open(sys.argv[1], encoding='utf-8-sig').read()
canonical = json.dumps(json.loads(text), sort_keys=True, separators=(',', ':'), ensure_ascii=False)
k = keccak.new(digest_bits=256)
k.update(canonical.encode('utf-8'))
print('0x' + k.hexdigest())
Script (Node.js 18+)
npm install js-sha3, then: node check-ip.mjs declaration.json
import fs from 'fs';
import { createRequire } from 'module';
const { keccak256 } = createRequire(import.meta.url)('js-sha3');
const sortValue = (v) => Array.isArray(v) ? v.map(sortValue) : v && typeof v === 'object' ? Object.fromEntries(Object.keys(v).sort().filter((k) => v[k] !== undefined).map((k) => [k, sortValue(v[k])])) : v;
const text = fs.readFileSync(process.argv[2], 'utf8').replace(/^\uFEFF/, '');
console.log('0x' + keccak256(JSON.stringify(sortValue(JSON.parse(text)))));
Both scripts print the same code for the test example above.