UNPKG

@arcblock/did

Version:
58 lines (57 loc) 2.21 kB
import { types } from '@ocap/mcrypto'; import { toAddress, toDid, BytesType } from '@ocap/util'; import { DidType, DIDType, DIDTypeShortcut, DIDTypeStr, DIDTypeArg, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, fromTypeInfo, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr } from './type'; import { DID_PREFIX, toStrictHex } from './util'; /** * Gen DID from private key and type config * * Spec: https://github.com/ArcBlock/ABT-DID-Protocol#create-did * * @public * @static * @param {string} sk - hex encoded secret key string * @param {object} type - wallet type, {@see @ocap/wallet#WalletType} * @returns {string} DID string */ declare const fromSecretKey: (sk: BytesType, type?: DIDTypeArg) => string; /** * Gen DID from public key and type config * * @public * @static * @param {string} pk - hex encoded public key * @param {object} type - wallet type, {@see @ocap/wallet#WalletType} * @returns {string} DID string */ declare const fromPublicKey: (pk: BytesType, type?: DIDTypeArg) => string; declare const fromPublicKeyHash: (buffer: string, type: DIDTypeArg) => string; /** * Gen DID from an hex encoded hash and role type * * @public * @static * @param {string} hash - hex encoded hash * @param {enum} role - role type, {@see @ocap/mcrypto#types} * @returns {string} DID string */ declare const fromHash: (hash: string, role?: number) => string; /** * Check if an DID is generated from a publicKey * * @public * @static * @param {string} did - string of the did, usually base58btc format * @param {string} pk - hex encoded publicKey string * @returns {boolean} */ declare const isFromPublicKey: (did: string, pk: BytesType) => boolean; /** * Check if a DID string is valid * * @public * @static * @param {string} did - address string * @returns {boolean} */ declare const isValid: (did: string) => boolean; export { DIDType, DIDTypeStr, DIDTypeArg, DIDTypeShortcut, types, toStrictHex, fromSecretKey, fromPublicKey, fromPublicKeyHash, fromHash, toAddress, toDid, isFromPublicKey, isValid, isEthereumDid, isEthereumType, toTypeInfo, toTypeInfoStr, fromTypeInfo, DidType, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, };