#did #forge #pk #address #hash #key #sk

forge_did

The rust language implementation of create did

4 releases

0.1.3 Oct 21, 2019
0.1.2 Oct 16, 2019
0.1.1 Oct 14, 2019
0.1.0 Oct 12, 2019

#4 in #pk

36 downloads per month
Used in 3 crates

Apache-2.0

40KB
781 lines

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);

Dependencies

~7.5MB
~114K SLoC