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

Error: Length of buffer does not match length of ASN.1 sequence #1248

Open
3 of 4 tasks
microchipgnu opened this issue Jan 10, 2024 · 31 comments · Fixed by #1309
Open
3 of 4 tasks

Error: Length of buffer does not match length of ASN.1 sequence #1248

microchipgnu opened this issue Jan 10, 2024 · 31 comments · Fixed by #1309
Labels
bug Something isn't working

Comments

@microchipgnu
Copy link
Contributor

microchipgnu commented Jan 10, 2024

Prerequisites

  • I'm using the latest version of near-api-js.
  • I have tried to start with a fresh project and reproduce the defect with minimal code changes.
  • 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

  1. Open any browser based on Chromium (v120+) on a Windows machine
  2. Create an account (this should work)
  3. 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.
@microchipgnu microchipgnu added the bug Something isn't working label Jan 10, 2024
@gtsonevv
Copy link
Collaborator

Hey @microchipgnu, we have updated the package, the problem should be solved.

@microchipgnu
Copy link
Contributor Author

Thanks @gtsonevv we are testing now.

@microchipgnu
Copy link
Contributor Author

microchipgnu commented Jan 11, 2024

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'

@gtsonevv
Copy link
Collaborator

Hey @microchipgnu, we will investigate why this is happening.

@gtsonevv
Copy link
Collaborator

@microchipgnu, is this error coming from the getKeys method again?

@vikinatora
Copy link
Collaborator

Hey @microchipgnu, could you provide a minimal reproducible example of the issue?

@microchipgnu
Copy link
Contributor Author

@microchipgnu
Copy link
Contributor Author

Any update @vikinatora @gtsonevv?

@gtsonevv
Copy link
Collaborator

gtsonevv commented Jan 15, 2024

Hey @microchipgnu, we are still investigating the issue, please use version 2.1.4 until we resolve the issue.

@SurgeCode
Copy link

Any update?

@vikinatora
Copy link
Collaborator

@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.

@SurgeCode
Copy link

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

@vikinatora
Copy link
Collaborator

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.

@SurgeCode
Copy link

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?

@vikinatora
Copy link
Collaborator

It's high priority. @gtsonevv is on it.

@microchipgnu
Copy link
Contributor Author

Any update?

@vikinatora
Copy link
Collaborator

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.

@vikinatora
Copy link
Collaborator

#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.

@microchipgnu
Copy link
Contributor Author

We will give this a try. Thanks!

@vikinatora
Copy link
Collaborator

Please let us know if the issue is resolved. Package is @near-js/biometric-ed25519@1.1.2

@microchipgnu
Copy link
Contributor Author

microchipgnu commented Mar 13, 2024

The issue is still happening on Windows.

Tested on:
Windows 11 Pro 23H2
Chrome 122.0.6261.112
Edge 122.0.2365.66

Can you please reopen the issue!

@vikinatora vikinatora reopened this Mar 13, 2024
@starpause
Copy link

starpause commented Mar 13, 2024

Reproducing the issue with the transaction that Micro provided above

UIMoiAwrrU.mp4

@myweb3gift
Copy link

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?

@vikpande
Copy link

@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.

@SurgeCode
Copy link

I'm also happy to contribute to get this fixed

@vikinatora
Copy link
Collaborator

vikinatora commented Mar 19, 2024

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.

@vikinatora
Copy link
Collaborator

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.

@vikinatora
Copy link
Collaborator

@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.

@starpause
Copy link

@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

msedge_biaQLWkfaE.mp4

@ssplashh
Copy link

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.

image
image

@starpause
Copy link

@vikinatora After bumping Mintbase Wallet dependency to @near-js/wallet-account@1.2.1 I'm still getting the ASN.1 error on my windows machine. Can you share a barebones test before pushing the next fix/update to make the feedback loop tighter? This has been open for months. Maybe fork https://near-biometric-issue-repro.vercel.app/ as shared above?

@github-project-automation github-project-automation bot moved this to Backlog 🥶 in DevRel May 30, 2024
@thisisjoshford thisisjoshford removed this from DevRel Oct 31, 2024
@github-project-automation github-project-automation bot moved this to NEW❗ in DevTools Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: NEW❗
Development

Successfully merging a pull request may close this issue.

8 participants