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 d6b444d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 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, 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
6 changes: 3 additions & 3 deletions packages/crypto/src/algorithms-api/aes/base.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Web5Crypto } from '../../types/web5-crypto.js';
import type { JwkOperation, PrivateKeyJwk } from '../../../src/jose.js';
import type { JwkOperation, PrivateKeyJwk } from '../../jose.js';

import { Jose } from '../../../src/jose.js';
import { Jose } from '../../jose.js';
import { InvalidAccessError } from '../errors.js';
import { checkRequiredProperty } from '../../utils.js';
import { CryptoAlgorithm } from '../crypto-algorithm.js';
import { InvalidAccessError } from '../errors.js';

export abstract class BaseAesAlgorithm extends CryptoAlgorithm {

Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/src/algorithms-api/aes/ctr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { universalTypeOf } from '@web5/common';

import type { Web5Crypto } from '../../types/web5-crypto.js';
import type { JwkOperation, PrivateKeyJwk } from '../../../src/jose.js';
import type { JwkOperation, PrivateKeyJwk } from '../../jose.js';

import { BaseAesAlgorithm } from './base.js';
import { OperationError } from '../errors.js';
Expand Down

0 comments on commit d6b444d

Please sign in to comment.