Skip to content

Commit

Permalink
encode did when calc digest hash
Browse files Browse the repository at this point in the history
  • Loading branch information
zzcwoshizz committed Feb 23, 2023
1 parent 2caa873 commit c7f2803
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-coins-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@zcloak/vc': minor
---

encode did when calc digest
2 changes: 1 addition & 1 deletion packages/did/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function typeTransform(type: KeypairType): VerificationMethodType {
* @summary
* encode `didUrl` to a bytes.
* @description
* encode `didUrl` to bytes with the identifier as HexString, and the prefix is `did:zk:'. Returns `Uint8Array`.
* encode `didUrl` to bytes with the identifier as HexString, and the prefix is `did:zk:`. Returns `Uint8Array`.
* @example
* ```typescript
* import { encodeDidUrl } from '@zcloak/did'
Expand Down
4 changes: 3 additions & 1 deletion packages/vc/src/digest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type { HashType, VerifiableCredentialVersion } from './types';

import { numberToU8a, stringToU8a, u8aConcat, u8aToHex } from '@polkadot/util';

import { encodeDidUrl } from '@zcloak/did';

import { DEFAULT_DIGEST_HASH_TYPE } from './defaults';
import { HASHER } from './hasher';

Expand Down Expand Up @@ -73,7 +75,7 @@ export function calcDigest<Version extends VerifiableCredentialVersion>(
} else {
encoded = u8aConcat(
payload.rootHash,
stringToU8a(payload.holder),
encodeDidUrl(payload.holder),
numberToU8a((payload as DigestPayload<'1'>).issuanceDate),
numberToU8a(payload.expirationDate || 0),
payload.ctype
Expand Down

0 comments on commit c7f2803

Please sign in to comment.