forge_did

Crates.ioforge_did
lib.rsforge_did
version0.1.3
sourcesrc
created_at2019-10-12 02:22:33.707551
updated_at2019-10-21 00:19:29.456421
descriptionThe rust language implementation of create did
homepagehttps://github.com/ArcBlock/forge-rust-sdk
repositoryhttps://github.com/ArcBlock/forge-rust-sdk
max_upload_size
id171822
size15,175
Pang Wei (qiangshou007)

documentation

https://docs.rs/forge-rust-sdk

README

Intro

forge_did implement by Rust. Forge_wallet core implementation.

Generate forge did from pk, or sk, or pk hash. forge did example did:abt:zNYm1gM23ZGHNYDYyBwSaywzTqLKoj4WuTeC. Prefix did means the string is a DID, abt means the did is forge did. zNYm1gM23ZGHNYDYyBwSaywzTqLKoj4WuTeC is address.

API

  • get_did_by_sk(sk: &[u8], did_type: &Option<DidType>) -> Result<String>
  • get_did_by_pk(pk: &[u8], did_type: &Option<DidType>) -> Result<String>
  • get_did_by_pk_hash(pk_hash: &[u8], did_type: &Option<DidType>) -> Result<String>

Usage

    // generate key pair
    let (sk, pk) = forge_signer::get_key_pair(Some(forge_signer::SignType::Ed25519));
    let did_type = create_did::DidType{
        role_type: Some(RoleType::Account),
        key_type: Some(KeyType::Ed25519),
        hash_type: Some(HashType::Sha3),
    }
    let did_by_sk = forge_did::get_did_by_sk(&sk, &Some(w_type.to_owned()))?;
    let did_by_pk = forge_did::get_did_by_pk(&pk, &Some(w_type.to_owned()))?;
    // did_by_pk example: "did:abt:zNYm1gM23ZGHNYDYyBwSaywzTqLKoj4WuTeC";
    assert_eq!(did_by_sk, did_by_pk);
Commit count: 0

cargo fmt