Skip to content

Commit

Permalink
Attempt to fix web5-spec
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Hinek <[email protected]>
  • Loading branch information
frankhinek committed Nov 28, 2023
1 parent 172641e commit 5034b4a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .web5-spec/credentials.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import { VerifiableCredential, SignOptions } from '@web5/credentials';
import { DidKeyMethod, PortableDid } from '@web5/dids';
import { Ed25519, Jose } from '@web5/crypto';
import { Ed25519, Jose, PrivateKeyJwk } from '@web5/crypto';
import { paths } from './openapi.js';

type Signer = (data: Uint8Array) => Promise<Uint8Array>;
Expand All @@ -24,9 +24,8 @@ export async function credentialIssue(req: Request, res: Response) {

// build signing options
const [signingKeyPair] = ownDid.keySet.verificationMethodKeys!;
const privateKey = (await Jose.jwkToKey({ key: signingKeyPair.privateKeyJwk!})).keyMaterial;
const subjectIssuerDid = body.credential.credentialSubject["id"] as string;
const signer = EdDsaSigner(privateKey);
const signer = EdDsaSigner(signingKeyPair.privateKeyJwk as PrivateKeyJwk);
const signOptions: SignOptions = {
issuerDid : ownDid.did,
subjectDid : subjectIssuerDid,
Expand All @@ -51,7 +50,7 @@ export async function credentialIssue(req: Request, res: Response) {
res.json(resp);
}

function EdDsaSigner(privateKey: Uint8Array): Signer {
function EdDsaSigner(privateKey: PrivateKeyJwk): Signer {
return async (data: Uint8Array): Promise<Uint8Array> => {
const signature = await Ed25519.sign({ data, key: privateKey});
return signature;
Expand Down

0 comments on commit 5034b4a

Please sign in to comment.