Skip to content

Commit

Permalink
chore: Debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Aug 6, 2024
1 parent 55dc32a commit fd6ff65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/key-utils/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export const asn1DerToRawPublicKey = (

export const isRawCompressedPublicKey = (key: Uint8Array): boolean => key.length === 33 && (key[0] === 0x02 || key[0] === 0x03)

export const rawToCompressedHexPublicKey = (rawPublicKey: Uint8Array, keyType: TKeyType): string => {
export const toRawCompressedHexPublicKey = (rawPublicKey: Uint8Array, keyType: TKeyType): string => {
if (!isRawCompressedPublicKey(rawPublicKey)) {
throw new Error('Invalid public key format, an uncompressed raw public key is required as input')
}
Expand Down
10 changes: 6 additions & 4 deletions packages/kms-musap-rn/src/MusapKeyManagerSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Loggers } from '@sphereon/ssi-types'
import { KeyMetadata } from './index'
import { PEMToBinary } from '@sphereon/ssi-sdk-ext.key-utils'
import {
rawToCompressedHexPublicKey, hexStringFromUint8Array,
toRawCompressedHexPublicKey, hexStringFromUint8Array,
isRawCompressedPublicKey,
asn1DerToRawPublicKey, isAsn1Der,
} from '@sphereon/ssi-sdk-ext.key-utils/dist'
Expand Down Expand Up @@ -156,11 +156,13 @@ export class MusapKeyManagementSystem extends AbstractKeyManagementSystem {
private asMusapKeyInfo(args: MusapKey): ManagedKeyInfo {
const keyType = this.mapAlgorithmTypeToKeyType(args.algorithm)
const pemBinary = PEMToBinary(args.publicKey.pem) // The der is flawed, it's not binary but a string [123, 4567]
logger.info("isAsn1Der", isAsn1Der(pemBinary) ) // TODO remove
const publicKeyBinary = isAsn1Der(pemBinary) ? asn1DerToRawPublicKey(pemBinary, keyType) : pemBinary
logger.info("isRawCompressedPublicKey", isRawCompressedPublicKey(publicKeyBinary)) // TODO remove
const publicKeyHex = isRawCompressedPublicKey(publicKeyBinary)
? rawToCompressedHexPublicKey(publicKeyBinary, keyType)
: hexStringFromUint8Array(publicKeyBinary)

? hexStringFromUint8Array(publicKeyBinary)
: toRawCompressedHexPublicKey(publicKeyBinary, keyType)
logger.info("publicKeyHex",publicKeyHex) // TODO remove
const keyInfo: Partial<ManagedKeyInfo> = {
kid: args.keyId,
type: keyType,
Expand Down

0 comments on commit fd6ff65

Please sign in to comment.