Linking an Identity
This document describes how to use the Litentry’s client-sdk to link an identity.
Before proceeding, ensure you have completed all the steps from the Installation section.
Linking an identity is typically a two-step process:
Create a proof of ownership.
Request the identity link to attach the proof of ownership.
The proof varies whether the identity to link is web2 (Twitter, Discord) or web3 (Substrate, Evm, Bitcoin, Solana).
Twitter: A challenge code has to be publicly posted. The user has to provide the URL to the post.
Discord: The challenge code has to be posted in the designated Discord channel. The user has to provide the URL to the post.
Web3 identities: The challenge code has to be signed by the user with the web3 identity to-be link.
For the following examples, you will use a Substrate address as the Prime Identity to hold our linked identities.
1. Generate the challenge code
2. Proof of identity ownership
The challenge code is a 32-byte hex-encoded string that is uniquely generated for the given identities and salted with the Litentry Enclave’s nonce.
Here is what it looks like:
For Web3 identities, the challenge code needs to be signed by the identity to be linked. Following our example, it should be signed by the Evm account: 0x0AcE67628Bd43213C1C41ca1DAEf47E63923c75c
.
The signature should be a hex-encoded string. Optionally accepted formats are: base58-encoded string for Solana and base64-encoded for Bitcoin identities.
For Web2 accounts, the challenge code needs to be posted, and the user has to provide the URL to it.
Given the user signature or post’s URL, we can build a LitentryValidationData
struct to hold the proof
For Twitter, the proof would look like:
For Discord,
Those Discords values can be extracted from the provided Discord URL to the user’s post. For instance:
3. Linking request
Build a secure trusted request
The call object has the following properties:
call.payloadToSign
: The hex-encoded trusted call.call.txHash
: Thehash
that will identify the request.call.send
: A callback function to send the request to the Litentry Enclave.
The trusted call needs to be signed by the prime identity. This ensures the mutation operation is legit. The message to sign is found in call.payloadToSign
.
The signature should be a hex-encoded string. Optionally accepted formats are: base58-encoded string for Solana and base64-encoded for Bitcoin identities.
4. Sending the link request.
Once the call.payloadToSign
the message is signed by the prime identity, we can send the transaction.
The result
object has the following properties:
result.response
: The raw Enclave’s response. aWorkerRpcReturnValue
struct.request.idGraphHash
: The resultinghash
of the new id graph.result.mutatedIdentities
: An array containing the new linking identities.
Last updated