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

Use the correct name of the binary encoding selector #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cameel
Copy link

@cameel cameel commented Nov 18, 2020

The library currently calls hash.digest('bin') which crashes browserify-sha3.

hash is either the C implementation which comes from sha3 package (when available) or the JS one from browserify-sha3 otherwise. The latter clearly expects the value to be 'binary', not 'bin'. Same for sha3 but it's more lax and just assumes 'binary' when the encoding is not recognized.

I'm not sure how to write a test for this but I checked it manually and 'binary' works with both.

Error output

I got this in ethereum/solc-bin#40. Apparently sha3 must have failed to build in Travis and it fell back to browserify-sha3: https://travis-ci.org/github/ethereum/solc-bin/builds/744413140

Computing hashes of '/linux-amd64/solc-linux-amd64-v0.4.10+commit.f0d539ae'
/home/travis/build/ethereum/solc-bin/node_modules/browserify-sha3/index.js:32
    throw new Error('Unsupported encoding for digest: ' + encoding)
          ^

Error: Unsupported encoding for digest: bin
    at hash.digest (/home/travis/build/ethereum/solc-bin/node_modules/browserify-sha3/index.js:32:11)
    at swarmHashBlock (/home/travis/build/ethereum/solc-bin/node_modules/swarmhash/index.js:11:27)
    at swarmHash (/home/travis/build/ethereum/solc-bin/node_modules/swarmhash/index.js:18:12)
    at swarmHash (/home/travis/build/ethereum/solc-bin/node_modules/swarmhash/index.js:29:21)
    at swarmHash (/home/travis/build/ethereum/solc-bin/node_modules/swarmhash/index.js:29:21)
    at makeEntry (/home/travis/build/ethereum/solc-bin/update:143:19)
    at async /home/travis/build/ethereum/solc-bin/update:193:43
    at async Promise.all (index 0)
    at async /home/travis/build/ethereum/solc-bin/update:179:25

@axic axic force-pushed the fix-binary-encoding-selector branch from a5a40e5 to fed61b7 Compare November 7, 2021 23:41
@axic
Copy link
Owner

axic commented Nov 7, 2021

@cameel you're correct! Also found that I made another change which would make this "obsolete". It was stuck in a branch for 3 years, made it into a PR #5 now. Do you think we could just merge that?

@cameel
Copy link
Author

cameel commented Nov 8, 2021

Switching to an actively mainained package seems like a good idea. It would also probably resolve the issue with axic/keccakjs#13.

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

Successfully merging this pull request may close these issues.

2 participants