1.0.0 • Published 9 months ago

@sybil-center/passport v1.0.0

Weekly downloads
-
License
(Apache-2.0 AND M...
Repository
github
Last release
9 months ago

Sybil Passport

The library will help you create a zk-program for user passport authentication based on the zCred protocol

Create JAL program

A JAL program is a JSON zk-program description that contains public and private inputs and a list of constraints that the Passport credential must satisfy.

import { getPassportSandbox } from "@sybil-center/passport";
import { assert, not, toJAL } from "@jaljs/js-zcred";

const {
  issuerURI, // issuer URI to get ZK Passpor
  inputSchema: {
    credential,
    context
  },
  olderThanYears,
  youngerThanYears,
  genderIs,
  fromCountry,
  passportNotExpired,
} = getPassportSandbox({
  subjectKeyType: "ethereum:address",
  zkProofSystem: "o1js",
  // isDev: true //for Dev purpuse
});
const attributes = credential.attributes;
const jalProgram = toJAL({
  target: "o1js:zk-program.cjs",
  credential: credential,
  publicInput: [
    attributes.subject.id.type,
    attributes.subject.id.key,
    attributes.document.sybilId,
    context.now
  ],
  commands: [
    assert(olderThanYears(18)),
    assert(youngerThanYears(45)),
    assert(genderIs("male")),
    assert(not(fromCountry("USA"))),
    assert(passportNotExpired())
  ],
  options: {
    signAlgorithm: "mina:pasta",
    hashAlgorithm: "mina:poseidon"
  }
});

How to use

Demo application example

1.0.0

9 months ago

0.0.2

12 months ago

0.0.1

1 year ago