Skip to content

Add radix-ness classifier as first step of the radix lower-bound path#85

Open
bc1cindy wants to merge 2 commits into
payjoin:masterfrom
bc1cindy:radix-analyzer
Open

Add radix-ness classifier as first step of the radix lower-bound path#85
bc1cindy wants to merge 2 commits into
payjoin:masterfrom
bc1cindy:radix-analyzer

Conversation

@bc1cindy

@bc1cindy bc1cindy commented May 25, 2026

Copy link
Copy Markdown
Contributor

the radix path applies when amounts decompose into Hamming-weight-1 denominations in complementary bases (2, 3, 10). geometric progressions with non-trivial multiplicity in those bases generate dense subset-sum instances, which let the number of valid sub-transaction mappings be lower-bounded cheaply

this PR delivers a classifier that, given a tx's input and output amounts, returns per-series multiplicity counts

primitives vendored from small hamming weight denominations for coinjoins. Consts and generators match the notebook

the gap/density check is deferred to the lower-bound consumer that uses it

part of #84

basically a classification, given a tx's input and output values, first analyze its radix-ness by separating to multiplicity
counts for each kind of value, and then for the low hamming weight ones, trying to assess whether or not there are
serious gaps
don't think about the score per output just yet

@bc1cindy bc1cindy marked this pull request as draft May 25, 2026 18:37
@bc1cindy

Copy link
Copy Markdown
Contributor Author

also related with #5

@bc1cindy bc1cindy marked this pull request as ready for review May 25, 2026 18:52

@arminsabouri arminsabouri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple questions to start with. Im curious how this will be used in the simulations. I may take a stab at integrating some of this

Comment thread src/crates/partitions/src/radix/denoms.rs Outdated
Comment thread src/crates/partitions/src/radix/mod.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs
bc1cindy added a commit to bc1cindy/tx-indexer that referenced this pull request Jun 1, 2026
Wires the dense-subset-sum 4-path subset-sum/coinjoin-mapping counts
(brute, radix, sparse, Sasamoto) into btsim two ways:

- As agent cost: WLowerBoundMetric (W lower bound via brute/sparse) and
  RadixMappingMetric (k×m! denomination mappings, gated by radix density)
  plug into the existing PrivacyBundle. With a subset_sum_threshold /
  radix_threshold set in ScorerConfig, each candidate plan is scored by a
  linear deficit to the threshold, so agents favor coinjoins with more
  subset-sum ambiguity.
- As measurement: four_counts runs all four paths over the sim's confirmed
  txs recording CPU, peak RAM (alloc-probe feature), and density regime
  (kappa via the L bracket). Plus a correctness benchmark against the dep's
  oracle, a kappa/L sweep, a switch_sweep locating the sparse->Sasamoto
  handoff, and a CJA comparison (W vs Maurer sub-transaction mappings).

Adds denominated funding (standard-denomination UTXOs in a band, via
mine_denominated) so the sim can produce dense coinjoins, and fixes a
latent over-spend in coin selection that the dense funding exposed
(select_all now returns None unless inputs cover the target; session
contribution is gated on coverage).

Exploration on the fork (review-only) - distinct from the native radix
metric of payjoin#84/payjoin#85. rustfmt + clippy clean.

@bc1cindy bc1cindy left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review @arminsabouri

Im curious how this will be used in the simulations.

test and measure benchmarks from the simulations of the four primitives: brute force / radix / sparse convolution / Sasamoto , who are competing/complementary, with two asymmetries worth stating:

  • brute, radix and sparse are guaranteed lower bounds while Sasamoto is an approximation
  • radix is the cheap, pre computable shortcut for the standard-denomination special case (it avoids solving subset-sum at all), whereas brute and sparse are the ones with real cost/limits. So in the sim we run them in parallel with guards(brute aborts before the exponential blow-up; sparse stops once the sumset table exceeds a RAM budget) and characterize each on two axes - correctness (matches the exact brute/DP count? lower bound holds? Sasamoto error?) and cost (CPU time, peak RAM). That's what lets us later compose them into per-actor profiles (a maker can spend minutes/GB; a mobile client can't) and pick the regime-switch points.

please take a look at #86, it will be better to see it

I may take a stab at integrating some of this

sounds great!

Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/denoms.rs Outdated
Comment thread src/crates/partitions/src/radix/mod.rs Outdated
@bc1cindy bc1cindy marked this pull request as draft June 1, 2026 20:26
@bc1cindy bc1cindy marked this pull request as ready for review June 1, 2026 22:07
@bc1cindy bc1cindy requested a review from arminsabouri June 1, 2026 22:07
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/sumset.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/sumset.rs Outdated
Comment thread src/crates/partitions/src/radix/sumset.rs Outdated

@bc1cindy bc1cindy left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed max_gap/max_combination_value/sumset from this PR, keeping just the per-series multiplicities. the gap/density check can come back with the lower-bound consumer

Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/analysis.rs Outdated
Comment thread src/crates/partitions/src/radix/sumset.rs Outdated
Comment thread src/crates/partitions/src/radix/sumset.rs Outdated
Comment thread src/crates/partitions/src/radix/sumset.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants