DFX identity issues


As seen in this photo, I have an issue with identity on dfx where I choose to use an identity and whenever I do dfx identity get-principal, it produces a principal I don’t know of and that is not in my list of principals. This has happened so many times and I’m wondering if that is normal? I can see that I’m using a specific identity with the * sign but get-principal produces a principal unrelated to the one I know. Any reason for this or way to solve it? This makes it hard to control canisters I added controllers to. Hope my explanation is clear enough.

The list dfx identity list shows is a list of names. The one with the * at the end is the currently active identity. dfx identity get-principal produces the principal that’s derived from the private key, and shows how the identity is identifiable for the system. The name you gave this identity (bve5y...) is not at all related to the identity’s private key.

I recommend you rename the identity to a more sensible name. You can use dfx identity rename <FROM> <TO> for that.

2 Likes

Thank you for your response. I have an understanding of this and I didnt name this one bve5… because it’s one of those resulting unknown identities. The main problem is each time I chose an identity to use, for instance, munki, and I try to get-principal, it results in an unknown principal because the principal ID i wrote down somewhere associated with munki isn’t the same to the unknown one. This means the canister that I control with munki refuses access even when I’m using munki identity. There must be some reason for this. I just created a new identity and that one consistently results in the same principal ID-- which is good. However, the older IDs created before computer crash are easily used and whoami is consistent but ids are not. Not sure If my ramblings are clear enough.

This could be the key to everything. I assume computer crash = data loss. Is that right? Afterwards, I assume you did dfx identity new munki. This does not work to re-create the same principal. Any dfx identity new generates a fresh private key with a new principal associated with it.

If you still have the .pem files from before the crash, you can import them with dfx identity import. This way, you can use the old keys which will produce the principals you wrote down.

Does this make sense?

2 Likes

Yes. Data was lost. However, I had saved all the principal ids in a backup file. What I did was just add them back. For instance, dfx identity new (principal id) where principal ID refers to the old ones. This added them back but then fails to work as controllers they were before. It makes sense what you say. appears that the .pem file is the key here. Thank you. I guess without them, I should forget about the old ids and canisters. Also, It’s possible that I misunderstood how the ID itself works. I thought it’s a key, but it appears it’s only a name itself and the .pem file that connects to it is the key.

If you want to learn more about how the identities work, have a look at this article: Web Authentication and Identity on the Internet Computer | by DFINITY | The Internet Computer Review | Medium

It is very in-depth and more than is necessary to understand, but maybe you’re interested…

2 Likes

Thank you! I’ll dig into it for sure.