Re-export types from arithmetic module at toplevel#58
Conversation
This commit removes the `arithmetic` module from the public API of the `k256` and `p256` crates, re-exporting the `AffinePoint`, `ProjectivePoint`, and `Scalar` types from the crate's toplevel. Additionally, it moves the `test_vectors` module to the toplevel, gated under the `test-vectors` feature (or `cfg(test))`). To make it clear these types are available conditionally based on the `arithmetic` and `test-vectors` features, `doc_cfg` is used to tag them in rustdoc as rendered by https://docs.rs
5069911 to
fe4ef9b
Compare
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
=======================================
Coverage 80.66% 80.66%
=======================================
Files 12 12
Lines 1355 1355
=======================================
Hits 1093 1093
Misses 262 262
Continue to review full report at Codecov.
|
newpavlov
left a comment
There was a problem hiding this comment.
I am not familiar enough with code in this repository to properly review changes, but at the first glance it looks good to me.
|
What is the reasoning for arithmetic being a feature (crate is rather barren without, and the feature doesn't trigger additional dependencies AIUI)? My instinct would be to organize the library around modules field, point/curve, scalar, signature, agree, with randomness the core optional feature. That said, I do prefer your suggestion over status quo. A remark that perhaps doesn't quite fit here but seems relevant: For my microcontroller stuff, FieldElement newtypes [u32; 8] instead of [u64; 4], which impacts all the other types (and I deal with it via features that switch the entire type, not traits/generics). |
These crates are used in two different ways at the moment:
This includes things like:
With the types defined in the curve crates, it's possible to use trait objects as a common interface for representing various ECDSA providers. For example, in the Tendermint KMS project I work on: https://github.com/iqlusioninc/tmkms/blob/develop/src/keyring/ecdsa.rs#L24 ...we are able to support a libsecp256k1-based signer, Ledgers, and YubiHSM2s through a common keyring. Arguably we could remove the
I'd say for the most part it is, but large parts of it are under the
Some semi-related precedent for this is the field implementations in the https://github.com/RustCrypto/universal-hashes/tree/master/polyval/src/field Namely there are separate I believe |


This commit removes the
arithmeticmodule from the public API of thek256andp256crates, re-exporting theAffinePoint,ProjectivePoint, andScalartypes from the crate's toplevel.Additionally, it moves the
test_vectorsmodule to the toplevel, gated under thetest-vectorsfeature (orcfg(test))).To make it clear these types are available conditionally based on the
arithmeticandtest-vectorsfeatures,doc_cfgis used to tag them in rustdoc as rendered by https://docs.rs