agent: Reality 密钥直接用 JWK base64url(与 sing-box 一致),去掉错误转换
This commit is contained in:
+2
-3
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user