Skip to content

Commit

Permalink
Merge branch 'main' into fix/oob-invitation-services
Browse files Browse the repository at this point in the history
  • Loading branch information
genaris committed Sep 18, 2023
2 parents 64066a2 + d299f55 commit 982b189
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 982b189

Please sign in to comment.