Skip to content

refactor: centralize mnemonic generation in the SDK - #593

Merged
n13 merged 1 commit into
mainfrom
refactor/centralize-seed-generation
Aug 2, 2026
Merged

refactor: centralize mnemonic generation in the SDK#593
n13 merged 1 commit into
mainfrom
refactor/centralize-seed-generation

Conversation

@n13

@n13 n13 commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Why

Seed generation lived in two places: SubstrateService.generateMnemonic() (used by the mobile and cold-wallet apps) and a duplicated copy in MinerWalletService. Duplicated entropy-generation code is a maintenance and audit risk — a future change to one path could silently diverge from the other.

What

  • MinerWalletService.generateMnemonic() now delegates to SubstrateService().generateMnemonic(), so all mnemonic/seed generation lives in one spot in quantus_sdk.
  • The SDK generator now reuses a single Random.secure() instance instead of constructing one per entropy byte (no behavior change — each instance was freshly OS-seeded anyway).

Both paths were and remain OS-CSPRNG-backed (Random.secure() → SecRandomCopyBytes / getrandom / BCryptGenRandom); this is a consolidation, not a security fix.

Verification

  • melos run format — clean
  • melos run analyze — clean for quantus_sdk, miner-app, cold-wallet-app (mobile-app's analysis server crashes with SIGKILL on this machine, unrelated to this change; mobile-app is untouched)

MinerWalletService re-implemented SubstrateService.generateMnemonic()
instead of calling it. Delegate to the SDK so all seed generation
lives in one place, and reuse a single Random.secure() instance when
filling the entropy buffer.

@dewabisma dewabisma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool! This is great!

@n13
n13 merged commit 0b5a869 into main Aug 2, 2026
1 check passed
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