mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
@@ -1,7 +1,9 @@
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve"
|
||||
import terser from "@rollup/plugin-terser"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import fs from "fs"
|
||||
import cleanup from "rollup-plugin-cleanup"
|
||||
import terser from "@rollup/plugin-terser"
|
||||
import nodePolyfills from "rollup-plugin-polyfill-node"
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
|
||||
const banner = `/**
|
||||
@@ -15,24 +17,45 @@ const banner = `/**
|
||||
|
||||
const name = pkg.name.split("/")[1].replace(/[-/]./g, (x: string) => x.toUpperCase()[1])
|
||||
|
||||
export default {
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{ file: pkg.exports["."].require, format: "cjs", banner },
|
||||
{ file: pkg.exports["."].default, format: "es", banner },
|
||||
{
|
||||
file: pkg.iife,
|
||||
name,
|
||||
format: "iife",
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: pkg.unpkg,
|
||||
name,
|
||||
format: "iife",
|
||||
plugins: [terser({ output: { preamble: banner } })]
|
||||
}
|
||||
],
|
||||
external: Object.keys(pkg.dependencies),
|
||||
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), cleanup({ comments: "jsdoc" })]
|
||||
}
|
||||
export default [
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{ file: pkg.exports["."].require, format: "cjs", banner },
|
||||
{ file: pkg.exports["."].default, format: "es", banner }
|
||||
],
|
||||
external: [
|
||||
...Object.keys(pkg.dependencies),
|
||||
"@zk-kit/utils/conversions",
|
||||
"@zk-kit/utils/f1-field",
|
||||
"@zk-kit/utils/scalar"
|
||||
],
|
||||
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), cleanup({ comments: "jsdoc" })]
|
||||
},
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
file: pkg.iife,
|
||||
name,
|
||||
format: "iife",
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: pkg.unpkg,
|
||||
name,
|
||||
format: "iife",
|
||||
plugins: [terser({ output: { preamble: banner } })]
|
||||
}
|
||||
],
|
||||
external: [],
|
||||
plugins: [
|
||||
typescript({
|
||||
tsconfig: "./build.tsconfig.json"
|
||||
}),
|
||||
nodeResolve({ preferBuiltins: false, browser: true }),
|
||||
nodePolyfills(),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { F1Field, leBigIntToBuffer, leBufferToBigInt, scalar } from "@zk-kit/utils"
|
||||
import { leBigIntToBuffer, leBufferToBigInt } from "@zk-kit/utils/conversions"
|
||||
import F1Field from "@zk-kit/utils/f1-field"
|
||||
import * as scalar from "@zk-kit/utils/scalar"
|
||||
import * as sqrt from "./sqrt"
|
||||
import { Point } from "./types"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { F1Field } from "@zk-kit/utils"
|
||||
import F1Field from "@zk-kit/utils/f1-field"
|
||||
|
||||
/**
|
||||
* The following is a sqrt function (i.e. tonelliShanks) with some pre-computed
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { BigNumber } from "@zk-kit/utils"
|
||||
import type { BigNumber } from "@zk-kit/utils"
|
||||
|
||||
export type Point<N = BigNumber> = [N, N]
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
"url": "https://github.com/privacy-scaling-explorations/zk-kit.git/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript && yarn build:iife",
|
||||
"build:iife": "rollup -c rollup.iife.config.ts --configPlugin typescript",
|
||||
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
|
||||
"prepublishOnly": "yarn build"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import commonjs from "@rollup/plugin-commonjs"
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve"
|
||||
import terser from "@rollup/plugin-terser"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import fs from "fs"
|
||||
import cleanup from "rollup-plugin-cleanup"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import nodePolyfills from "rollup-plugin-polyfill-node"
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
|
||||
const banner = `/**
|
||||
@@ -14,19 +16,53 @@ const banner = `/**
|
||||
* @see [Github]{@link ${pkg.homepage}}
|
||||
*/`
|
||||
|
||||
export default {
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{ file: pkg.exports["."].require, format: "cjs", banner },
|
||||
{ file: pkg.exports["."].default, format: "es", banner }
|
||||
],
|
||||
external: Object.keys(pkg.dependencies),
|
||||
plugins: [
|
||||
typescript({ tsconfig: "./build.tsconfig.json" }),
|
||||
commonjs(),
|
||||
nodeResolve({
|
||||
preferBuiltins: true
|
||||
}),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
}
|
||||
const name = pkg.name.split("/")[1].replace(/[-/]./g, (x: string) => x.toUpperCase()[1])
|
||||
|
||||
export default [
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{ file: pkg.exports["."].require, format: "cjs", banner },
|
||||
{ file: pkg.exports["."].default, format: "es", banner }
|
||||
],
|
||||
external: [
|
||||
...Object.keys(pkg.dependencies),
|
||||
"@zk-kit/utils/conversions",
|
||||
"@zk-kit/utils/f1-field",
|
||||
"@zk-kit/utils/scalar",
|
||||
"@zk-kit/utils/error-handlers",
|
||||
"@zk-kit/utils/type-checks"
|
||||
],
|
||||
plugins: [
|
||||
typescript({ tsconfig: "./build.tsconfig.json" }),
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
},
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
file: pkg.iife,
|
||||
name,
|
||||
format: "iife",
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: pkg.unpkg,
|
||||
name,
|
||||
format: "iife",
|
||||
plugins: [terser({ output: { preamble: banner } })]
|
||||
}
|
||||
],
|
||||
external: [],
|
||||
plugins: [
|
||||
typescript({ tsconfig: "./build.tsconfig.json" }),
|
||||
nodeResolve({ preferBuiltins: false, browser: true }),
|
||||
commonjs(),
|
||||
nodePolyfills(),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import commonjs from "@rollup/plugin-commonjs"
|
||||
import terser from "@rollup/plugin-terser"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import fs from "fs"
|
||||
import cleanup from "rollup-plugin-cleanup"
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
|
||||
const banner = `/**
|
||||
* @module ${pkg.name}
|
||||
* @version ${pkg.version}
|
||||
* @file ${pkg.description}
|
||||
* @copyright Ethereum Foundation ${new Date().getFullYear()}
|
||||
* @license ${pkg.license}
|
||||
* @see [Github]{@link ${pkg.homepage}}
|
||||
*/`
|
||||
|
||||
const name = pkg.name.split("/")[1].replace(/[-/]./g, (x: string) => x.toUpperCase()[1])
|
||||
|
||||
export default {
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
file: pkg.iife,
|
||||
name,
|
||||
format: "iife",
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: pkg.unpkg,
|
||||
name,
|
||||
format: "iife",
|
||||
plugins: [terser({ output: { preamble: banner } })]
|
||||
}
|
||||
],
|
||||
external: [],
|
||||
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), commonjs(), cleanup({ comments: "jsdoc" })]
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Point } from "@zk-kit/baby-jubjub"
|
||||
import { BigNumber } from "@zk-kit/utils"
|
||||
import type { Point } from "@zk-kit/baby-jubjub"
|
||||
import type { BigNumber } from "@zk-kit/utils"
|
||||
|
||||
export type Signature<N = BigNumber> = {
|
||||
R8: Point<N>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Point } from "@zk-kit/baby-jubjub"
|
||||
import { isBigNumberish, requireTypes, type BigNumberish } from "@zk-kit/utils"
|
||||
import type { BigNumberish } from "@zk-kit/utils"
|
||||
import { bigNumberishToBigInt, bigNumberishToBuffer, bufferToBigInt } from "@zk-kit/utils/conversions"
|
||||
import { isArray, isObject, isStringifiedBigInt } from "@zk-kit/utils/type-checks"
|
||||
import { requireTypes } from "@zk-kit/utils/error-handlers"
|
||||
import { isArray, isBigNumberish, isObject, isStringifiedBigInt } from "@zk-kit/utils/type-checks"
|
||||
import { Buffer } from "buffer"
|
||||
import { Signature } from "./types"
|
||||
import { Blake512 } from "./blake"
|
||||
import { Signature } from "./types"
|
||||
|
||||
/**
|
||||
* Prunes a buffer to meet the specific requirements for using it as a private key
|
||||
|
||||
@@ -48,16 +48,6 @@
|
||||
"types": "./dist/types/f1-field.d.ts",
|
||||
"require": "./dist/lib.commonjs/f1-field.cjs",
|
||||
"default": "./dist/lib.esm/f1-field.js"
|
||||
},
|
||||
"./crypto": {
|
||||
"types": "./dist/types/crypto.browser.d.ts",
|
||||
"node": {
|
||||
"types": "./dist/types/crypto.node.d.ts",
|
||||
"require": "./dist/lib.commonjs/crypto.node.cjs",
|
||||
"default": "./dist/lib.esm/crypto.node.js"
|
||||
},
|
||||
"browser": "./dist/lib.esm/crypto.browser.js",
|
||||
"default": "./dist/lib.esm/crypto.browser.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
@@ -72,9 +62,7 @@
|
||||
"url": "https://github.com/privacy-scaling-explorations/zk-kit.git/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && yarn build:browser && yarn build:node",
|
||||
"build:browser": "rollup -c rollup.browser.config.ts --configPlugin typescript",
|
||||
"build:node": "rollup -c rollup.node.config.ts --configPlugin typescript",
|
||||
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
|
||||
"prepublishOnly": "yarn build"
|
||||
},
|
||||
"publishConfig": {
|
||||
@@ -82,13 +70,13 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-alias": "^5.1.0",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@rollup/plugin-typescript": "^11.1.6",
|
||||
"@types/snarkjs": "^0",
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup": "^4.12.0",
|
||||
"rollup-plugin-cleanup": "^3.2.1"
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"rollup-plugin-polyfill-node": "^0.13.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"buffer": "^6.0.3"
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import terser from "@rollup/plugin-terser"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import fs from "fs"
|
||||
import cleanup from "rollup-plugin-cleanup"
|
||||
import alias from "@rollup/plugin-alias"
|
||||
import json from "@rollup/plugin-json"
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
|
||||
const banner = `/**
|
||||
* @module ${pkg.name}
|
||||
* @version ${pkg.version}
|
||||
* @file ${pkg.description}
|
||||
* @copyright Ethereum Foundation ${new Date().getFullYear()}
|
||||
* @license ${pkg.license}
|
||||
* @see [Github]{@link ${pkg.homepage}}
|
||||
*/`
|
||||
|
||||
const name = pkg.name.substr(1).replace(/[-/]./g, (x: any) => x.toUpperCase()[1])
|
||||
|
||||
export default {
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
file: pkg.iife,
|
||||
name,
|
||||
format: "iife",
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: pkg.unpkg,
|
||||
name,
|
||||
format: "iife",
|
||||
plugins: [terser({ output: { preamble: banner } })]
|
||||
},
|
||||
{
|
||||
file: pkg.exports["."].browser,
|
||||
format: "es",
|
||||
banner
|
||||
}
|
||||
],
|
||||
external: Object.keys(pkg.dependencies),
|
||||
plugins: [
|
||||
alias({
|
||||
entries: [{ find: "./crypto.node", replacement: "./crypto.browser" }]
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: "./build.tsconfig.json"
|
||||
}),
|
||||
cleanup({ comments: "jsdoc" }),
|
||||
json()
|
||||
]
|
||||
}
|
||||
101
packages/utils/rollup.config.ts
Normal file
101
packages/utils/rollup.config.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import alias from "@rollup/plugin-alias"
|
||||
import terser from "@rollup/plugin-terser"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import fs from "fs"
|
||||
import cleanup from "rollup-plugin-cleanup"
|
||||
import nodePolyfills from "rollup-plugin-polyfill-node"
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
|
||||
const banner = `/**
|
||||
* @module ${pkg.name}
|
||||
* @version ${pkg.version}
|
||||
* @file ${pkg.description}
|
||||
* @copyright Ethereum Foundation ${new Date().getFullYear()}
|
||||
* @license ${pkg.license}
|
||||
* @see [Github]{@link ${pkg.homepage}}
|
||||
*/`
|
||||
|
||||
const name = pkg.name.substr(1).replace(/[-/]./g, (x: any) => x.toUpperCase()[1])
|
||||
|
||||
export default [
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{ file: pkg.exports["."].node.require, format: "cjs", banner, exports: "auto" },
|
||||
{ file: pkg.exports["."].node.default, format: "es", banner }
|
||||
],
|
||||
external: [...Object.keys(pkg.dependencies), "crypto"],
|
||||
plugins: [
|
||||
typescript({
|
||||
tsconfig: "./build.tsconfig.json"
|
||||
}),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
},
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
file: pkg.exports["."].browser,
|
||||
format: "es",
|
||||
banner
|
||||
}
|
||||
],
|
||||
external: Object.keys(pkg.dependencies),
|
||||
plugins: [
|
||||
alias({
|
||||
entries: [{ find: "./crypto/crypto.node", replacement: "./crypto/crypto.browser" }]
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: "./build.tsconfig.json"
|
||||
}),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
},
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
file: pkg.iife,
|
||||
name,
|
||||
format: "iife",
|
||||
banner
|
||||
},
|
||||
{
|
||||
file: pkg.unpkg,
|
||||
name,
|
||||
format: "iife",
|
||||
plugins: [terser({ output: { preamble: banner } })]
|
||||
}
|
||||
],
|
||||
external: [],
|
||||
plugins: [
|
||||
alias({
|
||||
entries: [{ find: "./crypto/crypto.node", replacement: "./crypto/crypto.browser" }]
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: "./build.tsconfig.json"
|
||||
}),
|
||||
nodePolyfills(),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
},
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
dir: "./dist/lib.commonjs",
|
||||
format: "cjs",
|
||||
banner,
|
||||
preserveModules: true,
|
||||
entryFileNames: "[name].cjs"
|
||||
},
|
||||
{ dir: "./dist/lib.esm", format: "es", banner, preserveModules: true }
|
||||
],
|
||||
external: [...Object.keys(pkg.dependencies), "crypto"],
|
||||
plugins: [
|
||||
typescript({ tsconfig: "./build.tsconfig.json", declaration: false, declarationDir: undefined }),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,47 +0,0 @@
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import fs from "fs"
|
||||
import cleanup from "rollup-plugin-cleanup"
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
|
||||
const banner = `/**
|
||||
* @module ${pkg.name}
|
||||
* @version ${pkg.version}
|
||||
* @file ${pkg.description}
|
||||
* @copyright Ethereum Foundation ${new Date().getFullYear()}
|
||||
* @license ${pkg.license}
|
||||
* @see [Github]{@link ${pkg.homepage}}
|
||||
*/`
|
||||
|
||||
export default [
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{ file: pkg.exports["."].node.require, format: "cjs", banner, exports: "auto" },
|
||||
{ file: pkg.exports["."].node.default, format: "es", banner }
|
||||
],
|
||||
external: Object.keys(pkg.dependencies),
|
||||
plugins: [
|
||||
typescript({
|
||||
tsconfig: "./build.tsconfig.json"
|
||||
}),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
},
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
dir: "./dist/lib.commonjs",
|
||||
format: "cjs",
|
||||
banner,
|
||||
preserveModules: true,
|
||||
entryFileNames: "[name].cjs"
|
||||
},
|
||||
{ dir: "./dist/lib.esm", format: "es", banner, preserveModules: true }
|
||||
],
|
||||
plugins: [
|
||||
typescript({ tsconfig: "./build.tsconfig.json", declaration: false, declarationDir: undefined }),
|
||||
cleanup({ comments: "jsdoc" })
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src", "tests", "rollup.node.config.ts", "rollup.browser.config.ts"]
|
||||
"include": ["src", "tests", "rollup.config.ts"]
|
||||
}
|
||||
|
||||
@@ -3823,7 +3823,6 @@ __metadata:
|
||||
resolution: "@zk-kit/utils@workspace:packages/utils"
|
||||
dependencies:
|
||||
"@rollup/plugin-alias": "npm:^5.1.0"
|
||||
"@rollup/plugin-json": "npm:^6.1.0"
|
||||
"@rollup/plugin-terser": "npm:^0.4.4"
|
||||
"@rollup/plugin-typescript": "npm:^11.1.6"
|
||||
"@types/snarkjs": "npm:^0"
|
||||
@@ -3831,6 +3830,7 @@ __metadata:
|
||||
rimraf: "npm:^5.0.5"
|
||||
rollup: "npm:^4.12.0"
|
||||
rollup-plugin-cleanup: "npm:^3.2.1"
|
||||
rollup-plugin-polyfill-node: "npm:^0.13.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
|
||||
Reference in New Issue
Block a user