DIDPeer

Struct DIDPeer 

Source
pub struct DIDPeer;

Implementations§

Source§

impl DIDPeer

Source

pub async fn resolve(&self, did: &str) -> Result<Document, DIDPeerError>

Source§

impl DIDPeer

Source

pub fn create_peer_did( keys: &Vec<DIDPeerCreateKeys>, services: Option<&Vec<DIDPeerService>>, ) -> Result<(String, Vec<DIDPeerCreatedKeys>), DIDPeerError>

Creates a new did:peer DID

This will preserve the order of the keys and services in creating the did:peer string

§Examples

// Create a did:peer with pre-existing encryption key (Multibase base58-btc e.g: z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK)
let keys = vec![DIDPeerCreateKeys {
    type_: Some(DIDPeerKeyType::Ed25519),
    purpose: DIDPeerKeys::Encryption,
    public_key_multibase: Some("z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK".into()),
}];
let did_peer = DIDPeer::create_peer_did(&keys, None).expect("Failed to create did:peer");

// Create a random did:peer with services
let keys = vec![DIDPeerCreateKeys {
   type_: Some(DIDPeerKeyType::Secp256k1),
   purpose: DIDPeerKeys::Encryption,
   public_key_multibase: Some("z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK".into()),
 }];
let services: Vec<DIDPeerService> = vec![DIDPeerService {
   _type: "dm".into(),
   id: None,
   service_end_point: PeerServiceEndPoint::Long(PeerServiceEndPointLong {
       uri: "http://example.com/didcomm".into(),
       accept: vec!["didcomm/v2".into()],
       routing_keys: vec!["did:example:123456789abcdefghi#key-1".into()],
   }),
}];

let did_peer =
   DIDPeer::create_peer_did(&keys, Some(&services)).expect("Failed to create did:peer");

// How to create a key prior to creating a did:peer
let did =
    DIDKey::generate(&JWK::generate_ed25519().unwrap()).expect("Failed to create did:key");

let keys = vec![DIDPeerCreateKeys {
    type_: Some(DIDPeerKeyType::Ed25519),
    purpose: DIDPeerKeys::Verification,
    public_key_multibase: Some(did[8..].to_string()),
}];

let did_peer = DIDPeer::create_peer_did(&keys, None).expect("Failed to create did:peer");
Source

pub async fn expand_keys(doc: &Document) -> Result<Document, DIDPeerError>

Expands an existing DID Document from the did:key Multikeys to full JWT keys This is useful for when you want to resolve a did:peer DID Document to a full JWT included DID Document Converts base58 multi-keys to full JWTs in verificationMethod

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,