secret-stack icon indicating copy to clipboard operation
secret-stack copied to clipboard

docs — `seed` option

Open nichoth opened this issue 3 years ago • 4 comments

The tests show passing in an option seed to create --

var alice = create({ seed: seeds.alice })

https://github.com/ssb-js/secret-stack/blob/113efba0cfba73a6eebce8aa01b18d7d6ae5f3d2/test/server.js#L31

but I can't figure out what that is used for. Is it required?

nichoth avatar Feb 06 '22 20:02 nichoth

Hi @nichoth, I do not believe this is required, if it's present it gets used, if not, no big deal and it seems like it really appears mainly in tests tbh.

Looks like it gets added to the config and can be found at config.seed. it looks to be consumed by ssb-keys when generating a new keypair. check the docs for the generate method here: https://github.com/ssb-js/ssb-keys/blob/fa7a30f3f8a6895dead4bd9b43fba288894d48bc/README.md#L109

i think it also gets used when generating keys in the secret-handshake toKeys method: https://github.com/auditdrivencrypto/secret-handshake/blob/7a465d19f9c36fa2bb2cf6f4e5271bbd68d2cd74/crypto.js#L187

austinfrey avatar Feb 07 '22 16:02 austinfrey

thanks @austinfrey . So it is used to create the keys for ssb and also secret-handshake

nichoth avatar Feb 07 '22 17:02 nichoth

Although it looks like you do need to pass in something as config. I made an example repo showing how to use this -- https://github.com/nichoth/ss-example/blob/main/index.js#L29 -- and if you call it without the seed option it throws an error:

/Users/nick/code/ss-example/node_modules/separator-escape/index.js:36
        for(var i = 0; i < str.length; i++) {
                               ^

TypeError: Cannot read properties of undefined (reading 'length')

nichoth avatar Feb 07 '22 17:02 nichoth

@nichoth ~~correct, it can be an empty config object though I think: App({})~~

you might also try passing in keys App.({keys: ssbKey.loadOrCreate()})

  • edit: i think you can do seeds or keys: ssbKeys.generate() or something like that. it seems you need one or the other, can't be empty.

austinfrey avatar Feb 07 '22 21:02 austinfrey