Skip to content

Commit

Permalink
fix(cheqd): changed the name formatting to a encoded hex value (openw…
Browse files Browse the repository at this point in the history
…allet-foundation#1574)

Signed-off-by: Tom Lanser <tom@animo.id>
Signed-off-by: Ariel Gentile <gentilester@gmail.com>
  • Loading branch information
Tommylans authored and genaris committed Sep 22, 2023
1 parent 6fd60c9 commit a2b1079
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/cheqd/src/anoncreds/services/CheqdAnonCredsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
} from '@aries-framework/anoncreds'
import type { AgentContext } from '@aries-framework/core'

import { AriesFrameworkError, JsonTransformer, utils } from '@aries-framework/core'
import { AriesFrameworkError, Buffer, Hasher, JsonTransformer, TypedArrayEncoder, utils } from '@aries-framework/core'

import { CheqdDidResolver, CheqdDidRegistrar } from '../../dids'
import { cheqdSdkAnonCredsRegistryIdentifierRegex, parseCheqdDid } from '../utils/identifiers'
Expand Down Expand Up @@ -135,9 +135,16 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry {
const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar)
const { credentialDefinition } = options
const schema = await this.getSchema(agentContext, credentialDefinition.schemaId)
if (!schema.schema) {
throw new Error(`Schema not found for schemaId: ${credentialDefinition.schemaId}`)
}

const credDefName = `${schema.schema.name}-${credentialDefinition.tag}`
const credDefNameHashBuffer = Hasher.hash(Buffer.from(credDefName), 'sha2-256')

const credDefResource = {
id: utils.uuid(),
name: `${schema.schema?.name}-${credentialDefinition.tag}-CredDef`,
name: TypedArrayEncoder.toHex(credDefNameHashBuffer),
resourceType: 'anonCredsCredDef',
data: {
type: credentialDefinition.type,
Expand Down

0 comments on commit a2b1079

Please sign in to comment.