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.
- 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.
- 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.
- 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.
import{SignProtocolClient,SpMode,EvmChains,delegateSignAttestation,delegateSignRevokeAttestation,delegateSignSchema,}from"@ethsign/sp-sdk"import{privateKeyToAccount}from"viem/accounts"constprivateKey="0xabc"// optionalconstclient=newSignProtocolClient(SpMode.OnChain,{chain: EvmChains.sepolia,account: privateKeyToAccount(privateKey),// optional})//create schemaconstcreateSchemaRes=awaitclient.createSchema({name: "xxx",data: [{name: "name",type: "string"}],})// delegation create schemaconstdelegationPrivateKey="0xaaaaa"constinfo=awaitdelegateSignSchema({name: "xxx",data: [{name: "name",type: "string"}],},{chain: EvmChains.sepolia,delegationAccount: privateKeyToAccount(delegationPrivateKey),})constdelegateCreateSchemaRes=awaitclient.createSchema(info.schema,{delegationSignature: info.delegationSignature,})// create attestationconstcreateAttestationRes=awaitclient.createAttestation({schemaId: "0x3",data: {name: "a"},indexingValue: "xxx",},{gated: true,// Enable gatedaccessControlConditions: [{contractAddress: "0xC5E9dDebb09Cd64DfaCab4011A0D5cEDaf7c9BDb",standardContractType: "ProofOfHumanity",chain: "ethereum",method: "isRegistered",parameters: [":userAddress"],returnValueTest: {comparator: "=",value: "true",},},],// specify access control conditions})//revoke attestationconstgetAttestationRes=awaitclient.getAttestation("0x3",{gated: true,})// specify gated to decrypt attestationFollow the steps below to clone the repository, set up the environment, and run the demo:
Clone the repository to your local machine using the following command:
git clone https://github.com/DaevMithran/SignxLit.git
Navigate to the Demo Directory
cd demoInstall Dependencies
npm i --save
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>
Build the Project
npm run build
Start the Demo
npm start
- Developer Feedback: A detailed feedback can be found here
- Demo Video
