@0xcert/web3-sandbox 中文文档教程
// VERIFICATION EXAMPLE
// I share an evidence file that proofs certain JSON paths (e.g. public JSON)
// I have an object with just some data.
// The function recreates a recipe for this partial data object and assignes is to the evidence file.
// At this stage we modified evidence file with data we know.
// We then calculate the imprint which must match the one stored in the token.
// NOTE: Custom fields always pass.
// WORDING
// evidence -> consists of proofs -> forms an imprint
// data object -> consists of properties (props)
// USAGE
// Define arbitrary data object.
const data = { ... };
// Define certificate with JSON schema definition.
const cert = new Cert({ schema: { ...} });
// Notarize data object (returns all proofs for whole data object).
const proofs = await cert.notarize(data);
// Expose selected data keys (returns proofs and exposed values from which an imprint can be calculated).
const proofs = await cert.disclose(exampleData, [ ...paths... ]);
// Verify data object against proofs generated with function `disclose` (if object is valid, an imprint is the right root hash).
const imprint = await cert.calculate(data, proofs);
// Generate root hash from complete data object.
const imprint = await cert.imprint(data);
// VERIFICATION EXAMPLE
// I share an evidence file that proofs certain JSON paths (e.g. public JSON)
// I have an object with just some data.
// The function recreates a recipe for this partial data object and assignes is to the evidence file.
// At this stage we modified evidence file with data we know.
// We then calculate the imprint which must match the one stored in the token.
// NOTE: Custom fields always pass.
// WORDING
// evidence -> consists of proofs -> forms an imprint
// data object -> consists of properties (props)
// USAGE
// Define arbitrary data object.
const data = { ... };
// Define certificate with JSON schema definition.
const cert = new Cert({ schema: { ...} });
// Notarize data object (returns all proofs for whole data object).
const proofs = await cert.notarize(data);
// Expose selected data keys (returns proofs and exposed values from which an imprint can be calculated).
const proofs = await cert.disclose(exampleData, [ ...paths... ]);
// Verify data object against proofs generated with function `disclose` (if object is valid, an imprint is the right root hash).
const imprint = await cert.calculate(data, proofs);
// Generate root hash from complete data object.
const imprint = await cert.imprint(data);
更多
你可能也喜欢
- 12345-ui 中文文档教程
- 2mundos-cropperjs 中文文档教程
- @11tyrocks/eleventy-plugin-objectfit-focalpoint 中文文档教程
- @1hive/connect-ethereum 中文文档教程
- @3test/ethereum-value-ledger 中文文档教程
- @4awpawz/trio 中文文档教程
- @58zf/test-org-module 中文文档教程
- @8base/react-auth 中文文档教程
- @a2670392079/data-structure-ts 中文文档教程
- @aacassandra/jquery.pwstrength 中文文档教程