Skip to content

Commit

Permalink
Merge pull request #17 from iden3/chore/protocol-support
Browse files Browse the repository at this point in the history
add revocation status and proofs
  • Loading branch information
vmidyllic authored Apr 26, 2022
2 parents 6c5db43 + 0cedc1d commit a567def
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
11 changes: 11 additions & 0 deletions verifiable/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
66 changes: 66 additions & 0 deletions verifiable/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package verifiable

import (
mt "github.com/iden3/go-merkletree-sql"
"math/big"
)

// MTPProof JSON-LD merkle tree proof
Expand Down Expand Up @@ -67,3 +68,68 @@ 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

// String returns string representation of ProofType
func (p ProofType) String() string {
return string(p)
}

var (
// ZeroKnowledgeProofType describes zkp type
ZeroKnowledgeProofType ProofType = "zeroknowledge"
// SignatureProofType describes signature
SignatureProofType ProofType = "signature"
)

// ProofRequest is a request for zk / signature proof generation
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"`
}

// 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
}

0 comments on commit a567def

Please sign in to comment.