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

@daevm/ethsign-sp-sdk

v0.8.9

Published

### Demo

Downloads

314

Readme

Sign x Lit

Demo

alt text

Approach: Integrating Lit Protocol with Sign Protocol's SDK

This section outlines the steps and approach I followed to integrate the Lit Protocol with the Sign Protocol SDK for gated access and encrypted attestations. The focus was on ensuring compatibility while enhancing functionality with Lit's encryption capabilities.

Key Steps in the Integration

  • Migration to TSC Builder
  • Replaced the Rollups builder in the sp-sdk with the native TypeScript (TSC) builder.
  • This change resolved compatibility issues between the sp-sdk and Lit Protocol SDK.
  • The migration ensures smoother builds and aligns with the evolving requirements of the SDK ecosystem.

Support for Gated Access

  • Added additional arguments in options like gated, accessControlConditions in create, get and revoke attestations
  • Currently, this feature is limited to on-chain attestations only, with plans for broader support in future iterations.

Handling Encrypted Attestations

  • When an attestation is marked as encrypted the base64 encrypted string and data hash are securely stored on-chain.
  • These encrypted values can only be decrypted using the access conditions specified at the time of creation.
  • The integration with Lit Protocol ensures robust encryption and access control, leveraging its advanced encryption capabilities.

On chain gated attestations

import {
  SignProtocolClient,
  SpMode,
  EvmChains,
  delegateSignAttestation,
  delegateSignRevokeAttestation,
  delegateSignSchema,
} from "@ethsign/sp-sdk"
import { privateKeyToAccount } from "viem/accounts"
const privateKey = "0xabc" // optional

const client = new SignProtocolClient(SpMode.OnChain, {
  chain: EvmChains.sepolia,
  account: privateKeyToAccount(privateKey), // optional
})

//create schema
const createSchemaRes = await client.createSchema({
  name: "xxx",
  data: [{ name: "name", type: "string" }],
})

// delegation create schema
const delegationPrivateKey = "0xaaaaa"
const info = await delegateSignSchema(
  {
    name: "xxx",
    data: [{ name: "name", type: "string" }],
  },
  {
    chain: EvmChains.sepolia,
    delegationAccount: privateKeyToAccount(delegationPrivateKey),
  }
)
const delegateCreateSchemaRes = await client.createSchema(info.schema, {
  delegationSignature: info.delegationSignature,
})

// create attestation
const createAttestationRes = await client.createAttestation(
  {
    schemaId: "0x3",
    data: { name: "a" },
    indexingValue: "xxx",
  },
  {
    gated: true, // Enable gated
    accessControlConditions: [
      {
        contractAddress: "0xC5E9dDebb09Cd64DfaCab4011A0D5cEDaf7c9BDb",
        standardContractType: "ProofOfHumanity",
        chain: "ethereum",
        method: "isRegistered",
        parameters: [":userAddress"],
        returnValueTest: {
          comparator: "=",
          value: "true",
        },
      },
    ], // specify access control conditions
  }
)

//revoke attestation
const getAttestationRes = await client.getAttestation("0x3", {
  gated: true,
}) // specify gated to decrypt attestation

Instructions

Follow the steps below to clone the repository, set up the environment, and run the demo:

Clone the Repository

  1. Clone the repository to your local machine using the following command:

    git clone https://github.com/DaevMithran/SignxLit.git
  2. Navigate to the Demo Directory

    cd demo
  3. Install Dependencies

    npm i --save
  4. Add a Private Key

  • Create a .env file in the demo directory.

  • Add a 32-seed private key in the .env file as follows:

    PRIVATE_KEY=<your-32-seed-private-key>
  1. Build the Project

    npm run build
  2. Start the Demo

    npm start

Links