Skip to content

Commit 259313c

Browse files
authored
Implement session salt rotation and enhance logging
Added functionality to rotate session salt every hour and updated action logging to include detailed action types.
1 parent dfb931c commit 259313c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ if (!MASTER_KEY) {
8282
const ALL_MASTER_KEYS = [MASTER_KEY, ...BACKUP_KEYS];
8383

8484
// --- Session Salt for Stronger Key Derivation ---
85-
const sessionSalt = crypto.randomBytes(16);
85+
let sessionSalt = crypto.randomBytes(16);
86+
87+
// Rotate session salt hourly
88+
setInterval(() => {
89+
sessionSalt = crypto.randomBytes(16);
90+
console.log(chalk.cyan("🔑 Rotated session salt for key derivation"));
91+
}, 60 * 60 * 1000);
8692

8793
/**
8894
* Derives a cryptographic key from a master key and a session salt.
@@ -601,15 +607,19 @@ async function sendTx(wallet, provider, profile, url) {
601607

602608
// Determine recipient address
603609
let toAddress = wallet.address;
610+
let pingType = "self";
604611
if (action === "ping") {
605612
const rand = Math.random();
606613
if (rand < 0.5) {
607614
toAddress = wallet.address; // self
615+
pingType = "self";
608616
} else if (rand < 0.7) {
609617
toAddress = "0x0000000000000000000000000000000000000000"; // dead address
618+
pingType = "dead";
610619
} else {
611620
const randomWallet = ethers.Wallet.createRandom();
612621
toAddress = randomWallet.address; // random generated
622+
pingType = "random";
613623
}
614624
}
615625

@@ -661,6 +671,7 @@ async function sendTx(wallet, provider, profile, url) {
661671
}
662672

663673
// === Buffer to CSV (daily rotation) ===
674+
const detailedAction = action === "ping" ? `${action}_${pingType}` : action;
664675
const line = [
665676
new Date().toISOString(),
666677
wallet.address,
@@ -670,7 +681,7 @@ async function sendTx(wallet, provider, profile, url) {
670681
gasPriceGwei,
671682
feeCELO,
672683
status,
673-
action
684+
detailedAction
674685
].join(",");
675686
bufferTxLog(line);
676687

0 commit comments

Comments
 (0)