Skip to content

Commit

Permalink
Merge branch 'feat/docs' of https://github.com/iotaledger/identity.rs
Browse files Browse the repository at this point in the history
…into feat/docs
  • Loading branch information
JelleMillenaar authored and JelleMillenaar committed Feb 19, 2021
2 parents 4c70cbd + d1d8b2c commit bcaa9df
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 2 deletions.
5 changes: 5 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ path = "diff_chain.rs"
[[example]]
name = "resolution"
path = "resolution.rs"


[[example]]
name = "create_did"
path = "create_did.rs"
25 changes: 25 additions & 0 deletions examples/create_did.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
3 changes: 2 additions & 1 deletion identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
59 changes: 59 additions & 0 deletions identity/README.md
Original file line number Diff line number Diff line change
@@ -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
56 changes: 55 additions & 1 deletion identity/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit bcaa9df

Please sign in to comment.