Digital Identity Verification

What it does:
Enables individuals and organizations to create, verify, and manage digital identities on-chain with privacy-preserving credentials.

Why it matters:
Supports trustless interactions, KYC/AML compliance, DAO membership, voting, and access control without exposing sensitive personal data.

How it works:

  • Users register a digital identity linked to cryptographic keys

  • Identity verifiers (trusted authorities) validate identity claims

  • Verified credentials are issued as signed attestations or NFTs

  • Users control which credentials they share and with whom

  • Smart contracts enforce access, eligibility, and governance rights based on verified identities

  • All verification and credential activity is auditable on-chain

  • Can integrate with governance DAOs, token-gated platforms, and reputation systems

      // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title DigitalIdentityVerification
 * @author Nam
 * @notice On-chain digital identity creation, verification, and credential management
 */
contract DigitalIdentityVerification is Ownable {

    struct Identity {
        address user;
        bool verified;
        string metadataURI; // IPFS/Arweave hash of encrypted info or claims
    }

    mapping(address => Identity) public identities;
    mapping(address => bool) public verifiers;

    // -------------------- EVENTS --------------------

    event VerifierApproved(address verifier);
    event IdentityRegistered(address indexed user, string metadataURI);
    event IdentityVerified(address indexed user);

    // -------------------- VERIFIER MANAGEMENT --------------------

    function approveVerifier(address _verifier) external onlyOwner {
        verifiers[_verifier] = true;
        emit VerifierApproved(_verifier);
    }

    function revokeVerifier(address _verifier) external onlyOwner {
        verifiers[_verifier] = false;
    }

    // -------------------- IDENTITY REGISTRATION --------------------

    function registerIdentity(string calldata _metadataURI) external {
        require(bytes(_metadataURI).length > 0, "Metadata required");
        identities[msg.sender] = Identity({
            user: msg.sender,
            verified: false,
            metadataURI: _metadataURI
        });

        emit IdentityRegistered(msg.sender, _metadataURI);
    }

    // -------------------- VERIFICATION --------------------

    function verifyIdentity(address _user) external {
        require(verifiers[msg.sender], "Not authorized verifier");
        Identity storage id = identities[_user];
        require(!id.verified, "Already verified");

        id.verified = true;
        emit IdentityVerified(_user);
    }

    // -------------------- VIEW FUNCTIONS --------------------

    function isVerified(address _user) external view returns (bool) {
        return identities[_user].verified;
    }

    function getMetadata(address _user) external view returns (string memory) {
        return identities[_user].metadataURI;
    }
}