Skip to content

feat: EIP-712-style typed structured data hashing & credential hash registry (#64) - #70

Merged
michaelvic123 merged 1 commit into
laugh-tales:mainfrom
jotel-dev:issue-64-eip712-credential-registry
Jul 30, 2026
Merged

feat: EIP-712-style typed structured data hashing & credential hash registry (#64)#70
michaelvic123 merged 1 commit into
laugh-tales:mainfrom
jotel-dev:issue-64-eip712-credential-registry

Conversation

@jotel-dev

Copy link
Copy Markdown
Contributor

Description

Closes #64.

This PR implements an EIP-712-style typed structured data hashing scheme for StellarID credentials. It allows credentials to be verified off-chain (e.g. via QR code, NFC tap, or HTTP header) using only the credential fields and the issuer's public key, without performing any on-chain network queries.

Changes Made

  • Data Model: Updated Credential struct to include pub credential_hash: BytesN<32>.
  • Domain Separator: Defined deterministic domain separator formula: SHA-256("StellarID:v1:" || contract_address_32_bytes).
  • Canonical Hash Encoding: Formatted fixed-width big-endian byte concatenation:
    SHA-256(domain_separator || schema_id_be || subject_32_bytes || issuer_32_bytes || issued_at_be || expires_at_be)
  • Public Interface:
    • compute_expected_hash(env, schema_id, subject, issuer, issued_at, expires_at) -> BytesN<32> (pure helper for verifiers)
    • get_credential_hash(env, credential_id) -> BytesN<32>
    • verify_credential_hash(env, credential_id) -> bool
  • Credential Lifecycle Integration: Updated issue_credential, batch_issue_credentials, bridge_credential, and issue_multisig_credential to compute and store credential hashes.
  • Documentation: Updated docs/ARCHITECTURE.md with the canonical hashing specification.

Test Plan & Verification

  • test_credential_hash_calculation_and_verification: Verifies that stored credential hashes match off-chain computed hashes.
  • test_credential_hash_modifying_field_changes_hash: Verifies that altering any field changes the resulting hash.
  • All unit tests passing via cargo test.

@michaelvic123
michaelvic123 merged commit d481766 into laugh-tales:main Jul 30, 2026
2 of 3 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 on-chain credential registry with EIP-712-style typed structured data hashing

2 participants