diff --git a/src/cli.ts b/src/cli.ts index 42b20f5..23d5c84 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -118,11 +118,13 @@ async function cmdInstall(args: string[]): Promise { ...(token ? { token } : {}), }; await fsp.writeFile(agentConfigPath, JSON.stringify(agentConfig, null, 2) + '\n', 'utf-8'); + await fsp.chmod(agentConfigPath, 0o600); console.log(` Agent config: ${agentConfigPath}`); // Write private key (chmod 600) const keyPath = path.join(agentsDir, `${agentName}.key`); await fsp.writeFile(keyPath, privateKey, { encoding: 'utf-8', mode: 0o600 }); + await fsp.chmod(keyPath, 0o600); console.log(` Private key: ${keyPath}`); // Generate and write hook script (PostToolUse — audit logging) diff --git a/src/crypto.ts b/src/crypto.ts index d2a3e20..3fa7422 100644 --- a/src/crypto.ts +++ b/src/crypto.ts @@ -151,8 +151,7 @@ export function derivePublicKey(privateKeyBase64url: string): string { // --------------------------------------------------------------------------- /** - * The initial chain hash value: SHA-256 of 32 zero bytes, base64url encoded. + * The initial chain hash value: base64url encoding of 32 zero bytes. + * Must match the backend's GENESIS_CHAIN_HASH constant exactly. */ -export const ZERO_CHAIN_HASH: string = base64urlEncode( - crypto.createHash('sha256').update(Buffer.alloc(32, 0)).digest(), -); +export const ZERO_CHAIN_HASH: string = base64urlEncode(Buffer.alloc(32, 0));