feat(psi): expose PSI blind contact discovery endpoint and periodic L2 Merkle root anchor

Open
#5 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start with the L2 flags in src/config.rs (lines 29-31) and the Merkle root code in src/merkle.rs, then read src/http_server.rs to see how routes are wired. The new src/psi_service.rs module must blind contact tokens against registered identity hashes and produce anchor receipts. Done means POST /v1/contacts/psi and GET /v1/identity/anchors/latest return the specified responses, with cargo test, fmt and clippy passing in tests/node_test.rs.

Written by the indexing model from the issue text.

Description

area::node effort::m impact::high priority::high source::user status::review type::feature

Part of Meta-Issue alfonsodg/sonaraim#7
Ref alfonsodg/sonaraim-protocol#4, Ref alfonsodg/sonaraim-node#3

Problem

src/config.rs:29-31 parses l2_anchor_enabled and l2_rpc_url, and src/merkle.rs:42-269 computes Merkle roots, but sonaraim-node does not yet expose the Private Set Intersection (PSI) endpoint (POST /v1/contacts/psi) for Phase 2 social graph discovery or the optional periodic L2 state-root anchoring receipt generator (GET /v1/identity/anchors/latest).

Affected Files & Locations

  • src/config.rs:29-31
  • src/merkle.rs:42-269
  • src/psi_service.rs (new PSI blind evaluation & L2 anchor receipt module, < 300 lines)
  • src/http_server.rs
  • tests/node_test.rs:1-167

Evidence

// src/config.rs:29-31
pub l2_anchor_enabled: bool,
pub l2_rpc_url: Option<String>,

Impact and Blast Radius

Allows sonaraim-app users to privately discover which contacts already have Sonaraim installed (POST /v1/contacts/psi) and allows external auditors to verify hourly L2 state-root anchors of the Key Transparency log.

Historical Context and Anti-Regression

Builds on e62fca0 / 6eda03b (Issue #1) and Issues #2–#4. All pre-existing tests in tests/node_test.rs must remain 100% green.

Proposed Solution

  1. Implement src/psi_service.rs evaluating blinded contact tokens against registered identity hashes and generating verifiable L2 state-root anchor receipts when NODE_L2_ANCHOR_ENABLED=true.
  2. Expose POST /v1/contacts/psi and GET /v1/identity/anchors/latest in src/http_server.rs.

Acceptance Criteria

  • POST /v1/contacts/psi returns blinded tokens and never logs or accepts plaintext phone numbers (400 on invalid payload).
  • GET /v1/identity/anchors/latest returns the latest anchored Merkle root_hash, tree_size, and anchor receipt metadata.
  • cargo fmt --check, cargo clippy -- -D warnings, and cargo test pass with 0 warnings.

Validation Criteria

Level Applies Test Scenario Pass
Unit Yes tests/node_test.rs PSI batch evaluation & L2 anchor receipt verification 100% pass (cargo test)
Integration Yes tests/node_test.rs Live HTTP POST /v1/contacts/psi & GET /v1/identity/anchors/latest Status 200/400 verified
Contract Yes docs/API.md JSON request/response contract parity Verified
E2E Yes Sandbox container validation (REMOTE.md) Live PSI discovery query against sonaraim-node:8040 HTTP 200 verified
Dominant language
Rust
Stars
0
Forks
0
Avg merge
4m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alfonsodg/sonaraim-node

All issues in alfonsodg/sonaraim-node

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.