Skip to content

Deno support - Unknown cipher chacha20-poly1305 #587

@SgtPooki

Description

@SgtPooki

When testing Deno compatibility with Helia, we ran into some errors from @chainsafe/libp2p-noise:

2025-06-09T19:51:48.624Z libp2p:yamux:error internal error in sink TypeError: Unknown cipher chacha20-poly1305
    at new Cipheriv (ext:deno_node/internal/crypto/cipher.ts:40:21)
    at Object.createCipheriv (node:crypto:34:10)
    at Object.chaCha20Poly1305Encrypt (file:///Users/sgtpooki/code/work/ipshipyard/yeus/deno_helia/node_modules/.deno/@[email protected]/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/index.js:24:31)
    at Object.chaCha20Poly1305Encrypt [as encrypt] (file:///Users/sgtpooki/code/work/ipshipyard/yeus/deno_helia/node_modules/.deno/@[email protected]/node_modules/@chainsafe/libp2p-noise/dist/src/crypto/index.js:107:27)
    at CipherState.encryptWithAd (file:///Users/sgtpooki/code/work/ipshipyard/yeus/deno_helia/node_modules/.deno/@[email protected]/node_modules/@chainsafe/libp2p-noise/dist/src/protocol.js:26:31)
    at Object.encrypt (file:///Users/sgtpooki/code/work/ipshipyard/yeus/deno_helia/node_modules/.deno/@[email protected]/node_modules/@chainsafe/libp2p-noise/dist/src/performHandshake.js:34:37)
    at file:///Users/sgtpooki/code/work/ipshipyard/yeus/deno_helia/node_modules/.deno/@[email protected]/node_modules/@chainsafe/libp2p-noise/dist/src/streaming.js:19:38
    at Object.runMicrotasks (ext:core/01_core.js:692:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)

Can we fallback to the browser impl in cases like these or do we want to wait on better Deno support?

Related:

const cipher = crypto.createCipheriv(CHACHA_POLY1305, k, nonce, {

Related:
const decipher = crypto.createDecipheriv(CHACHA_POLY1305, k, nonce, {

Related: ipfs/helia#73 (comment)
Related: denoland/deno#28411

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions