On-chain identity refers to the representation of a user's identity on a blockchain, allowing for secure and verifiable interactions. This approach enables users to maintain control over their personal data while ensuring that their identity can be authenticated without relying on centralized authorities.
Unlike traditional identity systems that store user information in centralized databases, on-chain identities use cryptographic proofs and decentralized storage to give users sovereignty over their personal information while maintaining privacy and security.
By utilizing cryptographic techniques, on-chain identity systems provide higher security compared to traditional identity management systems while giving users granular control over how their information is shared and used.
Implementation involves using cryptographic techniques to create and manage identities on the blockchain. This typically includes the use of public-private key pairs for authentication and various approaches to store or reference identity data.
// Example of a simple identity contract in Solidity
pragma solidity ^0.8.0;
contract OnChainIdentity {
struct Identity {
string name;
string email;
address owner;
uint256 createdAt;
bool emailVerified;
}
mapping(address => Identity) public identities;
event IdentityCreated(address indexed owner, string name);
event IdentityUpdated(address indexed owner);
function createIdentity(string memory _name, string memory _email) public {
require(identities[msg.sender].owner == address(0), "Identity already exists");
identities[msg.sender] = Identity({
name: _name,
email: _email,
owner: msg.sender,
createdAt: block.timestamp,
emailVerified: false
});
emit IdentityCreated(msg.sender, _name);
}
function updateEmail(string memory _newEmail) public {
require(identities[msg.sender].owner == msg.sender, "Identity doesn't exist");
identities[msg.sender].email = _newEmail;
identities[msg.sender].emailVerified = false;
emit IdentityUpdated(msg.sender);
}
function verifyEmail(address _owner) public {
// In a real implementation, this would have access controls
// and integrate with an oracle or verification system
identities[_owner].emailVerified = true;
emit IdentityUpdated(_owner);
}
function getIdentity(address _owner) public view returns (Identity memory) {
return identities[_owner];
}
}
This contract allows users to create and manage their on-chain identity, storing their name and email address on the blockchain. It includes additional features like timestamps, verification flags, and events for identity changes.
Several standards and protocols have emerged to facilitate on-chain identity:
A standard for blockchain-based identity that defines a proxy contract owned by a user or entity. It separates identity from actions, allowing for key management and multiple execution methods.
interface IERC725 <br/>
function execute(uint256 _operation, address _to, uint256 _value, bytes _data) external;<br/>
function getData(bytes32[] _keys) external view returns (bytes[] _values);<br/>
A W3C standard for globally unique identifiers that don't require a centralized registry. DIDs are resolvable to DID documents that contain verification methods and service endpoints.
did:example:123456789abcdefghi