RangerMauve / hyper-sdk

Make your own hyper apps!
https://www.youtube.com/watch?v=HyHk4aImd_I&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=20
MIT License
291 stars 46 forks source link

Reuse existing identity on new node #75

Closed fmsouza closed 3 years ago

fmsouza commented 3 years ago

I looked around the docs and issues list for a way to reuse an existing secret key on the SDK startup, but found nothing. Is it possible? And if so, how to do it?

Use case for that would be using the same identity while accessing your data on the network in different devices. Imagine a Dat based "Twitter". I want to post from several different devices (computer, phone, etc.) but using the same identity, so I won't need to have a separate feed of things I posted for each device I am using.

DougAnderson444 commented 3 years ago

@fmsouza Fred, I believe this is in reference to the infamous multi-writer question. The Noise key in your pull request is based on the hypercore's master-key, which will be different for every device and will likely break the SDK dramatically if implemented. Imagine two noise peers with the same keypair... they can't have the same identity

There are a few ways to do multiwriter but not with this dat-sdk:

For example, I used kappa-multifeed to build HyPNS to pin identity and data in a bigger project I'm working on.

Hope that helps

fmsouza commented 3 years ago

Hello @DougAnderson444! Thank you very much for your response.

I read mentions about the multi-writer problem in a few discussions around hyperdrive and Dat protocol, but wasn't sure if it had anything to do with this problem I'm mentioning.

So basically what I understood from what you said is your networking identity on Dat is strictly coupled to the device you are using for access, right? So if I want to use the device as a way to access the network, but want to have a different identity, there'd need to be a second layer of identity management which would handle all the operations you'd be required to modify the contents from other nodes. Right?

But since the key is coupled to the device and I cannot change it, sounds like I cannot even create a sort of shared key which would allow me write to a node's directory from another one.

Sounds like I need to educate myself a bit more about it. Thanks for your guidance in this case, you helped a lot!

DougAnderson444 commented 3 years ago

Yes I think you're on the right track.

In hypercore, everything is in an immutable "append-only log" writable by that device only. There is no "write on one node from another node" yet. Although there are mounts and kappa structures, which do address the issue, but as high layer solutions.

RangerMauve commented 3 years ago

I do multi-writer hyperdrive using https://github.com/RangerMauve/co-hyperdrive

It's being used in the Natakanu app.

Regarding re-using keys, there's a master key that gets used to derive the identity and all the named drives. You can pass this into the corestoreOpts, an example of which can be found here: https://github.com/RangerMauve/hyperdrive-publisher/blob/default/index.js#L238

RangerMauve commented 3 years ago

Re-using the key should only be done for restoring form backups since you'll end up forking your feed history otherwise. 😅