Problem
When issuing a credential to a did:key subject (resolved via the universal resolver fallback from #81), the cipher crashes with:
TypeError: Cannot read properties of undefined (reading 'length')
Root cause: convertJwkToCompressedBytes in packages/cipher/src/cipher-base.ts accesses jwk.y, which is undefined for Ed25519/OKP keys (they only have x). The cipher currently only supports secp256k1 EC keys.
Proposed solution
Detect OKP keys (kty === "OKP") in encryptBytes/decryptBytes and use X25519 key agreement instead of secp256k1 ECDH:
- Convert the Ed25519 public key to X25519 using
edwardsToMontgomeryPub from @noble/curves (already in the dependency tree)
- Use
x25519.getSharedSecret() for key derivation
- The symmetric encryption (xchacha20poly1305) stays the same — only the shared secret derivation changes
Files to modify
packages/cipher/src/cipher-base.ts — key type detection + X25519 key agreement path
packages/cipher/src/types.ts — extend key types to support OKP JWKs
packages/cipher/package.json — add @noble/curves as a direct dependency
Context