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

Warning: "secp256k1 unavailable, reverting to browser version" #86

Open
honigkuchenbaer opened this issue Mar 26, 2022 · 6 comments
Open

Comments

@honigkuchenbaer
Copy link

How can we install this library that it will use a native compilation for secp256k1 instead of the slow browser version?

I found the root cause of this warning at the index.js of eccrypto:

try {
  var secp256k1 = require("secp256k1");
  var ecdh = require("./build/Release/ecdh");
} catch (e) {
  if (process.env.ECCRYPTO_NO_FALLBACK) {
    throw e;
  } else {
    console.info('secp256k1 unavailable, reverting to browser version');
    return (module.exports = require("./browser"));
  }
}

Obviously, one should do something that will build some stuff at a subfolder called "./build/Release". I could not find any further explanation.

How can we achieve that? What needs to be done?

@joshuarossi
Copy link

the openssl_config_path is wrong in the binding.gyp file

"openssl_config_path": "<(nodedir)/deps/openssl/config/arm"

which gives this error when you try to build it

gyp: Undefined variable openssl_config_path in binding.gyp while trying to load binding.gyp

I downloaded a standard openssl config
opensslconf.txt
except the file name has the extension .h

I then changed the path to where i had that file, and then I ran node-gyp rebuild

that built the file /build/Release/ecdh

then when you try to run index.js, it is now able to load the file, and avoids the catch block

this makes the error go away, and you are using the native bindings

@joshuarossi
Copy link

I may try to figure out a way to programatically find the correct file, and submit a PR, but I'm not sure where that file is normally located, and probably it varies a lot, due to usage of nvm, or different installs.

I suppose another option would be to add an optional command line argument so you could specify it for your system, because right now, while the error is "fixed" on my machine, any install will break it again

@joshuarossi
Copy link

also, at the very least, the error message doesn't really point in the right direction, as i already got secp256k1 to install correctly, it was ecdh that was not able to load

@tonimateos
Copy link

Hi @joshuarossi, do you know if any PR has fixed this issue at all? Thanks!

@thehenrytsai
Copy link

Hey @joshuarossi, not sure if you still remember, I tried to update the binding.gyp file like so:

...
          "conditions": [
            [
              "target_arch=='ia32'", {
                "variables": {
                  "openssl_config_path": "/private/etc/ssl/openssl.cnf"
                }
              }
            ],
            [
              "target_arch=='x64'", {
                "variables": {
                  "openssl_config_path": "/private/etc/ssl/openssl.cnf"
                },
              }
            ],
            [
              "target_arch=='arm'", {
                "variables": {
                  "openssl_config_path": "/private/etc/ssl/openssl.cnf"
                }
              }
            ],
          ],
...

But still have the same error:
gyp: Undefined variable openssl_config_path in binding.gyp while trying to load binding.gyp when running npm i

Any hints?

@JackAugust
Copy link

Thanks @joshuarossi for eccrypto.
And I will give a simple way to call secp256k1 by re-install secp256k1 and ecdh under the directory of eccrypto
I first use this in my main.js by require("eccrypto") then showed this warning, and I re-installed the eccrypto by npm install eccrypto but it did not work. Then I chose to change the code of eccrypto/index.js:

...
try {
  var secp256k1 = require("secp256k1");
  var ecdh = require("ecdh");
}
....

Then just in ./node_modules/eccrypto to install secp256k1 and ecdh
It works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants