0.0.3-beta • Published 5 months ago

arc102-zpass-sdk v0.0.3-beta

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

ARC102 ZPASS SDK

This module is used to transform the nested data into the format required by zPass Model specified by ARC-0102

Features

  • Supports yaml file

Examples

import { ZPass, DataHasher } from 'arc102-zpass-sdk';

const input = {
    type: "KYC",
    issuer: "aleo1plxqr032wuel5hfyfs94ka9hfx7wfcgzrgqfreulkqkur6a4esqqh6ffw5",
    dob: 284838282,
    address: { street: "Wonderland", city: 'Fairyland' },
};

// Create certificate from json/yaml file
const certificate = ZPass.generate(input, "json");

// Get certificate metadata
const { type, issuer, root } = ZPass.getInfo(certificate);

// Calculate hash and generate merkle proof
const dobKeyIdentifier = "3220137136791564816u64" // key,type,issuer
const keyValue = ZPass.getValueByIdentifier(certificate, dobKeyIdentifier);

if (!keyValue) throw Error("No value found")

const { salt, value } = keyValue;

const identifier = DataHasher.getKeyIdentifier("dob", type, issuer);
const leafHash = ZPass.calculateLeafHash(identifier, salt, value);
const proof = ZPass.getMerkleProof(certificate, leafHash).map(({ data }) => data);

// Verify the proof locally
const leaves = ZPass.getLeafHashes(certificate);
console.log(ZPass.verify(leaves, proof, leafHash, root));
0.0.3-beta

5 months ago

0.0.2-beta

5 months ago

0.0.1-beta

5 months ago