28 Commits

Author SHA1 Message Date
Thomas Eizinger
77149f08c4
fix(identity): correctly follow extract-expand for HKDF
As @mxinden pointed out in https://github.com/libp2p/rust-libp2p/pull/4554#discussion_r1344747938, we were not correctly following the HKDF steps of extract and expand.

Pull-Request: #4589.
2023-10-09 01:31:10 +00:00
Thomas Eizinger
ef1cd354d8
fix(identity): address clippy lint
Pull-Request: #4582.
2023-10-02 22:59:39 +00:00
João Oliveira
7f92cb0725
feat(quic): support stateless resets
Resolves #3419.

Pull-Request: #4554.
2023-10-02 00:28:32 +00:00
Thomas Eizinger
c6984dd51d
ci: do not tolerate rustc warnings in any job
Previously, only the clippy job was denying warnings. We have many other CI jobs that compile our library in all sorts of configurations. All of them should be free of warnings.

Pull-Request: #4384.
2023-08-25 10:14:01 +00:00
Thomas Eizinger
3bce9ebddf
refactor(identity): fix clippy beta lint
From the lint documentation:

> If both `PartialOrd` and `Ord` are implemented, they must agree. This is commonly done by wrapping the result of `cmp` in `Some` for `partial_cmp`. Not doing this may silently introduce an error upon refactoring.

Pull-Request: #4379.
2023-08-24 06:01:19 +00:00
João Oliveira
fb61697390
deps(identity): update ed25519-dalek to 2.0
Pull-Request: #4337.
2023-08-18 10:03:22 +02:00
João Oliveira
ceccb8e9c0
chore: fix clippy
Pull-Request: #4267.
2023-07-31 05:53:53 +00:00
Max Inden
5499333ff3
fix(identity): use test fixture for ed25519
Use test fixture from https://github.com/libp2p/specs/pull/537/ for ed25519 roundtrip test.

Pull-Request: #4228.
2023-07-29 19:56:11 +00:00
Max Inden
7f2ef013a8
feat(identity): implement from_protobuf_encoding for RSA keys
Add support for reading a libp2p RSA keypair from a Protobuf.

Pull-Request: #4193.
2023-07-24 19:03:04 +00:00
Nick
78510ede84
feat(identity): expose KeyType for PublicKey and Keypair
Resolves https://github.com/libp2p/rust-libp2p/issues/3649.

Pull-Request: #4107.


  
Co-Authored-By: Nick Pavlov <gurinderu@gmail.com>
  

  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-26 17:53:23 +00:00
Thomas Coratger
4532302917
refactor(identity): fix import warnings in keypair.rs
- Adding conditional `cfg` in `keypair.rs` imports.
- Adding `#[allow(unused_variables)]` on the top of the `sign` function.

Pull-Request: #4047.
2023-06-08 09:27:33 +00:00
Thomas Eizinger
0db9937ee5
feat: remove multiaddr dependency from libp2p-identity
Related: https://github.com/multiformats/rust-multiaddr/issues/73.
Depends-On: https://github.com/libp2p/rust-libp2p/pull/3514.

Pull-Request: #3656.
2023-06-06 17:27:13 +00:00
Max Inden
4fdd83e42f
fix(identity): remove unused file secp256r1.pk8
Introduced in https://github.com/libp2p/rust-libp2p/pull/3863/.

Pull-Request: #3950.
2023-05-16 05:31:30 +00:00
Thomas Coratger
3cc6c7e080
feat(identity): remove deprecated items
Related: https://github.com/libp2p/rust-libp2p/issues/3647.

Pull-Request: #3928.
2023-05-15 11:39:54 +00:00
Thomas Eizinger
25958a2f8c
feat(identity): make secp256k1::SecretKey::sign infallible
Previously, this function would return an error in case the provided digest is not of 32 bytes long. As per our [spec](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#secp256k1), we hash _all_ messages with SHA256 before signing, thus this error can never happen in practice.

This brings us one step closer to an infallible `Keypair::sign` which is now only fallible due to RSA signing. If we manage to fix that as well, constructors like `noise::Config::new` will become infallible.

Pull-Request: #3850.
2023-05-12 02:43:14 +00:00
Thomas Coratger
14938043cf
feat(identity): make Keypair and Publickey opaque
`Keypair` and `Publickey` are rendered opaque:
- `Keypair` is replaced by a private `KeyPairInner` enum that is encapsulated inside the `Keypair` `pub struct`
- `Publickey` is replaced by a private `PublickeyInner` enum that is encapsulated inside the `Publickey` `pub struct`

Resolves #3860.

Pull-Request: #3866.
2023-05-05 20:17:47 +00:00
DrHuangMHT
b8411d173f
feat(identity): allow importing and exporting secp256k1 keys
Related: #3681

Pull-Request: #3887.
2023-05-05 13:17:46 +00:00
DrHuangMHT
1eb929b38a
feat(identity): allow importing and exporting ECDSA keys
Implement encoding to/decoding from DER-encoded secret key document for `ecdsa::SecretKey`.
Implement encoding to/decoding from protobuf format for ECDSA keys.
Bump dependency `p256` from 0.12 to 0.13.
Bump dependency `sec1` from 0.3.0 to 0.7

Related: #3681.

Pull-Request: #3863.
2023-05-04 18:36:05 +00:00
Thomas Eizinger
d1fadc592d
fix(identity): handle warnings related to feature flags
Some of the feature-flags weren't set correctly and thus produced warnings for unused code. We can fix this by using absolute paths instead of imports and allow `dead_code` for the error constructor. It might be possible to write a correct `cfg` for this as well but I think it will be very verbose, hence I didn't bother.

Pull-Request: #3859.
2023-05-01 14:10:37 +00:00
Thomas Eizinger
135942d319
chore: enforce unreachable_pub lint
The `unreachable_pub` lint makes us aware of uses of `pub` that are not actually reachable from the crate root. This is considered good because it means reading a `pub` somewhere means it is actually public API. Some of our crates are quite large and keeping their entire API surface in your head is difficult.

We should strive for most items being `pub(crate)`. This lint helps us enforce that.

Pull-Request: #3735.
2023-04-26 07:31:56 +00:00
Thomas Coratger
13623b2da7
fix(identity): build with all features on docs.rs
Resolves #3810.

Pull-Request: #3828.
2023-04-25 14:06:54 +00:00
Doug A
e6f9d49109
fix(identity): add From & Into for public keys
This patch removes the `version 0.2.0` for deprecations as libp2p-identity is only at `0.1.1` and this can be confusing to the reader.

It also adds `impl From<ed25519::PublicKey> for PublicKey` (et al.) so that `PublicKey::from(ed25519::PublicKey)` works.

Fixes https://github.com/libp2p/rust-libp2p/issues/3802.

Pull-Request: #3805.
2023-04-22 10:16:58 +00:00
DrHuangMHT
058c2d85ec
refactor(identity): follow naming conventions for conversion methods
This PR renames some method names that don't follow Rust naming conventions or behave differently from what the name suggests:
- Enforce "try" prefix on all methods that return `Result`.
- Enforce "encode" method name for methods that return encoded bytes.
- Enforce "to_bytes" method name for methods that return raw bytes.
- Enforce "decode" method name for methods that convert encoded key.
- Enforce "from_bytes" method name for methods that convert raw bytes.

Pull-Request: #3775.
2023-04-14 08:55:13 +00:00
Thomas Eizinger
6b6187bd1c
fix(identity): remove prost dependency
Pull-Request: #3713.
2023-04-09 15:48:43 +00:00
Thomas Eizinger
dfa7bd6b57
refactor: don't depend on multihash features
All we need from the multihash is for it to be a data structure that we pass around. We only ever use the identity "hasher" and the sha256 hasher. Those are easily implemented without depending the (fairly heavy) machinery in `multihash`.

Unfortunately, this patch by itself does not yet lighten our dependency tree because `multiaddr` activates those features unconditionally. I opened a companion PR for this: https://github.com/multiformats/rust-multiaddr/pull/77.

https://github.com/multiformats/rust-multiaddr/pull/77 is another breaking change and we are trying to delay those at the moment. However, it will (hopefully) land eventually which should then be much easier to implement.

Fixes #3276.

Pull-Request: #3514.
2023-03-30 17:47:35 +00:00
Thomas Eizinger
75f967f4da
refactor(identity): leverage Copy impl for ed25519 public key
No need for function calls to `to_bytes` and `from_bytes` if the type is `Copy`.

Related: #3649.

Pull-Request: #3706.
2023-03-30 11:07:37 +00:00
creativcoder
14292c4758
feat(identity): add From impls for specific keypair types
Closes #3618.

Pull-Request: #3626.
2023-03-16 16:10:54 +00:00
Thomas Eizinger
2a14df25eb
feat: introduce libp2p-identity crate
This patch combines the `libp2p_core::identity` and `libp2p_core::peer_id` modules into a new crate: `libp2p-identity`.

Resolves https://github.com/libp2p/rust-libp2p/issues/3349.

Pull-Request: #3350.
2023-03-12 15:46:58 +01:00