pub struct IotaDocument {
    pub metadata: IotaDocumentMetadata,
    pub proof: Option<Proof>,
    /* private fields */
}
Expand description

A DID Document adhering to the IOTA DID method specification.

This extends CoreDocument.

Fields

metadata: IotaDocumentMetadataproof: Option<Proof>

Implementations

Creates a new DID Document from the given KeyPair.

The DID Document will be pre-populated with a single verification method derived from the provided KeyPair embedded as a capability invocation verification relationship. This method will have the DID URL fragment #sign-0 and can be easily retrieved with IotaDocument::default_signing_method.

NOTE: the generated document is unsigned, see IotaDocument::sign_self.

Example:

// Create a DID Document from a new Ed25519 keypair.
let keypair = KeyPair::new(KeyType::Ed25519).unwrap();
let document = IotaDocument::new(&keypair).unwrap();

Creates a new DID Document from the given KeyPair, network, and verification method fragment name.

See IotaDocument::new.

Arguments:

  • keypair: the initial verification method is derived from the public key of this KeyPair.
  • network: Tangle network to use for the DID; default Network::Mainnet.
  • fragment: name of the initial verification method; default DEFAULT_METHOD_FRAGMENT.

Example:

// Create a new DID Document for the devnet from a new Ed25519 keypair.
let keypair = KeyPair::new(KeyType::Ed25519).unwrap();
let document = IotaDocument::new_with_options(&keypair, Some(Network::Devnet.name()), Some("auth-key")).unwrap();
assert_eq!(document.id().network_str(), "dev");
assert_eq!(
  document.default_signing_method().unwrap().id().fragment().unwrap(),
  "auth-key"
);

Creates a new DID Document from the given IotaVerificationMethod, inserting it as the default capability invocation method.

NOTE: the generated document is unsigned, see IotaDocument::sign_self.

Returns whether the given MethodType can be used to sign document updates.

Returns a reference to the underlying IotaCoreDocument.

Returns a mutable reference to the underlying IotaCoreDocument.

Returns the DID document id.

Returns a reference to the IotaDocument controllers.

Returns a mutable reference to the IotaDocument controllers.

Returns a reference to the IotaDocument alsoKnownAs set.

Returns a mutable reference to the IotaDocument alsoKnownAs set.

Returns the first IotaVerificationMethod with a capability invocation relationship capable of signing this DID document.

Returns a reference to the custom DID Document properties.

Returns a mutable reference to the custom DID Document properties.

Return a set of all Services in the document.

Add a new IotaService to the document.

Returns true if the service was added.

Remove a IotaService identified by the given IotaDIDUrl from the document.

Returns true if a service was removed.

Returns an iterator over all IotaVerificationMethods in the DID Document.

Adds a new IotaVerificationMethod to the document in the given MethodScope.

Errors

Returns an error if a method with the same fragment already exists.

Removes all references to the specified VerificationMethod.

Errors

Returns an error if the method does not exist.

Attaches the relationship to the given method, if the method exists.

Note: The method needs to be in the set of verification methods, so it cannot be an embedded one.

Detaches the given relationship from the given method, if the method exists.

Returns the first IotaVerificationMethod with an id property matching the provided query and the verification relationship specified by scope if present.

Returns the first IotaVerificationMethod with an id property matching the provided query and the verification relationship specified by scope if present.

WARNING: improper usage of this allows violating the uniqueness of the verification method sets.

Attempts to resolve the given method query into a method capable of signing a document update.

Creates a new DocumentSigner that can be used to create digital signatures from verification methods in this DID Document.

Signs the provided data with the verification method specified by method_query. See IotaDocument::signer for creating signatures with a builder pattern.

NOTE: does not validate whether private_key corresponds to the verification method. See IotaDocument::verify_data.

Errors

Fails if an unsupported verification method is used, data serialization fails, or the signature operation fails.

Signs this DID document with the verification method specified by method_query. The method_query may be the full IotaDIDUrl of the method or just its fragment, e.g. “#sign-0”. The signing method must have a capability invocation verification relationship.

NOTE: does not validate whether private_key corresponds to the verification method. See IotaDocument::verify_document.

Errors

Fails if an unsupported verification method is used or the signature operation fails.

Verifies the signature of the provided data was created using a verification method in this DID Document.

Errors

Fails if an unsupported verification method is used, document serialization fails, or the verification operation fails.

Verifies that the signature on the DID document signed was generated by a valid method from this DID document.

Errors

Fails if:

  • The signature proof section is missing in the signed document.
  • The method is not found in this document.
  • An unsupported verification method is used.
  • The signature verification operation fails.

Verifies whether document is a valid root DID document according to the IOTA DID method specification.

It must be signed using a verification method with a public key whose BLAKE2b-256 hash matches the DID tag.

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Creates a DiffMessage representing the changes between self and other.

The returned DiffMessage will have a digital signature created using the specified private_key and method_query.

NOTE: the method must be a capability invocation method.

Errors

Fails if the diff operation or signature operation fails.

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Verifies the signature of the diff was created using a capability invocation method in this DID Document.

Errors

Fails if an unsupported verification method is used or the verification operation fails.

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Verifies a DiffMessage signature and merges the changes into self.

If merging fails self remains unmodified, otherwise self represents the merged document state.

See IotaDocument::verify_diff.

Errors

Fails if the merge operation or signature operation fails.

Returns the Tangle index of the integration chain for this DID.

This is equivalent to the tag segment of the IotaDID.

E.g. For an IotaDocument doc with "did:iota:1234567890abcdefghijklmnopqrstuvxyzABCDEFGHI", doc.integration_index() == "1234567890abcdefghijklmnopqrstuvxyzABCDEFGHI"

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Returns the Tangle index of the DID diff chain. This should only be called on messages from documents published on the integration chain.

This is the Base58-btc encoded SHA-256 digest of the hex-encoded message id.

Returns a vector of all verification methods capable of signing a document update.

If the document has a RevocationBitmap service identified by fragment, revoke all credentials with a revocationBitmapIndex in credential_indices.

If the document has a RevocationBitmap service identified by fragment, unrevoke all credentials with a revocationBitmapIndex in credential_indices.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

The Corresponding Diff Type for the implemented Type.

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Finds the difference between two types; self and other and returns Self::Type

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Merges a Self::Type with Self

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Converts a diff of type Self::Type to a Self.

👎 Deprecated since 0.5.0:

diff chain features are slated for removal

Converts a type of Self to a diff of Self::Type.

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Returns a reference to the Proof object, if any.

Returns a mutable reference to the Proof object, if any.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Sets the Proof object of self.

Flag that determines whether absolute or rleative URI

Returns an absolute or relative method URI, if any, depending on the MethodUriType. Read more

Returns String representation of absolute or relative method URI. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Format this as a JSON string or pretty-JSON string based on whether the # format flag was used. Read more

Returns the argument unchanged.

Deserialize Self from a string of JSON text.

Deserialize Self from bytes of JSON text.

Deserialize Self from a [serde_json::Value].

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

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

Calls U::from(self).

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

Should always be Self

Serialize self as a string of JSON.

Serialize self as a JSON byte vector.

Serialize self as a [serde_json::Value].

Serialize self as a pretty-printed string of JSON.

Serialize self as a JSON byte vector, normalized using JSON Canonicalization Scheme (JCS). Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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