question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Invalid Encoding"

See original GitHub issue

This function const decryptedMessege = decryptSafely({ encryptedData: {ciphertext: validator.data, version:"x25519-xsalsa20-poly1305", ephemPublicKey:validator.publicKey, nonce:"XUYgP2Bgtr4CPZVxTCPzKdSaTyMV7JzUkH7a5msSXxs="}, privateKey: validator.privateKey })

Leads to an “invalid encoding” error. I tracked it down to this piece of code:

function validateBase64(s) { if (!(/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(s))) { throw new TypeError('invalid encoding'); } }

And this appears to happen when s=validator.pubilcKey. That is to say, MetaMask public keys such as my own “0x3b89aC05D2d53f3775697B5Dbc75d8852E740403” is not valid according to the regex. If I remove the “0x” at the start it works but I instead get “bad public key size” error instead. So I don’t know what to do here.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mcmirecommented, Apr 7, 2022

According to the documentation for nacl.box.open, it will return null if authentication fails: https://github.com/dchest/tweetnacl-js#naclboxopenbox-nonce-theirpublickey-mysecretkey. So something must be wrong with either the public key or private key.

0reactions
Gudahttcommented, Apr 7, 2022

Closing as it doesn’t appear that this is due to a bug. Feel free to continue asking for help in this thread and we’ll help if we get time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix: Invalid UTF-8 encoding - Google Support
If you're using Notepad to save your file, please select Save As, and then select ANSI or UTF-8 in the Encoding options. If...
Read more >
How to fix "Invalid encoding' error in python 3? - Stack Overflow
The prompt string is not composed of characters that can be represented in latin-1, hence the error:
Read more >
Invalid UTF8 Encoding - Deep Security
Open the properties of the HTTP Protocol Decoder filter. Go to the Configuration tab and then select the Latin-1 encoding option. Click OK....
Read more >
Rails: Fixing 'Invalid query parameters: invalid %-encoding'
In a full stack apps, sometimes users manually edit query strings in the address bar, and make requests that have invalid encodings.
Read more >
"Invalid encoding for parameter" no more reaching action with ...
Hey, Looks like since rails 6.1, I am now getting the following errors getting thrown before reaching the controller action code: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found