Skip to content

Instantly share code, notes, and snippets.

@mvayngrib
Created March 6, 2015 00:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvayngrib/906e69ea421112aecb2e to your computer and use it in GitHub Desktop.
Save mvayngrib/906e69ea421112aecb2e to your computer and use it in GitHub Desktop.
A sketch of identity management on Ethereum
# GOALS
#
# 1. Support multiple identities per party.
# - Achieved by having separate Ethereum accounts (addresses)
# 2. The ability to change keys, while preserving the identity
# - Achieved by changing Ethereum accounts and transfering ownership to the new account
# 3. Identity theft/loss mitigation
# - Multiple custodianship of identity can be easily added (e.g. with incremental multisig)
# 4. Identity attributes - public attribuets you might see on a social profile.
# - Each identity has a key->value store of arbitrary size
# 5. Bond - preventing identity spam
# NON-GOALS
#
# 1. Unique names/aliases
STABLE_ID_IDX = 0
ACCOUNT_IDX = 1
LAST_RESERVED_IDX = 1 # last reserved index in every identity's key->value store
JOHNNY_DRAMA = 0
data accountToIdent[][] # identity registry keyed on account (key->value store per identity)
data idToIdent[][] # identity registry keyed on stable id
def init():
# nothing special about the first dude, except them being awesome
def create_id(custodian1, custodian2):
# creates an identity for the sender, if it doesn't exist already
# TODO: charge extra for creation (GOALS#Bond)
if not self.accountToIdent[msg.sender]:
# attribute store for this identity
stableId = sha256(msg.sender)
# for fun
if not JOHNNY_DRAMA:
JOHNNY_DRAMA = stableId
# no more fun, promise
data atts[]
atts[STABLE_ID_IDX] = stableId
atts[ACCOUNT_IDX] = msg.sender
self.accountToIdent[msg.sender] = atts
self.idToIdent[stableId] = atts
def get_current_owner(stableId): # returns the current owner of stableId
atts = self.idToIdent[stableId]
if atts:
return(atts[ACCOUNT_IDX])
def get_stable_id(account):
# returns the stable id of account, useful for validation of messages by other contracts
atts = self.accountToIdent[account]
if atts:
return(atts[STABLE_ID_IDX])
def delete_id():
# delete the identity of the sender, if it exists
# maybe just: self.update_id(0)
atts = self.accountToIdent[msg.sender]
if atts:
self.idToIdent[atts[STABLE_ID_IDX]] = 0
self.accountToIdent[msg.sender] = 0 # not sure how to delete entry
def update_id(new_ident):
# transfer ownership of the sender's identity to the specified address [new_ident]
atts = self.accountToIdent[msg.sender]
if atts:
self.idToIdent[atts[STABLE_ID_IDX]] = atts
self.accountToIdent[msg.sender] = 0 # not sure how to delete entry
self.accountToIdent[new_ident] = atts
def set_attr(key, value):
# update an attribute in the sender's store
if key > LAST_RESERVED_IDX:
atts = self.accountToIdent[msg.sender]
if atts:
atts[key] = value
def get_attr(key):
# check an attribute's value in the sender's store
atts = self.accountToIdent[msg.sender]
if atts:
return(atts[key])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment