-
Notifications
You must be signed in to change notification settings - Fork 3
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
provider record encryption #3
base: noot/prefix-lookup
Are you sure you want to change the base?
Conversation
…ad-dht into noot/provider-encrypt
pb/dht.pb.go
Outdated
// signature of the provided key + encrypted peer ID for ADD_PROVIDER messages | ||
Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` | ||
// public key of the peer for ADD_PROVIDER messages | ||
PublicKey *pb1.PublicKey `protobuf:"bytes,6,opt,name=publicKey,proto3" json:"publicKey,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the public key required in the message's content?
If we only want peers to publish content that they provide themselves, then this is not required. The public key can be derived from the peerID. However, it is useful in the case we want to allow peers to publish content that they do not provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, is it possible to derive the public key from the peer ID? I thought the peer ID was a hash of the public key, (https://github.com/libp2p/go-libp2p/blob/1ad0a50be62b1e00388b9d85fc997d66e8910c9d/core/peer/peer.go#L179) so I had to send the public key in the message to verify the signature.
…ad-dht into noot/provider-encrypt
"github.com/multiformats/go-multihash" | ||
) | ||
|
||
const ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to get these constants from somewhere where they are already defined instead of defining them again? This would help with code maintainability :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately the Go AES package doesn't define these :/ I'll try looking somewhere for them!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to get Nonce size from cipher.AEAD
interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
…ad-dht into noot/provider-encrypt
…ad-dht into noot/provider-encrypt
…ad-dht into noot/provider-encrypt
…ad-dht into noot/provider-encrypt
} | ||
|
||
ct := aesgcm.Seal(nil, nonce, plaintext, nil) | ||
return append(nonce, ct...), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need to append encryption algorithm here too so that the encryption function rotation doesn't require coordinated client update. I.e. for example AESGCM || nonce || enc(payload)
. That would also allow to have different encryption functions in the same DHT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, will add!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to add 6 bytes to every encrypted value. Can we use a varint as code for AESGSM, then update the spec to document it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@masih do you have a pointer to the AESGCM varint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we will have to define this mask ourselves and then document in the spec what that number means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. We'd need to define those in the spec ourselves.
This can also be a new multicodec. I recommend picking a varint that's not reserved already to have the option of adding it to the multicodec table later on.
ADD_PROVIDER
message, include signature of messagekey || encrypted peer ID
ADD_PROVIDER
message, verify this signatureProviderManager
to only deal with peer IDs, simplifies the code somewhat as it was only accepting peer IDs anyways