npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sybil-center/zkc-preparator

v0.0.4

Published

ZKCredential preparator

Downloads

6

Readme

ZK Credentials Preparator

Zero Knowledge Credentials (ZKC) Preparator is a library designed to assist developers in getting Zero Knowledge Credentials ready for use with Zero Knowledge Proof (ZKP) functions according to ZKC protocol (see ZK Credential: Preparation & Transformation Graphsections ).


API

Prepare ZK Credential

const zkCredential: ZKCredential = {
  isr: {
    id: { t: 1, k: "123456" }
  },
  sch: 1,
  isd: new Date().getTime(),
  exd: new Date().getTime(),
  sbj: {
    id: { k: "2345678", t: 2, },
    eth: "0x2...3",
    alias: "Test",
  }
};

const transSchema: TransCredSchema = {
  isr: {
    id: {
      t: ["uint32-bytes", "bytes-uint32", "uint32-boolean"],
      k: ["utf8-bytes"]
    },
  },
  sch: ["uint32-bytes", "bytes-base16"],
  isd: ["uint64-bytes", "bytes-base32"],
  exd: ["uint64-bytes", "bytes-utf8"],
  sbj: {
    id: {
      t: ["uint32-bytes"],
      k: ["utf8-bytes", "bytes-base16"]
    },
    alias: ["ascii-bytes", "bytes-uint128"],
    eth: ["utf8-bytes", "bytes-uint256"]
  }
};

const preparator = new Preparator();
const [
  isr_id_t, // boolean type
  isr_id_k, // Uint8Array
  sch,      // string as base16
  isd,      // string as base32
  exd,      // string as utf8
  sbj_id_t, // Uint8Array
  sbj_id_k, // string as base16
  alias,    // bigint
  eth       // bigint
] = preparator.prepare(zkCredential, transSchema);

Extend transformation graph

const preparator = new Preparator();
preparator.extendGraph([{ // extend transformation nodes
  name: "newNode",
  isType: (value: any) => value === "hello ZKCredentials"
}], [{ // extend transformation links
  inputType: "bytes",
  outputType: "bytes",
  name: "bytes.reverse",
  transform: (bytes: Uint8Array) => bytes.reverse()
}]);

Match between Transformation Graph types (nodes) and JS types

| Name | Description | JS Types | |-----------|-------------------------------------------------------------------------------------------------|---------------------------------------------------------------------| | utf8 | UTF-8 encoded string, according to https://datatracker.ietf.org/doc/html/rfc3629 | string | | base64 | Base64 encoded string, according to https://datatracker.ietf.org/doc/html/rfc3629 | string | | base32 | Base32 encoded string, according to https://datatracker.ietf.org/doc/html/rfc3629 | string | | base16 | Base16 encoded string, according to https://datatracker.ietf.org/doc/html/rfc3629 | string | | base64url | Base64url encoded string, according to https://datatracker.ietf.org/doc/html/rfc7515#appendix-C | string | | base58 | Base58 encoded string, according to https://en.bitcoin.it/wiki/Base58Check_encoding | string | | ascii | ACSII encoded string, according to https://datatracker.ietf.org/doc/html/rfc20 | string | | int16 | Integer 16 bits size | number or bigint as input type for link, only bigint as output type | | int32 | Integer 32 bits size | number or bigint as input type for link, only bigint as output type | | int64 | Integer 64 bits size | number or bigint as input type for link, only bigint as output type | | int128 | Integer 128 bits size | number or bigint as input type for link, only bigint as output type | | int256 | Integer 256 bits size | number or bigint as input type for link, only bigint as output type | | uint16 | Unsigned integer 16 bits size | number or bigint as input type for link, only bigint as output type | | uint32 | Unsigned integer 32 bits size | number or bigint as input type for link, only bigint as output type | | uint64 | Unsigned integer 64 bits size | number or bigint as input type for link, only bigint as output type | | uint128 | Unsigned integer 128 bits size | number or bigint as input type for link, only bigint as output type | | uint256 | Unsigned integer 256 bits size | number or bigint as input type for link, only bigint as output type | | uint | Unsigned integer withoout limits | number or bigint as input type for link, only bigint as output type | | float32 | Float according to IEEE 754 | number | | boolean | Boolean | boolean | | bytes | bytes array | Uint8Array |