Skip to content

feat: implement ADR-0001 private access mechanism using opaque hashes - #23

Merged
Joaco2603 merged 4 commits into
Stellar-AgentVerse:mainfrom
NovusCyber:feat/private-access-adr-0001
Jul 30, 2026
Merged

feat: implement ADR-0001 private access mechanism using opaque hashes#23
Joaco2603 merged 4 commits into
Stellar-AgentVerse:mainfrom
NovusCyber:feat/private-access-adr-0001

Conversation

@NovusCyber

@NovusCyber NovusCyber commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #20

Description

This PR implements the private-access mechanism selected by ADR-0001 in the PromptMarketplace smart contract, ensuring that prompt content, plaintext identifiers, and decryption keys remain off-chain and fully protected.

Affected Contracts

  • PromptMarketplace

Security Impact & Threat-Model Guarantees

  • Privacy Guarantees: Plaintext prompt_id and content_uri are never exposed on-chain. The new PrivatePrompt models use BytesN<32> opaque hashes (commitments).
  • Residual Metadata Leaks: Timing of purchases, the buyer's address, and token burn amounts remain observable on the public ledger. Opaque hashes allow linkability (an observer can see if the same prompt is bought multiple times, without knowing what the prompt is).
  • Atomic State Transitions: Replay protection (PrivatePurchase data keys) is atomically tied to the cross-contract token burn (sell_forwarded), ensuring no tokens are lost on failure and no access is granted without payment.
  • Trust Boundaries: The contract strictly handles access control logic and payment processing. Content delivery and DEK (Decryption Key) management are trusted to the off-chain backend service.

Migration Behavior

  • Legacy public prompt structures (Prompt) and their respective methods (register_prompt, buy_prompt) were intentionally preserved.
  • Explicit Non-compatibility: We do not silently reinterpret legacy public records as private access grants. Migration to the private structures should be handled progressively through the backend without disrupting legacy records or active clients.

Backend / Client Changes Required

  • Clients/Backend must now generate and submit a BytesN<32> hash (commitment) when registering or buying a private prompt.
  • Off-chain delivery services must verify the emission of the PrivatePromptPurchased event before securely delivering the prompt content via their out-of-band channels.

Deployment & Configuration Implications

  • No immediate deployment blockers. The MyToken contract does not require upgrades since we continue to use its existing forwarded auth methods.
  • Infrastructure teams must update indexers to listen for the new PrivatePromptRegistered and PrivatePromptPurchased event topics.

…ototype

- Update ADR 0001 status to Approved and Implemented
- Specify commitment construction: SHA256(PMPT_V1 || Prompt_ID || Salt)
- Document resource cost evidence (<100 stroops)
- Add isolated private_access_prototype contract for feasibility testing
- Prototype measures CPU/memory cost and validates replay protection

Resolves the ADR approval gate required by Stellar-AgentVerse#20
…verage

- Register and purchase private prompts using opaque BytesN<32> hashes
- Fix CI: PrivatePromptRegistered now used in event emission test
- Add test_cross_user_replay_prevented (replay attack)
- Add test_atomicity_fail_burn (rollback on insufficient funds)
- Add test_migration_compatibility (legacy + private coexistence)
- Add test_register_private_prompt_emits_event (storage/event inspection)
- Update integration-test.sh with private prompt Testnet flow (Steps 5-9)
- All 42 tests pass, clippy -D warnings clean

Closes Stellar-AgentVerse#20
@NovusCyber
NovusCyber force-pushed the feat/private-access-adr-0001 branch from bd3229e to d6ac5e7 Compare July 29, 2026 23:21
@Joaco2603
Joaco2603 force-pushed the feat/private-access-adr-0001 branch from a72acde to 093777a Compare July 30, 2026 00:15
@Joaco2603
Joaco2603 merged commit 645f8aa into Stellar-AgentVerse:main Jul 30, 2026
1 check 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.

feat(marketplace): implement approved private-access ADR

2 participants