Skip to content

Commit

Permalink
Add did:ion and Sidetree
Browse files Browse the repository at this point in the history
  • Loading branch information
clehner committed Feb 14, 2022
1 parent 63fe3ea commit 0cc6689
Show file tree
Hide file tree
Showing 5 changed files with 2,003 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ members = [
"did-sol",
"did-pkh",
"did-onion",
"did-ion",
"did-webkey",
"vc-test",
"did-test",
Expand Down
33 changes: 33 additions & 0 deletions did-ion/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "did-ion"
version = "0.1.0"
authors = ["Spruce Systems, Inc."]
edition = "2021"
license = "Apache-2.0"
keywords = ["ssi", "did"]
categories = ["web-programming::http-client"]
description = "did:ion DID method implementation, using the ssi crate and ION/Sidetree REST API"
repository = "https://github.com/spruceid/ssi/"
homepage = "https://github.com/spruceid/ssi/tree/main/did-ion/"
documentation = "https://docs.rs/did-ion/"

[features]

[dependencies]
ssi = { version = "0.3", path = "../", default-features = false, features = ["http-did", "secp256k1"] }
async-trait = "0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_jcs = "0.1"
anyhow = "1.0"
base64 = "0.12"
sha2 = "0.10"
json-patch = "0.2.6"
reqwest = { version = "0.11", features = ["json"] }

[target.'cfg(target_os = "android")'.dependencies.reqwest]
version = "0.11"
features = ["json", "native-tls-vendored"]

[dev-dependencies]
lazy_static = "1.4"
17 changes: 17 additions & 0 deletions did-ion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# did-ion

Rust implementation of the [did:ion][] [DID Method][], based on the [ssi][] library.

## Requirements

An ION node is needed, that is a [Sidetree REST API][] provider. The URL for
the ION/Sidetree node is to be stored in config TBD.

## License

[Apache License, Version 2.0](http://www.apache.org/licenses/)

[did:ion]: https://identity.foundation/ion/
[DID Method]: https://www.w3.org/TR/did-core/#methods
[ssi]: https://github.com/spruceid/ssi/
[Sidetree REST API]: https://identity.foundation/sidetree/api/
26 changes: 26 additions & 0 deletions did-ion/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use anyhow::{ensure, Context, Error, Result};
use ssi::jwk::{Algorithm, JWK};

pub mod sidetree;

use sidetree::{is_secp256k1, Sidetree, SidetreeClient};

pub struct ION;

/// did:ion Method
pub type DIDION = SidetreeClient<ION>;

impl Sidetree for ION {
fn generate_key() -> Result<JWK, Error> {
JWK::generate_secp256k1().context("Generate secp256k1 key")
}

fn validate_key(key: &JWK) -> Result<(), Error> {
ensure!(is_secp256k1(&key), "Key must be Secp256k1 for ION");
Ok(())
}

const SIGNATURE_ALGORITHM: Algorithm = Algorithm::ES256K;
const METHOD: &'static str = "ion";
const NETWORK: Option<&'static str> = Some("test");
}
Loading

0 comments on commit 0cc6689

Please sign in to comment.