Create Identity from Principal ID or _delegations

Support | Question

I’m trying to call a canister from my backend using the identity that the user obtained from the frontend. Is it possible to recreate this identity using the principal ID or from a _delegation by stringifying the Identity object? Thank you.

Delegations are a great way to send a user’s identity to the server without actually sending the private key.

Basically you’d:

  1. Creat identity on client side (can be ed25519, ecdsa etc)
  2. Create identity on server side (can be ed25519, ecdsa etc, doesn’t need to match client identity type)
  3. Send public key of server side identity to client
  4. Use DelegationChain.create with client identity and server identity public key
  5. Call toJSON on this delegation chain and send JSON to server
  6. Use DelegationChain.fromJSON to re-create it from the received JSON
  7. Use DelegationIdentity.fromDelegation with server identity and delegation chain
  8. Now you can make calls on behalf of user using this DelegationIdentiy
1 Like