From c3a2086273e67aa95267935a6066542478146860 Mon Sep 17 00:00:00 2001 From: Muse Date: Tue, 20 Oct 2026 01:51:04 +0800 Subject: [PATCH] =?UTF-8?q?agent:=20Reality=20=E5=AF=86=E9=92=A5=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E7=94=A8=20JWK=20base64url=EF=BC=88=E4=B8=8E=20sing-b?= =?UTF-8?q?ox=20=E4=B8=80=E8=87=B4=EF=BC=89=EF=BC=8C=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/agent.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/agent/agent.js b/agent/agent.js index 4f794f0..3c78333 100644 --- a/agent/agent.js +++ b/agent/agent.js @@ -66,9 +66,8 @@ function realityKey(keyId) { const priv = kp.privateKey.export({ format: 'jwk' }); const pub = kp.publicKey.export({ format: 'jwk' }); if (!priv.d || !pub.x) throw new Error('X25519 密钥生成失败'); - // JWK 用 base64url,sing-box 要标准 base64,用 Buffer 转 - const b64urlToB64 = (s) => Buffer.from(s, 'base64url').toString('base64'); - keys[keyId] = { privateKey: b64urlToB64(priv.d), publicKey: b64urlToB64(pub.x), createdAt: new Date().toISOString() }; + // JWK 的 base64url 无填充格式与 sing-box 的 reality-keypair 输出一致,直接用 + keys[keyId] = { privateKey: priv.d, publicKey: pub.x, createdAt: new Date().toISOString() }; saveKeys(keys); return keys[keyId]; }