From 51cbe861b6f5496e3378d9a51e8aaa07a20dd536 Mon Sep 17 00:00:00 2001 From: Oleg Lomaka Date: Tue, 29 Aug 2023 08:21:55 -0400 Subject: [PATCH] Upgrade github.com/iden3/go-iden3-core to v2 and bump self version to v2 (#42) * Upgrade github.com/iden3/go-iden3-core to v2 and bump self version to v2 * Upgrade go-iden3-core, go-circuits, go-jwz, iden3comm and go-schema-processor to latest versions * add supported operations for xsd double type (#55) * support non-merklized credentials (#60) --------- Co-authored-by: vmidyllic <74898029+vmidyllic@users.noreply.github.com> Co-authored-by: Ilya --- .github/workflows/ci-test.yaml | 3 - README.md | 4 +- auth.go | 138 +++++++--- auth_test.go | 429 ++++++++++--------------------- go.mod | 26 +- go.sum | 65 ++--- loaders/key.go | 2 +- loaders/schema.go | 43 ---- proofs/zk.go | 2 +- proofs/zk_test.go | 4 +- pubsignals/atomicMtpV2.go | 38 +-- pubsignals/atomicSigV2.go | 34 +-- pubsignals/authV2.go | 36 +-- pubsignals/circuitVerifier.go | 8 +- pubsignals/query.go | 108 ++++---- pubsignals/query_test.go | 357 ++++++++++++++----------- pubsignals/signals.go | 2 +- state/state.go | 4 +- state/state_test.go | 24 +- testdata/credentials-v1.json-ld | 237 +++++++++++++++++ testdata/kyc-nonmerklized.jsonld | 51 ++++ testdata/kyc-v101.json-ld | 79 ++++++ testdata/kyc-v2.json-ld | 48 ++++ testdata/kyc-v3.json-ld | 48 ++++ testdata/kyc-v4.json-ld | 48 ++++ transport/notification.go | 6 +- 26 files changed, 1133 insertions(+), 711 deletions(-) delete mode 100644 loaders/schema.go create mode 100644 testdata/credentials-v1.json-ld create mode 100644 testdata/kyc-nonmerklized.jsonld create mode 100644 testdata/kyc-v101.json-ld create mode 100644 testdata/kyc-v2.json-ld create mode 100644 testdata/kyc-v3.json-ld create mode 100644 testdata/kyc-v4.json-ld diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml index 4e50018..7b12b88 100644 --- a/.github/workflows/ci-test.yaml +++ b/.github/workflows/ci-test.yaml @@ -6,9 +6,6 @@ on: - main - develop pull_request: - branches: - - main - - develop jobs: test: strategy: diff --git a/README.md b/README.md index 26a4810..7883ae7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ > -`go get github.com/iden3/go-iden3-auth` +`go get github.com/iden3/go-iden3-auth/v2` ### General description: @@ -62,7 +62,7 @@ The blockchain verification algorithm is used 1. A non-empty GIST is returned, equal to the GIST is provided by the user, it means the user is using the latest state. 2. The non-empty GIST is returned and it’s not equal to the GIST is provided by a user. Gets the transition time of the GIST. The verification party can make a decision if it can accept this state based on that time frame. ## How to use: -1. `go get https://github.com/iden3/go-iden3-auth` +1. `go get https://github.com/iden3/go-iden3-auth/v2` 2. Request generation: basic auth: diff --git a/auth.go b/auth.go index 5a4689e..7f926d7 100644 --- a/auth.go +++ b/auth.go @@ -15,21 +15,33 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/google/uuid" "github.com/iden3/contracts-abi/state/go/abi" - "github.com/iden3/go-circuits" - "github.com/iden3/go-iden3-auth/loaders" - "github.com/iden3/go-iden3-auth/proofs" - "github.com/iden3/go-iden3-auth/pubsignals" - "github.com/iden3/go-iden3-auth/state" - "github.com/iden3/go-jwz" - "github.com/iden3/go-schema-processor/merklize" - "github.com/iden3/go-schema-processor/verifiable" - "github.com/iden3/iden3comm" - "github.com/iden3/iden3comm/packers" - "github.com/iden3/iden3comm/protocol" + "github.com/iden3/go-circuits/v2" + "github.com/iden3/go-iden3-auth/v2/loaders" + "github.com/iden3/go-iden3-auth/v2/proofs" + "github.com/iden3/go-iden3-auth/v2/pubsignals" + "github.com/iden3/go-iden3-auth/v2/state" + "github.com/iden3/go-jwz/v2" + schemaloaders "github.com/iden3/go-schema-processor/v2/loaders" + "github.com/iden3/go-schema-processor/v2/merklize" + "github.com/iden3/go-schema-processor/v2/verifiable" + "github.com/iden3/iden3comm/v2" + "github.com/iden3/iden3comm/v2/packers" + "github.com/iden3/iden3comm/v2/protocol" shell "github.com/ipfs/go-ipfs-api" + "github.com/piprate/json-gold/ld" "github.com/pkg/errors" ) +var defaultSchemaLoader ld.DocumentLoader + +// SetDocumentLoader sets the default schema loader that would be used if +// other is not set with WithDocumentLoader option. Also, this document loader +// is set for go-schema-processor library to use it for merklize. +func SetDocumentLoader(schemaLoader ld.DocumentLoader) { + defaultSchemaLoader = schemaLoader + merklize.SetDocumentLoader(schemaLoader) +} + // UniversalResolverURL is a url for universal resolver const UniversalResolverURL = "https://dev.uniresolver.io/1.0/identifiers" @@ -86,56 +98,86 @@ var UniversalDIDResolver = packers.DIDResolverHandlerFunc(func(did string) (*ver // Verifier is a struct for auth instance type Verifier struct { verificationKeyLoader loaders.VerificationKeyLoader - claimSchemaLoader loaders.SchemaLoader + documentLoader ld.DocumentLoader stateResolver map[string]pubsignals.StateResolver packageManager iden3comm.PackageManager } -// NewVerifier returns setup instance of auth library -// Deprecated: NewVerifier now return nil it can't set up default package manager for verifier, -// in future major release it will return error -func NewVerifier( - keyLoader loaders.VerificationKeyLoader, - claimSchemaLoader loaders.SchemaLoader, - resolver map[string]pubsignals.StateResolver, -) *Verifier { - v, err := NewVerifierWithExplicitError(keyLoader, claimSchemaLoader, - resolver) - if err != nil { - return nil +// VerifierOption is a function to set options for Verifier instance +type VerifierOption func(opts *verifierOpts) + +// WithDocumentLoader sets the document loader for Verifier instance +func WithDocumentLoader(docLoader ld.DocumentLoader) VerifierOption { + return func(opts *verifierOpts) { + opts.docLoader = docLoader } - return v } -// NewVerifierWithExplicitError returns verifier instance with default package manager and explicit error if it couldn't register default packers -// in future major release it will be renamed to NewVerifier -func NewVerifierWithExplicitError( +// WithIPFSClient sets the IPFS client for document loader of Verifier instance. +// If document loader is set with WithDocumentLoader function, this option is +// ignored. +func WithIPFSClient(ipfsCli *shell.Shell) VerifierOption { + return func(opts *verifierOpts) { + opts.ipfsCli = ipfsCli + } +} + +// WithIPFSGateway sets the IPFS gateway for document loader of Verifier +// instance. If document loader is set with WithDocumentLoader function, this +// option is ignored. If WithIPFSClient is set, this option is ignored also. +func WithIPFSGateway(ipfsGW string) VerifierOption { + return func(opts *verifierOpts) { + opts.ipfsGW = ipfsGW + } +} + +// WithDIDResolver sets the DID resolver for Verifier instance. The default +// value is UniversalDIDResolver. +func WithDIDResolver(resolver packers.DIDResolverHandlerFunc) VerifierOption { + return func(opts *verifierOpts) { + opts.didResolver = resolver + } +} + +type verifierOpts struct { + docLoader ld.DocumentLoader + ipfsCli *shell.Shell + ipfsGW string + didResolver packers.DIDResolverHandlerFunc +} + +func newOpts() verifierOpts { + return verifierOpts{ + didResolver: UniversalDIDResolver, + } +} + +// NewVerifier returns setup instance of auth library +func NewVerifier( keyLoader loaders.VerificationKeyLoader, - claimSchemaLoader loaders.SchemaLoader, resolver map[string]pubsignals.StateResolver, + opts ...VerifierOption, ) (*Verifier, error) { + vOpts := newOpts() + for _, optFn := range opts { + optFn(&vOpts) + } + + docLoader := getDocumentLoader(vOpts.docLoader, vOpts.ipfsCli, + vOpts.ipfsGW) v := &Verifier{ verificationKeyLoader: keyLoader, - claimSchemaLoader: claimSchemaLoader, + documentLoader: docLoader, stateResolver: resolver, packageManager: *iden3comm.NewPackageManager(), } - // try to extract IPFS_URL if the schema loader is the default one - if impl, ok := claimSchemaLoader.(loaders.DefaultSchemaLoader); ok && - impl.IpfsURL != "" { - - ipfsCli := shell.NewShell(impl.IpfsURL) - documentLoader := merklize.NewDocumentLoader(ipfsCli, "") - merklize.SetDocumentLoader(documentLoader) - } - err := v.SetupAuthV2ZKPPacker() if err != nil { return nil, err } - err = v.SetupJWSPacker(UniversalDIDResolver) + err = v.SetupJWSPacker(vOpts.didResolver) if err != nil { return nil, err } @@ -328,7 +370,7 @@ func (v *Verifier) VerifyAuthResponse( rawMessage = nil } - err = cv.VerifyQuery(ctx, query, v.claimSchemaLoader, rawMessage, opts...) + err = cv.VerifyQuery(ctx, query, v.documentLoader, rawMessage, opts...) if err != nil { return err } @@ -463,3 +505,17 @@ func findProofByRequestID(arr []protocol.ZeroKnowledgeProofResponse, id uint32) } return nil } + +func getDocumentLoader(docLoader ld.DocumentLoader, ipfsCli *shell.Shell, + ipfsGW string) ld.DocumentLoader { + + if docLoader != nil { + return docLoader + } + + if ipfsCli == nil && ipfsGW == "" && defaultSchemaLoader != nil { + return defaultSchemaLoader + } + + return schemaloaders.NewDocumentLoader(ipfsCli, ipfsGW) +} diff --git a/auth_test.go b/auth_test.go index 5db5d54..cf82ba4 100644 --- a/auth_test.go +++ b/auth_test.go @@ -3,20 +3,23 @@ package auth import ( "context" "encoding/json" + "fmt" "math/big" + "os" "testing" "time" "github.com/google/uuid" - "github.com/iden3/go-circuits" - "github.com/iden3/go-iden3-auth/loaders" - "github.com/iden3/go-iden3-auth/pubsignals" - "github.com/iden3/go-iden3-auth/state" + "github.com/iden3/go-circuits/v2" + "github.com/iden3/go-iden3-auth/v2/loaders" + "github.com/iden3/go-iden3-auth/v2/pubsignals" + "github.com/iden3/go-iden3-auth/v2/state" "github.com/iden3/go-rapidsnark/types" - "github.com/iden3/go-schema-processor/verifiable" - "github.com/iden3/iden3comm" - "github.com/iden3/iden3comm/packers" - "github.com/iden3/iden3comm/protocol" + "github.com/iden3/go-schema-processor/v2/verifiable" + "github.com/iden3/iden3comm/v2/packers" + "github.com/iden3/iden3comm/v2/protocol" + "github.com/piprate/json-gold/ld" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -28,254 +31,30 @@ import ( var verificationKeyloader = &loaders.FSKeyLoader{Dir: "./testdata"} -const kycV2Schema = `{ - "@context": [ - { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "KYCAgeCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v2.json-ld#KYCAgeCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "serialization": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/serialization.md#", - "birthday": { - "@id": "kyc-vocab:birthday", - "@type": "serialization:IndexDataSlotA" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "serialization:IndexDataSlotB" - } - } - }, - "KYCCountryOfResidenceCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v2.json-ld#KYCCountryOfResidenceCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "serialization": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/serialization.md#", - "countryCode": { - "@id": "kyc-vocab:countryCode", - "@type": "serialization:IndexDataSlotA" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "serialization:IndexDataSlotB" - } - } - } - } - ] -}` - -const kycV3Schema = `{ - "@context": [ - { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "KYCAgeCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCAgeCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "birthday": { - "@id": "kyc-vocab:birthday", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - }, - "KYCCountryOfResidenceCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "countryCode": { - "@id": "kyc-vocab:countryCode", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - } - } - ] -}` - -const kycV4Schema = `{ - "@context": [ - { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "KYCAgeCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld#KYCAgeCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "birthday": { - "@id": "kyc-vocab:birthday", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - }, - "KYCCountryOfResidenceCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld#KYCCountryOfResidenceCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "countryCode": { - "@id": "kyc-vocab:countryCode", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - } - } - ] -}` - -const kycV101Schema = `{ - "@context": [ - { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "KYCAgeCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCAgeCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "birthday": { - "@id": "kyc-vocab:birthday", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - }, - "KYCCountryOfResidenceCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCCountryOfResidenceCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "countryCode": { - "@id": "kyc-vocab:countryCode", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - }, - "KYCEmployee": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCEmployee", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - }, - "ZKPexperiance": { - "@id": "kyc-vocab:hasZKPexperiance", - "@type": "xsd:boolean" - }, - "hireDate": { - "@id": "kyc-vocab:hireDate", - "@type": "xsd:dateTime" - }, - "position": { - "@id": "kyc-vocab:position", - "@type": "xsd:string" - }, - "salary": { - "@id": "kyc-vocab:salary", - "@type": "xsd:double" - } - } - } - } - ] -}` - type mockJSONLDSchemaLoader struct { - schema string + schemas map[string]string + seen map[string]bool } -func (r *mockJSONLDSchemaLoader) Load(_ context.Context, _ string) (schema []byte, ext string, err error) { - return []byte(r.schema), "json-ld", nil +func (r *mockJSONLDSchemaLoader) LoadDocument(u string) (*ld.RemoteDocument, error) { + if body, ok := r.schemas[u]; ok { + if r.seen == nil { + r.seen = make(map[string]bool) + } + r.seen[u] = true + var doc = ld.RemoteDocument{DocumentURL: u} + err := json.Unmarshal([]byte(body), &doc.Document) + return &doc, err + } + return nil, fmt.Errorf("schema not found: %v", u) } -const exampleDidDoc = `{"@context":["https://www.w3.org/ns/did/v1",{"EcdsaSecp256k1RecoveryMethod2020":"https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#EcdsaSecp256k1RecoveryMethod2020","blockchainAccountId":"https://w3id.org/security#blockchainAccountId"}],"id":"did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65","verificationMethod":[{"id":"did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65#Recovery2020","type":"EcdsaSecp256k1RecoveryMethod2020","controller":"did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65","blockchainAccountId":"eip155:137:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65"}],"authentication":["did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65#Recovery2020"],"assertionMethod":["did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65#Recovery2020"]}` - -var didResolverHandler = packers.DIDResolverHandlerFunc(func(did string) (*verifiable.DIDDocument, error) { - didDoc := &verifiable.DIDDocument{} - - err := json.Unmarshal([]byte(exampleDidDoc), didDoc) - - if err != nil { - panic(err) +// assert that all schemas were loaded +func (r *mockJSONLDSchemaLoader) assert(t testing.TB) { + for url := range r.schemas { + require.True(t, r.seen[url], "schema not loaded: %v", url) } - - return didDoc, nil -}) +} /* mock for state resolver @@ -298,14 +77,12 @@ func (r *mockStateResolver) ResolveGlobalRoot(_ context.Context, _ *big.Int) (*s } func TestVerifyMessageWithSigProof_NonMerkalized(t *testing.T) { - // TODO(illia-korotia): for non merklized claim and schema don't know about xsd:types - t.Skip("skipping test") verifierID := "did:polygonid:polygon:mumbai:2qEevY9VnKdNsVDdXRv3qSLHRqoMGMRRdE5Gmc6iA7" callbackURL := "https://test.com/callback" reason := "test" var mtpProofRequest protocol.ZeroKnowledgeProofRequest - mtpProofRequest.ID = 23 + mtpProofRequest.ID = 84239 mtpProofRequest.CircuitID = string(circuits.AtomicQuerySigV2CircuitID) opt := true mtpProofRequest.Optional = &opt @@ -313,16 +90,16 @@ func TestVerifyMessageWithSigProof_NonMerkalized(t *testing.T) { "allowedIssuers": []string{"*"}, "credentialSubject": map[string]interface{}{ "documentType": map[string]interface{}{ - "$eq": 10, + "$eq": 99, }, }, - "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld", "type": "KYCAgeCredential", } request := CreateAuthorizationRequestWithMessage(reason, "message to sign", verifierID, callbackURL) request.Body.Scope = append(request.Body.Scope, mtpProofRequest) - userID := "did:polygonid:polygon:mumbai:2qD8Nsp4FQcdk1N3yhziquEBZGMXdVkKtBhtLdGnix" + userID := "did:polygonid:polygon:mumbai:2qKzaaAewvBVv11iZjJZzjTxBQioZLEujPYTUJp7gQ" responseUUID := uuid.New() // response @@ -337,50 +114,50 @@ func TestVerifyMessageWithSigProof_NonMerkalized(t *testing.T) { Message: "message to sign", Scope: []protocol.ZeroKnowledgeProofResponse{ { - ID: 23, + ID: 84239, CircuitID: mtpProofRequest.CircuitID, ZKProof: types.ZKProof{ Proof: &types.ProofData{ A: []string{ - "9518940539414587245794003192532307790550936491078690484579527365586406369952", - "18310892073224615121155590891657868809375867436314025475318265897577698765429", + "14056228231956087288378518013493130710375131807243578639863710060510262038676", + "15685597096933930175890593905690244171450509041610585092210638200145586390285", "1", }, B: [][]string{ { - "7473471862476301137207221898428038544241157556635980264621324015685573123570", - "12749169234766877085006220937362504781288470732483056139299482729458259754028", + "6867891861795556838771075779522609255721689620651295420993290050538780283807", + "12803728874072821363624664338413776845757845422512289455246307343796729670516", }, { - "3455578419807762064145715564295939767903330673624118421238034929096545128331", - "12484357578498567666992818368371681218686429789722992962435530253571008321433", + "1556511867067742689232747109877739227261867306751037654148240512509806309140", + "3417379743049361186708759271231315501277403869916476403120965486647240758779", }, { "1", "0", }}, C: []string{ - "2620490929586137686238649209251762311479806943644120771227616021811240503743", - "5676385148800793701377781773804054339642731549886824415936348195774348094130", + "10569434133480072042978475540156042501239134571700053665222790798542811352807", + "16412506719218682682070660169432465369639644911994254460610287965570092298694", "1", }, Protocol: "groth16", }, PubSignals: []string{ "0", - "23280069646923371456510050373677752848804011824981226331232885668622242306", - "2943483356559152311923412925436024635269538717812859789851139200242297094", - "23", - "22064883246134712298411652505170593669589088931416964593351226206090301954", + "23556362286864724741858679466282977995723542763829611007300550436288008706", + "6488011081960287964570775172930943914920953982696735236025195378048754598764", + "84239", + "21803003425107230045260507608510138502859759480520560654156359021447614978", + "1", + "6488011081960287964570775172930943914920953982696735236025195378048754598764", + "1693230616", + "198285726510688200335207273836123338699", "1", - "2943483356559152311923412925436024635269538717812859789851139200242297094", - "1642074362", - "74977327600848231385663280181476307657", - "0", "0", - "2", + "3", "1", - "10", + "99", "0", "0", "0", @@ -450,11 +227,17 @@ func TestVerifyMessageWithSigProof_NonMerkalized(t *testing.T) { }, } - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV2Schema} - authInstance, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) + schemaLoader := &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld": loadSchema("kyc-nonmerklized.jsonld"), + }, + } + authInstance, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader)) require.NoError(t, err) err = authInstance.VerifyAuthResponse(context.Background(), message, request) require.Nil(t, err) + schemaLoader.assert(t) } func TestVerifyMessageWithMTPProof_Merkalized(t *testing.T) { @@ -613,23 +396,29 @@ func TestVerifyMessageWithMTPProof_Merkalized(t *testing.T) { }, } - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV3Schema} - authInstance, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) + schemaLoader := &mockJSONLDSchemaLoader{ + schemas: map[string]string{"https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld")}, + } + authInstance, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader)) require.NoError(t, err) err = authInstance.VerifyAuthResponse(context.Background(), message, request, pubsignals.WithAcceptedProofGenerationDelay(proofGenerationDelay)) require.NoError(t, err) + schemaLoader.assert(t) } func TestVerifier_VerifyJWZ(t *testing.T) { token := `eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6IjljMGY5NjIzLWM1NmMtNDEwNC04ODk2LWVjMjgyYTNiMmExNyIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zY29tbS1wbGFpbi1qc29uIiwidHlwZSI6Imh0dHBzOi8vaWRlbjMtY29tbXVuaWNhdGlvbi5pby9hdXRob3JpemF0aW9uLzEuMC9yZXNwb25zZSIsInRoaWQiOiI3ZjM4YTE5My0wOTE4LTRhNDgtOWZhYy0zNmFkZmRiOGI1NDIiLCJmcm9tIjoiZGlkOnBvbHlnb25pZDpwb2x5Z29uOm11bWJhaToycVBETFhEYVUxeGExRVJUYjFYS0JmUENCM28yd0E0NnE0OW5laVhXd1kiLCJ0byI6ImRpZDpwb2x5Z29uaWQ6cG9seWdvbjptdW1iYWk6MnFKNjg5a3BvSnhjU3pCNXNBRkp0UHNTQlNySEY1ZHE3MjJCSE1xVVJMIiwiYm9keSI6eyJkaWRfZG9jIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy9ucy9kaWQvdjEiXSwiaWQiOiJkaWQ6cG9seWdvbmlkOnBvbHlnb246bXVtYmFpOjJxUERMWERhVTF4YTFFUlRiMVhLQmZQQ0IzbzJ3QTQ2cTQ5bmVpW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jQzMDAwNCIsIjEyNjkyNzA3NDA3MTczMDg0OTM5NzQ1ODU5NzE0ODMxNDYyMDQ1ODg5NDA4NTk4NTI3MjU0ODA3NzkwNDk0NDY2Mjc5Njg3ODU5MjQ3IiwiMSJdLCJwcm90b2NvbCI6Imdyb3RoMTYiLCJjdXJ2ZSI6ImJuMTI4In0sInB1Yl9zaWduYWxzIjpbIjI3MTUyNjc2OTg3MTI4NTQyMDY2ODA4NTkxOTk4NTczMDAwMzcwNDM2NDY0NzIyNTE5NTEzMzQ4ODkxMDQ5NjQ0ODEzNzE4MDE4IiwiMTIxODQ5NzQwNzE0Mjc3NjgzNTIwMjcwMDM4NzgzMTkzMzgyNDkzODM4NDYxNjQ3MzAyMDQ1MDUzMjY5NTM1NTA2NDczOTExNzg4MDAiLCI4NzU2MDYwMjA1MDg2ODAzMzM1MjUyMzE5NzQ4NzQ4MzU0NzYxOTYxODE0MDEyNzI1NDk5ODczMzgyOTg4MDU2NDE4NjgwNjI4NjE5Il19` - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV101Schema} - authInstance, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) + schemaLoader := &mockJSONLDSchemaLoader{} + authInstance, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader)) require.NoError(t, err) parsedToken, err := authInstance.VerifyJWZ(context.Background(), token) require.NoError(t, err) require.Equal(t, parsedToken.Alg, "groth16") + schemaLoader.assert(t) } func TestVerifier_FullVerify(t *testing.T) { @@ -665,11 +454,17 @@ func TestVerifier_FullVerify(t *testing.T) { token := `eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6IjljMGY5NjIzLWM1NmMtNDEwNC04ODk2LWVjMjgyYTNiMmExNyIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZ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1NDk5ODczMzgyOTg4MDU2NDE4NjgwNjI4NjE5Il19` - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV3Schema} - authInstance, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) + schemaLoader := &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + } + authInstance, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader)) require.NoError(t, err) _, err = authInstance.FullVerify(context.Background(), token, request, pubsignals.WithAcceptedProofGenerationDelay(proofGenerationDelay)) require.NoError(t, err) + schemaLoader.assert(t) } func TestVerifier_FullVerify_JWS(t *testing.T) { @@ -696,17 +491,31 @@ func TestVerifier_FullVerify_JWS(t *testing.T) { token := `eyJhbGciOiJFUzI1NkstUiIsImtpZCI6ImRpZDpwa2g6cG9seToweDcxNDFFNGQyMEY3NjQ0REM4YzBBZENBOGE1MjBFQzgzQzZjQUJENjUjUmVjb3ZlcnkyMDIwIiwidHlwIjoiYXBwbGljYXRpb24vaWRlbjNjb21tLXNpZ25lZC1qc29uIn0.eyJpZCI6IjJjOGQ5NzQ3LTQ0MTAtNGU5My1iZjg0LTRlYTNjZmY4MmY0MCIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zY29tbS1zaWduZWQtanNvbiIsInR5cGUiOiJodHRwczovL2lkZW4zLWNvbW11bmljYXRpb24uaW8vYXV0aG9yaXphdGlvbi8xLjAvcmVzcG9uc2UiLCJ0aGlkIjoiN2YzOGExOTMtMDkxOC00YTQ4LTlmYWMtMzZhZGZkYjhiNTQyIiwiYm9keSI6eyJzY29wZSI6W3siaWQiOjEsImNpcmN1aXRJZCI6ImNyZWRlbnRpYWxBdG9taWNRdWVyeVNpZ1YyIiwicHJvb2YiOnsicGlfYSI6WyIxMzI3Njk4Nzc5MjQ5MjM0OTA2MDcxMDc3NTEyOT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Wk6MnFMUHF2YXlOUXo5VEEycjVWUHhVdWdvRjE4dGVHVTU4M3pKODU5d2Z5In0.bWc2ECABj7nvHatD8AXWNJM2VtfhkIjNwz5BBIK9zBMsP0-UWLEWdAWcosiLkYoL0KWwZpgEOrPPepl6T5gC-AA` - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV4Schema} - v, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) - require.NoError(t, err) - pm := *iden3comm.NewPackageManager() - jwsPacker := packers.NewJWSPacker(didResolverHandler, nil) + schemaLoader := &mockJSONLDSchemaLoader{schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld": loadSchema("kyc-v4.json-ld"), + }} + + mockedResolver := func(did string) (*verifiable.DIDDocument, error) { + if did != "did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65" { + return nil, errors.Errorf("unexpected DID: %v", did) + } + data := `{"@context":["https://www.w3.org/ns/did/v1",{"EcdsaSecp256k1RecoveryMethod2020":"https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#EcdsaSecp256k1RecoveryMethod2020","blockchainAccountId":"https://w3id.org/security#blockchainAccountId"}],"id":"did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65","verificationMethod":[{"id":"did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65#Recovery2020","type":"EcdsaSecp256k1RecoveryMethod2020","controller":"did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65","blockchainAccountId":"eip155:137:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65"}],"authentication":["did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65#Recovery2020"],"assertionMethod":["did:pkh:poly:0x7141E4d20F7644DC8c0AdCA8a520EC83C6cABD65#Recovery2020"]}` + var doc verifiable.DIDDocument + err := json.Unmarshal([]byte(data), &doc) + if err != nil { + return nil, err + } + return &doc, nil + } - err = pm.RegisterPackers(jwsPacker) + v, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader), + WithDIDResolver(mockedResolver)) require.NoError(t, err) - v.SetPackageManager(pm) _, err = v.FullVerify(context.Background(), token, request, pubsignals.WithAcceptedProofGenerationDelay(proofGenerationDelay)) require.NoError(t, err) + + schemaLoader.assert(t) } func TestVerifyAuthResponseWithEmptyReq(t *testing.T) { @@ -859,11 +668,17 @@ func TestVerifyAuthResponseWithEmptyReq(t *testing.T) { To: authReq.From, } - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV2Schema} - authInstance, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) + schemaLoader := &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v2.json-ld": loadSchema("kyc-v2.json-ld"), + }, + } + authInstance, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader)) require.NoError(t, err) err = authInstance.VerifyAuthResponse(context.Background(), resp, authReq) require.NoError(t, err) + schemaLoader.assert(t) } func TestCreateAuthorizationRequest(t *testing.T) { @@ -921,11 +736,18 @@ func TestVerifier_FullVerifySelectiveDisclosure(t *testing.T) { token := `eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6ImE2ZWM2ZTE5LWQwYzAtNDUxYi04NDg3LWRhODAwZGMzMDgxOCIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zY29tbS1wbGFpbi1qc29uIiwidHlwZSI6Imh0dHBzOi8vaWRlbjMtY29tbXVuaWNhdGlvbi5pby9hdXRob3JpemF0aW9uLzEuMC9yZXNwb25zZSIsInRoaWQiOiI3ZjM4YTE5My0wOTE4LTRhN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IxIl0sInByb3RvY29sIjoiZ3JvdGgxNiIsImN1cnZlIjoiYm4xMjgifSwicHViX3NpZ25hbHMiOlsiMjE1MTMxNDA1MzAyMzM5MjE1MTU4MDkyMzUzODg3ODAxMzQ2ODEyNDU2MTI4NTg3NDQ5MDAyOTc3NDA0OTA0NDc3Mzg1NzMzMTQiLCI0MzA0NjAwNjM3MTg5NzI2OTU0Nzg4MTMzNDIxNjc0ODk0NzYxODQ0OTE2MDgyMTY2MjgyMzA4MDAyMDY1MDI4NTY4ODY0Mjg5Njc1IiwiNTIyOTY2ODY4NjU1NzYzNzAxNzc4MTE1NzM1NjMwNDc2OTY2MTcwOTIzODY3MDI3MDYxMzU2MDg4NzY5OTM1Mjk0NDk5NjU1MDI5NSJdfQ` - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV4Schema} - authInstance, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) + schemaLoader := &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld": loadSchema("kyc-v4.json-ld"), + "https://www.w3.org/2018/credentials/v1": loadSchema("credentials-v1.json-ld"), + }, + } + authInstance, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader)) require.NoError(t, err) _, err = authInstance.FullVerify(context.Background(), token, request, pubsignals.WithAcceptedProofGenerationDelay(proofGenerationDelay)) require.NoError(t, err) + schemaLoader.assert(t) } func TestEmptyCredentialSubject(t *testing.T) { @@ -951,9 +773,24 @@ func TestEmptyCredentialSubject(t *testing.T) { token := `eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6Ijc0MWU2MTA4LTM4MzgtNDFiYS1hMGIwLTlhZmZkZjY1NTg2YSIsInR5cCI6ImF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I2NDE0MTgyOTU4NDk2Mjg3MTUwMDY4IiwiMTA1MjI5NTY0NzMwODM3MjU4OTA1Nzk2ODUxMjM2NzgyNTYxNzQ5MTMyOTY0MTI5MTIzMDE0MzU0NTIwNjAyOTQ2ODI1MTEzODU0NzMiXX0` - schemaLoader := &mockJSONLDSchemaLoader{schema: kycV101Schema} - authInstance, err := NewVerifierWithExplicitError(verificationKeyloader, schemaLoader, stateResolvers) + schemaLoader := &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld": loadSchema("kyc-v101.json-ld"), + }, + } + authInstance, err := NewVerifier(verificationKeyloader, stateResolvers, + WithDocumentLoader(schemaLoader)) require.NoError(t, err) _, err = authInstance.FullVerify(context.Background(), token, request, pubsignals.WithAcceptedProofGenerationDelay(proofGenerationDelay)) require.NoError(t, err) + + schemaLoader.assert(t) +} + +func loadSchema(name string) string { + bs, err := os.ReadFile("testdata/" + name) + if err != nil { + panic(err) + } + return string(bs) } diff --git a/go.mod b/go.mod index 1cbab0b..00f4c15 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/iden3/go-iden3-auth +module github.com/iden3/go-iden3-auth/v2 go 1.18 @@ -8,17 +8,17 @@ require ( github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/iden3/contracts-abi/state/go/abi v1.0.0-beta.3 - github.com/iden3/go-circuits v1.0.3 - github.com/iden3/go-iden3-core v1.0.2 - github.com/iden3/go-jwz v1.0.0 + github.com/iden3/go-circuits/v2 v2.0.0 + github.com/iden3/go-iden3-core/v2 v2.0.0 + github.com/iden3/go-jwz/v2 v2.0.0 github.com/iden3/go-rapidsnark/types v0.0.3 github.com/iden3/go-rapidsnark/verifier v0.0.5 - github.com/iden3/go-schema-processor v1.3.1 - github.com/iden3/iden3comm v1.1.1-0.20230810141028-42068fe8ad57 + github.com/iden3/go-schema-processor/v2 v2.0.0 + github.com/iden3/iden3comm/v2 v2.0.0 github.com/ipfs/go-ipfs-api v0.6.0 github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 ) require ( @@ -41,8 +41,8 @@ require ( github.com/iden3/go-iden3-crypto v0.0.15 // indirect github.com/iden3/go-merkletree-sql/v2 v2.0.4 // indirect github.com/iden3/go-rapidsnark/prover v0.0.10 // indirect - github.com/iden3/go-rapidsnark/witness v0.0.6 // indirect - github.com/iden3/wasmer-go v0.0.1 // indirect + github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 // indirect + github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e // indirect github.com/ipfs/boxo v0.8.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect @@ -50,7 +50,7 @@ require ( github.com/lestrrat-go/httpcc v1.0.1 // indirect github.com/lestrrat-go/httprc v1.0.4 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect - github.com/lestrrat-go/jwx/v2 v2.0.9-0.20230429214153-5090ec1bd2cd // indirect + github.com/lestrrat-go/jwx/v2 v2.0.12 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect @@ -69,14 +69,16 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pquerna/cachecontrol v0.1.0 // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 // indirect + github.com/segmentio/asm v1.2.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/tetratelabs/wazero v1.1.0 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.0 // indirect github.com/whyrusleeping/tar-utils v0.0.0-20201201191210-20a61371de5b // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect - golang.org/x/crypto v0.8.0 // indirect - golang.org/x/sys v0.8.0 // indirect + golang.org/x/crypto v0.12.0 // indirect + golang.org/x/sys v0.11.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/go-jose/go-jose.v2 v2.6.1 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect diff --git a/go.sum b/go.sum index 87e3512..273c83b 100644 --- a/go.sum +++ b/go.sum @@ -74,7 +74,7 @@ github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84= +github.com/gofrs/uuid/v5 v5.0.0 h1:p544++a97kEL+svbcFbCQVM9KFu0Yo25UoISXGNNH9M= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= @@ -107,14 +107,14 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY= github.com/iden3/contracts-abi/state/go/abi v1.0.0-beta.3 h1:ZHFnK2dU3NJglY+igY48JLHWtNGN/Vhf5/L/qrFk/tM= github.com/iden3/contracts-abi/state/go/abi v1.0.0-beta.3/go.mod h1:TxgIrXCvxms3sbOdsy8kTvffUCIpEEifNy0fSXdkU4w= -github.com/iden3/go-circuits v1.0.3 h1:mZqHvuXIAjCQdwRFiq2472KYfKHtzomYoKu0BtF3+5c= -github.com/iden3/go-circuits v1.0.3/go.mod h1:YbuzfvSyr8BwNHnjRJEvnRQ2lJKzVQ9Sgz3OAdqv5Is= -github.com/iden3/go-iden3-core v1.0.2 h1:HwNDFeqcUv4ybZj5tH+58JKWKarn/qqBpNCqTLxGP0Y= -github.com/iden3/go-iden3-core v1.0.2/go.mod h1:X4PjlJG8OsEQEsSbzzYqqAk2olYGZ2nuGqiUPyEYjOo= +github.com/iden3/go-circuits/v2 v2.0.0 h1:Bw0mpsqeip06d6I2ktgfhTVB7Jk9mSHi8myHZWkoc6w= +github.com/iden3/go-circuits/v2 v2.0.0/go.mod h1:VIFIp51+IH0hOzjnKhb84bCeyq7hq76zX/C14ua6zh4= +github.com/iden3/go-iden3-core/v2 v2.0.0 h1:sQEuuq3RLfyYSY8qPiqxQ6YBpGbiAwepHJD/vjf1adA= +github.com/iden3/go-iden3-core/v2 v2.0.0/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4= github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= -github.com/iden3/go-jwz v1.0.0 h1:tRyAMK9unf21z8uNvJ8V2LFvXdlYZe7pgRE7V19Q/vs= -github.com/iden3/go-jwz v1.0.0/go.mod h1:vX0kANbDvoNUAevlWyU1UDVQ0PWgplOK0YK1+8BaOz4= +github.com/iden3/go-jwz/v2 v2.0.0 h1:VsU2PrmcchPMx/V0IhamMZRNjiQYZoyJopO8K8uSZOY= +github.com/iden3/go-jwz/v2 v2.0.0/go.mod h1:JBJ58Cef8h+4Uz8qaVRsNjiT/Ubqb800dGKTZt66NkU= github.com/iden3/go-merkletree-sql/v2 v2.0.4 h1:Dp089P3YNX1BE8+T1tKQHWTtnk84Y/Kr7ZAGTqwscoY= github.com/iden3/go-merkletree-sql/v2 v2.0.4/go.mod h1:kRhHKYpui5DUsry5RpveP6IC4XMe6iApdV9VChRYuEk= github.com/iden3/go-rapidsnark/prover v0.0.10 h1:NvOfRPpex/k646UsqOcUy7a7uVl17t4ok9kWvpQg4+k= @@ -123,20 +123,14 @@ github.com/iden3/go-rapidsnark/types v0.0.3 h1:f0s1Qdut1qHe1O67+m+xUVRBPwSXnq5j0 github.com/iden3/go-rapidsnark/types v0.0.3/go.mod h1:ApgcaUxKIgSRA6fAeFxK7p+lgXXfG4oA2HN5DhFlfF4= github.com/iden3/go-rapidsnark/verifier v0.0.5 h1:J7y0ovrEjDQoWtZmlrp4tgGng1A9faMeYsQH4igAEqA= github.com/iden3/go-rapidsnark/verifier v0.0.5/go.mod h1:KgL3Yr9NehlFDI4EIWVLE3UDUi8ulyjbp7HcXSBfiGI= -github.com/iden3/go-rapidsnark/witness v0.0.6 h1:p+6QBymSV3XWm1kB2PL2vlXxKXJN8GyWuqNJv/0PGGU= -github.com/iden3/go-rapidsnark/witness v0.0.6/go.mod h1:57IHQpnvx0CeS6cAT07oN/lqwT5LRc4zicYoZ1cnAPE= -github.com/iden3/go-schema-processor v1.3.1 h1:LJfFInfYGMOp0bTKKC17R8q4XI+VtqhFLPTEqnOIvlM= -github.com/iden3/go-schema-processor v1.3.1/go.mod h1:NwJ1nuGdRlCFaN1/V6mS0AOAdvpLcGf4KKq0mluLG7U= -github.com/iden3/iden3comm v1.1.0 h1:feWurfGJV6YZyxi4J3U2jqQ+RUo0mo36Aoqyck1ZnHg= -github.com/iden3/iden3comm v1.1.0/go.mod h1:1bJHz0xNhwbQGDxYfVwMVYsdsMjFQRkHJF/eq5Rc9wE= -github.com/iden3/iden3comm v1.1.1-0.20230810101037-f49961bb9e6c h1:JSsDSdkhkZNPD6dwNG3jua1QWbTERmA+oALrcy+Q3aU= -github.com/iden3/iden3comm v1.1.1-0.20230810101037-f49961bb9e6c/go.mod h1:1bJHz0xNhwbQGDxYfVwMVYsdsMjFQRkHJF/eq5Rc9wE= -github.com/iden3/iden3comm v1.1.1-0.20230810105009-6a98a9309fed h1:2aBuvK/GPWiqMDu2NoNKp8X2Wrm6xEiQC0uH6oeyz7Y= -github.com/iden3/iden3comm v1.1.1-0.20230810105009-6a98a9309fed/go.mod h1:1bJHz0xNhwbQGDxYfVwMVYsdsMjFQRkHJF/eq5Rc9wE= -github.com/iden3/iden3comm v1.1.1-0.20230810141028-42068fe8ad57 h1:+UukNLBWlCIvUqDA79pHBCXYarGt6VQH2WsNJv9dUYs= -github.com/iden3/iden3comm v1.1.1-0.20230810141028-42068fe8ad57/go.mod h1:1bJHz0xNhwbQGDxYfVwMVYsdsMjFQRkHJF/eq5Rc9wE= -github.com/iden3/wasmer-go v0.0.1 h1:TZKh8Se8B/73PvWrcu+FTU9L1k5XYAmtFbioj7l0Uog= -github.com/iden3/wasmer-go v0.0.1/go.mod h1:ZnZBAO012M7o+Q1INXLRIxKQgEcH2FuwL0Iga8A4ufg= +github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 h1:mkY6VDfwKVJc83QGKmwVXY2LYepidPrFAxskrjr8UCs= +github.com/iden3/go-rapidsnark/witness/v2 v2.0.0/go.mod h1:3JRjqUfW1hgI9hzLDO0v8z/DUkR0ZUehhYLlnIfRxnA= +github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e h1:WeiFCrpj5pLRtSA4Mg03yTrSZhHHqN/k5b6bwxd9/tY= +github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e/go.mod h1:UEBifEzw62T6VzIHJeHuUgeLg2U/J9ttf7hOwQEqnYk= +github.com/iden3/go-schema-processor/v2 v2.0.0 h1:izbC5+rd7rV1np+tjCqDe016qlOKu6JF7r8LQvdObWM= +github.com/iden3/go-schema-processor/v2 v2.0.0/go.mod h1:eWRQDbxixZ/9k/uPlciKIy6TUYlKX/6hdqyTuAQi3wE= +github.com/iden3/iden3comm/v2 v2.0.0 h1:cFDfF6aJ589ENg5zlTBEPK6Qqv4I11C/gliAWZORpyY= +github.com/iden3/iden3comm/v2 v2.0.0/go.mod h1:wrXoxi8eoQSLopatRW5+hYF9lDRvzGL2As9ZE88q/kA= github.com/ipfs/boxo v0.8.0 h1:UdjAJmHzQHo/j3g3b1bAcAXCj/GM6iTwvSlBDvPBNBs= github.com/ipfs/boxo v0.8.0/go.mod h1:RIsi4CnTyQ7AUsNn5gXljJYZlQrHBMnJp94p73liFiA= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= @@ -163,8 +157,8 @@ github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJG github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= -github.com/lestrrat-go/jwx/v2 v2.0.9-0.20230429214153-5090ec1bd2cd h1:jzU4xunmLFc7uF97O5PhEFmAuiRSuG7/RKrX2gkKWeY= -github.com/lestrrat-go/jwx/v2 v2.0.9-0.20230429214153-5090ec1bd2cd/go.mod h1:6etqt12jS77WEY6WPM9nmnIaG6fMo5yQmtTSqB2eLk4= +github.com/lestrrat-go/jwx/v2 v2.0.12 h1:3d589+5w/b9b7S3DneICPW16AqTyYXB7VRjgluSDWeA= +github.com/lestrrat-go/jwx/v2 v2.0.12/go.mod h1:Mq4KN1mM7bp+5z/W5HS8aCNs5RKZ911G/0y2qUjAQuQ= github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= @@ -229,6 +223,8 @@ github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 h1:uIkTLo0AGRc8l7h5l9r+GcYi9qfVPt6lD4/bhmzfiKo= github.com/santhosh-tekuri/jsonschema/v5 v5.3.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= +github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= +github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -241,10 +237,12 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ= +github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms= @@ -263,8 +261,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -279,7 +277,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -300,25 +298,28 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= diff --git a/loaders/key.go b/loaders/key.go index 4a4eb8c..c789097 100644 --- a/loaders/key.go +++ b/loaders/key.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/iden3/go-circuits" + "github.com/iden3/go-circuits/v2" ) // VerificationKeyLoader load verification key bytes for specific circuit diff --git a/loaders/schema.go b/loaders/schema.go deleted file mode 100644 index 04c8f23..0000000 --- a/loaders/schema.go +++ /dev/null @@ -1,43 +0,0 @@ -package loaders - -import ( - "context" - "fmt" - "net/url" - - "github.com/iden3/go-schema-processor/loaders" - "github.com/iden3/go-schema-processor/processor" -) - -// SchemaLoader is an interface for schema loading -type SchemaLoader interface { - Load(ctx context.Context, URL string) (schemaBytes []byte, extension string, err error) -} - -// DefaultSchemaLoader is loader defined by auth lib, but can be replaced with any custom loader -type DefaultSchemaLoader struct { - IpfsURL string `json:"ipfs_url"` -} - -// Load loads schema from IPFS or by http link -// -//nolint:gocritic // URL is correct name for variable that describes URL. -func (d DefaultSchemaLoader) Load(ctx context.Context, URL string) (schemaBytes []byte, extension string, err error) { - var loader processor.SchemaLoader - schemaURL, err := url.Parse(URL) - if err != nil { - return nil, "", err - } - switch schemaURL.Scheme { - case "http", "https": - loader = &loaders.HTTP{URL: URL} - case "ipfs": - loader = loaders.IPFS{ - URL: d.IpfsURL, - CID: schemaURL.Host, - } - default: - return nil, "", fmt.Errorf("loader for %s is not supported", schemaURL.Scheme) - } - return loader.Load(ctx) -} diff --git a/proofs/zk.go b/proofs/zk.go index c15ac02..fede73f 100644 --- a/proofs/zk.go +++ b/proofs/zk.go @@ -2,7 +2,7 @@ package proofs import ( "github.com/iden3/go-rapidsnark/verifier" - "github.com/iden3/iden3comm/protocol" + "github.com/iden3/iden3comm/v2/protocol" "github.com/pkg/errors" ) diff --git a/proofs/zk_test.go b/proofs/zk_test.go index 838f3c1..b1437a2 100644 --- a/proofs/zk_test.go +++ b/proofs/zk_test.go @@ -4,9 +4,9 @@ import ( "os" "testing" - "github.com/iden3/go-circuits" + "github.com/iden3/go-circuits/v2" "github.com/iden3/go-rapidsnark/types" - "github.com/iden3/iden3comm/protocol" + "github.com/iden3/iden3comm/v2/protocol" "github.com/stretchr/testify/assert" ) diff --git a/pubsignals/atomicMtpV2.go b/pubsignals/atomicMtpV2.go index 3459697..b44d548 100644 --- a/pubsignals/atomicMtpV2.go +++ b/pubsignals/atomicMtpV2.go @@ -7,9 +7,10 @@ import ( "math/big" "time" - "github.com/iden3/go-circuits" - "github.com/iden3/go-iden3-auth/loaders" - core "github.com/iden3/go-iden3-core" + "github.com/iden3/go-circuits/v2" + core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-iden3-core/v2/w3c" + "github.com/piprate/json-gold/ld" "github.com/pkg/errors" ) @@ -22,7 +23,7 @@ type AtomicQueryMTPV2 struct { func (c *AtomicQueryMTPV2) VerifyQuery( ctx context.Context, query Query, - schemaLoader loaders.SchemaLoader, + schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, opts ...VerifyOpt, ) error { @@ -42,12 +43,18 @@ func (c *AtomicQueryMTPV2) VerifyQuery( } // VerifyStates verifies user state and issuer claim issuance state in the smart contract. -func (c *AtomicQueryMTPV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error { - issuerDID, err := core.ParseDIDFromID(*c.IssuerID) +func (c *AtomicQueryMTPV2) VerifyStates(ctx context.Context, + stateResolvers map[string]StateResolver, opts ...VerifyOpt) error { + + blockchain, err := core.BlockchainFromID(*c.IssuerID) + if err != nil { + return err + } + networkID, err := core.NetworkIDFromID(*c.IssuerID) if err != nil { return err } - resolver, ok := stateResolvers[fmt.Sprintf("%s:%s", issuerDID.Blockchain, issuerDID.NetworkID)] + resolver, ok := stateResolvers[fmt.Sprintf("%s:%s", blockchain, networkID)] if !ok { return errors.Errorf("%s resolver not found", resolver) } @@ -88,20 +95,17 @@ func (c *AtomicQueryMTPV2) VerifyIDOwnership(sender string, requestID *big.Int) return errors.New("invalid requestID in proof") } - userDID, err := core.ParseDIDFromID(*c.UserID) - if err != nil && err == core.ErrDIDMethodNotSupported { - // sender to id - senderHashedID := IDFromUnknownDID(sender) - if senderHashedID.String() != c.UserID.String() { - return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", senderHashedID.String(), c.UserID.String()) - } - return nil + did, err := w3c.ParseDID(sender) + if err != nil { + return errors.Wrap(err, "sender must be a valid did") } + senderID, err := core.IDFromDID(*did) if err != nil { return err } - if sender != userDID.String() { - return fmt.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", sender, c.UserID.String()) + + if senderID.String() != c.UserID.String() { + return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", senderID.String(), c.UserID.String()) } return nil } diff --git a/pubsignals/atomicSigV2.go b/pubsignals/atomicSigV2.go index ef9519a..0076fe8 100644 --- a/pubsignals/atomicSigV2.go +++ b/pubsignals/atomicSigV2.go @@ -7,9 +7,10 @@ import ( "math/big" "time" - "github.com/iden3/go-circuits" - "github.com/iden3/go-iden3-auth/loaders" - core "github.com/iden3/go-iden3-core" + "github.com/iden3/go-circuits/v2" + core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-iden3-core/v2/w3c" + "github.com/piprate/json-gold/ld" "github.com/pkg/errors" ) @@ -22,7 +23,7 @@ type AtomicQuerySigV2 struct { func (c *AtomicQuerySigV2) VerifyQuery( ctx context.Context, query Query, - schemaLoader loaders.SchemaLoader, + schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, opts ...VerifyOpt, ) error { @@ -47,11 +48,15 @@ func (c *AtomicQuerySigV2) VerifyQuery( // VerifyStates verifies user state and issuer auth claim state in the smart contract. func (c *AtomicQuerySigV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error { - issuerDID, err := core.ParseDIDFromID(*c.IssuerID) + blockchain, err := core.BlockchainFromID(*c.IssuerID) if err != nil { return err } - resolver, ok := stateResolvers[fmt.Sprintf("%s:%s", issuerDID.Blockchain, issuerDID.NetworkID)] + networkID, err := core.NetworkIDFromID(*c.IssuerID) + if err != nil { + return err + } + resolver, ok := stateResolvers[fmt.Sprintf("%s:%s", blockchain, networkID)] if !ok { return errors.Errorf("%s resolver not found", resolver) } @@ -93,20 +98,17 @@ func (c *AtomicQuerySigV2) VerifyIDOwnership(sender string, requestID *big.Int) return errors.New("invalid requestID in proof") } - userDID, err := core.ParseDIDFromID(*c.UserID) - if err != nil && err == core.ErrDIDMethodNotSupported { - // sender to id - senderHashedID := IDFromUnknownDID(sender) - if senderHashedID.String() != c.UserID.String() { - return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", senderHashedID.String(), c.UserID.String()) - } - return nil + did, err := w3c.ParseDID(sender) + if err != nil { + return errors.Wrap(err, "sender must be a valid did") } + senderID, err := core.IDFromDID(*did) if err != nil { return err } - if sender != userDID.String() { - return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", sender, c.UserID.String()) + + if senderID.String() != c.UserID.String() { + return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", senderID.String(), c.UserID.String()) } return nil } diff --git a/pubsignals/authV2.go b/pubsignals/authV2.go index 3d397ac..39cb161 100644 --- a/pubsignals/authV2.go +++ b/pubsignals/authV2.go @@ -7,9 +7,10 @@ import ( "math/big" "time" - "github.com/iden3/go-circuits" - "github.com/iden3/go-iden3-auth/loaders" - core "github.com/iden3/go-iden3-core" + "github.com/iden3/go-circuits/v2" + core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-iden3-core/v2/w3c" + "github.com/piprate/json-gold/ld" "github.com/pkg/errors" ) @@ -22,7 +23,7 @@ type AuthV2 struct { func (c *AuthV2) VerifyQuery( _ context.Context, _ Query, - _ loaders.SchemaLoader, + _ ld.DocumentLoader, _ json.RawMessage, _ ...VerifyOpt) error { return errors.New("authV2 circuit doesn't support queries") @@ -30,11 +31,15 @@ func (c *AuthV2) VerifyQuery( // VerifyStates verify AuthV2 tests. func (c *AuthV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error { - userDID, err := core.ParseDIDFromID(*c.UserID) + blockchain, err := core.BlockchainFromID(*c.UserID) if err != nil { return err } - chainInfo := fmt.Sprintf("%s:%s", userDID.Blockchain, userDID.NetworkID) + networkID, err := core.NetworkIDFromID(*c.UserID) + if err != nil { + return err + } + chainInfo := fmt.Sprintf("%s:%s", blockchain, networkID) resolver, ok := stateResolvers[chainInfo] if !ok { return errors.Errorf("%s resolver not found", chainInfo) @@ -58,25 +63,22 @@ func (c *AuthV2) VerifyStates(ctx context.Context, stateResolvers map[string]Sta // VerifyIDOwnership returns error if ownership id wasn't verified in circuit. func (c *AuthV2) VerifyIDOwnership(sender string, challenge *big.Int) error { - if challenge.Cmp(c.Challenge) != 0 { return errors.Errorf("challenge is not used for proof creation, expected , expected %s, challenge from public signals: %s}", challenge.String(), c.Challenge.String()) } - userDID, err := core.ParseDIDFromID(*c.UserID) - if err != nil && err == core.ErrDIDMethodNotSupported { - // sender to id - senderHashedID := IDFromUnknownDID(sender) - if senderHashedID.String() != c.UserID.String() { - return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", senderHashedID.String(), c.UserID.String()) - } - return nil + did, err := w3c.ParseDID(sender) + if err != nil { + return errors.Wrap(err, "sender must be a valid did") } + senderID, err := core.IDFromDID(*did) if err != nil { return err } - if sender != userDID.String() { - return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", sender, userDID) + + if senderID.String() != c.UserID.String() { + return errors.Errorf("sender is not used for proof creation, expected %s, user from public signals: %s}", senderID.String(), c.UserID.String()) } + return nil } diff --git a/pubsignals/circuitVerifier.go b/pubsignals/circuitVerifier.go index 550ada6..79206f9 100644 --- a/pubsignals/circuitVerifier.go +++ b/pubsignals/circuitVerifier.go @@ -5,9 +5,9 @@ import ( "encoding/json" "math/big" - "github.com/iden3/go-circuits" - "github.com/iden3/go-iden3-auth/loaders" - "github.com/iden3/go-iden3-auth/state" + "github.com/iden3/go-circuits/v2" + "github.com/iden3/go-iden3-auth/v2/state" + "github.com/piprate/json-gold/ld" ) // StateResolver is a state resolver interface @@ -18,7 +18,7 @@ type StateResolver interface { // Verifier is interface for verification of public signals of zkp type Verifier interface { - VerifyQuery(ctx context.Context, query Query, schemaLoader loaders.SchemaLoader, verifiablePresentation json.RawMessage, opts ...VerifyOpt) error + VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, opts ...VerifyOpt) error VerifyStates(ctx context.Context, resolvers map[string]StateResolver, opts ...VerifyOpt) error VerifyIDOwnership(userIdentifier string, challenge *big.Int) error diff --git a/pubsignals/query.go b/pubsignals/query.go index f5692b6..a474e7a 100644 --- a/pubsignals/query.go +++ b/pubsignals/query.go @@ -3,19 +3,17 @@ package pubsignals import ( "bytes" "context" - "crypto/sha256" "encoding/json" "fmt" "math/big" "strconv" "time" - "github.com/iden3/go-circuits" - "github.com/iden3/go-iden3-auth/loaders" - core "github.com/iden3/go-iden3-core" - jsonSuite "github.com/iden3/go-schema-processor/json" - "github.com/iden3/go-schema-processor/merklize" - "github.com/iden3/go-schema-processor/utils" + "github.com/iden3/go-circuits/v2" + core "github.com/iden3/go-iden3-core/v2" + parser "github.com/iden3/go-schema-processor/v2/json" + "github.com/iden3/go-schema-processor/v2/merklize" + "github.com/iden3/go-schema-processor/v2/utils" "github.com/piprate/json-gold/ld" "github.com/pkg/errors" ) @@ -29,13 +27,14 @@ var allOperations = map[int]struct{}{ circuits.NE: {}, } -var availabelTypesOperations = map[string]map[int]struct{}{ +var availableTypesOperations = map[string]map[int]struct{}{ ld.XSDBoolean: {circuits.EQ: {}, circuits.NE: {}}, ld.XSDInteger: allOperations, ld.XSDInteger + "nonNegativeInteger": allOperations, ld.XSDInteger + "positiveInteger": allOperations, ld.XSDString: {circuits.EQ: {}, circuits.NE: {}, circuits.IN: {}, circuits.NIN: {}}, ld.XSDNS + "dateTime": allOperations, + ld.XSDDouble: {circuits.EQ: {}, circuits.NE: {}, circuits.IN: {}, circuits.NIN: {}}, } // PathToSubjectType path to description of subject type. @@ -82,9 +81,11 @@ type CircuitOutputs struct { } // Check checks if proof was created for this query. +// Would be good to use ctx for external http requests, but current interfaces +// doesn't allow to do it. Left it for future. func (q Query) Check( - ctx context.Context, - loader loaders.SchemaLoader, + _ context.Context, + loader ld.DocumentLoader, pubSig *CircuitOutputs, verifiablePresentation json.RawMessage, opts ...VerifyOpt, @@ -93,20 +94,22 @@ func (q Query) Check( return err } - schemaBytes, _, err := loader.Load(ctx, q.Context) + schemaDoc, err := loader.LoadDocument(q.Context) if err != nil { return fmt.Errorf("failed load schema by context: %w", err) } - if err := q.verifySchemaID(schemaBytes, pubSig); err != nil { + schemaBytes, err := json.Marshal(schemaDoc.Document) + if err != nil { + return fmt.Errorf("failed jsonify schema document: %w", err) + } + + if err := q.verifySchemaID(schemaBytes, pubSig, loader); err != nil { return err } - if err := q.verifyCredentialSubject( - pubSig, - verifiablePresentation, - schemaBytes, - ); err != nil { + if err := q.verifyCredentialSubject(pubSig, verifiablePresentation, + schemaBytes, loader); err != nil { return err } @@ -125,10 +128,12 @@ func (q Query) Check( return ErrProofGenerationOutdated } - return q.verifyClaim(ctx, schemaBytes, pubSig) + return q.verifyClaim(schemaBytes, pubSig, loader) } -func (q Query) verifyClaim(_ context.Context, schemaBytes []byte, pubSig *CircuitOutputs) error { +func (q Query) verifyClaim(schemaBytes []byte, pubSig *CircuitOutputs, + schemaLoader ld.DocumentLoader) error { + if len(q.CredentialSubject) == 0 { return nil } @@ -139,7 +144,8 @@ func (q Query) verifyClaim(_ context.Context, schemaBytes []byte, pubSig *Circui } if pubSig.Merklized == 1 { - path, err := merklize.NewFieldPathFromContext(schemaBytes, q.Type, fieldName) + path, err := merklize.Options{DocumentLoader: schemaLoader}. + FieldPathFromContext(schemaBytes, q.Type, fieldName) if err != nil { return err } @@ -161,12 +167,12 @@ func (q Query) verifyClaim(_ context.Context, schemaBytes []byte, pubSig *Circui return errors.New("proof doesn't contains target query key") } } else { - slotIdx, err := jsonSuite.Parser{}.GetFieldSlotIndex(fieldName, schemaBytes) + slotIndex, err := parser.Parser{}.GetFieldSlotIndex(fieldName, q.Type, schemaBytes) if err != nil { - return err + return errors.Errorf("failed to get field slot: %v", err) } - if pubSig.SlotIndex != slotIdx { - return errors.New("different slot index for claim") + if slotIndex != pubSig.SlotIndex { + return errors.New("proof was generated for another slot") } } @@ -186,10 +192,11 @@ func (q Query) verifyIssuer(pubSig *CircuitOutputs) error { return ErrUnavailableIssuer } -func (q Query) verifySchemaID(schemaBytes []byte, - pubSig *CircuitOutputs) error { +func (q Query) verifySchemaID(schemaBytes []byte, pubSig *CircuitOutputs, + schemaLoader ld.DocumentLoader) error { - schemaID, err := merklize.TypeIDFromContext(schemaBytes, q.Type) + schemaID, err := merklize.Options{DocumentLoader: schemaLoader}. + TypeIDFromContext(schemaBytes, q.Type) if err != nil { return err } @@ -204,6 +211,7 @@ func (q Query) verifyCredentialSubject( pubSig *CircuitOutputs, verifiablePresentation json.RawMessage, ctxBytes []byte, + schemaLoader ld.DocumentLoader, ) error { fieldName, predicate, err := extractQueryFields(q.CredentialSubject) if err != nil { @@ -212,10 +220,8 @@ func (q Query) verifyCredentialSubject( var fieldType string if fieldName != "" { - fieldType, err = merklize.TypeFromContext( - ctxBytes, - fmt.Sprintf("%s.%s", q.Type, fieldName), - ) + fieldType, err = merklize.Options{DocumentLoader: schemaLoader}. + TypeFromContext(ctxBytes, fmt.Sprintf("%s.%s", q.Type, fieldName)) if err != nil { return err } @@ -224,12 +230,8 @@ func (q Query) verifyCredentialSubject( // validate selectivity disclosure request if q.isSelectivityDisclosure(predicate) { ctx := context.Background() - return q.validateDisclosure( - ctx, - pubSig, - fieldName, - verifiablePresentation, - ) + return q.validateDisclosure(ctx, pubSig, fieldName, + verifiablePresentation, schemaLoader) } // validate empty credential subject request @@ -271,12 +273,10 @@ func (q Query) verifyCredentialSubject( return nil } -func (q Query) validateDisclosure( - ctx context.Context, - pubSig *CircuitOutputs, - key string, - verifiablePresentation json.RawMessage, -) error { +func (q Query) validateDisclosure(ctx context.Context, pubSig *CircuitOutputs, + key string, verifiablePresentation json.RawMessage, + schemaLoader ld.DocumentLoader) error { + if verifiablePresentation == nil { return errors.New("selective disclosure value is missed") } @@ -291,12 +291,16 @@ func (q Query) validateDisclosure( } } - mz, err := merklize.MerklizeJSONLD(ctx, bytes.NewBuffer(verifiablePresentation)) + mz, err := merklize.MerklizeJSONLD(ctx, + bytes.NewBuffer(verifiablePresentation), + merklize.WithDocumentLoader(schemaLoader)) if err != nil { return errors.Errorf("failed to merklize doc: %v", err) } - merklizedPath, err := merklize.NewPathFromDocument(verifiablePresentation, fmt.Sprintf("verifiableCredential.credentialSubject.%s", key)) + merklizedPath, err := merklize.Options{DocumentLoader: schemaLoader}. + NewPathFromDocument(verifiablePresentation, + fmt.Sprintf("verifiableCredential.credentialSubject.%s", key)) if err != nil { return errors.Errorf("failed build path to '%s' key: %v", key, err) } @@ -458,10 +462,10 @@ func isValidOperation(typ string, op int) bool { return true } - ops, ok := availabelTypesOperations[typ] + ops, ok := availableTypesOperations[typ] if !ok { // by default all unknown types will be considered as string - ops = availabelTypesOperations[ld.XSDString] + ops = availableTypesOperations[ld.XSDString] _, ok = ops[op] return ok } @@ -469,13 +473,3 @@ func isValidOperation(typ string, op int) bool { _, ok = ops[op] return ok } - -// IDFromUnknownDID returns ID from did with unsupported by go-iden3-core did method -// type is set to [255,255] hash alg is sha256 -func IDFromUnknownDID(did string) core.ID { - hash := sha256.Sum256([]byte(did)) - var genesis [27]byte - copy(genesis[:], hash[len(hash)-27:]) - var tp = [2]byte{0b11111111, 0b11111111} - return core.NewID(tp, genesis) -} diff --git a/pubsignals/query_test.go b/pubsignals/query_test.go index 318df01..9f3b716 100644 --- a/pubsignals/query_test.go +++ b/pubsignals/query_test.go @@ -6,122 +6,45 @@ import ( "errors" "fmt" "math/big" + "os" "testing" "time" - core "github.com/iden3/go-iden3-core" + core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-schema-processor/v2/utils" + "github.com/piprate/json-gold/ld" "github.com/stretchr/testify/require" ) var ( - issuerDID = "did:polygonid:polygon:mumbai:2qHSHBGWGJ68AosMKcLCTp8FYdVrtYE6MtNHhq8xpK" - iid, _ = new(big.Int).SetString("22638457188543025296541325416907897762715008870723718557276875842936181250", 10) - issuerID, _ = core.IDFromInt(iid) - - schemaHashKYCEmployee, _ = big.NewInt(0).SetString("40507426258035268209384482717564233104", 10) - KYCEmployeeSchema = core.NewSchemaHashFromInt(schemaHashKYCEmployee) - - schemaHashKYCCountry, _ = big.NewInt(0).SetString("336615423900919464193075592850483704600", 10) - KYCCountrySchema = core.NewSchemaHashFromInt(schemaHashKYCCountry) - + issuerDID = "did:polygonid:polygon:mumbai:2qHSHBGWGJ68AosMKcLCTp8FYdVrtYE6MtNHhq8xpK" + iid, _ = new(big.Int).SetString("22638457188543025296541325416907897762715008870723718557276875842936181250", 10) + issuerID, _ = core.IDFromInt(iid) bigIntTrueHash, _ = big.NewInt(0).SetString("18586133768512220936620570745912940619677854269274689475585506675881198879027", 10) ) -type mockMemorySchemaLoader struct { +type mockJSONLDSchemaLoader struct { + schemas map[string]string + seen map[string]bool } -func (r *mockMemorySchemaLoader) Load(_ context.Context, _ string) (schema []byte, ext string, err error) { - return []byte(`{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "$metadata": { - "uris": { - "jsonLdContext": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", - "jsonSchema": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCCountryOfResidenceCredential-v2.json" - }, - "serialization": { - "valueDataSlotB": "countryCode" +func (r *mockJSONLDSchemaLoader) LoadDocument(u string) (*ld.RemoteDocument, error) { + if body, ok := r.schemas[u]; ok { + if r.seen == nil { + r.seen = make(map[string]bool) + } + r.seen[u] = true + var doc = ld.RemoteDocument{DocumentURL: u} + err := json.Unmarshal([]byte(body), &doc.Document) + return &doc, err } - }, - "@context": [ - { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "KYCAgeCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCAgeCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "birthday": { - "@id": "kyc-vocab:birthday", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - }, - "KYCCountryOfResidenceCredential": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "countryCode": { - "@id": "kyc-vocab:countryCode", - "@type": "xsd:integer" - }, - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - } - } - }, - "KYCEmployee": { - "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCEmployee", - "@context": { - "@version": 1.1, - "@protected": true, - "id": "@id", - "type": "@type", - "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", - "xsd": "http://www.w3.org/2001/XMLSchema#", - "documentType": { - "@id": "kyc-vocab:documentType", - "@type": "xsd:integer" - }, - "ZKPexperiance": { - "@id": "kyc-vocab:hasZKPexperiance", - "@type": "xsd:boolean" - }, - "hireDate": { - "@id": "kyc-vocab:hireDate", - "@type": "xsd:dateTime" - }, - "position": { - "@id": "kyc-vocab:position", - "@type": "xsd:string" - }, - "salary": { - "@id": "kyc-vocab:salary", - "@type": "xsd:double" - } - } - } - } - ] + return nil, fmt.Errorf("schema not found: %v", u) } -`), "json-ld", nil + +func (r *mockJSONLDSchemaLoader) assert(t testing.TB) { + for url := range r.schemas { + require.True(t, r.seen[url], "schema not loaded: %v", url) + } } var vp = []byte(`{ @@ -170,6 +93,7 @@ func TestCheckRequest_Success(t *testing.T) { query Query pubSig *CircuitOutputs vp json.RawMessage + loader *mockJSONLDSchemaLoader }{ { name: "Check merkalized query", @@ -185,7 +109,7 @@ func TestCheckRequest_Success(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -196,6 +120,11 @@ func TestCheckRequest_Success(t *testing.T) { IsRevocationChecked: 1, Timestamp: now, }, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Selective disclosure", @@ -209,7 +138,7 @@ func TestCheckRequest_Success(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -221,6 +150,12 @@ func TestCheckRequest_Success(t *testing.T) { Timestamp: now, }, vp: vp, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + "https://www.w3.org/2018/credentials/v1": loadSchema("credentials-v1.json-ld"), + }, + }, }, { name: "Query with boolean type", @@ -231,12 +166,12 @@ func TestCheckRequest_Success(t *testing.T) { "$eq": true, }, }, - Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", Type: "KYCEmployee", }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCEmployeeSchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCEmployee")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("1944808975288007371356450257872165609440470546066507760733183342797918372827", 10) return v @@ -247,6 +182,11 @@ func TestCheckRequest_Success(t *testing.T) { IsRevocationChecked: 1, Timestamp: now, }, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld": loadSchema("kyc-v101.json-ld"), + }, + }, }, { name: "Selective disclosure with xsd:string type", @@ -255,12 +195,12 @@ func TestCheckRequest_Success(t *testing.T) { CredentialSubject: map[string]interface{}{ "position": map[string]interface{}{}, }, - Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", Type: "KYCEmployee", }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCEmployeeSchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCEmployee")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("15406634529806189041952040954758558497189093183268091368437514469450172572054", 10) return v @@ -275,6 +215,12 @@ func TestCheckRequest_Success(t *testing.T) { Timestamp: now, }, vp: vpEmployee, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld": loadSchema("kyc-v101.json-ld"), + "https://www.w3.org/2018/credentials/v1": loadSchema("credentials-v1.json-ld"), + }, + }, }, { name: "EQ operator for xsd:string type", @@ -285,12 +231,12 @@ func TestCheckRequest_Success(t *testing.T) { "$eq": "Software Engineer", }, }, - Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", Type: "KYCEmployee", }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCEmployeeSchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCEmployee")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("15406634529806189041952040954758558497189093183268091368437514469450172572054", 10) return v @@ -305,13 +251,47 @@ func TestCheckRequest_Success(t *testing.T) { Timestamp: now, }, vp: vpEmployee, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld": loadSchema("kyc-v101.json-ld"), + }, + }, + }, + { + name: "Non merklized claim", + query: Query{ + AllowedIssuers: []string{"*"}, + CredentialSubject: map[string]interface{}{ + "birthday": map[string]interface{}{ + "$eq": "19960424", + }, + }, + Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld", + Type: "KYCAgeCredential", + }, + pubSig: &CircuitOutputs{ + IssuerID: &issuerID, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld#KYCAgeCredential")), + Operator: 1, + Value: []*big.Int{big.NewInt(19960424)}, + Merklized: 0, + SlotIndex: 2, + IsRevocationChecked: 1, + Timestamp: now, + }, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld": loadSchema("kyc-nonmerklized.jsonld"), + }, + }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := tt.query.Check(context.Background(), &mockMemorySchemaLoader{}, tt.pubSig, tt.vp) + err := tt.query.Check(context.Background(), tt.loader, tt.pubSig, tt.vp) require.NoError(t, err) + tt.loader.assert(t) }) } } @@ -326,6 +306,7 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { pubSig *CircuitOutputs vp json.RawMessage expErr error + loader *mockJSONLDSchemaLoader }{ { name: "Generated proof is outdated", @@ -341,7 +322,7 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -353,6 +334,11 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { Timestamp: dayAndMinuteAgo, }, expErr: errors.New("generated proof is outdated"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Empty disclosure value for disclosure request", @@ -367,7 +353,7 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { vp: nil, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -379,6 +365,11 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("selective disclosure value is missed"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Not EQ operation for disclosure request", @@ -393,7 +384,7 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { vp: vp, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -405,6 +396,11 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("selective disclosure available only for equal operation"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Not array of values for disclosure request", @@ -419,7 +415,7 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { vp: vp, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -431,6 +427,11 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("selective disclosure not available for array of values"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Proof was generated for another disclosure value", @@ -445,7 +446,7 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { vp: vp, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -457,6 +458,12 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("different value between proof and disclosure value"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + "https://www.w3.org/2018/credentials/v1": loadSchema("credentials-v1.json-ld"), + }, + }, }, { name: "Different key between proof and disclosure response", @@ -471,7 +478,7 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { vp: vp, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: func() *big.Int { v, _ := big.NewInt(0).SetString("17002437119434618783545694633038537380726339994244684348913844923422470806844", 10) return v @@ -483,13 +490,20 @@ func TestCheckRequest_SelectiveDisclosure_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("path '[https://www.w3.org/2018/credentials#verifiableCredential https://www.w3.org/2018/credentials#credentialSubject https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#documentType]' doesn't exist in document"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + "https://www.w3.org/2018/credentials/v1": loadSchema("credentials-v1.json-ld"), + }, + }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := tt.query.Check(context.Background(), &mockMemorySchemaLoader{}, tt.pubSig, tt.vp) + err := tt.query.Check(context.Background(), tt.loader, tt.pubSig, tt.vp) require.EqualError(t, err, tt.expErr.Error()) + tt.loader.assert(t) }) } } @@ -501,6 +515,7 @@ func TestCheckRequest_Error(t *testing.T) { query Query pubSig *CircuitOutputs expErr error + loader *mockJSONLDSchemaLoader }{ { name: "Invalid issuer", @@ -511,6 +526,7 @@ func TestCheckRequest_Error(t *testing.T) { IssuerID: &issuerID, }, expErr: ErrUnavailableIssuer, + loader: &mockJSONLDSchemaLoader{}, }, { name: "Invalid Schema ID", @@ -521,10 +537,15 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), Timestamp: now, }, expErr: ErrSchemaID, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Multiply query", @@ -539,10 +560,15 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), Timestamp: now, }, expErr: errors.New("multiple requests not supported"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Failed params in request", @@ -556,10 +582,15 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), Timestamp: now, }, expErr: errors.New("failed cast type map[string]interface"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Multiple predicates in one request", @@ -576,10 +607,15 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), Timestamp: now, }, expErr: errors.New("multiple predicates for one field not supported"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Proof was generated for another query operator", @@ -595,11 +631,16 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), Operator: 3, Timestamp: now, }, expErr: ErrRequestOperator, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Proof was generated for another values", @@ -615,12 +656,17 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), Operator: 5, Value: []*big.Int{big.NewInt(40)}, Timestamp: now, }, expErr: ErrInvalidValues, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Proof was generated for another path", @@ -636,7 +682,7 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), ClaimPathKey: big.NewInt(0), Operator: 5, Value: []*big.Int{big.NewInt(20)}, @@ -645,30 +691,11 @@ func TestCheckRequest_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("proof was generated for another path"), - }, - { - name: "Different slot index", - query: Query{ - AllowedIssuers: []string{issuerDID}, - Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", - Type: "KYCCountryOfResidenceCredential", - CredentialSubject: map[string]interface{}{ - "countryCode": map[string]interface{}{ - "$nin": []interface{}{float64(20)}, - }, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), }, }, - pubSig: &CircuitOutputs{ - IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, - Operator: 5, - Value: []*big.Int{big.NewInt(20)}, - Merklized: 0, - SlotIndex: 0, - IsRevocationChecked: 1, - Timestamp: now, - }, - expErr: errors.New("different slot index for claim"), }, { name: "Check revocation is required", @@ -685,7 +712,7 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCCountrySchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential")), Operator: 5, Value: []*big.Int{big.NewInt(20)}, Merklized: 0, @@ -694,12 +721,17 @@ func TestCheckRequest_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("check revocation is required"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld": loadSchema("kyc-v3.json-ld"), + }, + }, }, { name: "Unsupported lt operator for xsd:boolean", query: Query{ AllowedIssuers: []string{issuerDID}, - Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", Type: "KYCEmployee", CredentialSubject: map[string]interface{}{ "ZKPexperiance": map[string]interface{}{ @@ -710,7 +742,7 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCEmployeeSchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCEmployee")), Operator: 2, Value: []*big.Int{big.NewInt(20)}, Merklized: 0, @@ -719,12 +751,17 @@ func TestCheckRequest_Error(t *testing.T) { Timestamp: now, }, expErr: errors.New("invalid operation '$lt' for field type 'http://www.w3.org/2001/XMLSchema#boolean'"), + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld": loadSchema("kyc-v101.json-ld"), + }, + }, }, { name: "Negative value in request", query: Query{ AllowedIssuers: []string{issuerDID}, - Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + Context: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld", Type: "KYCEmployee", CredentialSubject: map[string]interface{}{ "documentType": map[string]interface{}{ @@ -735,7 +772,7 @@ func TestCheckRequest_Error(t *testing.T) { }, pubSig: &CircuitOutputs{ IssuerID: &issuerID, - ClaimSchema: KYCEmployeeSchema, + ClaimSchema: utils.CreateSchemaHash([]byte("https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCEmployee")), Operator: 1, Value: []*big.Int{big.NewInt(-1)}, Merklized: 0, @@ -744,13 +781,19 @@ func TestCheckRequest_Error(t *testing.T) { Timestamp: now, }, expErr: ErrNegativeValue, + loader: &mockJSONLDSchemaLoader{ + schemas: map[string]string{ + "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld": loadSchema("kyc-v101.json-ld"), + }, + }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := tt.query.Check(context.Background(), &mockMemorySchemaLoader{}, tt.pubSig, nil) + err := tt.query.Check(context.Background(), tt.loader, tt.pubSig, nil) require.EqualError(t, err, tt.expErr.Error()) + tt.loader.assert(t) }) } } @@ -847,3 +890,11 @@ func TestVerifyQuery_Error(t *testing.T) { }) } } + +func loadSchema(name string) string { + bs, err := os.ReadFile("../testdata/" + name) + if err != nil { + panic(err) + } + return string(bs) +} diff --git a/pubsignals/signals.go b/pubsignals/signals.go index 4bf7383..73fc6a2 100644 --- a/pubsignals/signals.go +++ b/pubsignals/signals.go @@ -4,7 +4,7 @@ import ( "reflect" "sync" - "github.com/iden3/go-circuits" + "github.com/iden3/go-circuits/v2" "github.com/pkg/errors" ) diff --git a/state/state.go b/state/state.go index 9a84855..4305d5f 100644 --- a/state/state.go +++ b/state/state.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/iden3/contracts-abi/state/go/abi" - core "github.com/iden3/go-iden3-core" + core "github.com/iden3/go-iden3-core/v2" "github.com/pkg/errors" ) @@ -124,7 +124,7 @@ func CheckGenesisStateID(id, state *big.Int) (bool, error) { if err != nil { return false, err } - identifier, err := core.IdGenesisFromIdenState(userID.Type(), state) + identifier, err := core.NewIDFromIdenState(userID.Type(), state) if err != nil { return false, err } diff --git a/state/state_test.go b/state/state_test.go index 0c26971..2c2a677 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -7,9 +7,10 @@ import ( "github.com/golang/mock/gomock" "github.com/iden3/contracts-abi/state/go/abi" - "github.com/iden3/go-iden3-auth/state" - mock "github.com/iden3/go-iden3-auth/state/mock" - core "github.com/iden3/go-iden3-core" + "github.com/iden3/go-iden3-auth/v2/state" + mock "github.com/iden3/go-iden3-auth/v2/state/mock" + core "github.com/iden3/go-iden3-core/v2" + "github.com/iden3/go-iden3-core/v2/w3c" "github.com/pkg/errors" "github.com/stretchr/testify/require" ) @@ -303,19 +304,26 @@ func TestResolveGlobalRoot_Error(t *testing.T) { } func TestCheckGenesisStateID(t *testing.T) { - userDID, err := core.ParseDID("did:iden3:polygon:mumbai:x6suHR8HkEYczV9yVeAKKiXCZAd25P8WS6QvNhszk") + userDID, err := w3c.ParseDID("did:iden3:polygon:mumbai:x6suHR8HkEYczV9yVeAKKiXCZAd25P8WS6QvNhszk") require.NoError(t, err) - genesisID, ok := big.NewInt(0).SetString("7521024223205616003431860562270429547098131848980857190502964780628723574810", 10) + genesisID, ok := big.NewInt(0).SetString( + "7521024223205616003431860562270429547098131848980857190502964780628723574810", + 10) require.True(t, ok) - isGenesis, err := state.CheckGenesisStateID(userDID.ID.BigInt(), genesisID) + uID, err := core.IDFromDID(*userDID) + require.NoError(t, err) + + isGenesis, err := state.CheckGenesisStateID(uID.BigInt(), genesisID) require.NoError(t, err) require.True(t, isGenesis) - notGenesisState, ok := big.NewInt(0).SetString("6017654403209798611575982337826892532952335378376369712724079246845524041042", 10) + notGenesisState, ok := big.NewInt(0).SetString( + "6017654403209798611575982337826892532952335378376369712724079246845524041042", + 10) require.True(t, ok) - isGenesis, err = state.CheckGenesisStateID(userDID.ID.BigInt(), notGenesisState) + isGenesis, err = state.CheckGenesisStateID(uID.BigInt(), notGenesisState) require.NoError(t, err) require.False(t, isGenesis) } diff --git a/testdata/credentials-v1.json-ld b/testdata/credentials-v1.json-ld new file mode 100644 index 0000000..0124a3c --- /dev/null +++ b/testdata/credentials-v1.json-ld @@ -0,0 +1,237 @@ +{ + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "VerifiableCredential": { + "@id": "https://www.w3.org/2018/credentials#VerifiableCredential", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "cred": "https://www.w3.org/2018/credentials#", + "sec": "https://w3id.org/security#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + + "credentialSchema": { + "@id": "cred:credentialSchema", + "@type": "@id", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "cred": "https://www.w3.org/2018/credentials#", + + "JsonSchemaValidator2018": "cred:JsonSchemaValidator2018" + } + }, + "credentialStatus": {"@id": "cred:credentialStatus", "@type": "@id"}, + "credentialSubject": {"@id": "cred:credentialSubject", "@type": "@id"}, + "evidence": {"@id": "cred:evidence", "@type": "@id"}, + "expirationDate": {"@id": "cred:expirationDate", "@type": "xsd:dateTime"}, + "holder": {"@id": "cred:holder", "@type": "@id"}, + "issued": {"@id": "cred:issued", "@type": "xsd:dateTime"}, + "issuer": {"@id": "cred:issuer", "@type": "@id"}, + "issuanceDate": {"@id": "cred:issuanceDate", "@type": "xsd:dateTime"}, + "proof": {"@id": "sec:proof", "@type": "@id", "@container": "@graph"}, + "refreshService": { + "@id": "cred:refreshService", + "@type": "@id", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "cred": "https://www.w3.org/2018/credentials#", + + "ManualRefreshService2018": "cred:ManualRefreshService2018" + } + }, + "termsOfUse": {"@id": "cred:termsOfUse", "@type": "@id"}, + "validFrom": {"@id": "cred:validFrom", "@type": "xsd:dateTime"}, + "validUntil": {"@id": "cred:validUntil", "@type": "xsd:dateTime"} + } + }, + + "VerifiablePresentation": { + "@id": "https://www.w3.org/2018/credentials#VerifiablePresentation", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "cred": "https://www.w3.org/2018/credentials#", + "sec": "https://w3id.org/security#", + + "holder": {"@id": "cred:holder", "@type": "@id"}, + "proof": {"@id": "sec:proof", "@type": "@id", "@container": "@graph"}, + "verifiableCredential": {"@id": "cred:verifiableCredential", "@type": "@id", "@container": "@graph"} + } + }, + + "EcdsaSecp256k1Signature2019": { + "@id": "https://w3id.org/security#EcdsaSecp256k1Signature2019", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "sec": "https://w3id.org/security#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + + "challenge": "sec:challenge", + "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "domain": "sec:domain", + "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "jws": "sec:jws", + "nonce": "sec:nonce", + "proofPurpose": { + "@id": "sec:proofPurpose", + "@type": "@vocab", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "sec": "https://w3id.org/security#", + + "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, + "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + } + }, + "proofValue": "sec:proofValue", + "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + } + }, + + "EcdsaSecp256r1Signature2019": { + "@id": "https://w3id.org/security#EcdsaSecp256r1Signature2019", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "sec": "https://w3id.org/security#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + + "challenge": "sec:challenge", + "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "domain": "sec:domain", + "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "jws": "sec:jws", + "nonce": "sec:nonce", + "proofPurpose": { + "@id": "sec:proofPurpose", + "@type": "@vocab", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "sec": "https://w3id.org/security#", + + "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, + "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + } + }, + "proofValue": "sec:proofValue", + "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + } + }, + + "Ed25519Signature2018": { + "@id": "https://w3id.org/security#Ed25519Signature2018", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "sec": "https://w3id.org/security#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + + "challenge": "sec:challenge", + "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "domain": "sec:domain", + "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "jws": "sec:jws", + "nonce": "sec:nonce", + "proofPurpose": { + "@id": "sec:proofPurpose", + "@type": "@vocab", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "sec": "https://w3id.org/security#", + + "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, + "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + } + }, + "proofValue": "sec:proofValue", + "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + } + }, + + "RsaSignature2018": { + "@id": "https://w3id.org/security#RsaSignature2018", + "@context": { + "@version": 1.1, + "@protected": true, + + "challenge": "sec:challenge", + "created": {"@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime"}, + "domain": "sec:domain", + "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "jws": "sec:jws", + "nonce": "sec:nonce", + "proofPurpose": { + "@id": "sec:proofPurpose", + "@type": "@vocab", + "@context": { + "@version": 1.1, + "@protected": true, + + "id": "@id", + "type": "@type", + + "sec": "https://w3id.org/security#", + + "assertionMethod": {"@id": "sec:assertionMethod", "@type": "@id", "@container": "@set"}, + "authentication": {"@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set"} + } + }, + "proofValue": "sec:proofValue", + "verificationMethod": {"@id": "sec:verificationMethod", "@type": "@id"} + } + }, + + "proof": {"@id": "https://w3id.org/security#proof", "@type": "@id", "@container": "@graph"} + } +} diff --git a/testdata/kyc-nonmerklized.jsonld b/testdata/kyc-nonmerklized.jsonld new file mode 100644 index 0000000..bd53901 --- /dev/null +++ b/testdata/kyc-nonmerklized.jsonld @@ -0,0 +1,51 @@ +{ + "@context": [ + { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "KYCAgeCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld#KYCAgeCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "iden3_serialization": "iden3:v1:slotIndexA=birthday&slotIndexB=documentType", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "birthday": { + "@id": "kyc-vocab:birthday", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + }, + "KYCCountryOfResidenceCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld#KYCCountryOfResidenceCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "iden3_serialization": "iden3:v1:slotIndexA=birthday&slotIndexB=documentType", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "countryCode": { + "@id": "kyc-vocab:countryCode", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + } + } + ] + } + \ No newline at end of file diff --git a/testdata/kyc-v101.json-ld b/testdata/kyc-v101.json-ld new file mode 100644 index 0000000..94812e1 --- /dev/null +++ b/testdata/kyc-v101.json-ld @@ -0,0 +1,79 @@ +{ + "@context": [ + { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "KYCAgeCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCAgeCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "birthday": { + "@id": "kyc-vocab:birthday", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + }, + "KYCCountryOfResidenceCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCCountryOfResidenceCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "countryCode": { + "@id": "kyc-vocab:countryCode", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + }, + "KYCEmployee": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v101.json-ld#KYCEmployee", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + }, + "ZKPexperiance": { + "@id": "kyc-vocab:hasZKPexperiance", + "@type": "xsd:boolean" + }, + "hireDate": { + "@id": "kyc-vocab:hireDate", + "@type": "xsd:dateTime" + }, + "position": { + "@id": "kyc-vocab:position", + "@type": "xsd:string" + }, + "salary": { + "@id": "kyc-vocab:salary", + "@type": "xsd:double" + } + } + } + } + ] +} diff --git a/testdata/kyc-v2.json-ld b/testdata/kyc-v2.json-ld new file mode 100644 index 0000000..0834274 --- /dev/null +++ b/testdata/kyc-v2.json-ld @@ -0,0 +1,48 @@ +{ + "@context": [ + { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "KYCAgeCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v2.json-ld#KYCAgeCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "serialization": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/serialization.md#", + "birthday": { + "@id": "kyc-vocab:birthday", + "@type": "serialization:IndexDataSlotA" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "serialization:IndexDataSlotB" + } + } + }, + "KYCCountryOfResidenceCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v2.json-ld#KYCCountryOfResidenceCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "serialization": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/serialization.md#", + "countryCode": { + "@id": "kyc-vocab:countryCode", + "@type": "serialization:IndexDataSlotA" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "serialization:IndexDataSlotB" + } + } + } + } + ] +} diff --git a/testdata/kyc-v3.json-ld b/testdata/kyc-v3.json-ld new file mode 100644 index 0000000..4c86336 --- /dev/null +++ b/testdata/kyc-v3.json-ld @@ -0,0 +1,48 @@ +{ + "@context": [ + { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "KYCAgeCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCAgeCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "birthday": { + "@id": "kyc-vocab:birthday", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + }, + "KYCCountryOfResidenceCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld#KYCCountryOfResidenceCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "countryCode": { + "@id": "kyc-vocab:countryCode", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + } + } + ] +} diff --git a/testdata/kyc-v4.json-ld b/testdata/kyc-v4.json-ld new file mode 100644 index 0000000..09f1938 --- /dev/null +++ b/testdata/kyc-v4.json-ld @@ -0,0 +1,48 @@ +{ + "@context": [ + { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "KYCAgeCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld#KYCAgeCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "birthday": { + "@id": "kyc-vocab:birthday", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + }, + "KYCCountryOfResidenceCredential": { + "@id": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v4.jsonld#KYCCountryOfResidenceCredential", + "@context": { + "@version": 1.1, + "@protected": true, + "id": "@id", + "type": "@type", + "kyc-vocab": "https://github.com/iden3/claim-schema-vocab/blob/main/credentials/kyc.md#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "countryCode": { + "@id": "kyc-vocab:countryCode", + "@type": "xsd:integer" + }, + "documentType": { + "@id": "kyc-vocab:documentType", + "@type": "xsd:integer" + } + } + } + } + ] +} diff --git a/transport/notification.go b/transport/notification.go index 6d3c742..dce72c4 100644 --- a/transport/notification.go +++ b/transport/notification.go @@ -4,9 +4,9 @@ import ( "context" "encoding/json" - "github.com/iden3/go-schema-processor/verifiable" - "github.com/iden3/iden3comm/protocol" - "github.com/iden3/iden3comm/transport/notification" + "github.com/iden3/go-schema-processor/v2/verifiable" + "github.com/iden3/iden3comm/v2/protocol" + "github.com/iden3/iden3comm/v2/transport/notification" "github.com/pkg/errors" )