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

Hardhat's key derivation doesn't work with Node 17 #1988

Closed
gungunfebrianza opened this issue Oct 23, 2021 · 12 comments
Closed

Hardhat's key derivation doesn't work with Node 17 #1988

gungunfebrianza opened this issue Oct 23, 2021 · 12 comments
Labels
type:bug Something isn't working

Comments

@gungunfebrianza
Copy link

Hello, just install hardhat on my local project, windows os version 10.
Iam trying to run task hardhat accounts and getting this errors :

An unexpected error occurred:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at hash160 (F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\ethereum-cryptography\vendor\hdkey-without-crypto.js:249:21)
    at HDKey.set (F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\ethereum-cryptography\vendor\hdkey-without-crypto.js:50:24)
    at Function.HDKey.fromMasterSeed (F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\ethereum-cryptography\vendor\hdkey-without-crypto.js:194:20)
    at Object.deriveKeyFromMnemonicAndPath (F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\hardhat\src\internal\util\keys-derivation.ts:21:27)
    at derivePrivateKeys (F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\hardhat\src\internal\core\providers\util.ts:29:24)
    at Object.normalizeHardhatNetworkAccountsConfig (F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\hardhat\src\internal\core\providers\util.ts:56:10)     
    at Object.createProvider (F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\hardhat\src\internal\core\providers\construction.ts:75:22)
    at F:\ROXI-Repositories\ROXI Company\Roxi Token Development\hardhat-1\node_modules\hardhat\src\internal\core\runtime-environment.ts:80:14 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Here is my actual devDependencies :

  "devDependencies": {
    "@nomiclabs/hardhat-ethers": "^2.0.2",
    "@nomiclabs/hardhat-waffle": "^2.0.1",
    "chai": "^4.3.4",
    "ethereum-waffle": "^3.4.0",
    "ethers": "^5.5.1",
    "hardhat": "^2.6.7"
  }

thanks you

@alcuadrado
Copy link
Member

Are you using node 17?

If so, please try downgrading it.

For an explanation of what's going on, please take a look at this: https://medium.com/the-node-js-collection/node-js-17-is-here-8dba1e14e382#5f07

@alcuadrado alcuadrado added package:hardhat-core type:bug Something isn't working labels Oct 23, 2021
@alcuadrado alcuadrado changed the title NPX hardhat accounts Failure Hardhat's key derivation doesn't work with Node 17 Oct 23, 2021
@gungunfebrianza
Copy link
Author

yes i am using v17.0.1, okay i will try. thank you
will update you soon

@tldrs
Copy link

tldrs commented Nov 1, 2021

try using node 14 it works best or just install WSL2 Ubuntu or any Linux distro on your machine if you hit more config problems.

@rickstaa
Copy link

The workarround for this is to set the following environmental variable:

export NODE_OPTIONS=--openssl-legacy-provider

@wulymammoth
Copy link

wulymammoth commented Jan 6, 2022

remains an issue when that option is set with node 17.3.0

$ npx hardhat accounts
An unexpected error occurred:

Error: error:0308010C:digital envelope routines::unsupported
│ │ at new Hash (node:internal/crypto/hash:67:19)
│ │ at Object.createHash (node:crypto:130:10)
│ │ at hash160 (~/Desktop/crypto/hardhat-quickstart/node_modules/ethereum-cryptography/vendor/hdkey-without-crypto.js:249:21)
│ │ at HDKey.set (~/Desktop/crypto/hardhat-quickstart/node_modules/ethereum-cryptography/vendor/hdkey-without-crypto.js:50:24)
│ │ at Function.HDKey.fromMasterSeed (~/Desktop/crypto/hardhat-quickstart/node_modules/ethereum-cryptography/vendor/hdkey-without-crypto.js:194:20)
│ │ at deriveKeyFromMnemonicAndPath (~/Desktop/crypto/hardhat-quickstart/node_modules/hardhat/src/internal/util/keys-derivation.ts:21:27)
│ │ at derivePrivateKeys (~/Desktop/crypto/hardhat-quickstart/node_modules/hardhat/src/internal/core/providers/util.ts:29:52)
│ │ at normalizeHardhatNetworkAccountsConfig (~/Desktop/crypto/hardhat-quickstart/node_modules/hardhat/src/internal/core/providers/util.ts:56:10)
│ │ at createProvider (~/Desktop/crypto/hardhat-quickstart/node_modules/hardhat/src/internal/core/providers/construction.ts:78:59)
│ │ at ~/Desktop/crypto/hardhat-quickstart/node_modules/hardhat/src/internal/core/runtime-environment.ts:80:28 {
│ opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
│ library: 'digital envelope routines',
│ reason: 'unsupported',
│ code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

$ node -v
v17.3.0

$ echo $NODE_OPTIONS
--openssl-legacy-provider

I use asdf to manage my node versions and I tried every 17.x.x version and it wasn't until I went down to LTS v16.13.1 before this worked. For those in my situation, if you're going to use an older (long term support) version of node, remember to remove the --openssl-legacy-provider option in your NODE_OPTIONS environment variable

@OCWC22
Copy link

OCWC22 commented Jan 13, 2022

Will Hardhat work to make node 17+ be compatible?

@cruzdanilo
Copy link

please, upgrade ethereum-cryptography

https://github.com/ethereum/js-ethereum-cryptography#upgrading

@feuGeneA
Copy link
Contributor

The fix for this (upgrading ethereum-cryptography) has been implemented in this PR: #2705

@pedjaaaaa
Copy link

opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'

% node -v
v16.15.0

I initial downgrade hardhat from node 17 to 16.5.0 and it worked for a while. Recently it completely broke on me. Not sure whats gonig on.

@github-actions
Copy link
Contributor

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added Stale and removed Stale labels Jul 15, 2022
@albatros-github
Copy link

greetings!

I have the same issue and being working with a technology (blockchain) that its heart and core is cryptography and being using a tool that doesn't worry to be working with an outdated cryptographyc "framework" / algorithms seems pretty concerning to me

*Just like openssl points:
https://www.openssl.org/docs/manmaster/man7/OSSL_PROVIDER-legacy.html

_**"The OpenSSL legacy provider supplies OpenSSL implementations of algorithms that have been deemed legacy. Such algorithms have commonly fallen out of use, have been deemed insecure by the cryptography community, or something similar.

We can consider this the retirement home of cryptographic algorithms.**_"

@github-actions github-actions bot added the Stale label Oct 3, 2022
@fvictorio
Copy link
Member

I'm going to close this one because node 17 has already reached end of life and, as far as I know, this works well with node 18.

If someone has some problem around this, please open a new issue with reproduction steps.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests