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

generate() fails in electron #28

Closed
uiur opened this issue Sep 3, 2016 · 2 comments
Closed

generate() fails in electron #28

uiur opened this issue Sep 3, 2016 · 2 comments

Comments

@uiur
Copy link
Contributor

uiur commented Sep 3, 2016

electron: v1.2.8

ssbKeys.generate() throws an error in my electron environment.

Error: argument sd must be a buffer
    at Error (native)
    at Object.generate (/Users/zat/.ghq/github.com/uiureo/sonoba/node_modules/ssb-keys/sodium.js:13:30)
    at Object.exports.generate (/Users/zat/.ghq/github.com/uiureo/sonoba/node_modules/ssb-keys/index.js:78:37)
    at Object.<anonymous> (/Users/zat/.ghq/github.com/uiureo/sonoba/main.js:8:21)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at loadApplicationPackage (/Users/zat/.ghq/github.com/uiureo/sonoba/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/default_app.asar/main.js:257:12)

The problem is that sodium.randombytes(buffer) returns true in the electron environment.
This is weird because it returns null in node environment and works correctly.

seed = seed || sodium.randombytes(seed = new Buffer(32))
var keys = seed ? sodium.crypto_sign_seed_keypair(seed) : sodium.crypto_sign_keypair()

seed = seed || sodium.randombytes(seed = new Buffer(32))

I think that seed = seed || sodium.randombytes(seed = new Buffer(32)) is not necessary and removing this line resolves the issue.
But I don't understand well how it behaves in other environments.

@dominictarr
Copy link
Contributor

Thanks, fixed in ssb-keys@6.1.2
By the way, we are shifting development of ssb-* modules to use https://github.com/clehner/git-ssb
we'll still take pull requests via github, of course, but git-ssb is preferred.

@uiur
Copy link
Contributor Author

uiur commented Sep 5, 2016

Thanks! git-ssb looks nice.

@uiur uiur closed this as completed Mar 20, 2017
This issue was closed.
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

2 participants