mirror of
https://github.com/0xbow-io/privacy-pools-core.git
synced 2026-01-07 00:33:51 -05:00
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)
})()
```
27 lines
740 B
JSON
27 lines
740 B
JSON
/* Based on total-typescript no-dom app config */
|
|
/* https://github.com/total-typescript/tsconfig */
|
|
{
|
|
"compilerOptions": {
|
|
/* Base Options: */
|
|
"esModuleInterop": true,
|
|
"skipLibCheck": true,
|
|
"target": "es2022",
|
|
"allowJs": true,
|
|
"resolveJsonModule": true,
|
|
"moduleDetection": "force",
|
|
"isolatedModules": true,
|
|
"verbatimModuleSyntax": false,
|
|
/* Strictness */
|
|
"strict": true,
|
|
"noUncheckedIndexedAccess": true,
|
|
"useUnknownInCatchVariables": true,
|
|
"forceConsistentCasingInFileNames": true,
|
|
"noImplicitOverride": true,
|
|
/* If transpiling with TypeScript: */
|
|
"module": "NodeNext",
|
|
"sourceMap": true,
|
|
/* If your code doesn't run in the DOM: */
|
|
"lib": ["es2022"]
|
|
}
|
|
}
|