Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubkey.toDer() generates a wrong DER key #839

Open
vporton opened this issue Jan 31, 2024 · 2 comments
Open

pubkey.toDer() generates a wrong DER key #839

vporton opened this issue Jan 31, 2024 · 2 comments

Comments

@vporton
Copy link

vporton commented Jan 31, 2024

I obtain an Internet Identity key as follows (in frontend):

const pubkey = authClient.getIdentity().getPublicKey();
const der = Buffer.from(pubkey.toDer())
...
const response = await axios.post(`${SCORER_BACKEND}account/verify/ic`, {
  pubkey: der.toString("hex"),
  // ...
});

Then, I pass the key hex-encoded to a Python endpoint:

public_key = bytes.fromhex(payload.pubkey)
key = ecdsa.VerifyingKey.from_der(public_key, hashfunc=hashlib.sha256)

Python says:

ecdsa.der.UnexpectedDER: Unexpected object identifier in DER encoding: (1, 3, 6, 1, 4, 1, 56387, 1, 2)

Accordingly this, the error is not in the Python ecdsa package.

Here is my public key produced by .toDer(): 303c300c060a2b0601040183b8430102032c000a00000000000000070101a40eb8c9b8ac02422243970c2c0ff6974bddb796eaa1c26a0ca8ebbd11ac5090.

A side note: Bard claims that the key is in RSA format. I wonder: Shouldn't it be in ECDSA format? Maybe Bard hallutinated?

This issue first appeared here.

@krpeacock
Copy link
Contributor

What type of base key are you using with the AuthClient? Are you using the default create settings?

@vporton
Copy link
Author

vporton commented Feb 16, 2024

Are you using the default create settings?

Yes:

const authClient = await AuthClient.create({});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants