decentralized-identity / decentralized-identity/web5-rs
Consider standardizing all key representations to `Jwk` & remove `PrivateKey`, `PublicKey`, and `Key` traits
- Dominant language
- Kotlin
- Stars
- 19
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
Currently we have three traits:
```rust
pub trait Key: Send + Sync {
fn alias(&self) -> Result;
fn jwk(&self) -> Result, KeyError>;
}
pub trait PublicKey: Key + Send + Sync {
fn verify(&self, payload: &[u8], signature: &[u8]) -> Result<(), KeyError>;
}
pub trait PrivateKey: Key + Send + Sync {
fn to_public(&self) -> Result, KeyError>;
fn sign(&self, payload: &[u8]) -> Result, KeyError>;
}
```
These traits are all object safe so they can be dynamically dispatched, namely `PublicKey` and `PrivateKey` (for example, see the `KeyManager` trait). The idea being that we want to enable key managers which don't represent keys as JWK data structures.
However, the idea that key managers don't have to represent keys as JWK's is incompatible with our current DID strategy. We currently [require `publicKeyJwk` in our _Verification Method Data Model_](https://github.com/TBD54566975/web5-spec/blob/main/spec/did.md#verification-method-data-model).
If we remove these traits and standardize our approach to only JWK as the required representation, then we disable our ability to support DID key representations as `publicKeyMultibase` ([spec](https://www.w3.org/TR/did-core/#dfn-publickeymultibase)).
If we can safely assume we will never support `publicKeyMultibase` then we can reduce unnecessary abstraction and the downstream overhead with our binding initiatives.
Contributor guide
Assessment
This issue has not been assessed yet.