From 75f2997bb1cd6d55534722a4ed3f8332f3d9041f Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Fri, 1 Sep 2023 09:30:16 -0700 Subject: [PATCH] Add deserialize subcommand to EncryptionPublicKeys tool. --- .../api/v2alpha/tools/EncryptionPublicKeys.kt | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/EncryptionPublicKeys.kt b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/EncryptionPublicKeys.kt index d69adcaccdd..62da9b28b5c 100644 --- a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/EncryptionPublicKeys.kt +++ b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/EncryptionPublicKeys.kt @@ -33,7 +33,7 @@ import picocli.CommandLine */ @CommandLine.Command( description = ["Utility for EncryptionPublicKey messages."], - subcommands = [CommandLine.HelpCommand::class, Serialize::class, Sign::class] + subcommands = [CommandLine.HelpCommand::class, Serialize::class, Deserialize::class, Sign::class] ) class EncryptionPublicKeys private constructor() : Runnable { override fun run() { @@ -74,6 +74,25 @@ private class Serialize : Runnable { } } +@CommandLine.Command(name = "deserialize", showDefaultValues = true) +private class Deserialize : Runnable { + @CommandLine.Option( + names = ["--in", "-i"], + description = ["Input File containing EncryptionPublicKey message"], + required = true + ) + private lateinit var input: File + + @CommandLine.Option(names = ["--out", "-o"], description = ["Output file"], required = true) + private lateinit var output: File + + override fun run() { + val message = input.inputStream().use { EncryptionPublicKey.parseFrom(it) } + + output.outputStream().use { message.data.writeTo(it) } + } +} + @CommandLine.Command(name = "sign") private class Sign : Runnable { @CommandLine.Option(