diff --git a/examples/Cargo.toml b/examples/Cargo.toml index e0277e8569..fcd93614ea 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -20,3 +20,8 @@ path = "diff_chain.rs" [[example]] name = "resolution" path = "resolution.rs" + + +[[example]] +name = "create_did" +path = "create_did.rs" diff --git a/examples/create_did.rs b/examples/create_did.rs new file mode 100644 index 0000000000..d35f648fb7 --- /dev/null +++ b/examples/create_did.rs @@ -0,0 +1,25 @@ +use identity::iota::Client; +use identity::iota::IotaDocument; +use identity::crypto::KeyPair; + +use identity::iota::Result; + + +#[smol_potat::main] +async fn main() -> Result<()> { + let client: Client = Client::new()?; + + let (mut document, keypair): (IotaDocument, KeyPair) = IotaDocument::builder() + .authentication_tag("key-1") + .did_network(client.network().as_str()) + .build()?; + + // Sign the DID Document with the default authentication key. + document.sign(keypair.secret())?; + + // Use the client to publish the DID Document to the Tangle. + let transaction: _ = client.publish_document(&document).await?; + println!("DID Document Transaction > {}", client.transaction_url(&transaction)); + + Ok(()) +} diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 9d3884fbdd..c889d59b4c 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -7,8 +7,9 @@ description = "Tools for working with Self-sovereign Identity." readme = "../README.md" repository = "https://github.com/iotaledger/identity.rs" license = "Apache-2.0" -keywords = ["iota", "tangle", "identity"] +keywords = ["iota", "tangle", "identity", "did"] homepage = "https://www.iota.org" +documentation = "https://identity.docs.iota.org" [dependencies] identity-core = { version = "=0.1.0", path = "../identity-core" } diff --git a/identity/README.md b/identity/README.md new file mode 100644 index 0000000000..ea8146ba95 --- /dev/null +++ b/identity/README.md @@ -0,0 +1,59 @@ +# identity + +## IOTA Identity +IOTA Identity is a [Rust](https://www.rust-lang.org/) implementation of decentralized identity, also known as Self Sovereign Identity (SSI), through the [W3C Decentralized Identifiers (DID)](https://w3c.github.io/did-core/) and [Verifiable Credentials](https://www.w3.org/TR/vc-data-model/) standards alongside supporting methods, utilizing the [IOTA Distributed Ledger](https://www.iota.org). + + +## Example +```rust +use identity::iota::Client; +use identity::iota::IotaDocument; +use identity::crypto::KeyPair; +use identity::iota::Result; + +#[smol_potat::main] +async fn main() -> Result<()> { + + // Create a client to interact with the IOTA Tangle. + let client: Client = Client::new()?; + + // Create a DID Document (an identity). + let (mut document, keypair): (IotaDocument, KeyPair) = IotaDocument::builder() + .authentication_tag("key-1") + .did_network(client.network().as_str()) + .build()?; + + // Sign the DID Document with the default authentication key. + document.sign(keypair.secret())?; + + // Use the client to publish the DID Document to the IOTA Tangle. + let transaction: _ = client.publish_document(&document).await?; + + // Print the DID Document transaction link. + println!("DID Document Transaction > {}", client.transaction_url(&transaction)); + + Ok(()) +} + +``` + +**Output**: Example DID Document in the [Tangle Explorer](https://explorer.iota.org/mainnet/transaction/LESUXJUMJCOWGHU9CQQUIHCIPYELOBMHZT9CHCYHJPO9BONQ9IQIFJSREYNOCTYCTQYBHBMBBWJJZ9999). + +## Documentation & Community Resources +- [identity.rs](https://github.com/iotaledger/identity.rs): Rust source code of this library on GitHub. +- [Identity Documentation Pages](https://identity.docs.iota.org/welcome.html): Supplementing documentation with simple examples on library usage to get you started. +- [More Examples](https://github.com/iotaledger/identity.rs/tree/dev/examples): Practical examples to get started with the library. +- [IOTA Identity Experience Team Website](https://iota-community.github.io/X-Team_IOTA_Identity/): Website of aforementioned team. + +## Structure (Temporary) + +- Resources + - Docs Link (Website & User Guide) + - X-Team +- Simple Example +- Architecture/Overview +- Get + + + +License: Apache-2.0 diff --git a/identity/src/lib.rs b/identity/src/lib.rs index 04baf7f517..c81d6fd961 100644 --- a/identity/src/lib.rs +++ b/identity/src/lib.rs @@ -1,7 +1,61 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//! IOTA Identity +//! # IOTA Identity +//! IOTA Identity is a [Rust](https://www.rust-lang.org/) implementation of decentralized identity, also known as Self Sovereign Identity (SSI), through the [W3C Decentralized Identifiers (DID)](https://w3c.github.io/did-core/) and [Verifiable Credentials](https://www.w3.org/TR/vc-data-model/) standards alongside supporting methods, utilizing the [IOTA Distributed Ledger](https://www.iota.org). +//! +//! +//! # Example +//! ``` +//! use identity::iota::Client; +//! use identity::iota::IotaDocument; +//! use identity::crypto::KeyPair; +//! use identity::iota::Result; +//! +//! #[smol_potat::main] +//! async fn main() -> Result<()> { +//! +//! // Create a client to interact with the IOTA Tangle. +//! let client: Client = Client::new()?; +//! +//! // Create a DID Document (an identity). +//! let (mut document, keypair): (IotaDocument, KeyPair) = IotaDocument::builder() +//! .authentication_tag("key-1") +//! .did_network(client.network().as_str()) +//! .build()?; +//! +//! // Sign the DID Document with the default authentication key. +//! document.sign(keypair.secret())?; +//! +//! // Use the client to publish the DID Document to the IOTA Tangle. +//! let transaction: _ = client.publish_document(&document).await?; +//! +//! // Print the DID Document transaction link. +//! println!("DID Document Transaction > {}", client.transaction_url(&transaction)); +//! +//! Ok(()) +//! } +//! +//! ``` +//! +//! **Output**: Example DID Document in the [Tangle Explorer](https://explorer.iota.org/mainnet/transaction/LESUXJUMJCOWGHU9CQQUIHCIPYELOBMHZT9CHCYHJPO9BONQ9IQIFJSREYNOCTYCTQYBHBMBBWJJZ9999). +//! +//! # Documentation & Community Resources +//! - [identity.rs](https://github.com/iotaledger/identity.rs): Rust source code of this library on GitHub. +//! - [Identity Documentation Pages](https://identity.docs.iota.org/welcome.html): Supplementing documentation with simple examples on library usage to get you started. +//! - [More Examples](https://github.com/iotaledger/identity.rs/tree/dev/examples): Practical examples to get started with the library. +//! - [IOTA Identity Experience Team Website](https://iota-community.github.io/X-Team_IOTA_Identity/): Website of aforementioned team. +//! +//! # Structure (Temporary) +//! +//! - Resources +//! - Docs Link (Website & User Guide) +//! - X-Team +//! - Simple Example +//! - Architecture/Overview +//! - Get +//! +//! #![warn( rust_2018_idioms,