amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.14k stars 1.17k forks source link

Public-key authentication #1147

Closed sberbom closed 3 years ago

sberbom commented 3 years ago

Hi,

I'm trying to understand the security measures of Gun. Due to its decentralized property there is obviously no central unit storing data, and no central unit storing or issuing security and cryptographic keying material. From the documentation of SEA it seems like a PKI is used to secure, encrypt and authenticate data. This raises the question on how to trust the authenticity of the public keys being used. With an centralized architecture, an central trusted unit is often used to sign the public keys proving their authenticity. With a decentralized architecture no such unit exists, and the use of distributed ledgers or web of trust seems to be applied solutions to this problem.

How do you solve this problem in Gun?

shocknet-justin commented 3 years ago

Cryptography doesn't need a centralized authority, anyone can generate a key and sign or encrypt something, anyone can cryptographically validate that signature with standard libraries, or decrypt it if they posses a key to do so.

sberbom commented 3 years ago

Yes I agree. The question is how do you trust the keys generated when there is not central trusted unit to sign them?

A user, userA, can generate his key pair and propagate his public key on the network. Then a second user, userB, can generate a new key pair and propagate the public key on the network claiming it belongs to userA. Then when I want to send a message to userA I will find two public keys. The one generated by userA, and the fake one generated by userB. Without a central trusted unit to sign the key I will have no way of knowing which key actually belong to userA and I may end up communicating with userB beliving it is user A.

Do I understand this correct or have I misunderstood something?

i001962 commented 3 years ago

Better place for questions like this is chat.gun.eco

shocknet-justin commented 3 years ago

There are no users perse, a user alias in gun is a name for a keypair.

Two keypairs with like aliases could exist, but they're still distinct keypairs. One couldn't sign/decrypt as the other.

In the case of duplicate aliases existing, the CRDT would let you sort to see which is the original based on when it was synchronized in. You may also want to introduce your own logic on user creation to prevent duplicates on the application side.

In any event, it's wise to address the users by their public key and not the alias.

amark commented 3 years ago

👏 @capitalistdog !!

Yeah, most apps just share it as https://app.com/#~pub.key no need to argue over "who". Names are not globally unique anyways. If you want to do something like that, more advanced apps like Iris use a Web of Trust as their "registry", so "Elon Musk" would still pull up a search result list, but the top hit would be the most trusted/attested of your friend-of-friends network.

I also explain this in the Twitter Bluesky proposal that's slowly moving forward: https://hackernoon.com/twitter-bluesky-a-decentralized-protocol-proposal-hi193337

Like Kevin said, let's continue this on the chat.. issues are meant for bugs. Closing!