diff --git a/packages/ssi-sdk-core/src/utils/__tests__/encoding.test.ts b/packages/ssi-sdk-core/src/utils/__tests__/encoding.test.ts index 832f1c0e2..ac9cdbfb3 100644 --- a/packages/ssi-sdk-core/src/utils/__tests__/encoding.test.ts +++ b/packages/ssi-sdk-core/src/utils/__tests__/encoding.test.ts @@ -7,8 +7,8 @@ describe('@sphereon/ssi-sdk-core:encoding', () => { // Hex to multibase it('should encode hex to multibase base58', () => { - expect(hexToMultibase(HEX_EXAMPLE, MultibaseFormat.BASE58)).toEqual({ value: BASE58_EXAMPLE, format: MultibaseFormat.BASE58 }) - expect(hexToMultibase(HEX_EXAMPLE.toUpperCase(), MultibaseFormat.BASE58)).toEqual({ value: BASE58_EXAMPLE, format: MultibaseFormat.BASE58 }) + expect(hexToMultibase(HEX_EXAMPLE, MultibaseFormat.BASE58)).toEqual({ value: MULTIBASE_EXAMPLE, format: MultibaseFormat.BASE58 }) + expect(hexToMultibase(HEX_EXAMPLE.toUpperCase(), MultibaseFormat.BASE58)).toEqual({ value: MULTIBASE_EXAMPLE, format: MultibaseFormat.BASE58 }) }) it('should not encode hex to not supported multibase format', () => { expect(() => hexToMultibase(HEX_EXAMPLE, 'e' as never)).toThrowError() diff --git a/packages/ssi-sdk-core/src/utils/encoding.ts b/packages/ssi-sdk-core/src/utils/encoding.ts index e59a16417..13ce930fa 100644 --- a/packages/ssi-sdk-core/src/utils/encoding.ts +++ b/packages/ssi-sdk-core/src/utils/encoding.ts @@ -8,7 +8,7 @@ export function hexToMultibase(hex: string, format: MultibaseFormat): { value: s if (format !== MultibaseFormat.BASE58) { throw new Error('Only base58 supported for now using multibase!') } - return { value: base58.encode(hexToBytes(hex)), format } + return { value: MultibaseFormat.BASE58 + base58.encode(hexToBytes(hex)), format } function hexToBytes(hex: string): Uint8Array { let bytes: number[] = []