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..91ced39 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,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 +}