Files
privacy-pools-core/packages/sdk/package.json
bezze 7e2881573b feat: adding rollup bundler and a minimal groth16 prover interface (#32)
Because the SDK is meant to run both in web and nodejs I focused
bundling for those two targets. I chose Rollup.js as a bundler because
it is commonly used for bundling libraries and achives a decent tradeoff
between speed and flexibility.

The nodejs bundle will have the artifacts embedded in the package, while
the web bundle will need to have the artifacts being hosted at
/artifacts/{artifact_name}. The API for the circuits has an async
initializer that abstracts away the platform and loads the binaries.
Once initialized, the `circuits` object is used to initialize the
`ZkOps` class that uses the loaded binaries under the hood.

Observation: ~~currently, to build the bundle, the scripts assume you
have all the circuits artifacts at `src/circuits/artifacts`. The PR was
getting too big so I'll relax that assumption later.~~
EDIT: Build will now succeed without the artifacts because building them
in the ci/cd was way out of scope. I provided a script to install the
artifacts to the bundle build for local testing.

Usage example:

```typescript
import { ZkOps, circuits } from "@privacy-pool-core/sdk";

; (async () => {

    await circuits.downloadArtifacts("latest");
    const zkOps = new ZkOps(circuits);
    const input = {
        value: "1",
        label: BigInt("0"),
        nullifier: BigInt("123"),
        secret: BigInt("456"),
    };

    let r = await zkOps.proveCommitment(input);
    console.log(r)

})()
```
2025-01-23 08:14:21 +00:00

90 lines
2.8 KiB
JSON

{
"name": "@privacy-pool-core/sdk",
"version": "0.1.0",
"private": true,
"description": "Typescript SDK for the Privacy Pool protocol",
"repository": "https://github.com/defi-wonderland/privacy-pool-core",
"license": "MIT",
"author": "Wonderland",
"type": "module",
"main": "./dist/node/index.mjs",
"module": "./dist/esm/index.mjs",
"browser": "./dist/esm/index.mjs",
"types": {
"import": "./dist/index.d.mts"
},
"exports": {
"node": {
"types": "./dist/index.d.mts",
"default": "./dist/node/index.mjs"
},
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"browser": {
"types": "./dist/index.d.mts",
"default": "./dist/esm/index.mjs"
}
},
"directories": {
"src": "src"
},
"files": [
"dist/*",
"src",
"package.json",
"!**/*.tsbuildinfo"
],
"scripts": {
"circuits:setup": "cd ../circuits/ && yarn install && yarn compile && yarn setup:all",
"circuits:copy": "sh ./scripts/copy_circuits.sh",
"build": "yarn clean && rollup -c ./configs/rollup.config.mjs",
"build:bundle": "yarn clean && rollup -c ./configs/rollup.config.mjs && yarn circuits:setup && yarn circuits:copy",
"check-types": "tsc --noEmit -p ./tsconfig.json",
"clean": "rm -rf dist .rollup.cache tsconfig.build.tsbuildinfo",
"format": "prettier --check \"{src,test}/**/*.{js,ts,json}\"",
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\"",
"lint": "eslint \"{src,test}/**/*.{js,ts,json}\"",
"lint:fix": "eslint --fix",
"test": "vitest run --config vitest.config.ts --passWithNoTests",
"test:cov": "vitest run --config vitest.config.ts --coverage"
},
"dependencies": {
"viem": "2.21.4"
},
"devDependencies": {
"@commitlint/config-conventional": "19.4.1",
"@eslint/js": "9.18.0",
"@ianvs/prettier-plugin-sort-imports": "4.3.1",
"@rollup/plugin-alias": "5.1.1",
"@rollup/plugin-commonjs": "28.0.2",
"@rollup/plugin-inject": "5.0.5",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-node-resolve": "16.0.0",
"@rollup/plugin-typescript": "12.1.2",
"@rollup/plugin-wasm": "6.2.2",
"@types/node": "20.3.1",
"@types/snarkjs": "0.7.9",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"@vitest/coverage-v8": "2.0.5",
"commitlint": "19.4.1",
"eslint": "9.18.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.14.0",
"husky": "9.1.5",
"lint-staged": "15.2.10",
"memfs": "4.17.0",
"prettier": "3.3.3",
"rollup": "4.30.1",
"rollup-plugin-dts": "6.1.1",
"snarkjs": "0.7.5",
"sort-package-json": "2.10.1",
"typescript": "5.5.4",
"typescript-eslint": "8.20.0",
"vitest": "2.0.5"
}
}