Skip to content

feat: hierarchical category assignment system for IP records (#459)#643

Merged
fejilaup-cloud merged 1 commit into
AtomicIP:mainfrom
Sundriveauto:feat/459-hierarchical-category-system
Jun 17, 2026
Merged

feat: hierarchical category assignment system for IP records (#459)#643
fejilaup-cloud merged 1 commit into
AtomicIP:mainfrom
Sundriveauto:feat/459-hierarchical-category-system

Conversation

@Sundriveauto

Copy link
Copy Markdown
Contributor

Summary

Implements a hierarchical category assignment system for IP records to support deep organizational structures (e.g., Software/Cryptography/ZK-Proofs). Closes #459.

Changes

Contract (contracts/ip_registry/src/lib.rs)

  • New error variants: InvalidCategoryHash, InvalidCategoryDepth, CategoryNotFound
  • New constant: MAX_CATEGORY_DEPTH = 10
  • New DataKey: CategoryDepth(BytesN<32>) — stores depth per category hash
  • New struct: CategoryInfo — path + depth metadata
  • New public functions:
    • register_category_path(env, path) -> BytesN<32> — registers a path, validates depth, returns hash
    • validate_category(env, category_hash) — validates hash is non-zero, registered, depth within limits
  • Updated: assign_ip_to_category now validates the category is registered before assigning

Security

  • Category assignment restricted to IP owner via require_auth() (existing behavior preserved)
  • Unregistered category hashes are rejected, preventing arbitrary hash injection

Tests (17 new + 4 updated, all passing)

  • Depth validation: 5-level, 8-level, max boundary, exceeding max depth
  • Path traversal: attempting to assign with unregistered/bogus hashes
  • Validation: zero hash, unregistered hash, valid registered hash
  • Original tests: updated to register categories via register_category_path first

Documentation (docs/api-reference.md)

  • Added category schema table (types, constants, error codes)
  • Documented register_category_path and validate_category
  • Updated example to show hierarchical path usage

Verification

  • cargo test -p ip_registry — 90 passed, 0 failed
  • cargo build -p ip_registry — no errors

AtomicIP#459)

Add register_category_path and validate_category functions with depth
validation. Update assign_ip_to_category to enforce category registration
before assignment. Add comprehensive tests for hierarchy depth (5+ levels),
path traversal attempts, and invalid hash validation.

- Add ContractError variants: InvalidCategoryHash, InvalidCategoryDepth, CategoryNotFound
- Add DataKey::CategoryDepth for depth tracking
- Add CategoryInfo struct for path metadata
- Add MAX_CATEGORY_DEPTH = 10 constant
- Update api-reference.md with category schema documentation
@fejilaup-cloud fejilaup-cloud merged commit 23dfc23 into AtomicIP:main Jun 17, 2026
0 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement IP Commitment Hierarchical Storage

2 participants