Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
491 changes: 359 additions & 132 deletions inputs_sig.go

Large diffs are not rendered by default.

69 changes: 67 additions & 2 deletions inputs_sig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,65 @@ func TestPrepareInputs(t *testing.T) {
EnvConfig{}, "", "")
})

t.Run("LinkedMultiQueryInputsFromJson - Sig - Selective Disclosure with meta field", func(t *testing.T) {
ipfsURL := os.Getenv("IPFS_URL")
if ipfsURL == "" {
t.Fatal("IPFS_URL is not set")
}

defer preserveIPFSHttpCli()()

cid := uploadIPFSFile(t, ipfsURL, "testdata/ipfs_QmZbsTnRwtCmbdg3r9o7Txid37LmvPcvmzVi1Abvqu1WKL.json")
require.Equal(t, "QmZbsTnRwtCmbdg3r9o7Txid37LmvPcvmzVi1Abvqu1WKL", cid)

defer httpmock.MockHTTPClient(t, map[string]string{
`http://localhost:8545%%%{"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"from":"0x0000000000000000000000000000000000000000","input":"0xb4bdea55000e4309ebc549d974a1c8de06d5146790a53c667ed3a49f82079597ab781301","to":"0x1a4cc30f2aa0377b0c3bc9848766d90cb4404124"},"latest"]}`: "testdata/httpresp_eth_resp4.json",
"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld": "testdata/httpresp_iden3proofs.jsonld",
"https://rhs-staging.polygonid.me/node/22963e52a4c04ef499f1d2930867ebdb5596a73dbcd77477b5519a299ff7b815": "testdata/httpresp_rhs_22963e52a4c04ef499f1d2930867ebdb5596a73dbcd77477b5519a299ff7b815.json",
"https://rhs-staging.polygonid.me/node/b2c723870c6b85698de19c06166d1159fb5082018430b15b1c00de9f38a34809": "testdata/httpresp_rhs_b2c723870c6b85698de19c06166d1159fb5082018430b15b1c00de9f38a34809.json",
})()

wantVerifiablePresentation := map[string]any{
"@context": []any{"https://www.w3.org/2018/credentials/v1"},
"type": "VerifiablePresentation",
"verifiableCredential": map[string]any{
"@context": []any{
"https://www.w3.org/2018/credentials/v1",
"ipfs://QmZbsTnRwtCmbdg3r9o7Txid37LmvPcvmzVi1Abvqu1WKL",
},
"type": []any{"VerifiableCredential", "BasicPerson"},
"issuanceDate": "2026-06-09T17:14:29.328Z",
"expirationDate": "2058-07-10T11:33:20Z",
"credentialSubject": map[string]any{
"type": "BasicPerson",
"placeOfBirth": map[string]any{
"countryCode": "UA-ua",
},
},
"credentialStatus": map[string]any{
"id": "https://rhs-staging.polygonid.me/node?state=ed17a07e8b78ab979507829fa4d37e663ca5906714d506dec8a174d949c5eb09",
"type": "Iden3ReverseSparseMerkleTreeProof",
"revocationNonce": float64(2837597946),
},
},
}

cfg := EnvConfig{
IPFSNodeURL: ipfsURL,
ChainConfigs: map[core.ChainID]ChainConfig{
80002: {
RPCUrl: "http://localhost:8545",
StateContractAddr: common.HexToAddress("0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124"),
},
},
}

doTest(t, "atomic_query_v3_sig_selective_disclosure_with_meta_fields_inputs.json",
"atomic_query_v3_sig_selective_disclosure_with_meta_fields_outputs.json",
LinkedMultiQueryInputsFromJson, wantVerifiablePresentation,
cfg, "", "")
})

t.Run("AtomicQueryV3OnChainInputsFromJson - Transaction Data", func(t *testing.T) {
defer httpmock.MockHTTPClient(t, map[string]string{
"http://localhost:8001/api/v1/identities/did%3Apolygonid%3Apolygon%3Amumbai%3A2qDnyCaxj4zdYmj6LbegYMjWSnkbKAyqtq31YeuyZV/claims/revocation/status/3972757": "testdata/httpresp_rev_status_3972757.json",
Expand Down Expand Up @@ -1465,7 +1524,7 @@ func TestDescribeID(t *testing.T) {
require.EqualError(t, err, "id and idAsInt are different")
}

func TestMkVPObj(t *testing.T) {
func TestInsertKV(t *testing.T) {
const tp = "tp"

testCases := []struct {
Expand Down Expand Up @@ -1518,7 +1577,13 @@ func TestMkVPObj(t *testing.T) {

for i, tc := range testCases {
t.Run(strconv.Itoa(i), func(t *testing.T) {
out, err := mkVPObj(tp, tc.in...)
out := jsonObj{"type": tp}
var err error
for _, kv := range tc.in {
if err = insertKV(out, kv); err != nil {
break
}
}
if tc.wantErr != "" {
require.EqualError(t, err, tc.wantErr)
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"id": "x1QQ78ktjAmia48pyEZENyurZhpRSdPMWmtv1zbsi",
"claimSubjectProfileNonce": "0",
"linkNonce": "559585013",
"verifiableCredentials": {
"id": "urn:e551891e-504f-41c4-83c3-e32f1b375c35",
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://schema.iden3.io/core/jsonld/iden3proofs.jsonld",
"ipfs://QmZbsTnRwtCmbdg3r9o7Txid37LmvPcvmzVi1Abvqu1WKL"
],
"type": [
"VerifiableCredential",
"BasicPerson"
],
"expirationDate": "2058-07-10T11:33:20.000Z",
"issuanceDate": "2026-06-09T17:14:29.328Z",
"credentialSubject": {
"id": "did:iden3:polygon:amoy:xDLAgEFPZFhRbTyp8Xe3ob7Lm52Qk5XULGQgu7yBS",
"fullName": "John Doe",
"firstName": "John",
"familyName": "Doe",
"dateOfBirth": 838531598,
"governmentIdentifier": "RRRRR",
"governmentIdentifierType": "passport",
"placeOfBirth": {
"countryCode": "UA-ua"
},
"type": "BasicPerson"
},
"credentialStatus": {
"id": "https://rhs-staging.polygonid.me/node?state=ed17a07e8b78ab979507829fa4d37e663ca5906714d506dec8a174d949c5eb09",
"type": "Iden3ReverseSparseMerkleTreeProof",
"revocationNonce": 2837597946
},
"issuer": "did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX",
"credentialSchema": {
"id": "ipfs://QmTojMfyzxehCJVw7aUrdWuxdF68R7oLYooGHCUr9wwsef",
"type": "JsonSchema2023"
},
"proof": [
{
"issuerData": {
"id": "did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX",
"state": {
"rootOfRoots": "0000000000000000000000000000000000000000000000000000000000000000",
"revocationTreeRoot": "0000000000000000000000000000000000000000000000000000000000000000",
"claimsTreeRoot": "6091193ec58a6c020183c2d889a92c32410f31812595f228d67a2bf37e04a729",
"value": "ed17a07e8b78ab979507829fa4d37e663ca5906714d506dec8a174d949c5eb09"
},
"mtp": {
"existence": true,
"siblings": []
},
"authCoreClaim": "cca3371a6cb1b715004407e325bd993c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bd045c3101b2a0bcd60106ff21a680d86af3dbbdec406764f93ab82849410e1c27eb6114eeff7eb030b34d1db28b46d61cb6d7efbec190a0b1c1664664ced80f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"credentialStatus": {
"id": "https://rhs-staging.polygonid.me/node?state=ed17a07e8b78ab979507829fa4d37e663ca5906714d506dec8a174d949c5eb09",
"type": "Iden3ReverseSparseMerkleTreeProof",
"revocationNonce": 0
}
},
"type": "BJJSignature2021",
"coreClaim": "7ed2bce3d6fab6efe706a7e76a0881dd2a00000000000000000000000000000001138c8ddaf071794a4cc9c9c43d596dcc8a1d9829f6946e14d90d166c780d00ec8f7ddaa4cd48bddfb308cc3f0bca5b220e29e197f410a481ac894bef7759150000000000000000000000000000000000000000000000000000000000000000fa4e22a90000000080d481a60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"signature": "5a9a14c1dbd446b1cd9b17dadba1d95681d819e2217163a6f90507e0819a100122fd96e5caea78a12813f4c8442e041e8b4e70a09552e7ad6931b727960f5501"
}
]
},
"request": {
"id": 1,
"circuitId": "linkedMultiQuery10-beta.1",
"optional": false,
"query": {
"groupId": 1,
"proofType": "BJJSignature2021",
"allowedIssuers": [
"*"
],
"type": "BasicPerson",
"context": "ipfs://QmZbsTnRwtCmbdg3r9o7Txid37LmvPcvmzVi1Abvqu1WKL",
"credentialStatus": {
"revocationNonce": {}
},
"expirationDate": {},
"issuanceDate": {},
"credentialSubject": {
"placeOfBirth.countryCode": {}
}
}
}
}
Loading
Loading