ssbc / secret-stack

connect peers to each other using secret-handshakes
MIT License
90 stars 19 forks source link

docs — `seed` option #76

Open nichoth opened 2 years ago

nichoth commented 2 years ago

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?

austinfrey commented 2 years ago

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

nichoth commented 2 years ago

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

nichoth commented 2 years ago

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')
austinfrey commented 2 years ago

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

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