Skip to content

Commit

Permalink
fix(cheqd): changed the name formatting to a encoded hex value (#1574)
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Lanser <tom@animo.id>
  • Loading branch information
Tommylans committed Sep 18, 2023
1 parent d2f8851 commit d299f55
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/cheqd/src/anoncreds/services/CheqdAnonCredsRegistry.ts
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 d299f55

Please sign in to comment.