Crates.io | forge_did |
lib.rs | forge_did |
version | 0.1.3 |
source | src |
created_at | 2019-10-12 02:22:33.707551 |
updated_at | 2019-10-21 00:19:29.456421 |
description | The rust language implementation of create did |
homepage | https://github.com/ArcBlock/forge-rust-sdk |
repository | https://github.com/ArcBlock/forge-rust-sdk |
max_upload_size | |
id | 171822 |
size | 15,175 |
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.
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>
// 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);