-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
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
edwardsToMontgomeryPubfrom@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 pathpackages/cipher/src/types.ts— extend key types to support OKP JWKspackages/cipher/package.json— add@noble/curvesas a direct dependency
Context
- Depends on Add universal resolver to gatekeeper service #81 (universal resolver) for resolving
did:keyDIDs did:key:z6Mk...prefix indicates Ed25519 keys- Test DID:
did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels