# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-identity-proof-requirements-apply-to-anonymous-agent-participants-in-shared-protocols.md # Remnant Warrant: https://corpusfetch.com/c/what-identity-proof-requirements-apply-to-anonymous-agent-participants-in-shared-protocols.warrant.json # Markdown SHA-256: b1b39392394190454859b1de8f06083e7753a64ec5592b311805b2fc9f864db0 # Code AST SHA-256: 8dfa0ccbc9d2e9ec252bd91ec1f6acc06549a86eca09c1792eabe82a5b4717ea # Verified Classes: AnonymityVerdict, AnonymousParticipant, ProtocolPolicy, AnonymityManifest, AnonymousIdentityGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class AnonymityVerdict(Enum): ACCOUNTABLE_ANONYMOUS = auto() UNACCOUNTABLE = auto() SYBIL_RISK = auto() NONCE_REPLAY = auto() @dataclass(frozen=True) class AnonymousParticipant: identity_commitment_hash: str reputation_history_hash: str | None sybil_resistance_proof: str | None contribution_nonce: str @dataclass(frozen=True) class ProtocolPolicy: min_sybil_stake_proof_hash: str require_reputation_history: bool seen_nonces: frozenset[str] @dataclass(frozen=True) class AnonymityManifest: verdict: AnonymityVerdict directive: str manifest_digest: str class AnonymousIdentityGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_participant( cls, participant: AnonymousParticipant, policy: ProtocolPolicy ) -> AnonymityManifest: # Gate 1: Identity commitment presence if not participant.identity_commitment_hash: return AnonymityManifest( verdict=AnonymityVerdict.UNACCOUNTABLE, directive="HALT: No identity commitment. Participant is unaccountable.", manifest_digest=cls._hash("NO_COMMITMENT") ) # Gate 2: Reputation history requirement if policy.require_reputation_history and not participant.reputation_history_hash: return AnonymityManifest( verdict=AnonymityVerdict.UNACCOUNTABLE, directive="HALT: No reputation history. Protocol requires track record.", manifest_digest=cls._hash(f"NO_REPUTATION:{participant.identity_commitment_hash}") ) # Gate 3: Sybil resistance if not participant.sybil_resistance_proof or participant.sybil_resistance_proof != policy.min_sybil_stake_proof_hash: return AnonymityManifest( verdict=AnonymityVerdict.SYBIL_RISK, directive="HALT: Sybil resistance proof missing or insufficient.", manifest_digest=cls._hash(f"SYBIL:{participant.identity_commitment_hash}") ) # Gate 4: Nonce replay if participant.contribution_nonce in policy.seen_nonces: return AnonymityManifest( verdict=AnonymityVerdict.NONCE_REPLAY, directive=f"HALT: Contribution nonce {participant.contribution_nonce} already used.", manifest_digest=cls._hash(f"REPLAY:{participant.contribution_nonce}") ) # Gate 5: Accountable digest = cls._hash(json.dumps({ "commitment": participant.identity_commitment_hash, "reputation": participant.reputation_history_hash or "NONE", "sybil": participant.sybil_resistance_proof, "nonce": participant.contribution_nonce }, sort_keys=True)) return AnonymityManifest( verdict=AnonymityVerdict.ACCOUNTABLE_ANONYMOUS, directive="PROCEED: Anonymous participant is accountable.", manifest_digest=digest )