-
Notifications
You must be signed in to change notification settings - Fork 31
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
WIP: secp256k1 DHKEM #52
base: main
Are you sure you want to change the base?
Conversation
Cargo.toml
Outdated
# Include serde Serialize/Deserialize impls for all relevant types | ||
serde_impls = ["serde", "generic-array/serde"] | ||
serde_impls = ["dep:serde", "generic-array/serde", "x25519-dalek?/serde", "p256?/serde", "p384?/serde", "k256?/serde", "p256?/pkcs8", "p384?/pkcs8", "k256?/pkcs8"] |
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 pkcs8
is possibly necessary because Serialize
is only impld for curves which are AssociatedOid
, which is only impld when pkcs8
is enabled.
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.
Yep, the serde serializers use SPKI as the serialization format for public keys, which needs the pkcs8
feature.
I suppose it could be better documented.
Thanks for developing this crate and being so on top of this new addition. I'm developing some software that uses HPKE and OHTTP in bitcoin contexts where the Are there other production efforts wishing to use the |
@DanGould the main advantages of |
232540f
to
469dd34
Compare
@kwantam just rebased on You probably can't push to this branch, so feel free to fork it and make a new PR when you're ready. |
Should probably also rename the macro: diff --git a/src/dhkex/ecdh_nist.rs b/src/dhkex/ecdh_nist.rs
index c2702e0..36df025 100644
--- a/src/dhkex/ecdh_nist.rs
+++ b/src/dhkex/ecdh_nist.rs
@@ -1,5 +1,5 @@
// We define all the NIST P- curve ECDH functionalities in one macro
-macro_rules! nistp_dhkex {
+macro_rules! nist_dhkex {
(
$curve_name:expr,
$dh_name:ident,
@@ -238,7 +238,7 @@ macro_rules! nistp_dhkex {
use generic_array::typenum;
#[cfg(feature = "p256")]
-nistp_dhkex!(
+nist_dhkex!(
"P-256",
DhP256,
p256,
@@ -249,7 +249,7 @@ nistp_dhkex!(
);
#[cfg(feature = "p384")]
-nistp_dhkex!(
+nist_dhkex!(
"P-384",
DhP384,
p384,
@@ -260,7 +260,7 @@ nistp_dhkex!(
);
#[cfg(feature = "k256")]
-nistp_dhkex!(
+nist_dhkex!(
"K-256",
DhK256,
k256, |
I was able to rebase on main, come up with some test vectors, and take Carl's macro naming advice in #59 which appears to pass tests for k256 now. |
Started working on this and immediately hit a snag I can't figure out. The following fails
cargo check --no-default-features --features "k256,serde_impls"
with the error
However,
PublicKey
does implement these traits.So it seems like a dependency version issue, right? Nope. The version of
serde
is consistently v1.0.190 throughout the dep tree (output ofcargo tree --no-default-features --features "k256,serde_impls"
).Even weirder, replacing the
k256
feature withp256
in thecago check
makes the problem go away entirely, despite the fact that those crates have the same deps and the same source of serde impls!Curious if I'm missing anything. Maybe @tarcieri has a quick solution. Otherwise, I'll have to spend more time on this. Also help welcome from @kwantam if you wanna use this as a jumping off point for #50 .