From 4a78ca6c05049380c42394ca77cea7b9c9a1e73d Mon Sep 17 00:00:00 2001 From: adityankannan-tw Date: Wed, 18 Dec 2024 18:01:36 +0530 Subject: [PATCH] [INJIMOB-2550]: encode ed25519 public key and pass to library Signed-off-by: adityankannan-tw --- machines/openID4VP/openID4VPServices.ts | 3 ++- shared/openID4VP/OpenID4VP.ts | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/machines/openID4VP/openID4VPServices.ts b/machines/openID4VP/openID4VPServices.ts index 8234880e9..730d8aba9 100644 --- a/machines/openID4VP/openID4VPServices.ts +++ b/machines/openID4VP/openID4VPServices.ts @@ -1,6 +1,7 @@ import {CACHED_API} from '../../shared/api'; import {fetchKeyPair} from '../../shared/cryptoutil/cryptoUtil'; import {hasKeyPair} from '../../shared/openId4VCI/Utils'; +import base64url from 'base64url'; import { constructProofJWT, isClientValidationRequired, @@ -53,7 +54,7 @@ export const openID4VPServices = () => { const vpResponseMetadata = { jws: proofJWT, signatureAlgorithm: OpenID4VP_Proof_Algo_Type, - publicKey: context.publicKey, + publicKey: base64url(context.publicKey), domain: OpenID4VP_Domain, }; return await OpenID4VP.shareVerifiablePresentation(vpResponseMetadata); diff --git a/shared/openID4VP/OpenID4VP.ts b/shared/openID4VP/OpenID4VP.ts index 6005d3eb4..033062395 100644 --- a/shared/openID4VP/OpenID4VP.ts +++ b/shared/openID4VP/OpenID4VP.ts @@ -6,8 +6,9 @@ import {getJWK} from '../openId4VCI/Utils'; import getAllConfigurations from '../api'; export const OpenID4VP_Key_Ref = 'OpenID4VP_KeyPair'; -export const OpenID4VP_Proof_Algo_Type = 'RsaSignature2018'; +export const OpenID4VP_Proof_Algo_Type = 'Ed25519Signature2018'; export const OpenID4VP_Domain = 'OpenID4VP'; +export const OpenID4VP_Proof_Algo = 'EdDSA'; export class OpenID4VP { static InjiOpenID4VP = NativeModules.InjiOpenID4VP; @@ -62,13 +63,13 @@ export class OpenID4VP { } export async function constructProofJWT( - publicKey: string, - privateKey: string, + publicKey: any, + privateKey: any, vpToken: Object, keyType: string, ): Promise { const jwtHeader = { - alg: keyType, + alg: OpenID4VP_Proof_Algo, jwk: await getJWK(publicKey, keyType), };