Public Key format difference between `extractPublicKey` and `encrypt` question
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- cryptography
Research direction
Start by comparing the public-key representations returned by extractPublicKey and accepted by encrypt, using the example signatures and MetaMask-exported key in the issue. Done when the compatibility or required encoding conversion is established and documented, with the API behavior explained clearly.
Written by the indexing model from the issue text.
Description
Hi, probably missing something obvious and sorry to bother you but I'm trying to use the extracted public key from a personal_sign'ed message to encrypt a return message to a user... but the public key returned by extractPublicKey is a 130 byte hex-encoded string (starting with 0x4) whereas the encrypt method requires the public key be a 44 character (base64 encoded?) string. Am I missing something terribly obvious? I cannot figure out how to convert the hex-encoded to the 44 character version.
try {
console.log("Account: ", connector.accounts[0]);
const msg = `0x${Buffer.from("Hello World", "utf8").toString("hex")}`;
console.log("MessageHashBytes: ", msg);
const signature = await connector.signPersonalMessage([
msg,
connector.accounts[0],
]);
console.log("Signature: ", signature);
const result = recoverPersonalSignature({ data: msg, signature });
console.log("Result: ", result);
const publicKey = extractPublicKey({
data: msg,
signature
});
console.log('Public Key: ', publicKey)
console.log('Public Key Length: ', publicKey.length);
const questionMark = Buffer.from(publicKey).toString('base64');
console.log('Hmm: ', questionMark, questionMark.length)
} catch (error) {
if (error instanceof Error) console.log(error.message);
}
produces the following output:
Account: 0x0C0Bd9c93596F6FC9F7E3dd8F53EF73a6759873b
MessageHashBytes: 0x48656c6c6f20576f726c64
Signature: 0x618ebc96d5a7ea456ecbf3bc938e28a5329e1dc063ef26b94c8a8a11cfca0ff26783259b56921dec86bfa2115765624b58ce4a9799ac43f5321c2ac2b7af7f2a1c
Result: 0x0c0bd9c93596f6fc9f7e3dd8f53ef73a6759873b
Public Key: 0x4d979e20ed15805a4b9aec2d9b8dfe256a174844f20ecd26ca5a571e70907a04bbc9be04b47bdc3a73cfdfe7b5536d4bb15fec07e7d9db076816e7f80cd28200
Public Key Length: 130
Hmm: MHg0ZDk3OWUyMGVkMTU4MDVhNGI5YWVjMmQ5YjhkZmUyNTZhMTc0ODQ0ZjIwZWNkMjZjYTVhNTcxZTcwOTA3YTA0YmJjOWJlMDRiNDdiZGMzYTczY2ZkZmU3YjU1MzZkNGJiMTVmZWMwN2U3ZDlkYjA3NjgxNmU3ZjgwY2QyODIwMA== 176
When I export my public key from metamask I receive +5ar2xujBQQPv+RTRU2tzO6sjSuTMZSosAx5NAdfkw0=
Thanks in advance anyone who can point me in the right direction! <3
- Dominant language
- TypeScript
- Stars
- 584
- Forks
- 230
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MetaMask/eth-sig-util
-
team-wallet-framework
Difficulty 1/5 Under an hour Newbie friendliness 50/100
MetaMask/eth-sig-util#353 ·
-
tsconfig: Disable `strictNullChecks`, enable `strict`Possibly taken @itzKLAUS claimed this 17 days ago. Openteam-wallet-framework
Difficulty 1/5 Under an hour Newbie friendliness 55/100
MetaMask/eth-sig-util#352 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
MetaMask/eth-sig-util#328 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
MetaMask/eth-sig-util#304 · 4 comments · 4 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
MetaMask/eth-sig-util#303 ·
All issues in MetaMask/eth-sig-util
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ccch1mneyyy/dsh-TUI#1631 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MiniMax-AI/minimax-code#507 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Transient OAuth login failure persists in getLoginStatus and masks active account in dashboardMay be free again A pull request for this issue was closed without being merged. Openaccount-pool bug gui
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
lidge-jun/opencodex#7378 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day