[Your question is quite broad, and may get flagged as such... ]
Have a look at uPort, the white paper for which is entitled "uPort: A Platform for Self-Sovereign Identity". It contains some pseudo-code, which might help generate some ideas.
Anything on Consensys's official media stream containing the "identity" tag might also be helpful.
Also of interest would be the new ERC-725 contract standard, entitled "Identity". From the EIP abstract:
The following describes standard functions for a unique identity for
humans, groups, objects and machines. This identity can hold keys to
sign actions (transactions, documents, logins, access, etc), and
claims, which are attested from third parties (issuers) and self
attested, as well as a proxy function to act directly on the