Skip to content

Commit

Permalink
chore(docs): sample data
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmoro committed Nov 25, 2024
1 parent 44bedb6 commit 61b4f46
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 8 deletions.
161 changes: 161 additions & 0 deletions apps/docs/src/components/sample-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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",
},
};
12 changes: 4 additions & 8 deletions apps/docs/src/components/test-zkapp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};

Expand All @@ -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",
Expand Down

0 comments on commit 61b4f46

Please sign in to comment.