30 Commits

Author SHA1 Message Date
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
Max Inden
59f073df82
chore(identity): remove "unreleased" from v0.2.0 changelog entry
Pull-Request: #4048.
2023-06-07 10:44:26 +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
dependabot[bot]
b73f7209c5
deps: bump bs58 from 0.4.0 to 0.5.0
Pull-Request: #3999.
2023-05-30 19:27:34 +00:00
dependabot[bot]
34e1780498
deps: bump criterion from 0.4.0 to 0.5.1
Pull-Request: #4002.
2023-05-30 02:06:57 +00:00
dependabot[bot]
c5dd0a2e14
deps: bump base64 from 0.21.0 to 0.21.2
Pull-Request: #3993.
2023-05-28 06:36:18 +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
996b5c8bd0
chore: leverage cargo's workspace inheritance
Previously, we would specify the version and path of our workspace dependencies in each of our crates. This is error prone as https://github.com/libp2p/rust-libp2p/pull/3658#discussion_r1153278072 for example shows. Problems like these happened in the past too.

There is no need for us to ever depend on a earlier version than the most current one in our crates. It thus makes sense that we manage this version in a single place.

Cargo supports a feature called "workspace inheritance" which allows us to share a dependency declaration across a workspace and inherit it with `{ workspace = true }`.

We do this for all our workspace dependencies and for the MSRV.

Resolves #3787.

Pull-Request: #3715.
2023-05-02 09:14:14 +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
Max Inden
2d9ae3800f
chore: prepare patch releases on top of v0.51.3
Note that this does not release v0.51.4, i.e. there is no patch release of the meta crate `libp2p`.

Pull-Request: #3854.
2023-05-01 02:56:32 +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
dependabot[bot]
06ea8cef7e
deps: bump asn1_der from 0.7.5 to 0.7.6
Pull-Request: #3752.
2023-04-10 15:40:51 +00:00
Thomas Eizinger
6b6187bd1c
fix(identity): remove prost dependency
Pull-Request: #3713.
2023-04-09 15:48:43 +00:00
dependabot[bot]
95fa913923
deps: bump multiaddr from 0.17.0 to 0.17.1
Pull-Request: #3688.
2023-04-04 13:38:53 +00:00
Max Inden
d7396706d0
fix(changelog): Make release heading levels consistent
See `##` for release headings everywhere. This is consistent with markdown conventions of one `#` per document and in line with https://keepachangelog.com/.

See report in https://github.com/libp2p/rust-libp2p/issues/3531.

Pull-Request: #3561.
2023-03-30 21:04:01 +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
dependabot[bot]
bd0459121f
deps: bump zeroize from 1.5.7 to 1.6.0
Pull-Request: #3685.
2023-03-29 12:07:18 +00:00
Thomas Eizinger
8f271caec3
chore(identity): prepare 0.1.1 release
As discussed in https://github.com/libp2p/rust-libp2p/pull/3626#pullrequestreview-1344657608.

Pull-Request: #3631.
2023-03-18 11:11:21 +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
hanabi1224
873a90edbd
fix(identity): remove prost-build from build deps
There's no `build.rs` and `build-dependency` is not needed

Pull-Request: #3619.
2023-03-16 09:55:42 +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