From 4942e45787714e982e158c504fd7274358456454 Mon Sep 17 00:00:00 2001 From: vmidyllic <74898029+vmidyllic@users.noreply.github.com> Date: Sat, 16 Apr 2022 00:25:37 +0300 Subject: [PATCH 1/2] add revocation status and proofs --- verifiable/credential.go | 11 ++++++++ verifiable/proof.go | 57 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/verifiable/credential.go b/verifiable/credential.go index fcb9f00..2c4d565 100644 --- a/verifiable/credential.go +++ b/verifiable/credential.go @@ -37,3 +37,14 @@ type CredentialStatusType string // JSONSchemaValidator2018 JSON schema const JSONSchemaValidator2018 = "JsonSchemaValidator2018" + +// RevocationStatus status of revocation nonce. Info required to check revocation state of claim in circuits +type RevocationStatus struct { + Issuer struct { + State *string `json:"state"` + RootOfRoots *string `json:"root_of_roots,omitempty"` + ClaimsTreeRoot *string `json:"claims_tree_root,omitempty"` + RevocationTreeRoot *string `json:"revocation_tree_root,omitempty"` + } `json:"issuer"` + MTP `json:"mtp"` +} diff --git a/verifiable/proof.go b/verifiable/proof.go index a488b79..4e6a7d0 100644 --- a/verifiable/proof.go +++ b/verifiable/proof.go @@ -2,6 +2,7 @@ package verifiable import ( mt "github.com/iden3/go-merkletree-sql" + "math/big" ) // MTPProof JSON-LD merkle tree proof @@ -67,3 +68,59 @@ const ( // ProofPurposeAuthentication is a proof for authentication ProofPurposeAuthentication ProofPurpose = "Authentication" ) + +// ProofData is structure that represents SnarkJS library result of proof generation +type ProofData struct { + A []string `json:"pi_a"` + B [][]string `json:"pi_b"` + C []string `json:"pi_c"` + Protocol string `json:"protocol"` +} + +// ZKProof is proof data with public signals +type ZKProof struct { + Proof *ProofData `json:"proof"` + PubSignals []string `json:"pub_signals"` +} + +// ProofType is a type that must be used for proof definition +type ProofType string + +func (p ProofType) String() string { + return string(p) +} + +var ( + // ZeroKnowledgeProofType describes zkp type + ZeroKnowledgeProofType ProofType = "zeroknowledge" + // SignatureProofType describes signature + SignatureProofType ProofType = "signature" +) + +type ProofRequest interface { + GetType() ProofType + GetRules() map[string]interface{} + GetID() string + GetChallenge() *big.Int +} + +// ZeroKnowledgeProofRequest represents structure of zkp object +type ZeroKnowledgeProofRequest struct { + Type ProofType `json:"type"` + CircuitID string `json:"circuit_id"` + Challenge *big.Int `json:"challenge"` + Rules map[string]interface{} `json:"rules,omitempty"` +} + +func (r *ZeroKnowledgeProofRequest) GetType() ProofType { + return r.Type +} +func (r *ZeroKnowledgeProofRequest) GetID() string { + return r.CircuitID +} +func (r *ZeroKnowledgeProofRequest) GetRules() map[string]interface{} { + return r.Rules +} +func (r *ZeroKnowledgeProofRequest) GetChallenge() *big.Int { + return r.Challenge +} From 0cedc1d675297d6b169d57f6221c7bc5ddca7cca Mon Sep 17 00:00:00 2001 From: vmidyllic <74898029+vmidyllic@users.noreply.github.com> Date: Tue, 26 Apr 2022 10:54:05 +0300 Subject: [PATCH 2/2] fix linter --- verifiable/proof.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/verifiable/proof.go b/verifiable/proof.go index 4e6a7d0..91ced39 100644 --- a/verifiable/proof.go +++ b/verifiable/proof.go @@ -86,6 +86,7 @@ type ZKProof struct { // ProofType is a type that must be used for proof definition type ProofType string +// String returns string representation of ProofType func (p ProofType) String() string { return string(p) } @@ -97,6 +98,7 @@ var ( SignatureProofType ProofType = "signature" ) +// ProofRequest is a request for zk / signature proof generation type ProofRequest interface { GetType() ProofType GetRules() map[string]interface{} @@ -112,15 +114,22 @@ type ZeroKnowledgeProofRequest struct { Rules map[string]interface{} `json:"rules,omitempty"` } +// GetType returns type from zkp request func (r *ZeroKnowledgeProofRequest) GetType() ProofType { return r.Type } + +// GetID returns id from zkp request func (r *ZeroKnowledgeProofRequest) GetID() string { return r.CircuitID } + +// GetRules rules from zkp request func (r *ZeroKnowledgeProofRequest) GetRules() map[string]interface{} { return r.Rules } + +// GetChallenge challenge from zkp request func (r *ZeroKnowledgeProofRequest) GetChallenge() *big.Int { return r.Challenge }