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

@nexeraprotocol/nexera-id-zkp-gating-contracts

v1.0.5

Published

Nexera ID ZKP Based Gating Contracts

Downloads

1

Readme

@nexeraprotocol/nexera-id-zkp-gating-contracts

@nexeraprotocol/nexera-id-zkp-gating-contracts

This repository contains smart contracts developed by Nexera ID to help our customers restrict access to their smart contracts.

There are two ways to do this:

  • Signature Based Gating: users are verified in our back-end and receive authorization signatures through our api
  • ZKP Based gating: using polygon ID, users can generate ZKPs and get verified on-chain

Signature Based Gating Contracts

From the docs:

NexeraID's signature based gating solution is based on the unified user profile that each customer has in the NexeraID Dashboard. Rather than having separate on-chain and off-chain lists, a customer is allowed (or denied) access to a smart contract based on their status in the NexeraID Dashboard.

The user authenticates with their wallet (1) and prepares an action (2). Then the front end generates a transaction and requests a signature through the NexeraID API (3). The API checks with the NexeraID user profile (4), and if the user is approved, the API signs the transaction and returns it to the front end (5). The front end constructs the final transaction and presents it to the user for their signature (6). The user publishes the transaction which is sent to the signature verifier smart contract, TxAuthDataVerifier (7). If the signature is valid, the transaction is sent to the gated smart contract.

Instructions can be found here

Contracts

Examples

./contracts/gatedExamples/ contains examples of an NFT Minter using our signature based gating contracts. /**

  • Example Gated NFT Minter NFT minting contract with gated access based on off-chain signature verification. This contract extends ERC721 for NFT functionality, TxAuthDataVerifier for signature verification, and Ownable for ownership management.

  • Example Gated NFT Minter (Upgradeable) Upgradeable NFT minting contract with gated access based on off-chain signature verification. This contract extends ERC721Upgradeable for NFT functionality, TxAuthDataVerifierUpgradeable for signature verification, and OwnableUpgradeable for ownership management.

  • Example Multiple Inputs Contract This contract demonstrates a contract inheriting from TxAuthDataVerifier to update variables with signature verification. This contract tests more complex inputs such as bytes inputs or no inputs

  • Non Gated Example NFT Minter for comparaison

Verifiers

./contracts/sigVerifiers/ contains the smart contracts used to verify signatures

  • Base Transaction Authentication Data Verifier Provides mechanisms for verifying transaction authentication data, including signature verification and nonce management. This contract is designed to be extended by other contracts requiring transaction authentication based on digital signatures. It includes functionality for:

  • Verifying transaction signatures against a specified signer address.

  • Ensuring transactions have not expired based on their block expiration.

  • Incrementing nonces to prevent replay attacks.

  • The contract utilizes OZ SignatureChecker for signature verification (compatible with both EOA and smart contract signers).

  • Transaction Authentication Data Verifier Contract for verifying transaction authentication data, including signature verification and nonce management. It extends BaseTxAuthDataVerifier to provide core functionality for transaction data verification and inherits Context for access control utilities.

  • Transaction Authentication Data Verifier (Upgradeable) Upgradeable contract for verifying transaction authentication data, including signature verification and nonce management. It extends BaseTxAuthDataVerifier to provide core functionality for transaction data verification. It is intended to be deployed behind a proxy for upgradeability.

Signer Manager

./contracts/signerManager/NexeraIDSignerManager.sol is a smart contract that we use to manage the signer address used in our API.

That way, if this address is compromised, we can change it without every customer having to call _setSigner.

Sig Gating Tests

./test/SIgGatingTests/ features tests for signature gating using our examples.

ZKP Based Gating Contracts

More about this here.

Relevant files: ./contracts/validators/ ZKP Validators ./contracts/zkpVerifiers/ ZKP Verifiers ./contracts/gatedExamples/ Examples

ScenarioVerifier Contract

The ScenarioVerifier contract implements a whitelist for N Rules. In order to get in the whitelist, a user has to submit a ZKProof for each rule and then call the whitelistScenario function to finalize whitelisting.

The deployment of the contract subsequently calls setRequest with the right parameters to set up the conditions to be met by the ZKProof for each Rule. A different Rule ID (request id) has to be specified for each setRequest call.

A lib function helps setup the contract and submit proof for different credential types.

NexeraVerifierEntrypoint

This contract manages the registration, update, and verification of Scenario Verifiers for a single project

ProxyAavePool

ProxyAavePool has the same interface as Aave Pool contract (includes supply call), but supply throws error if user is not whitelisted. This contract needs INexeraVerifierEntrypoint address in the constructor.

ZKP Gating Tests

./test/ZKPGatingTests/