near-api-js
near-api-js copied to clipboard
Error: Length of buffer does not match length of ASN.1 sequence
Prerequisites
- [X] I'm using the latest version of
near-api-js
. - [x] I have tried to start with a fresh project and reproduce the defect with minimal code changes.
- [x] I have read the console error messages carefully (if applicable).
Description
We have several users using Chromium-based browsers (v120+) like Brave, Chrome and Edge on Windows machines.
We integrated @near-js/biometric-ed25519
and the getKeys
method throws an error when executed in this environment.
Reproducible demo
https://wallet.mintbase.xyz
Steps to reproduce
- Open any browser based on Chromium (v120+) on a Windows machine
- Create an account (this should work)
- Try signing any transaction with the wallet
Expected behavior
Not to throw an error and return keys.
Actual behavior
Error: Length of buffer does not match length of ASN.1 sequence.
at V.parse (4011-d66488a438fc0322.js:477:36669)
at 4011-d66488a438fc0322.js:470:51173
at Generator.next (<anonymous>)
at 4011-d66488a438fc0322.js:470:49049
at new Promise (<anonymous>)
at en (4011-d66488a438fc0322.js:470:48830)
at 4011-d66488a438fc0322.js:470:50853
at async i (page-4ae5a0be2a9f3743.js:1:20136)
at async sendTransaction (page-4ae5a0be2a9f3743.js:1:15438)
at async send (page-4ae5a0be2a9f3743.js:1:16668) 'error'
Your environment
- NEAR JavaScript API version used: 1.0.1
- Frontend framework (if applicable): NextJS (client rendered component)
- OS: Windows
Self-service
- [ ] I'd be willing to fix this bug myself.
Hey @microchipgnu, we have updated the package, the problem should be solved.
Thanks @gtsonevv we are testing now.
Hey @gtsonevv we are seeing a new error now. This happens on all devices now.
Error: r must be 0 < r < CURVE.n
at eO.assertValidity (6887-25fc58e43eeff16f.js:471:77431)
at new eO (6887-25fc58e43eeff16f.js:471:77159)
at 6887-25fc58e43eeff16f.js:470:54149
at Generator.next (<anonymous>)
at 6887-25fc58e43eeff16f.js:470:52568
at new Promise (<anonymous>)
at en (6887-25fc58e43eeff16f.js:470:52349)
at em (6887-25fc58e43eeff16f.js:470:54012)
at 6887-25fc58e43eeff16f.js:470:51450
at Generator.next (<anonymous>) 'error'
Hey @microchipgnu, we will investigate why this is happening.
@microchipgnu, is this error coming from the getKeys
method again?
Hey @microchipgnu, could you provide a minimal reproducible example of the issue?
Yes.
https://near-biometric-issue-repro.vercel.app/
Any update @vikinatora @gtsonevv?
Hey @microchipgnu, we are still investigating the issue, please use version 2.1.4 until we resolve the issue.
Any update?
@SurgeCode, @microchipgnu Does the issues still persist on near-api-js v2.1.4? This issue is on our priority list, but we have a few other stuff to do, before we dive deep here. Thank you for your patience.
1.0.1 -> Doesn't work on any window machines - Error: Length of buffer does not match length of ASN.1 sequence.
1.1.0 -> Doesn't work in general (all machines we tested)- Error: r must be 0 < r < CURVE.n
reproduction -> create, get, check console https://near-biometric-issue-repro.vercel.app/
This issue is quite critical for us at the moment
Hey, no update here unfortunately. Most likely the asn-parser
library is causing the issue. Replacing it would require refactoring of the existing functionality, so I can't give you an estimate of when you can expect this issue to be resolved.
This seems pretty critical as it makes the library entirely unusable in a lot of cases. Could you give me some information on how much of a priority this is for your team or if we should explore our own implementation?
It's high priority. @gtsonevv is on it.
Any update?
Hey, we’ve been investigating the issue in the past weeks. Unfortunately, no substantial progress has been made and this issue won't be a quick fix. We're researching currently what it will take to make the module working.
For the time being, please use v1.0.1 which doesn't work on Windows as per your comments.
#1309 Should resolve the issue, waiting for the CI node to be back up, so that checks can pass and we will release it. Thank you for the patience.
We will give this a try. Thanks!
Please let us know if the issue is resolved. Package is @near-js/[email protected]
The issue is still happening on Windows.
- Create account works ✅
- Submitting Transaction does not work ❌
Tested on: Windows 11 Pro 23H2 Chrome 122.0.6261.112 Edge 122.0.2365.66
Can you please reopen the issue!
Reproducing the issue with the transaction that Micro provided above
https://github.com/near/near-api-js/assets/408953/0ff78885-4bee-4f93-8e0a-aebe8cc4e918
Seems like the issue is there, since I got the same error message. That means noone using a windows machine can transaction currently? I expect most of our users (we are addressing normies) will not be able to use this mintbase wallet then...or am I missing something? Is there a workaround?
@vikinatora , do you want to jam on this one over a call & close this? its been a while and Mintbase is getting a lot of not-so-happy users coz of it.
I'm also happy to contribute to get this fixed
Contributions are more than welcome, our team has comittment on a different group of functionalities and we're trying to solve this issue with the time we have to spare between tasks.
Unfortunately, the issue here is not an easy one.
My thoughts are to resolve the windows issue, the whole fido2-lib will have to be replaced with an alternative.
Regarding the signing issue, that's probably a hard to spot bug. We've not worked on the initial implementation and it's hard to debug as there are no tests for the biometric module.
@starpause, @myweb3gift can you try out the logic here? I've replaced the ASN.1 parsing library, maybe that will help as I couldn't reproduce the issue on my windows machine.
In the app you just have to press the "Create and Get Key" button and check the console for errors.
@vikinatora we had been chatting on telegram but thought to update the issue with my findings after you replaced the ASN.1 library.
I still get an error in console: Error initializing NEAR: Length over 48 bits not supported at position 1
https://github.com/near/near-api-js/assets/408953/9578fbf4-6dca-4fdd-b218-18691be1db08
Hi, I try to log in the account with the Windows passkey, when I type the PIN it doesn't tell me it's incorrect, but it won't loge me in. Also, I have another account I'm logged on, but it's impossible to get the seed phrase. I'm using Windows 10 and latest version of Chrome. After I put the PIN, I'm back to the connection page, nothing happens. Please, advise.