Skip to content

Commit 7a4f988

Browse files
committed
Add crypto consensus test infrastructure
This adds the commands ``` rolling-shutter crypto testdata [output_file] rolling-shutter crypto jsontests -f input_file ``` that will generate or execute tests for the methods ``` shcrypto.Encrypt shcrypto.EncryptedMessage.Decrypt shcrypto.VerifyEpochSecret ``` The output from `testdata` is a json file with test specifications similar to ``` [ { "name": "decryption 2", "id": "3", "description": "A 1 byte message.", "type": "decryption", "test_data": { "cipher": "0x20b1bd1817ead1ccf50b04ef9b77fac4c6d9b60b63436b54483f642128df31fb204d9460355ab724eb255fba7459b170306f42fd2dd7d5acc43b9c96287602760ed9138b682a195489749669573a8492b615e9c1b5185fc272a1268fad8c035e03162b507b968a34d211f168e5c1e9e3df975974e242d36d6be99ba88dcb0944fdcb3887b2fda72ce25f0dfcd8ef6d7de49a1c4d66de07ed591aa84caf406c42c1c88417d5cee83b3ef00da832d3ed35017ddc602c3a24c7deac3af725f27266", "epoch_secret_key": "0x144e428af1602d58bfb9a12bb31597f45c6c2c9d227b7a6d3f35f37d333548eb0888206e52d7cb2c6b1de7770fc2ce475a08e6cf4e95a608ec5bd93efafed6f3", "expected": "0x11" } }, ... ] ``` There are three test types corresponding to the crypto methods from above: `decryption, encryption, verification`. For `decryption` and `encryption` tests, an `expected` value of `0x` means that the result should be empty (i.e. a failure, with the exception of the special case of an empty encrypted message). For verification tests the `expected` value is a boolean `true/false`.
1 parent 3dc72d8 commit 7a4f988

File tree

5 files changed

+656
-2
lines changed

5 files changed

+656
-2
lines changed

rolling-shutter/cmd/cryptocmd/cryptocmd.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,23 @@ var (
2020
epochIDFlag string
2121
sigmaFlag string
2222
threshold uint64
23+
filename string
2324
)
2425

2526
func Cmd() *cobra.Command {
2627
cmd := &cobra.Command{
2728
Use: "crypto",
2829
Short: "CLI tool to access crypto functions",
2930
Long: `This command provides utility functions to manually encrypt messages with an eon
30-
key, decrypt them with a decryption key, and check that a decryption key is correct.`,
31+
key, decrypt them with a decryption key, and check that a decryption key is correct. It also hosts
32+
a tool to generate and run crypto tests in a JSON formatted collection.`,
3133
}
3234
cmd.AddCommand(encryptCmd())
3335
cmd.AddCommand(decryptCmd())
3436
cmd.AddCommand(verifyKeyCmd())
3537
cmd.AddCommand(aggregateCmd())
38+
cmd.AddCommand(GenerateTestdata())
39+
cmd.AddCommand(RunJSONTests())
3640
return cmd
3741
}
3842

0 commit comments

Comments
 (0)