Lemma Overview

Lemma is a mathematically guaranteed truth layer that lets AI reason over verified data without exposing the underlying sensitive content. It acts as a high‑trust storage and reference layer for mission‑critical data rather than a universal wrapper for all AI interactions.

AI agents access Lemma via MCP as a reliable data source for use cases like safety‑critical workflows, fair rights management, and accurate responses based on cryptographically verified facts.

Key Features and Benefits

Technical Foundations

Spec summary


Use-Cases

DeFi Private Lending & Under-Collateralized Loans

DeFi Compliance — Privacy-Preserving KYC/AML

RWA — Tokenization of Real-World Assets

Autonomous AI Agent Settlement & Personal Data

KYC, Identity & Credential Attestation

Sensitive Data Screening — Payroll, Health & Loans

Protecting Originality & Compensating Data Creators

Verified Information for AI / RAG

Attribute-Based Access Control


Minimal developer workflow (simplified)

1. Install and initialize

npm install @lemmaoracle/sdk
import { create } from "@lemmaoracle/sdk";

const client = create({
  apiBase: "https://api.lemma.example.com",
  apiKey: process.env.LEMMA_API_KEY!,
});

2. Define schema and normalization

import { define } from "@lemmaoracle/sdk";

type UserKycRaw = { age: number; country: string };
type UserKycNorm = { age_bucket: "adult" | "minor"; country: string };

const userKycSchema = define<UserKycRaw, UserKycNorm>({
  id: "user-kyc-v1",
  normalize: (raw) => ({
    age_bucket: raw.age >= 18 ? "adult" : "minor",
    country: raw.country,
  }),
});

3. Encrypt and prepare

import { encrypt, prepare } from "@lemmaoracle/sdk";

const rawDoc: UserKycRaw = { age: 25, country: "JP" };
const holderPubKey = "...";

const enc = await encrypt(client, {
  payload: rawDoc,
  holderKey: holderPubKey,
});
// enc.docHash, enc.cid, enc.encryptedDocBase64, enc.algorithm

const prep = await prepare<UserKycRaw, UserKycNorm>(client, {
  schema: userKycSchema.id,
  payload: rawDoc,
});
// prep.normalized, prep.commitments (includes scheme, commitmentRoot, perAttributeCommitments, randomness)

One line explanation: encrypt returns docHash/cid, and prepare returns normalized attributes plus commitments.

4. Sign and create selective disclosure

import { disclose } from "@lemmaoracle/sdk";

const issuerPrivateKey = "...";

const signed = await disclose.sign(client, {
  payload: rawDoc,
  issuerKey: issuerPrivateKey,
});
// signed.signature

const sd = await disclose.reveal(client, {
  signedPayload: signed.signature,
  attributes: ["age"],
});
// sd.disclosed, sd.proof

5. Register document (options trimmed)

import { documents } from "@lemmaoracle/sdk";

await documents.register(client, {
  schema: userKycSchema.id,
  docHash: enc.docHash,
  cid: enc.cid,
  commitments: {
    scheme: "poseidon",
    commitmentRoot: prep.commitments.commitmentRoot,
    perAttributeCommitments: prep.commitments.perAttributeCommitments,
  },
  signature: {
    format: "bbs+",
    payload: signed.signature,
    issuerId: "issuer-1",
  },
});

Non-essential options such as detailed revocation settings and onchainHooks are omitted here.

6. Generate and submit proof (options trimmed)

import { prover, proofs } from "@lemmaoracle/sdk";

const zkResult = await prover.prove(client, {
  circuitId: "age-over-18",
  witness: {
    age_bucket: prep.normalized.age_bucket,
    randomness: prep.commitments.randomness,
    attr_commitment_root: prep.commitments.commitmentRoot,
  },
});
// zkResult.proofBytes, zkResult.publicInputs
await proofs.submit(client, {
  docHash: enc.docHash,
  circuitId: "age-over-18",
  proofBytes: zkResult.proofBytes,
  inputs: zkResult.inputs,
  selectiveDisclosure: {
    format: "bbs+",
    disclosedAttributes: sd.disclosed,
    proof: sd.proof,
  },
});

Here we keep only the core fields needed to attach the proof and link it to the document.

7. Query verified attributes

import { attributes } from "@lemmaoracle/sdk";

const results = await attributes.query(client, {
  query: "users over 18 in Japan",
  mode: "natural",
  proof: { required: true, type: "zk-snark" },
  targets: { schemas: ["user-kyc-v1"] },
});

This returns verified attributes plus proof status that your app or AI agent can consume.