Git Product home page Git Product logo

Comments (7)

chjj avatar chjj commented on July 23, 2024 1
      at Object.randomBytes (node_modules/bcrypto/lib/native/random.js:20:18)
      at Function.randomBits (node_modules/bcrypto/lib/js/bn.js:3459:25)

This stack trace is confusing. Why does electron succeed at dynamically loading the binding? The random object is always on the exposed binding no matter what. Is electron does giving us an empty object for compatibility purposes?

but does not enter the catch block here

@supaiku0, what about NODE_BACKEND=node. Does that give any better results?

We only fall back to the JS random backend in the browser (which uses getRandomValues() instead of the crypto module).

I'm still fuzzy on what electron does/doesn't support and there doesn't seem to be a simple writeup anywhere. Personally I prefer not to touch electron, so I'm basically shooting in the dark here.

from bcrypto.

pinheadmz avatar pinheadmz commented on July 23, 2024

Possible duplicate issue: #15

Looks like the recommendation for now is to fall back to the JavaScript methods.

from bcrypto.

pinheadmz avatar pinheadmz commented on July 23, 2024

The environment variable is NODE_BACKEND=<js|node>

from bcrypto.

spkjp avatar spkjp commented on July 23, 2024

Thanks for the reply. I tried playing around with NODE_BACKEND=js before and the issue still persists:

    console.log node_modules/bcrypto/lib/native/binding.js:9
      js
    console.log node_modules/bcrypto/lib/native/binding.js:11
      boom
    console.log node_modules/bcrypto/lib/random.js:11
      all ok

In other words, it throws the exception here:
https://github.com/bcoin-org/bcrypto/blob/master/lib/native/binding.js#L9

but does not enter the catch block here:
https://github.com/bcoin-org/bcrypto/blob/master/lib/random.js#L12

from bcrypto.

chjj avatar chjj commented on July 23, 2024

Also, is there an easy way to detect electron? Do they expose a property on the process object or something?

from bcrypto.

tynes avatar tynes commented on July 23, 2024

It looks like process.versions.electron is set when running in electron.

electron/electron#2288 (comment)

from bcrypto.

spkjp avatar spkjp commented on July 23, 2024

@chjj @tynes This is a bit embarassing, but it's not actually Electron at fault here. I was only able to reproduce the error when running unit tests via jest and for some reason I mixed it up with Electron. I can no longer reproduce it after I wiped everything on my Linux system. It must have been a local issue on my side.

Sorry, for the confusion!

from bcrypto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.