Flash Transaction
A nonce-less transaction format. Replay protection is provided by a bounded per-account window of recently applied identifiers, not by a monotonic counter. The window lives inside the account SMT leaf, committed by the same root that commits to balance.
1. Formal Definition
A Flash Transaction is a signed intent to move a specific amount from a sender to a recipient, valid within a bounded DAA-score window, uniquely identified by a 32-byte hash of its own fields.
Definition 1.1 (FlashTransaction)
struct FlashTransaction {
version: u16,
pubkey: Vec<u8>, // 1952 B (ML-DSA-65)
recipient: Vec<u8>, // 20 B address hash
amount: u64, // kana
fee: u64, // kana, min 1000
expiry_daa_score: u64, // current_daa + buffer
salt: [u8; 16], // CSPRNG
signature: Vec<u8>, // 3309 B (ML-DSA-65)
}
Total size (excluding signature vector overhead): ~5.3 KB
Definition 1.2 (flash_id)
flash_id : FlashTransaction → {0,1}^256
flash_id(tx) = SHA3-256(
D_FLASH_ID
‖ tx.version (u16 LE)
‖ tx.pubkey
‖ tx.recipient
‖ tx.amount (u64 LE)
‖ tx.fee (u64 LE)
‖ tx.expiry_daa_score (u64 LE)
‖ tx.salt
)
where D_FLASH_ID = "SAHYADRI_FLASH_ID_V1"
The salt guarantees uniqueness across intentional distinct
transfers. Without it, two transfers of the same amount to
the same recipient would have identical identifiers and one
would be rejected as a replay.2. Why Nonce-Less
A sequential nonce assumes per-account ordering: transaction N+1 cannot be applied before N. A DAG does not provide per-account ordering across parallel blocks — two transactions from the same account can be in parallel blocks, and their canonical order is determined by consensus, not by their arrival.
Requirement (from SahyadriDAG):
1. Order-independent within a mergeset.
Replay protection must accept or reject a transaction based on
its own fields, not on its position relative to other
transactions from the same account.
2. Bounded per-account storage.
The cost of tracking replay state per account must not grow
with chain length or with total transactions ever sent.
3. Deterministic across nodes.
Two nodes processing the same block must compute the same
state — including replay state — bit-for-bit.
4. Committed atomically with balance.
A state proof for one account must simultaneously attest to
balance AND replay state. No separate proof, no side table.
Constraint 1 eliminates nonce-based schemes.
Constraint 4 eliminates side-registry schemes.
The bounded-window approach satisfies both.3. The Replay Window
Each account state contains a bounded vector of recently applied flash entries. The vector is part of the account leaf that the SMT commits to.
Definition 3.1 (Account state)
struct AccountState {
balance: u64,
recent_flashes: Vec<FlashEntry>,
// legacy fields (nonce, last_applied_tx_id) — deprecated
}
struct FlashEntry {
flash_id: Hash,
expiry_daa_score: u64,
block_hash: Hash, // reorg-local, not in committed hash
}
Definition 3.2 (Replay check)
is_replay(A, tx) ⟺ flash_id(tx) ∈ A.recent_flashes
If true, tx is rejected from any block that would apply it to A.
Constants:
FLASH_EXPIRY_BLOCKS = 100 (validity window in DAA score)
FLASH_PRUNE_BUFFER = 50
FLASH_PRUNE_WINDOW = 150 (= 100 + 50)The two constants define two independent protections. Expiry ensures a transaction cannot be applied after 100 DAA score; the buffer ensures that the replay entry is retained for 50 more, closing any race between expiry check and replay check.
4. Validation Predicate
A Flash Transaction is accepted if and only if all six conditions hold. Each condition is cheap, except signature verification, which is deliberately last.
Definition 4.1 (Validation)
valid(tx, A, current_daa) ⟺
(1) current_daa ≤ tx.expiry_daa_score
(expiry window not passed)
(2) tx.fee ≥ 1000
(fee floor)
(3) flash_id(tx) ∉ A.recent_flashes
(replay window clean)
(4) Verify_ML-DSA-65(
tx.signature,
tx.pubkey,
sighash(tx)
) = ⊤
(signature valid)
(5) A.balance ≥ tx.amount + tx.fee
(sufficient balance)
(6) ∀ other tx' from same sender in same block:
flash_id(tx') ≠ flash_id(tx)
(no in-batch duplicate)
Order of evaluation:
Cheapest checks first:
(1) one integer comparison
(2) one integer comparison
(3) hash-set lookup, O(window size)
(6) hash-set lookup, O(batch size)
(5) one integer comparison
(4) ML-DSA-65 verify, ~35 µs
Signature verification runs only if all five preceding checks
pass. This minimizes wasted CPU on invalid inputs.5. Batch Validation
A block's flash transactions are validated as a batch. The key invariant: same-sender transactions are aggregated before balance validation to prevent double-spend within one block.
Algorithm 5.1 (Batch-validate)
Input: flash_txs [tx_1, ..., tx_N], block_daa_score
Output: effects applied, or block rejected
Step 1: Aggregate sender debits
debits: Map<PubKey, u64> = {}
for tx in flash_txs:
spk = pubkey_to_spk(tx.pubkey)
debits[spk] += tx.amount + tx.fee
// overflow checked
Step 2: Cumulative balance check
for (spk, total_debit) in debits:
account = get_account(spk)
if account.balance < total_debit:
return reject (SpendTooHigh)
Step 3: Per-tx checks and application
seen: Set<Hash> = {}
for tx in flash_txs:
id = flash_id(tx)
if id ∈ seen:
skip (duplicate within batch)
if block_daa_score > tx.expiry_daa_score:
skip (expired)
if is_replay(sender(tx), id):
skip (replay from earlier block)
if not verify_signature(tx):
skip (invalid signature)
seen.insert(id)
apply_to_overlay(tx)
Step 4: Commit overlay to SMT
Key design choices:
(a) Balance check runs first per sender, before any signature
verification. Cheapest-first.
(b) Duplicates are skipped, not rejected. In a DAG, the same
flash transaction can appear in parallel blocks. Rejecting
the batch on a duplicate would drop unrelated valid txs
from the same block.
(c) Signature verification is last. It is ~1000× more expensive
than the other checks combined.6. Reorg Correctness
When a block is removed from the virtual chain, its contributions to the replay window must be removed surgically. A naive reset of the entire window would make previously applied transactions replayable.
Algorithm 6.1 (Reorg-unwind) Input: account A, block B being removed Output: A with B's flash entries removed A.recent_flashes.retain(|e| e.block_hash ≠ B.hash) Correctness: Every entry added by B has block_hash = B.hash (by construction). Every entry added by any other block has a different block_hash. The retain removes exactly B's entries. Entries from parallel blocks in the same mergeset are untouched. Their replay protection remains intact through the reorg. After unwind: The reorg handler applies newly-canonical blocks in order. Any flash transaction that appeared in a removed block and reappears in an added block is treated as a fresh apply — its flash_id is re-inserted with the new block's hash. Because duplicates are skipped (Section 5.b), a flash transaction already present from a parallel block does not cause the added block to be rejected.
7. Committed State
The replay window is not a side table. It is part of the account leaf that the SMT commits to, hashed by the same content hash as balance. Two properties follow.
Content hash (from account_store.rs):
fn content_hash(&self) -> Hash {
let mut out = Vec::new();
out.extend_from_slice(&self.balance.to_le_bytes());
let mut flashes: Vec<&FlashEntry> = self.recent_flashes.iter().collect();
flashes.sort_by(|a, b| a.flash_id.as_bytes()
.cmp(&b.flash_id.as_bytes()));
out.extend_from_slice(&(flashes.len() as u32).to_le_bytes());
for f in flashes {
out.extend_from_slice(&f.flash_id.as_bytes());
out.extend_from_slice(&f.expiry_daa_score.to_le_bytes());
// block_hash is NOT included
}
SHA3-256(b"SAHYADRI_ACCOUNT_STATE_V1" ‖ out)
}
Property 7.1 (Atomic binding)
A state proof for account A simultaneously attests to:
- A.balance
- A.recent_flashes (the entire set, sorted)
One proof, two guarantees. There is no window where balance
has advanced but replay state has not — they are the same
commitment.
Property 7.2 (Order independence)
Sorting by flash_id makes the content hash a function of the
SET of entries, not the order of the vector:
hash({e1, e2, e3}) = hash({e3, e1, e2}) = hash of any permutation
Without sorting, a reorg could silently change the vector order
and therefore the committed root, forking the chain. Sorting
eliminates this failure mode.8. Deterministic Pruning
Entries are pruned when their expiry falls too far behind the current DAA score. Pruning must be deterministic across nodes — two nodes that accept the same block must compute the same root.
Algorithm 8.1 (Prune)
For each account A touched by block B:
cutoff = B.daa_score - FLASH_PRUNE_BUFFER
A.recent_flashes.retain(|e| e.expiry_daa_score > cutoff)
Critical details:
(a) Uses B.daa_score, NOT the virtual tip's DAA score.
Two nodes may have different tips. If pruning used the
tip's score, they would prune different entries for the
same block and produce different roots.
(b) Runs only on accounts touched by B.
Untouched accounts keep their entries. "Touched" is
determined by B's effects, which are deterministic.
(c) Pruning is lazy.
An account untouched for longer than FLASH_PRUNE_WINDOW
keeps its expired entries until some future block touches
it. When that block runs, all expired entries are pruned
in a single pass. The leaf collapses to what it would
have been had no flash ever been sent.9. Transaction Envelope
A Flash Transaction is wrapped in a standard Sahyadri transaction envelope using a magic prefix. This allows the protocol to distinguish flash transactions from other transaction types without a new type field at the networking layer.
Encoding (byte-for-byte):
FLASH_V1
‖ version (u16 LE)
‖ pubkey_len (u32 LE) ‖ pubkey
‖ recipient_len (u32 LE) ‖ recipient
‖ amount (u64 LE)
‖ fee (u64 LE)
‖ expiry_daa_score (u64 LE)
‖ salt (16 B)
‖ signature_len (u32 LE) ‖ signature
The magic prefix "FLASH_V1" (8 bytes) identifies the type.
Fields are length-prefixed to support future pubkey/signature
algorithm migration without changing the envelope.
Signature:
Signature is over the SHA3-256 of the fields above the signature:
sighash = SHA3-256(
D_TX_SIGN ‖
version ‖ pubkey ‖ recipient ‖
amount ‖ fee ‖ expiry ‖ salt
)
where D_TX_SIGN = "SAHYADRI_FLASH_TX_V1"
Any mutation of any field invalidates the signature.10. Expiry Semantics
The expiry_daa_score field is chosen by the sender at signing time. Two design questions follow: how large should the buffer be, and what happens after expiry.
Buffer size (SDK default):
expiry_daa_score = current_daa_score + 90
Rationale:
- At 1 BPS, 90 DAA score ≈ 90 seconds of validity
- Network round-trip for broadcast + mempool + block inclusion
rarely exceeds 5-10 seconds in normal operation
- 90 provides 9× margin against worst-case delays
- Users are not exposed to a large replay window if their
key is compromised — the window is bounded
After expiry:
A transaction is rejected if current_daa > expiry_daa_score.
Two independent checks catch this:
(a) Validation check 1: expiry check rejects immediately
(b) Even if the flash_id were pruned, check 1 still fires
The two checks are not redundant — they run at different
points and defend against different attacks. Check 1 defends
against delayed replay. The flash_id set defends against
immediate replay. Both are required.11. Attack Analysis
Attack 11.1: Direct replay
Adversary rebroadcasts a signed transaction.
Defense: check 3 fires — flash_id ∈ recent_flashes
Bound: Pr[success] = 0 (deterministic)
Attack 11.2: Mutation replay
Adversary modifies amount, recipient, or salt to produce a
new flash_id.
Defense: check 4 fires — signature no longer verifies
Bound: Pr[success] ≤ Adv_MLWE(λ) + negl(λ)
Attack 11.3: Delayed replay
Adversary holds a valid transaction past expiry, then broadcasts
it hoping the replay entry has been pruned.
Defense: check 1 fires — expiry check is independent of replay
Bound: Pr[success] = 0 (two independent checks)
Attack 11.4: Cross-account replay
Adversary uses Alice's signed transaction against Bob's account.
Defense: sender is derived from tx.pubkey, not from recipient.
Bob's account never sees a transaction signed by Alice.
Bound: Pr[success] = 0 (sender derivation is deterministic)
Attack 11.5: Batch duplicate
Same flash_id appears twice in one block, or a flash_id from a
parallel block appears again.
Defense: batch validator skips duplicates (Section 5.b)
Bound: Pr[double-apply] = 0
Attack 11.6: Reorg replay
A block applies a flash transaction, then the block is reorged.
Adversary rebroadcasts.
Defense: if the transaction is expired, check 1 rejects. If not
expired, the transaction is legitimately re-applied
(this is correct — it was undone by reorg).
Bound: Both outcomes are correct. No attacker gain.
Attack 11.7: Recipient broadcast
The recipient of a transfer rebroadcasts the transaction for a
double credit.
Defense: identical to direct replay — check 3 fires
Bound: Pr[success] = 012. Comparison
| Scheme | Mechanism | Order req. | Side registry | In state commitment |
|---|---|---|---|---|
| Bitcoin | UTXO references | Yes | UTXO set | UTXO set hash |
| Ethereum | Monotonic nonce | Yes | State trie | State trie |
| Solana | Recent blockhash | Yes | Blockhash cache | Not committed |
| Stellar | Sequence + timebounds | Yes | Ledger entry | Ledger entry |
| Monero | Key image set | No | Key image set | Set hash (grows) |
| Sahyadri | Bounded flash window | Not required | None | Account SMT leaf |
Time-bounded replay windows are not unique to Sahyadri. Stellar uses timebounds; Monero uses a growing key-image set; several DAG-based chains use variations. What differs in Sahyadri is the combination:
(a) Order-independent — no per-account ordering is required
because the replay check is a set-membership test.
(b) Bounded — window contains only entries from the last
~150 DAA score, not chain history.
(c) Committed inside the same SMT leaf as balance — one proof
simultaneously attests to both.
(d) No side registry — no second Merkle tree, no auxiliary
store, no cross-store consistency to maintain.13. Limitations
Limitation 13.1: No hard cap on entries per account
An adversary can flood their own account with flash transactions
in one window, inflating their own leaf. This costs them fees
and storage; it does not affect other accounts.
Status: Per-account cap planned. Not implemented.
Limitation 13.2: Pruning must use block's own DAA score
If pruning runs at the virtual tip's DAA score instead of the
block being processed, two nodes with different tips could
prune different entries and produce different roots.
Status: Enforced by policy. Tests cover the invariant.
Limitation 13.3: Legacy account transactions still accepted
The chain's account-model-native path is flash-only. The
validator does not yet reject legacy account txs, which are
treated as no-ops for the SMT commitment.
Status: To be removed by deleting the legacy path.
Date not scheduled.
Limitation 13.4: Duplicate-skip vs reject semantics in progress
The batch validator needs to skip duplicates rather than reject
the batch. Some code paths still reject; fix pending.
Status: Partial. In-progress fix.14. SDK Usage
The Sahyadri SDK exposes two operations: build a signed flash transaction, and broadcast it. Expiry is computed automatically from the current DAA score returned by any full node.
import {
buildFlashTransactionHex,
RpcClient,
Encoding,
} from '@sahyadrinet/web3.js';
const rpc = new RpcClient({
url: '127.0.0.1',
encoding: Encoding.Borsh,
networkId: 'mainnet',
});
await rpc.connect();
// Fetch current DAA score from node RPC (getBlockDagInfo)
const { virtualDaaScore: daa } = await rpc.getBlockDagInfo();
// Build a signed, ready-to-broadcast transaction.
// The SDK computes expiry as daa + 90.
const txHex = buildFlashTransactionHex({
secretKey: wallet.secretKey, // 4032 B
publicKey: wallet.publicKey, // 1952 B
recipient: recipientHash20, // 20 B
amount: 50_000_000n, // 0.5 CSM in kana
fee: 1_000n, // min fee
currentDaaScore: daa,
});
// Broadcast
const txid = await rpc.submitTransaction(txHex);15. Summary
A Flash Transaction is a signed intent with a bounded validity window and a deterministic identifier. Replay protection is not a global nonce and not a UTXO reference — it is a per-account, time-bounded set of recently applied identifiers, committed inside the same SMT leaf that commits to balance.
The scheme is order-independent (works in a DAG without per-account ordering), registry-free (no side table), and atomically bound to balance (one state proof attests to both). Every property of the SMT — canonical roots, content addressing, atomic commitment — extends automatically to replay protection.
The cost is small: 16 bytes of salt per transaction, and a bounded vector per account that self-prunes lazily when the account is next touched. The benefit is a transaction layer whose correctness follows from the same primitive that proves the balance.