abe/cpabe/tkn20: fix AND-gate secret sharing. - #610
Merged
Conversation
cjpatton
force-pushed
the
cjpatton/cpabe-addshare-bug
branch
4 times, most recently
from
May 30, 2026 00:53
a01af54 to
17ea642
Compare
thibmeu
approved these changes
Jun 1, 2026
thibmeu
left a comment
Member
There was a problem hiding this comment.
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
(*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
force-pushed
the
cjpatton/cpabe-addshare-bug
branch
from
June 1, 2026 14:31
7ac84c3 to
e3b1064
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(*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.