Create message array
Important
Before creating a message array please ensure that you have constructed the credential.
Create a message array by deconstructing the credential into different parts.
const {
id,
"@context": context,
type,
issuer,
issuanceDate,
credentialSchema,
credentialStatus,
credentialSubject,
} = credential;
const messages = [
Uint8Array.from(Buffer.from(JSON.stringify(id), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(context), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(type), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(issuer), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(issuanceDate), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(credentialSchema), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(credentialStatus), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(credentialSubject.id), "utf8")),
Uint8Array.from(Buffer.from(JSON.stringify(credentialSubject.name), "utf8")),
Uint8Array.from(
Buffer.from(JSON.stringify(credentialSubject.birthDate), "utf8")
),
Uint8Array.from(
Buffer.from(JSON.stringify(credentialSubject.customerReference), "utf8")
),
Uint8Array.from(
Buffer.from(JSON.stringify(credentialSubject.expiryDate), "utf8")
),
Uint8Array.from(
Buffer.from(JSON.stringify(credentialSubject.publicAddress), "utf8")
),
Uint8Array.from(Buffer.from(JSON.stringify(credentialSubject.type), "utf8")),
Uint8Array.from(
Buffer.from(JSON.stringify(credentialSubject.licenseNumber), "utf8")
),
Uint8Array.from(
Buffer.from(JSON.stringify(credentialSubject.stateOfIssuance), "utf8")
),
];