Skip to content

fix: #131 use SecureRandom for default wallet id generator - #139

Open
edmoffo wants to merge 1 commit into
zold-io:masterfrom
edmoffo:131-securerandom
Open

fix: #131 use SecureRandom for default wallet id generator#139
edmoffo wants to merge 1 commit into
zold-io:masterfrom
edmoffo:131-securerandom

Conversation

@edmoffo

@edmoffo edmoffo commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

The default constructor WalletsIn(Path) was seeding wallet-id generation with new java.util.Random(), the 48-bit LCG that #131 flagged as recoverable from a small handful of observed outputs. That let any observer of past ids enumerate upcoming ones and race the existence check on the next create() call. The two-arg constructor that takes a caller-supplied Random was kept untouched so deterministic test seeds stay unchanged.

Switched the default to new java.security.SecureRandom(). SecureRandom extends Random, so the rest of the constructor chain and the random.nextLong() call inside create() need no further adjustment. The change is two lines in WalletsIn.java: one new import and one swapped allocator.

Local checks: mvn -B test (68 tests, 0 failures, 5 skipped — same skipped set as master) and mvn -B -Pqulice -DskipTests verify both pass on this branch.

Closes #131

WalletsIn(Path) now seeds its randomizer with java.security.SecureRandom
instead of java.util.Random. The 48-bit LCG output of the previous default
is recoverable from a handful of observed samples, letting an observer
enumerate upcoming wallet ids and race the existence check in create().
The two-arg constructor that accepts an explicit Random is untouched, so
tests injecting deterministic generators stay unchanged.

Closes zold-io#131
@edmoffo
edmoffo force-pushed the 131-securerandom branch from 1c3cdb4 to 07dfb12 Compare June 22, 2026 00:35
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.

WalletsIn seeds wallet ID generation with java.util.Random

2 participants