diff --git a/abe/cpabe/tkn20/longpt_test.go b/abe/cpabe/tkn20/longpt_test.go new file mode 100644 index 000000000..861e5facc --- /dev/null +++ b/abe/cpabe/tkn20/longpt_test.go @@ -0,0 +1,60 @@ +package tkn20_test + +import ( + "bytes" + "crypto/sha256" + "fmt" + "io" + "testing" + + cpabe "github.com/cloudflare/circl/abe/cpabe/tkn20" + "github.com/cloudflare/circl/internal/test" + "github.com/cloudflare/circl/xof" +) + +func TestLongPlaintext(t *testing.T) { + // Fixed PRNG for test reproducibility. + prng := xof.SHAKE128.New() + + pk, msk, err := cpabe.Setup(prng) + test.CheckNoErr(t, err, "setup failed") + + attrs := cpabe.Attributes{} + attrs.FromMap(map[string]string{ + "occupation": "doctor", + "country": "US", + "age": "16", + }) + + sk, err := msk.KeyGen(prng, attrs) + test.CheckNoErr(t, err, "master key generation failed") + + policy := cpabe.Policy{} + err = policy.FromString(`(occupation: doctor) and (country: US)`) + test.CheckNoErr(t, err, "policy parsing failed") + + const N = 20 // 2^N bytes of plaintext + buffer := make([]byte, 1<