revocation-keypair.go 1.4 KB
Newer Older
1
2
3
package cmd

import (
4
	"github.com/privacybydesign/gabi/gabikeys"
5
	"github.com/spf13/cobra"
6
7
8
)

var revokeKeypairCmd = &cobra.Command{
9
	Use:   "revocation-keypair <privatekey> <publickey>",
10
11
	Short: "Augment an IRMA private-public keypair with revocation key material",
	Long: `Augment an IRMA private-public keypair with newly generated revocation key material.
12
13
This is required before credential types requiring revocation can be issued under this keypair.
(New keypairs generated with "irma scheme issuer keygen" already support revocation.)`,
14
15
	Args: cobra.ExactArgs(2),
	Run: func(cmd *cobra.Command, args []string) {
16
		sk, err := gabikeys.NewPrivateKeyFromFile(args[0], false)
17
18
19
20
21
22
23
		if err != nil {
			die("failed to read private key", err)
		}
		if sk.RevocationSupported() {
			die("private key already supports revocation", nil)
		}

24
		pk, err := gabikeys.NewPublicKeyFromFile(args[1])
25
26
27
28
29
30
31
		if err != nil {
			die("failed to read public key", err)
		}
		if pk.RevocationSupported() {
			die("public key already supports revocation", nil)
		}

32
		if err = gabikeys.GenerateRevocationKeypair(sk, pk); err != nil {
33
34
35
36
37
38
39
40
41
42
43
44
45
46
			die("failed to generate revocation keys", err)
		}

		if _, err = sk.WriteToFile(args[0], true); err != nil {
			die("failed to write private key", err)
		}
		if _, err = pk.WriteToFile(args[1], true); err != nil {
			die("failed to write public key", err)
		}

	},
}

func init() {
47
	issuerCmd.AddCommand(revokeKeypairCmd)
48
}