Skip to content

Commit

Permalink
Using SHAKE128 as a fixed prgn for golden files.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Apr 24, 2024
1 parent 2c600ff commit fe2b663
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
7 changes: 6 additions & 1 deletion abe/cpabe/tkn20/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ func Example() {
if err != nil {
log.Fatalf("%s", err)
}
fmt.Printf("plaintext size: %v bytes\n", len(msgStr))
fmt.Printf("ciphertext size: %v bytes\n", len(ct))

// generate secret key for certain set of attributes
wrongAttrs := cpabe.Attributes{}
Expand Down Expand Up @@ -127,6 +129,9 @@ func Example() {
log.Fatalf("recovered plaintext: %s is not equal to original msg: %s", pt, msgStr)
}
fmt.Println("Successfully recovered plaintext")
// Output: (occupation:doctor and country:US)
// Output:
// (occupation:doctor and country:US)
// plaintext size: 27 bytes
// ciphertext size: 2735 bytes
// Successfully recovered plaintext
}
11 changes: 3 additions & 8 deletions abe/cpabe/tkn20/gen_testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ package main

import (
"encoding"
mrand "math/rand"
"os"
"path/filepath"

cpabe "github.com/cloudflare/circl/abe/cpabe/tkn20"
"github.com/cloudflare/circl/xof"
)

func writeToFile(name string, data []byte) {
Expand All @@ -30,13 +29,9 @@ func dumpToFile(name string, m encoding.BinaryMarshaler) {

func main() {
// Using fixed PRNG for reproducibility,
fixedSeed := int64(0xC1C1C1C1)
prng := mrand.New(mrand.NewSource(fixedSeed))
if prng == nil {
panic("failed to create PRNG")
}
prng := xof.SHAKE128.New()

err := os.MkdirAll(filepath.Join(".", "testdata"), 0o755)
err := os.MkdirAll("testdata", 0o755)
if err != nil {
panic(err)
}
Expand Down
Binary file modified abe/cpabe/tkn20/testdata/attributeKey
Binary file not shown.
Binary file modified abe/cpabe/tkn20/testdata/ciphertext
Binary file not shown.
Binary file modified abe/cpabe/tkn20/testdata/publicKey
Binary file not shown.
Binary file modified abe/cpabe/tkn20/testdata/secretKey
Binary file not shown.

0 comments on commit fe2b663

Please sign in to comment.