Skip to content

Commit

Permalink
Merge pull request #84 from 0xPolygonID/fix/onchain-request-builder
Browse files Browse the repository at this point in the history
fix urls
  • Loading branch information
vmidyllic authored Dec 13, 2023
2 parents 6e989b7 + 6453213 commit a13a7bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 96 deletions.
6 changes: 3 additions & 3 deletions docs/verifier/on-chain-verification/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ The actual ZKP request "to be born before 01/01/2002" hasn't been added to the S
3. `data` encoded bytes of <a href="https://github.com/iden3/contracts/blob/master/contracts/validators/CredentialAtomicQueryValidator.sol#L12" target="_blank">CredentialAtomicQuery</a> struct.

CredentialAtomicQuery struct contains 10 fields:
1. `schema` namely the bigInt representation of the schema of the requested credential. This can be obtained by passing your schema to this [Go Sandbox](https://go.dev/play/p/rnrRbxXTRY6). In order to use the sandbox, the constants `jsonLDContext`, `typ`, `fieldName` and `schemaJSONLD` need to be modified according to your request.
2. `claimPathKey` represents the path to the queries key inside the merklized credential. In this case, it is the path to the `birthday` key. This can be obtained by passing your schema to this [Go Sandbox](https://go.dev/play/p/rnrRbxXTRY6). In order to use the sandbox, the constants `jsonLDContext`, `typ`, `fieldName` and `schemaJSONLD` need to be modified according to your request.
1. `schema` namely the bigInt representation of the schema of the requested credential. This can be obtained by passing your schema to this [Go Sandbox](https://go.dev/play/p/3id7HAhf-Wi). In order to use the sandbox, the constants `jsonLDContext`, `typ`, `fieldName` and `schemaJSONLD` need to be modified according to your request.
2. `claimPathKey` represents the path to the queries key inside the merklized credential. In this case, it is the path to the `birthday` key. This can be obtained by passing your schema to this [Go Sandbox](https://go.dev/play/p/3id7HAhf-Wi). In order to use the sandbox, the constants `jsonLDContext`, `typ`, `fieldName` and `schemaJSONLD` need to be modified according to your request.
3. `operator` is either 1,2,3,4,5,6. To understand more about the operator you can check the [zk query language](/docs/verifier/verification-library/zk-query-language.md).
4. `slotIndex` represents specific position for <a href="https://docs.iden3.io/protocol/claims-structure/#index-vs-value" target="_blank">data in claim</a>.
5. `value` represents the threshold value you are querying. In this case, it is the date 01/01/2002.
Expand Down Expand Up @@ -424,7 +424,7 @@ function calculateQueryHash(

async function main() {

// you can run https://go.dev/play/p/rnrRbxXTRY6 to get schema hash and claimPathKey using YOUR schema
// you can run https://go.dev/play/p/3id7HAhf-Wi to get schema hash and claimPathKey using YOUR schema
const schemaBigInt = "74977327600848231385663280181476307657"

const type = 'KYCAgeCredential';
Expand Down
100 changes: 7 additions & 93 deletions docs/verifier/verification-library/zk-query-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The `ProofOfHumanity` Schema encodes whether a user has been verified as a human

You can create customized schemas, check out this [<ins>tutorial</ins>](/docs/issuer/schema)!

:::
:::

**Query**

Expand Down Expand Up @@ -78,22 +78,9 @@ When presented with this query, the user must prove that he/she is a Person.
</TabItem>
<TabItem value="on-chain">

```ts
// you can run https://go.dev/play/p/rnrRbxXTRY6 to get schema hash and claimPathKey using YOUR schema
const schemaBigInt = "324849518749029195374186444632030216125"

// merklized path to field in the W3C credential according to JSONLD schema
const schemaClaimPathKey = "14815366841010849835350402710291849818496586666144492189460088557509920034090"

const requestId = 1;
Please, check out our [<ins>Onchain verification tutorial to build a query</ins>](/docs/verifier/on-chain-verification/overview.md) to learn more how to set zk request for onchain

const query = {
schema: schemaBigInt,
claimPathKey : schemaClaimPathKey,
operator: 1,
value: [1, ...new Array(63).fill(0).map(i => 0)], // for operators 1,2,3,6 only first value matters
};
```

</TabItem>
</Tabs>
Expand Down Expand Up @@ -171,22 +158,7 @@ When presented with this query, the user must prove that he/she has been born be
</TabItem>
<TabItem value="on-chain">

```ts
// you can run https://go.dev/play/p/rnrRbxXTRY6 to get schema hash and claimPathKey using YOUR schema
const schemaBigInt = "267831521922558027206082390043321796944"

// merklized path to field in the W3C credential according to JSONLD schema
const schemaClaimPathKey = "20376033832371109177683048456014525905119173674985843915445634726167450989630"

const requestId = 1;

const query = {
schema: schemaBigInt,
claimPathKey : schemaClaimPathKey,
operator: 1,
value: [1, ...new Array(63).fill(0).map(i => 0)], // for operators 1,2,3,6 only first value matters
};
```
Please, check out our [<ins>Onchain verification tutorial to build a query</ins>](/docs/verifier/on-chain-verification/overview.md) to learn more how to set zk request for onchain

</TabItem>
</Tabs>
Expand Down Expand Up @@ -262,22 +234,7 @@ When presented with this query, the user must prove that his/her monthly salary
</TabItem>
<TabItem value="on-chain">

```ts
// you can run https://go.dev/play/p/rnrRbxXTRY6 to get schema hash and claimPathKey using YOUR schema
const schemaBigInt = "215529050624769177581695011121804343416"

// merklized path to field in the W3C credential according to JSONLD schema
const schemaClaimPathKey = "18323209396655941018370955962714740724727867245625378697671016248362870463698"

const requestId = 1;

const query = {
schema: schemaBigInt,
claimPathKey : schemaClaimPathKey,
operator: 3, // operator
value: [1000, ...new Array(63).fill(0).map(i => 0)],
};
```
Please, check out our [<ins>Onchain verification tutorial to build a query</ins>](/docs/verifier/on-chain-verification/overview.md) to learn more how to set zk request for onchain

</TabItem>
</Tabs>
Expand Down Expand Up @@ -355,22 +312,8 @@ When presented with this query, the user must prove that he/she is either an Adm
</TabItem>
<TabItem value="on-chain">

```ts
// you can run https://go.dev/play/p/rnrRbxXTRY6 to get schema hash and claimPathKey using YOUR schema
const schemaBigInt = "80689572245316684375295691372009959153"

// merklized path to field in the W3C credential according to JSONLD schema
const schemaClaimPathKey = "19483179179477598314891505360164348442915562939736565831310034495973163044179"
Please, check out our [<ins>Onchain verification tutorial to build a query</ins>](/docs/verifier/on-chain-verification/overview.md) to learn more how to set zk request for onchain

const requestId = 1;

const query = {
schema: schemaBigInt,
claimPathKey : schemaClaimPathKey,
operator: 4, // operator
value: [4, 5, ...new Array(62).fill(0).map(i => 0)],
};
```

</TabItem>
</Tabs>
Expand Down Expand Up @@ -445,22 +388,7 @@ When presented with this query, the user must prove that he/she is not a residen
</TabItem>
<TabItem value="on-chain">

```ts
// you can run https://go.dev/play/p/rnrRbxXTRY6 to get schema hash and claimPathKey using YOUR schema
const schemaBigInt = "201134713754279235117373236841506344285"

// merklized path to field in the W3C credential according to JSONLD schema
const schemaClaimPathKey = "17002437119434618783545694633038537380726339994244684348913844923422470806844"

const requestId = 1;

const query = {
schema: schemaBigInt,
claimPathKey : schemaClaimPathKey,
operator: 5, // operator
value: [840, 120, 340, 509, ...new Array(60).fill(0).map(i => 0)],
};
```
Please, check out our [<ins>Onchain verification tutorial to build a query</ins>](/docs/verifier/on-chain-verification/overview.md) to learn more how to set zk request for onchain

</TabItem>
</Tabs>
Expand Down Expand Up @@ -536,22 +464,8 @@ When presented with this query, the user must prove that he/she is not a residen
</TabItem>
<TabItem value="on-chain">

```ts
// you can run https://go.dev/play/p/rnrRbxXTRY6 to get schema hash and claimPathKey using YOUR schema
const schemaBigInt = "201134713754279235117373236841506344285"

// merklized path to field in the W3C credential according to JSONLD schema
const schemaClaimPathKey = "17002437119434618783545694633038537380726339994244684348913844923422470806844"

const requestId = 1;
Please, check out our [<ins>Onchain verification tutorial to build a query</ins>](/docs/verifier/on-chain-verification/overview.md) to learn more how to set zk request for onchain

const query = {
schema: schemaBigInt,
claimPathKey : schemaClaimPathKey,
operator: 6,
value: [840, ...new Array(63).fill(0).map(i => 0)], // for operators 1,2,3,6 only first value matters
};
```

</TabItem>
</Tabs>
Expand Down

0 comments on commit a13a7bf

Please sign in to comment.