From 61b4f46c8ea439cbde0277efc63c3e781a376a03 Mon Sep 17 00:00:00 2001 From: Marton Moro Date: Mon, 25 Nov 2024 16:47:34 +0100 Subject: [PATCH] chore(docs): sample data --- apps/docs/src/components/sample-data.ts | 161 ++++++++++++++++++++++++ apps/docs/src/components/test-zkapp.tsx | 12 +- 2 files changed, 165 insertions(+), 8 deletions(-) diff --git a/apps/docs/src/components/sample-data.ts b/apps/docs/src/components/sample-data.ts index cf15781..ef373ff 100644 --- a/apps/docs/src/components/sample-data.ts +++ b/apps/docs/src/components/sample-data.ts @@ -47,6 +47,70 @@ export const sampleCredential1 = { }, }; +export const sampleCredential2 = { + version: "v0", + witness: { + type: "simple", + issuer: { + _type: "PublicKey", + value: "B62qqRryvaLH99vsPx6kL8cuWFq2AZZsDjaQftab4hpGA5Du3Jju6kP", + }, + issuerSignature: { + _type: "Signature", + value: { + r: "18608032094363426526383612175861105396636219252290095846645842383039012234860", + s: "16614231870158121751259974049410646935461628042855821394498854808344556066615", + }, + }, + }, + credential: { + owner: { + _type: "PublicKey", + value: "B62qqBvUfKppzx3omv5g9YSooRuqA3YVG5zq4j33tN2THA6tGc7JUij", + }, + data: { + age: { _type: "Field", value: "18" }, + name: { + _type: "Bytes", + value: + "416c696365000000000000000000000000000000000000000000000000000000", + }, + }, + }, +}; + +export const sampleCredential3 = { + version: "v0", + witness: { + type: "simple", + issuer: { + _type: "PublicKey", + value: "B62qipmSo9Bju1XPtHfH8ukLWSMgur6e2xiUcfzbqwKEMdzSfQNbfbS", + }, + issuerSignature: { + _type: "Signature", + value: { + r: "15369596967930537948249866433896467790855310091967164859503093172192059176638", + s: "18498891580394813079080734274552796309574738769075217343428610783674309728163", + }, + }, + }, + credential: { + owner: { + _type: "PublicKey", + value: "B62qrVPwPbeogxQKzPcV5dTSTmNo39g1T2hAM19cJ5Dtwk1p4STmKAE", + }, + data: { + age: { _type: "Field", value: "18" }, + name: { + _type: "Bytes", + value: + "416c696365000000000000000000000000000000000000000000000000000000", + }, + }, + }, +}; + export const samplePresentationRequest = { type: "zk-app", spec: { @@ -151,3 +215,100 @@ export const samplePresentationRequest = { action: { _type: "Field", value: "123" }, }, }; + +export const samplePresentationRequest1 = { + type: "https", + spec: { + inputs: { + signedData: { + type: "credential", + credentialType: "simple", + witness: { + type: { type: "Constant", value: "simple" }, + issuer: { _type: "PublicKey" }, + issuerSignature: { _type: "Signature" }, + }, + data: { age: { _type: "Field" }, name: { _type: "Bytes", size: 32 } }, + }, + targetAge: { type: "claim", data: { _type: "Field" } }, + targetName: { + type: "constant", + data: { _type: "Bytes", size: 32 }, + value: + "416c696365000000000000000000000000000000000000000000000000000000", + }, + }, + logic: { + assert: { + type: "and", + inputs: [ + { + type: "equals", + left: { + type: "property", + key: "age", + inner: { + type: "property", + key: "data", + inner: { + type: "property", + key: "signedData", + inner: { type: "root" }, + }, + }, + }, + right: { + type: "property", + key: "targetAge", + inner: { type: "root" }, + }, + }, + { + type: "equals", + left: { + type: "property", + key: "name", + inner: { + type: "property", + key: "data", + inner: { + type: "property", + key: "signedData", + inner: { type: "root" }, + }, + }, + }, + right: { + type: "property", + key: "targetName", + inner: { type: "root" }, + }, + }, + ], + }, + outputClaim: { + type: "property", + key: "age", + inner: { + type: "property", + key: "data", + inner: { + type: "property", + key: "signedData", + inner: { type: "root" }, + }, + }, + }, + }, + }, + claims: { targetAge: { _type: "Field", value: "18" } }, + inputContext: { + type: "https", + serverNonce: { + _type: "Field", + value: + "4343919140832211358170758874350867217600871707216240107166052913905177631127", + }, + action: "POST /api/verify", + }, +}; diff --git a/apps/docs/src/components/test-zkapp.tsx b/apps/docs/src/components/test-zkapp.tsx index 2a5ef04..cf29f73 100644 --- a/apps/docs/src/components/test-zkapp.tsx +++ b/apps/docs/src/components/test-zkapp.tsx @@ -2,16 +2,12 @@ import { createStore } from "@mina-js/connect"; import { useLocalStorage, useObjectState } from "@uidotdev/usehooks"; import { clsx } from "clsx"; import { useState, useSyncExternalStore } from "react"; -import { sampleCredential, samplePresentationRequest } from "./sample-data"; +import { sampleCredential3, samplePresentationRequest1 } from "./sample-data"; const store = createStore(); const sampleSignFieldsWithPassphrase = { - fields: [ - "15194438335254979123992673494772742932886141479807135737958843785282001151979", - "13058445919007356413345300070030973942059862825965583483176167800381508277987", - "26067489438851605530938171293652363087823200555042082718868551789908955769071", - ], + fields: ["1", "2", "3"], passphrase: "1234", }; @@ -25,10 +21,10 @@ export const TestZkApp = () => { const [signFieldsWithPassphraseInput, setSignFieldsWithPassphraseInput] = useState(JSON.stringify(sampleSignFieldsWithPassphrase, null, 2)); const [credentialInput, setCredentialInput] = useState( - JSON.stringify(sampleCredential, null, 2), + JSON.stringify(sampleCredential3, null, 2), ); const [presentationRequest, setPresentationRequest] = useState( - JSON.stringify(samplePresentationRequest, null, 2), + JSON.stringify(samplePresentationRequest1, null, 2), ); const [transactionBody, setTransactionBody] = useObjectState({ to: "B62qnVUL6A53E4ZaGd3qbTr6RCtEZYTu3kTijVrrquNpPo4d3MuJ3nb",