Most (all?) of the RustCrypto crates re-export other RustCrypto crates that are used which allows one to not have to directly depend on said crates which in turn ensures compatibility issues won't arise either. For example, p256 re-exports elliptic_curve::pkcs8—this isn't even necessary since elliptic_curve is also re-exported which re-exports pkcs8, but it does make accessing it easier and more obvious.
I would like to access EncodePublicKey since it's a trait implemented by some of the types in ml-dsa. Unless there is something I'm missing (e.g., I tried traversing the re-exported signature, and I couldn't find a way to access that trait), could pkcs8 be re-exported?
use ::ml_dsa::{MlDsa44, VerifyingKey, signature::digest::array::Array};
// This is required, but there is no way to access this via `ml_dsa` requiring one to directly depend on
// `pkcs8` which opens up the possibility of SemVer issues.
use ::pkcs8::EncodePublicKey as _;
fn foo() {
assert_eq!(
VerifyingKey::<MlDsa44>::decode(&Array([0; 1312]))
.to_public_key_der()
.map(|doc| <[u8; 1312 + 22]>::try_from(doc.as_bytes())
.unwrap_or_else(|_e| unreachable!("bug!"))),
Ok({
let mut data = [0; 1312 + 22];
data[..21].copy_from_slice(&[
48, 130, 5, 50, 48, 11, 6, 9, 96, 134, 72, 1, 101, 3, 4, 3, 17, 3, 130, 5, 33,
]);
data
})
);
}
Most (all?) of the RustCrypto crates re-export other RustCrypto crates that are used which allows one to not have to directly depend on said crates which in turn ensures compatibility issues won't arise either. For example,
p256re-exportselliptic_curve::pkcs8—this isn't even necessary sinceelliptic_curveis also re-exported which re-exportspkcs8, but it does make accessing it easier and more obvious.I would like to access
EncodePublicKeysince it's atraitimplemented by some of the types inml-dsa. Unless there is something I'm missing (e.g., I tried traversing the re-exportedsignature, and I couldn't find a way to access thattrait), couldpkcs8be re-exported?