Skip to content

abe/cpabe/tkn20: fix AND-gate secret sharing. - #610

Merged
cjpatton merged 3 commits into
mainfrom
cjpatton/cpabe-addshare-bug
Jun 1, 2026
Merged

abe/cpabe/tkn20: fix AND-gate secret sharing.#610
cjpatton merged 3 commits into
mainfrom
cjpatton/cpabe-addshare-bug

Conversation

@cjpatton

Copy link
Copy Markdown
Contributor

(*Formula).share split an AND gate's parent share incorrectly: In0 was set to a fresh random matrix but then overwritten with (Out - In1) where In1 was the zero matrix, so In0 received the entire parent share and In1 received zero. A single AND leaf could therefore reconstruct the shared secret on its own.

The CCA (Boneh-Katz) transform wraps every policy in a new outer AND gate whose left child is an internal wildcard leaf, and every CCA attribute key carries that attribute as a wildcard. Combined with the sharing bug, that single leaf received the full KEM secret, so a key that does not satisfy the public policy could recover the message by running the decapsulation pairing equations on the wildcard wire alone. The stock API's Satisfaction() check is only local logic and does not prevent this, breaking the scheme's access-control (soundness) guarantee for any policy containing at least one gate.

Share the parent across the two AND inputs correctly: one input gets a fresh random share and the other gets (parent - random), so the shares sum to the parent but neither input alone reveals it.

This changes only how the secret is shared at encryption time; the ciphertext format and decryption are unchanged, and both old and new sharings are valid additive sharings that a satisfying set reconstructs. Ciphertexts produced by the previous code remain decryptable by satisfying keys.

Add regression tests:

  • tkn.TestShareAndGateNoSingleLeafReconstructs: at the share() level, the two AND child shares sum to the secret but neither alone equals it or is zero.

  • tkn.TestBKWildcardAttackFails: simulates the attack end to end and asserts a non-satisfying key can no longer recover the plaintext via the wildcard wire.

  • tkn20.TestAndShareInteropBuggyCiphertext: decrypts a hard-coded ciphertext produced by the pre-fix code using a satisfying key derived on the fixed code, guarding ciphertext backwards-compatibility.

@cjpatton
cjpatton force-pushed the cjpatton/cpabe-addshare-bug branch 4 times, most recently from a01af54 to 17ea642 Compare May 30, 2026 00:53

@thibmeu thibmeu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I confirm that fixes a bug. The comment should be edited to reflect the current version of the code rather than use a description about a "preovious" version

Comment thread abe/cpabe/tkn20/internal/tkn/formula.go Outdated
Comment thread abe/cpabe/tkn20/internal/tkn/tk.go
Comment thread abe/cpabe/tkn20/internal/tkn/formula.go
cjpatton added 3 commits June 1, 2026 07:31
(*Formula).share split an AND gate's parent share incorrectly: In0 was
set to a fresh random matrix but then overwritten with (Out - In1) where
In1 was the zero matrix, so In0 received the entire parent share and In1
received zero. A single AND leaf could therefore reconstruct the shared
secret on its own.

The CCA (Boneh-Katz) transform wraps every policy in a new outer AND
gate whose left child is an internal wildcard leaf, and every CCA
attribute key carries that attribute as a wildcard. Combined with the
sharing bug, that single leaf received the full KEM secret, so a key
that does not satisfy the public policy could recover the message by
running the decapsulation pairing equations on the wildcard wire alone.
The stock API's Satisfaction() check is only local logic and does not
prevent this, breaking the scheme's access-control (soundness) guarantee
for any policy containing at least one gate.

Share the parent across the two AND inputs correctly: one input gets a
fresh random share and the other gets (parent - random), so the shares
sum to the parent but neither input alone reveals it.

This changes only how the secret is shared at encryption time; the
ciphertext format and decryption are unchanged, and both old and new
sharings are valid additive sharings that a satisfying set reconstructs.
Ciphertexts produced by the previous code remain decryptable by
satisfying keys.

Add regression tests:

  - tkn.TestShareAndGateNoSingleLeafReconstructs: at the share() level,
    the two AND child shares sum to the secret but neither alone equals
    it or is zero.

  - tkn.TestBKWildcardAttackFails: simulates the attack end to end and
    asserts a non-satisfying key can no longer recover the plaintext via
    the wildcard wire.

  - tkn20.TestAndShareInteropBuggyCiphertext: decrypts a hard-coded
    ciphertext produced by the pre-fix code using a satisfying key
    derived on the fixed code, guarding ciphertext
    backwards-compatibility.
@cjpatton
cjpatton force-pushed the cjpatton/cpabe-addshare-bug branch from 7ac84c3 to e3b1064 Compare June 1, 2026 14:31
@cjpatton
cjpatton merged commit 91088f2 into main Jun 1, 2026
13 checks passed
@cjpatton
cjpatton deleted the cjpatton/cpabe-addshare-bug branch June 1, 2026 14:48
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