From 683bc42bf09985fc3fb3ea560279928e6b121f1f Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 5 Dec 2025 18:45:04 +0100 Subject: [PATCH] fix: initialize SHA-512 hash function for @noble/ed25519 v3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @noble/ed25519 v3.0.0 requires explicit SHA-512 hash function setup before using any cryptographic operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/crypto.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/crypto.ts b/src/crypto.ts index e14f874..afe0d15 100644 --- a/src/crypto.ts +++ b/src/crypto.ts @@ -6,6 +6,12 @@ import * as ed25519 from '@noble/ed25519'; +// Set SHA-512 hash function for ed25519 (required in @noble/ed25519 v3+) +// Uses Web Crypto API (compatible with both Node.js and Cloudflare Workers) +ed25519.hashes.sha512Async = async (message: Uint8Array) => { + return new Uint8Array(await crypto.subtle.digest('SHA-512', message as BufferSource)); +}; + const ALGORITHM = 'AES-GCM'; const IV_LENGTH = 12; // 96 bits for GCM const KEY_LENGTH = 32; // 256 bits