Skip to content

Commit

Permalink
feat: expose more did:key-related functionality (#66)
Browse files Browse the repository at this point in the history
* Update deps, use ssi crates in teddybear-did-key

* Expose more did:key-related functions
  • Loading branch information
ivan770 authored Aug 19, 2024
1 parent 4453cce commit 73428b4
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 127 deletions.
76 changes: 39 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions crates/teddybear-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use ssi_jwk::{Algorithm, Params};
use ssi_jws::{
decode_jws_parts, decode_verify, encode_sign_custom_header, split_jws, verify_bytes, Header,
};
use ssi_security::MultibaseBuf;
use ssi_verification_methods::{
ControllerError, ControllerProvider, GenericVerificationMethod, InvalidVerificationMethod,
ProofPurpose,
Expand Down Expand Up @@ -269,6 +270,10 @@ impl PrivateEd25519 {
DIDKey.generate(&self.inner.verifying_key())
}

pub fn to_did_key_url_fragment(&self) -> MultibaseBuf {
DIDKey.generate_ed25519_fragment(&self.inner.verifying_key())
}

pub fn to_verification_method(
&self,
id: IriBuf,
Expand Down Expand Up @@ -306,6 +311,10 @@ impl PrivateX25519 {
JWK::from(Params::OKP(self.inner.encode_okp()))
}

pub fn to_did_key_url_fragment(&self) -> MultibaseBuf {
DIDKey.generate_x25519_fragment(&x25519_dalek::PublicKey::from(&self.inner))
}

pub fn to_verification_method(
&self,
id: IriBuf,
Expand Down
4 changes: 3 additions & 1 deletion crates/teddybear-did-key/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ categories.workspace = true

[dependencies]
ssi-dids-core = { workspace = true }
ssi-multicodec = { workspace = true }
ssi-security = { workspace = true }

ed25519-dalek = { workspace = true }
iref = { workspace = true }
multibase = { workspace = true }
serde_json = { workspace = true }
static-iref = { workspace = true }
x25519-dalek = { workspace = true }
Loading

0 comments on commit 73428b4

Please sign in to comment.