Skip to content

Commit

Permalink
feat: add support for credential status for public credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
noandrea committed May 22, 2022
1 parent 8e10c51 commit 9391d93
Show file tree
Hide file tree
Showing 4 changed files with 457 additions and 57 deletions.
19 changes: 17 additions & 2 deletions proto/credential/v1/credential.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,20 @@ message PublicVerifiableCredential {
// the date-time of expiration
google.protobuf.Timestamp expirationDate = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];

// credential status for the revocation lists
CredentialStatus credentialStatus = 7 [(gogoproto.nullable) = true];


// the subject of the credential
// the preferred way to handle the subject will be to use the Struct type
// but at the moment is not supported
// google.protobuf.Struct credentialSubject = 7;
bytes credentialSubject = 7;
bytes credentialSubject = 8;

// One or more cryptographic proofs that can be used to detect tampering
// and verify the authorship of a credential or presentation. The specific
// method used for an embedded proof MUST be included using the type property.
Proof proof = 8;
Proof proof = 9;
}


Expand All @@ -99,3 +103,14 @@ message Proof {
string signature = 5;
}

// CredentialStatus implement support for biststring based revocation lists
// as described here: https://w3c-ccg.github.io/vc-status-rl-2020/#revocationlist2020status
message CredentialStatus {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;

string id = 1;
string type = 2;
int64 revocationListIndex = 3;
string revocationListCredential = 4;
}
1 change: 1 addition & 0 deletions scripts/seeds/03_credential_seeds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ echo "Sign and issue public credential"

elestod tx credential issue-public-credential revocation-list-2020 03_credential.json \
--export 03_credential.signed.json \
--non-revocable \
--from regulator \
--chain-id elesto -y --broadcast-mode block

Expand Down
12 changes: 10 additions & 2 deletions x/credential/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ func GetTxCmd() *cobra.Command {
// NewIssuePublicCredential defines the command to publish credential definitions
func NewIssuePublicCredential() *cobra.Command {

var credentialFileOut string
var (
credentialFileOut string
nonRevocable bool
)

cmd := &cobra.Command{
Use: "issue-public-credential credential-definition-id credential_file",
Expand All @@ -65,6 +68,11 @@ func NewIssuePublicCredential() *cobra.Command {
println("error building credential definition", err)
return err
}
// is it revocable
if !nonRevocable && wc.CredentialStatus == nil {
println("credential status for revocation is missing, if this is intended use the flag --non-revocable", err)
return err
}
// get the issuer did
vmID := wc.GetIssuerDID().NewVerificationMethodID(signer.String())
if err = sign(wc, clientCtx.Keyring, signer, vmID); err != nil {
Expand Down Expand Up @@ -102,7 +110,7 @@ func NewIssuePublicCredential() *cobra.Command {
}
// add flags
cmd.Flags().StringVar(&credentialFileOut, "export", "", "export the signed credential to a json file")

cmd.Flags().BoolVar(&nonRevocable, "non-revocable", false, "if not set, the credential must contain the credentialStatus field")
flags.AddTxFlagsToCmd(cmd)
return cmd
}
Expand Down
Loading

0 comments on commit 9391d93

Please sign in to comment.