-
Notifications
You must be signed in to change notification settings - Fork 25
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
Generate and write public and private key using HPKE. #654
Conversation
These will be used to encrypt and decrypt match key shares
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 assume that this is only part of the whole. I don't see the use of these keys anywhere.
With that in mind, this is good, but I would avoid using Option<T>
for these. It will be easier if we retain a code path where possible.
src/config.rs
Outdated
@@ -96,13 +96,16 @@ pub struct PeerConfig { | |||
/// If a certificate is specified here, only the specified certificate will be accepted. The system | |||
/// truststore will not be used. | |||
pub certificate: Option<String>, | |||
|
|||
pub matchkey_encryption_key: Option<String>, |
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 won't be optional in practice, so maybe just make this a String
directly.
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.
Sounds good. Although do we need to pass the matchkey public key to the peers?
I think we should also add it to ServerConfig. Will do that
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.
The other peers won't need this, but it probably makes sense to reuse the same configuration (or at least a subset of it) for client configuration.
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.
Yes, I hope ServerConfig is the right place to put 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.
I think ServerConfig
indeed needs both the private key and the public key (in some formats, the private key is stored with a copy of the public key, but if we're just using raw bytes, that won't be the case).
I also think that the public key should go in NetworkConfig
(network.toml
). The idea is that network.toml
gets distributed to clients of the helper network. test_mpc
already takes an argument --network network.toml
, and the event generation stuff that @akoshelev is adding to it will soon (possibly immediately, if configuration/use of the report key is mandatory) need to support encrypting the reports.
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.
Within NetworkConfig we have a PeerConfig. Should we add a ClientConfig which will store the public key needed for encryption? There might be other information which would be needed to communicated to clients which can go there. @andyleiserson
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 think the public key could go directly in PeerConfig. The only significance that I had in mind for PeerConfig
was that it was a container for the configuration that needed to be replicated 3x for the helpers.
Another possibility is to represent the key information in the OHTTP key configuration format mentioned in https://github.com/patcg-individual-drafts/ipa/blob/main/details/encryption.md#helper-key-configuration, but that doesn't seem important to do right now, and even using that format I think we could nest it within PeerConfig.
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.
There are a few things in PeerConfig (e.g. port) which advertisers/publishers don't care about. I will move public_key inside PeerConfig and then we can see how it evolves. The other configuration stuff will be added as we implement decryption
…behind test-fixture feature
I agree that these aren't really optional, in the long term. There is a question of whether we want to support bypassing the match key encryption for some kinds of testing / protocol development work, like how we support HTTP for testing. Another issue that may come up is how the encryption interacts with the choice between
|
I think we should support bypassing encryption for now. |
src/config.rs
Outdated
@@ -167,24 +183,37 @@ pub struct ServerConfig { | |||
|
|||
/// TLS configuration for helper-to-helper communication | |||
pub tls: Option<TlsConfig>, | |||
|
|||
/// Configuration needed for encrypting and decrypting match keys | |||
pub matchkey_encryption_info: Option<MatchKeyEncryptionConfig>, |
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.
@andyleiserson I have stored public and private keys as optional as MatchKeyEncryptionConfig in ServerConfig. Lets leave it optional for now to support disabling encryption of match keys
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.
Added a flag in net/test.rs for disable_matchkey_encryption but not adding any test for that as yet. Will add it along with coding decryption handling of the reports
I resolved the merge conflicts with #653 and #647, you can pull the resolved version from the |
Thanks a lot for that! Will take a look |
* HPKE module encapsulates the actual encryption type we use and it should not be visible to the other modules. So now it exposes `KeyPair` type and serialization methods on it. That allows keygen not to worry about the actual encryption type used. * Rename HPKE encryption parameters to make it a bit easier to type and consistent with TLS arguments naming This is how `network.toml` looks like ```toml [client.http_config] version = "http2" [[peers]] certificate = """ -----BEGIN CERTIFICATE----- MIIBZTCCAQugAwIBAgIIbSvJ07OOLJwwCgYIKoZIzj0EAwIwFDESMBAGA1UEAwwJ bG9jYWxob3N0MB4XDTIzMDUyNDE4MzMyOVoXDTIzMDgyMzE4MzMyOVowFDESMBAG A1UEAwwJbG9jYWxob3N0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1hGZwFS6 gMHLsyzKK6voi4sNCMuhyAUkeib8PgDE8Sw1r5hAkuOd582gXaO3hske2NAbx1DB PFNX64l06N2vHqNHMEUwFAYDVR0RBA0wC4IJbG9jYWxob3N0MA4GA1UdDwEB/wQE AwICpDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwCgYIKoZIzj0EAwID SAAwRQIgJzHHbPDNcyA0qeTvX3k6PB7Ecapr4xI8zkn4T/Njyb8CIQDA+IB5QBgI JlilqZIGGNpVqMXBgVK/KdaxurK/NqgJsA== -----END CERTIFICATE----- """ url = "localhost:51126" [peers.hpke] public_key = "5c0376ff2746767deb791219c0853325b49301081a009bcc133582ae8ee24e22" ```
@richajaindce I made some small changes, lmk what you think, if you are ok with these, we probably can push it |
The changes look great!! Thanks for them. Lets ship it! |
These will be used to encrypt and decrypt match key shares