1.2.0 • Published 1 year ago

semaphore-webauthn v1.2.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

semaphore-webauthn

Example usage:

import { WebAuthnIdentity } from "semaphore-webauthn";

// STEP 1: Configure WebAuthn options
const options = {
  rpName: "my-app",
  rpID: window.location.hostname,
  userID: "my-id",
  userName: "my-name",
};

// STEP 2: Register a new WebAuthn credential and get its Semaphore identity
const newWebAuthnIdentity = await WebAuthnIdentity.fromRegister(options);

// Now we can save this commitment in our DB (pseudocode)
const { commitment } = newWebAuthnIdentity.getIdentity();
fetch("/api/register" /* Replace this with your endpoint */, {
  commmitment,
  // ...
});

// STEP 3: Authenticate existing WebAuthn credential and signal
const existingWebAuthnIdentity = await WebAuthnIdentity.fromRegister(options);
// Get existing group and anonymously signal (pseudocode)
import { Group } from "@semaphore-protocol/group";
import { generateProof } from "@semaphore-protocol/proof";

const group = new Group(groupId, groupSize);
group.addMembers(memberList);

generateProof(
  existingWebAuthnIdentity.getIdentity(),
  group,
  groupId,
  "this is a signal",
  {
    zkeyFilePath: "./semaphore.zkey",
    wasmFilePath: "./semaphore.wasm",
  }
);
1.2.0

1 year ago

1.1.0

1 year ago

0.0.0

1 year ago

0.1.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

1.0.0

1 year ago