Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import of poseidon-lite dependency #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
550 changes: 550 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

Large diffs are not rendered by default.

786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .yarn/releases/yarn-3.2.1.cjs.REMOVED.git-id

This file was deleted.

8 changes: 4 additions & 4 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ checksumBehavior: update
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.2.1.cjs
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Semaphore v3.15.2 Fork

This is a very tiny fork of `@semaphore-protocol/proof` version v3.15.2 to patch the inclusion of `poseidon-lite`, so that:
a) the package is listed as a dependency rather than devDependency, allowing bundlers to handle it correctly
b) only the necessary `poseidon2` constants are imported, rather than the full set of constants (many of which are very large)

The net effect is to reduce the output bundle for `@semaphore-protocol/proof` from >600KiB to ~45KiB, with no change in functionality.

This branch also includes the re-addition of Yarn 3.2.1, which is required in order to build the 3.15.2 branch, but which was deleted from the git history in the original Semaphore repo.

To build, run `yarn build:libraries`.
To publish the patched package, run `./publish-patched-proof-package.sh`.

---

<p align="center">
<h1 align="center">
<picture>
Expand Down
53 changes: 53 additions & 0 deletions packages/proof/package-patched.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@pcd/semaphore-proof-v3",
"version": "3.15.2",
"description": "A library to generate and verify Semaphore proofs.",
"license": "MIT",
"main": "dist/index.node.js",
"exports": {
"import": "./dist/index.node.mjs",
"require": "./dist/index.node.js",
"types": "./dist/types/index.d.ts"
},
"types": "dist/types/index.d.ts",
"files": [
"dist/",
"src/",
"LICENSE",
"README.md"
],
"repository": "https://github.com/semaphore-protocol/semaphore",
"homepage": "https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof",
"bugs": {
"url": "https://github.com/semaphore-protocol/semaphore.git/issues"
},
"scripts": {
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^15.0.2",
"rimraf": "^5.0.5",
"rollup": "^4.0.2",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-typescript2": "^0.31.2"
},
"peerDependencies": {
"@semaphore-protocol/group": "3.15.2",
"@semaphore-protocol/identity": "3.15.2"
},
"dependencies": {
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/keccak256": "^5.7.0",
"@ethersproject/strings": "^5.5.0",
"@zk-kit/groth16": "0.3.0",
"@zk-kit/incremental-merkle-tree": "0.4.3",
"poseidon-lite": "^0.2.0"
}
}
4 changes: 2 additions & 2 deletions packages/proof/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^15.0.2",
"poseidon-lite": "^0.2.0",
"rimraf": "^5.0.5",
"rollup": "^4.0.2",
"rollup-plugin-cleanup": "^3.2.1",
Expand All @@ -49,6 +48,7 @@
"@ethersproject/keccak256": "^5.7.0",
"@ethersproject/strings": "^5.5.0",
"@zk-kit/groth16": "0.3.0",
"@zk-kit/incremental-merkle-tree": "0.4.3"
"@zk-kit/incremental-merkle-tree": "0.4.3",
"poseidon-lite": "^0.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/proof/src/calculateNullifierHash.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BytesLike, Hexable } from "@ethersproject/bytes"
import { poseidon2 } from "poseidon-lite"
import { poseidon2 } from "poseidon-lite/poseidon2"
import hash from "./hash"

/**
Expand Down
12 changes: 12 additions & 0 deletions publish-patched-proof-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

npm login

BASEDIR=$(dirname "$0")
cd $BASEDIR/packages/proof
cp package.json package-backup.json
rm package.json
cp package-patched.json package.json
npm publish
rm package.json
mv package-backup.json package.json
Loading