Go to file
Kirill Pimenov 0c77cc4534
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
End to end test / e2e-test (push) Has been cancelled
Trivy scan / Analyze (push) Has been cancelled
Yarn tests / yarn (push) Has been cancelled
fix: correct reprint threshold display and de-duplicate the formula (#124)
* fix: correct reprint threshold display and de-duplicate the formula (F5)

Print.vue recomputed the recovery threshold as floor(total/2)+2 and stored
the *total* in a field misleadingly named `requiredShards`. The reprint
sheets therefore overstated how many more QR codes are needed (e.g. total=5
showed "need 4" instead of the correct 3) — misleading during recovery,
though the QR payloads themselves were always untouched.

Root cause: the threshold policy was duplicated. Share.vue computes
floor(total/2)+1; Print.vue re-implemented it and drifted. Extract a single
`defaultThreshold()` helper (src/util/shards.ts) and use it in both, so they
can never disagree again. Rename Print.vue's field to `totalShards` to match
what it actually holds.

Add unit tests for the helper, including the exact F5 case (total=5 -> 3) and
a strict-majority invariant across the whole 3..255 UI range.

* fix: reject fractional shard counts, clamp the remaining-code count

Review follow-ups on the reprint view.

`<input type="number">` only constrains the spinner, not the value: typing
"3.5" (or clearing the box, which `v-model.number` leaves as "") sailed
through the old `>= 3 && <= 255` check and reached defaultThreshold(),
producing fractional totals and remaining counts. Add `step="1"` for the
spinner and gate on a shared `isValidShardCount()` predicate that also
requires a whole number, so the input and the threshold policy keep agreeing
about what a shard count is.

`needMoreShards` compared with `!==`, so scanning more codes than announced
kept the scanner open and drove `remainingCodes` negative. Compare with `<`
and clamp the remainder at 0.

`threshold` returned 0 for "nothing entered yet", a valid-looking value that
could reach ShardInfo's required-shards prop. Return `undefined` instead and
guard the consuming block on it, making the not-yet-entered state explicit.

The `threshold` and validation paths are covered by shards.spec.ts; the
scanner-overshoot clamp is not, as the repo has no component-test harness yet.

* fix: apply the same shard-count validation to the generator

Share.vue's shard-count input had the defect Copilot flagged on Print.vue's:
no `step`, no integer check, and `totalShards` fed straight into
crypto.share() — a fractional count surfaced as an opaque secrets.js error
routed through the generic error hub, and an emptied box passed "" through.

Reuse `isValidShardCount()` and gate the generate button on it, matching the
existing `secretTooLong` pattern (disabled button plus an inline error span),
so both shard-count inputs now agree on what a shard count is.

* fix: stop rendering a threshold derived from an invalid shard count

Gating the generate button left the sentence above it still interpolating
defaultThreshold(totalShards) for values that had just been rejected: an
emptied field coerces to 0 and renders "Will require any 1 shards", and 3.5
renders 2. Give Share.vue's `requiredShards` the same contract as Print.vue's
`threshold` — `undefined` unless the count is usable — show an em dash in the
sentence, and guard both the generated-shards block and crypto.share() on it.

Also strengthen the threshold invariant test. Asserting only
`defaultThreshold(n) > n / 2` does not pin the policy: floor(n/2)+2, the very
formula this branch removed, satisfies it for every even n. Assert the
smallest strict majority instead, which floor(n/2)+1 alone satisfies.
2026-08-04 16:10:30 +02:00
.github bump gha versions and add dependabot (#97) 2022-08-26 11:44:16 +07:00
public It shares 2018-11-18 17:23:19 +01:00
src fix: correct reprint threshold display and de-duplicate the formula (#124) 2026-08-04 16:10:30 +02:00
tests fix: correct reprint threshold display and de-duplicate the formula (#124) 2026-08-04 16:10:30 +02:00
.babelrc First test for crypto.js 2018-11-26 20:18:17 +01:00
.eslintrc.js add end-to-end UI tests. Resolves #30 2021-11-17 11:21:00 +07:00
.gitignore add end-to-end UI tests. Resolves #30 2021-11-17 11:21:00 +07:00
.nvmrc fix #35 migrate to Typescript 2021-09-23 12:00:36 +07:00
jest.config.js fix #35 migrate to Typescript 2021-09-23 12:00:36 +07:00
LICENSE License it under GPL-3.0 2019-01-29 17:54:17 +01:00
package.json Bump gh-pages from 2.2.0 to 5.0.0 (#111) 2024-08-23 11:37:21 +02:00
playwright.config.ts add end-to-end UI tests. Resolves #30 2021-11-17 11:21:00 +07:00
README.md add end-to-end UI tests. Resolves #30 2021-11-17 11:21:00 +07:00
tsconfig.json fix #35 migrate to Typescript 2021-09-23 12:00:36 +07:00
vue.config.js always show git hash in bs version (#81) 2021-12-13 15:12:43 +07:00
yarn.lock Bump elliptic from 6.5.4 to 6.5.7 (#112) 2024-08-23 11:37:32 +02:00

Banana Split 🍌 · Yarn tests Join the chat at https://gitter.im/paritytech/banana_split

Banana Split makes your paper backups more resilient and secure using Shamirs secret sharing.

It splits your secret (e.g., paper backup) into N pieces, but only requires a majority of those pieces (N/2+1) to recover your secret.

Why Banana Split?

Theres a few problems with normal paper backups: If you have the whole paper backup somewhere, youre vulnerable to someone finding it and stealing it—without you ever knowing they did (e.g., they can just take a photo of it). If you split your paper backup into two, what happens if one of those pieces goes missing?

For example:

You use Banana Split to split your paper backup into 5 pieces. You then give 5 friends a piece. It only takes 3 of those friends to come together to retrieve the paper backup. If 2 of your friends end up losing their piece, its okay. And if 2 of your friends collude and try to retrieve your backup, they wont be able to. That is to say:

Any 3 friends will know everything; any 2 friends will know nothing.

Usage

How do you make a Banana Split?

  1. Save the Banana Split HTML page and open it in offline mode.
  2. Type your secret into Banana Split. Your secret will be encrypted with an auto-generated passphrase and split it into the number of QR codes you specify.
  3. Print out your QR codes.
  4. Write the passphrase by hand on every sheet. Doing this by hand protects against an attacker intercepting things youre sending to the printer.

How do you retrieve a Banana Split?

Recovery can be done on any device with a webcam.

  1. Save the Banana Split HTML page and open it in offline mode.
  2. Using your webcam, scan in a majority of your QR code printouts (e.g., if you had 7 printouts, youll need 4).
  3. Enter your passphrase.
  4. Viola! Your secret is restored.

⚠️ Important

Work local and offline

Banana Split is a self-contained HTML page. To ensure your precious data is never sent outside, it only works when opened from your local hard drive while your browser is in Offline mode.

Without the passphrase, you wont be able to retrieve your secret

To retrieve your secret, youll need to have a majority of the printouts and know the passphrase. This is why it is critical for you to write the passphrase on every printout.

Keep the HTML document

This HTML page is a fully self-contained application under GPLv3 license. Please feel free to copy and share it with anyone you want to use it. The more copies out there, the less likely it will be compromised or taken down.

Development

Project setup

yarn install

Compiles and hot-reloads for development

yarn run serve

Compiles and minifies for production

yarn run build

Run unit tests

yarn run test:unit

Run end-to-end UI tests

yarn run test:e2e

Lints and fixes files

yarn run lint

Customize configuration

See Configuration Reference.