mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
feat: add merkle-tree package
This commit is contained in:
145
packages/merkle-tree/README.md
Normal file
145
packages/merkle-tree/README.md
Normal file
@@ -0,0 +1,145 @@
|
||||
<p align="center">
|
||||
<h1 align="center">
|
||||
Merkle Tree
|
||||
</h1>
|
||||
<p align="center">Merkle tree implementation in TypeScript.</p>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/appliedzkp/zk-kit">
|
||||
<img src="https://img.shields.io/badge/project-ZK-kit-blue.svg?style=flat-square">
|
||||
</a>
|
||||
<a href="https://github.com/appliedzkp/zk-kit/blob/main/LICENSE">
|
||||
<img alt="Github license" src="https://img.shields.io/github/license/appliedzkp/zk-kit.svg?style=flat-square">
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/@zk-kit/merkle-tree">
|
||||
<img alt="NPM version" src="https://img.shields.io/npm/v/@zk-kit/merkle-tree?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://npmjs.org/package/@zk-kit/merkle-tree">
|
||||
<img alt="Downloads" src="https://img.shields.io/npm/dm/@zk-kit/merkle-tree.svg?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://bundlephobia.com/package/@zk-kit/merkle-tree">
|
||||
<img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/minzip/@zk-kit/merkle-tree" />
|
||||
</a>
|
||||
<a href="https://eslint.org/">
|
||||
<img alt="Linter eslint" src="https://img.shields.io/badge/linter-eslint-8080f2?style=flat-square&logo=eslint" />
|
||||
</a>
|
||||
<a href="https://prettier.io/">
|
||||
<img alt="Code style prettier" src="https://img.shields.io/badge/code%20style-prettier-f8bc45?style=flat-square&logo=prettier" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## 🛠 Install
|
||||
|
||||
### npm or yarn
|
||||
|
||||
Install the `@zk-kit/merkle-tree` package with npm:
|
||||
|
||||
```bash
|
||||
npm i @zk-kit/merkle-tree --save
|
||||
```
|
||||
|
||||
or yarn:
|
||||
|
||||
```bash
|
||||
yarn add @zk-kit/merkle-tree
|
||||
```
|
||||
|
||||
### CDN
|
||||
|
||||
You can also load it using a `script` tag using [unpkg](https://unpkg.com/):
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/@zk-kit/merkle-tree/"></script>
|
||||
```
|
||||
|
||||
or [JSDelivr](https://www.jsdelivr.com/):
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/@zk-kit/merkle-tree/"></script>
|
||||
```
|
||||
|
||||
## 📜 Usage
|
||||
|
||||
\# **new MerkleTree**(hash: _HashFunction_, depth: _number_, zero: _Node_): _MerkleTree_
|
||||
|
||||
```typescript
|
||||
import { MerkleTree } from "@zk-kit/merkle-tree"
|
||||
import { poseidon } from "circomlibjs" // v0.0.8
|
||||
|
||||
const tree = new MerkleTree(poseidon, 16, BigInt(0))
|
||||
|
||||
console.log(tree.root) // 19217088683336594659449020493828377907203207941212636669271704950158751593251
|
||||
```
|
||||
|
||||
\# **insert**(leaf: _Node_)
|
||||
|
||||
```typescript
|
||||
tree.insert(BigInt(1))
|
||||
|
||||
console.log(tree.root) // 16211261537006706331557500769845541584780950636316907182067421710925347020533
|
||||
```
|
||||
|
||||
\# **delete**(index: _number_)
|
||||
|
||||
```typescript
|
||||
tree.delete(0)
|
||||
|
||||
console.log(tree.root) // 19217088683336594659449020493828377907203207941212636669271704950158751593251
|
||||
```
|
||||
|
||||
\# **indexOf**(leaf: _Node_): _number_
|
||||
|
||||
```typescript
|
||||
tree.insert(BigInt(2))
|
||||
|
||||
const index = tree.indexOf(BigInt(2))
|
||||
|
||||
console.log(index) // 1
|
||||
// The first element is the previously deleted leaf = 0.
|
||||
```
|
||||
|
||||
\# **createProof**(index: _number_): _Proof_
|
||||
|
||||
```typescript
|
||||
const proof = tree.createProof(1)
|
||||
|
||||
console.log(proof)
|
||||
/*
|
||||
{
|
||||
root: 2187155820074874614256666533049960968550634565313477432886010125943412357599n,
|
||||
leaf: 2n,
|
||||
siblingNodes: [
|
||||
0n,
|
||||
14744269619966411208579211824598458697587494354926760081771325075741142829156n,
|
||||
7423237065226347324353380772367382631490014989348495481811164164159255474657n,
|
||||
11286972368698509976183087595462810875513684078608517520839298933882497716792n,
|
||||
3607627140608796879659380071776844901612302623152076817094415224584923813162n,
|
||||
19712377064642672829441595136074946683621277828620209496774504837737984048981n,
|
||||
20775607673010627194014556968476266066927294572720319469184847051418138353016n,
|
||||
3396914609616007258851405644437304192397291162432396347162513310381425243293n,
|
||||
21551820661461729022865262380882070649935529853313286572328683688269863701601n,
|
||||
6573136701248752079028194407151022595060682063033565181951145966236778420039n,
|
||||
12413880268183407374852357075976609371175688755676981206018884971008854919922n,
|
||||
14271763308400718165336499097156975241954733520325982997864342600795471836726n,
|
||||
20066985985293572387227381049700832219069292839614107140851619262827735677018n,
|
||||
9394776414966240069580838672673694685292165040808226440647796406499139370960n,
|
||||
11331146992410411304059858900317123658895005918277453009197229807340014528524n,
|
||||
15819538789928229930262697811477882737253464456578333862691129291651619515538n
|
||||
],
|
||||
path: [
|
||||
1, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0
|
||||
]
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
\# **verifyProof**(proof: _Proof_): _boolean_
|
||||
|
||||
```typescript
|
||||
console.log(tree.verifyProof(proof)) // true
|
||||
```
|
||||
7
packages/merkle-tree/build.tsconfig.json
Normal file
7
packages/merkle-tree/build.tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declarationDir": "dist/types"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
10
packages/merkle-tree/jest.config.json
Normal file
10
packages/merkle-tree/jest.config.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"displayName": "merkle-tree",
|
||||
"transform": {
|
||||
"\\.(ts|tsx)": "ts-jest"
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
|
||||
"moduleFileExtensions": ["ts", "js"],
|
||||
"coveragePathIgnorePatterns": ["/node_modules/", "/test/"],
|
||||
"collectCoverageFrom": ["src/**/*.{js,ts}"]
|
||||
}
|
||||
42
packages/merkle-tree/package.json
Normal file
42
packages/merkle-tree/package.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@zk-kit/merkle-tree",
|
||||
"version": "0.2.1",
|
||||
"description": "Merkle tree implementation in TypeScript.",
|
||||
"iife": "dist/index.js",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"jsdelivr": "dist/index.min.js",
|
||||
"main": "dist/index.node.js",
|
||||
"exports": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.node.js"
|
||||
},
|
||||
"types": "dist/types/index.d.ts",
|
||||
"files": [
|
||||
"dist/",
|
||||
"src/",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"repository": "git@github.com:appliedzkp/zk-kit.git",
|
||||
"homepage": "https://github.com/appliedzkp/zk-kit/tree/main/packages/merkle-tree",
|
||||
"author": {
|
||||
"name": "Omar Desogus",
|
||||
"email": "me@cedoor.dev",
|
||||
"url": "https://cedoor.dev"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
|
||||
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
|
||||
"prepublishOnly": "yarn build"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-node-resolve": "^13.0.6",
|
||||
"@rollup/plugin-typescript": "^8.3.0",
|
||||
"circomlibjs": "^0.0.8",
|
||||
"rollup-plugin-terser": "^7.0.2"
|
||||
}
|
||||
}
|
||||
36
packages/merkle-tree/rollup.config.ts
Normal file
36
packages/merkle-tree/rollup.config.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve"
|
||||
import typescript from "@rollup/plugin-typescript"
|
||||
import fs from "fs"
|
||||
import { terser } from "rollup-plugin-terser"
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
|
||||
const banner = `/**
|
||||
* @module ${pkg.name}
|
||||
* @version ${pkg.version}
|
||||
* @file ${pkg.description}
|
||||
* @copyright ${pkg.author.name} ${new Date().getFullYear()}
|
||||
* @license ${pkg.license}
|
||||
* @see [Github]{@link ${pkg.homepage}}
|
||||
*/`
|
||||
const name = pkg.name.substr(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 } })]
|
||||
},
|
||||
{ file: pkg.exports.require, format: "cjs", banner, exports: "auto" },
|
||||
{ file: pkg.exports.import, format: "es", banner }
|
||||
],
|
||||
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), nodeResolve()]
|
||||
}
|
||||
9
packages/merkle-tree/src/checkParameter.ts
Normal file
9
packages/merkle-tree/src/checkParameter.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default function checkParameter(value: any, name: string, ...types: string[]) {
|
||||
if (value === undefined) {
|
||||
throw new TypeError(`Parameter '${name}' is not defined`)
|
||||
}
|
||||
|
||||
if (!types.includes(typeof value)) {
|
||||
throw new TypeError(`Parameter '${name}' is none of these types: ${types.join(", ")}`)
|
||||
}
|
||||
}
|
||||
4
packages/merkle-tree/src/index.ts
Normal file
4
packages/merkle-tree/src/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import MerkleTree from "./merkle-tree"
|
||||
|
||||
export { MerkleTree }
|
||||
export * from "./types"
|
||||
221
packages/merkle-tree/src/merkle-tree.ts
Normal file
221
packages/merkle-tree/src/merkle-tree.ts
Normal file
@@ -0,0 +1,221 @@
|
||||
import checkParameter from "./checkParameter"
|
||||
import { HashFunction, Proof, Node } from "./types"
|
||||
|
||||
/**
|
||||
* A Merkle tree is a tree in which every leaf node is labelled with the cryptographic hash of a
|
||||
* data block, and every non-leaf node is labelled with the cryptographic hash of the labels of its child nodes.
|
||||
* It allows efficient and secure verification of the contents of large data structures.
|
||||
* The MerkleTree class is a TypeScript implementation of Merkle tree and it provides all the functions to create
|
||||
* efficient trees and to generate and verify proofs of membership.
|
||||
*/
|
||||
export default class MerkleTree {
|
||||
static readonly maxDepth = 32 // 2**32 = 4294967296 possible leaves.
|
||||
|
||||
private _root: Node
|
||||
private readonly _nodes: Node[][]
|
||||
private readonly _zeroes: Node[]
|
||||
private readonly _hash: HashFunction
|
||||
private readonly _depth: number
|
||||
|
||||
/**
|
||||
* Initializes the Merkle tree with the hash function, the depth and the zero value to use for zeroes.
|
||||
* @param hash Hash function.
|
||||
* @param depth Tree depth.
|
||||
* @param zeroValue Zero values for zeroes.
|
||||
*/
|
||||
constructor(hash: HashFunction, depth: number, zeroValue: Node) {
|
||||
checkParameter(hash, "hash", "function")
|
||||
checkParameter(depth, "depth", "number")
|
||||
checkParameter(zeroValue, "zeroValue", "number", "string", "bigint")
|
||||
|
||||
if (depth < 1 || depth > MerkleTree.maxDepth) {
|
||||
throw new Error("The tree depth must be between 1 and 32")
|
||||
}
|
||||
|
||||
// Initialize the attributes.
|
||||
this._hash = hash
|
||||
this._depth = depth
|
||||
this._zeroes = []
|
||||
this._nodes = []
|
||||
|
||||
for (let i = 0; i < depth; i += 1) {
|
||||
this._zeroes.push(zeroValue)
|
||||
this._nodes[i] = []
|
||||
// There must be a zero value for each tree level (except the root).
|
||||
zeroValue = hash([zeroValue, zeroValue])
|
||||
}
|
||||
|
||||
// The default root is the last zero value.
|
||||
this._root = zeroValue
|
||||
|
||||
// Freeze the array objects. It prevents unintentional changes.
|
||||
Object.freeze(this._zeroes)
|
||||
Object.freeze(this._nodes)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root hash of the tree.
|
||||
* @returns Root hash.
|
||||
*/
|
||||
public get root(): Node {
|
||||
return this._root
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the depth of the tree.
|
||||
* @returns Tree depth.
|
||||
*/
|
||||
public get depth(): number {
|
||||
return this._depth
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the leaves of the tree.
|
||||
* @returns List of leaves.
|
||||
*/
|
||||
public get leaves(): Node[] {
|
||||
return this._nodes[0].slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the zeroes nodes of the tree.
|
||||
* @returns List of zeroes.
|
||||
*/
|
||||
public get zeroes(): Node[] {
|
||||
return this._zeroes
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new leaf in the tree.
|
||||
* @param leaf New leaf.
|
||||
*/
|
||||
public insert(leaf: Node) {
|
||||
checkParameter(leaf, "leaf", "number", "string", "bigint")
|
||||
|
||||
if (leaf === this._zeroes[0]) {
|
||||
throw new Error("The leaf cannot be a zero value")
|
||||
}
|
||||
|
||||
if (this.leaves.length >= 2 ** this._depth) {
|
||||
throw new Error("The tree is full")
|
||||
}
|
||||
|
||||
let node = leaf
|
||||
|
||||
this.forEachLevel(this.leaves.length, (l, i, d) => {
|
||||
this._nodes[l][i] = node
|
||||
|
||||
if (d) {
|
||||
node = this._hash([node, this._zeroes[l]])
|
||||
} else {
|
||||
node = this._hash([this._nodes[l][i - 1], node])
|
||||
}
|
||||
})
|
||||
|
||||
this._root = node
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a leaf from the tree. It does not remove the leaf from
|
||||
* the data structure. It set the leaf to be deleted to a zero value.
|
||||
* @param index Index of the leaf to be deleted.
|
||||
*/
|
||||
public delete(index: number) {
|
||||
checkParameter(index, "index", "number")
|
||||
|
||||
if (index < 0 || index >= this.leaves.length) {
|
||||
throw new Error("The leaf does not exist in this tree")
|
||||
}
|
||||
|
||||
let node = this._zeroes[0]
|
||||
|
||||
this.forEachLevel(index, (l, i, d) => {
|
||||
this._nodes[l][i] = node
|
||||
|
||||
if (d) {
|
||||
node = this._hash([node, this._nodes[l][i + 1] || this._zeroes[l]])
|
||||
} else {
|
||||
node = this._hash([this._nodes[l][i - 1], node])
|
||||
}
|
||||
})
|
||||
|
||||
this._root = node
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a proof of membership.
|
||||
* @param index Index of the proof's leaf.
|
||||
* @returns Proof object.
|
||||
*/
|
||||
public createProof(index: number): Proof {
|
||||
checkParameter(index, "index", "number")
|
||||
|
||||
if (index < 0 || index >= this.leaves.length) {
|
||||
throw new Error("The leaf does not exist in this tree")
|
||||
}
|
||||
|
||||
const siblingNodes: Node[] = []
|
||||
const path: (0 | 1)[] = []
|
||||
|
||||
this.forEachLevel(index, (l, i, d) => {
|
||||
if (d) {
|
||||
path.push(0)
|
||||
siblingNodes.push(this._nodes[l][i + 1] || this._zeroes[l])
|
||||
} else {
|
||||
path.push(1)
|
||||
siblingNodes.push(this._nodes[l][i - 1])
|
||||
}
|
||||
})
|
||||
|
||||
return { root: this._root, leaf: this.leaves[index], siblingNodes, path }
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies a proof and return true or false.
|
||||
* @param proof Proof to be verified.
|
||||
* @returns True or false.
|
||||
*/
|
||||
public verifyProof(proof: Proof): boolean {
|
||||
checkParameter(proof, "proof", "object")
|
||||
checkParameter(proof.root, "proof.root", "number", "string", "bigint")
|
||||
checkParameter(proof.leaf, "proof.leaf", "number", "string", "bigint")
|
||||
checkParameter(proof.siblingNodes, "proof.siblingNodes", "object")
|
||||
checkParameter(proof.path, "proof.path", "object")
|
||||
|
||||
let node = proof.leaf
|
||||
|
||||
for (let i = 0; i < proof.siblingNodes.length; i += 1) {
|
||||
if (proof.path[i]) {
|
||||
node = this._hash([proof.siblingNodes[i], node])
|
||||
} else {
|
||||
node = this._hash([node, proof.siblingNodes[i]])
|
||||
}
|
||||
}
|
||||
|
||||
return proof.root === node
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of a leaf. If the leaf does not exist it returns -1.
|
||||
* @param leaf Tree leaf.
|
||||
* @returns Index of the leaf.
|
||||
*/
|
||||
public indexOf(leaf: Node): number {
|
||||
checkParameter(leaf, "leaf", "number", "string", "bigint")
|
||||
|
||||
return this.leaves.indexOf(leaf)
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a bottom-up tree traversal where for each level it calls a callback.
|
||||
* @param index Index of the leaf.
|
||||
* @param callback Callback with tree level, index of node in that level and direction (left node: true, right node: false).
|
||||
*/
|
||||
private forEachLevel(index: number, callback: (level: number, index: number, direction: boolean) => void) {
|
||||
for (let level = 0; level < this._depth; level += 1) {
|
||||
callback(level, index, index % 2 === 0)
|
||||
|
||||
index = Math.floor(index / 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
10
packages/merkle-tree/src/types/index.ts
Normal file
10
packages/merkle-tree/src/types/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export type Node = any
|
||||
|
||||
export type HashFunction = (values: Node[]) => Node
|
||||
|
||||
export type Proof = {
|
||||
root: Node
|
||||
leaf: Node
|
||||
siblingNodes: Node[]
|
||||
path: (0 | 1)[]
|
||||
}
|
||||
122
packages/merkle-tree/test/index.test.ts
Normal file
122
packages/merkle-tree/test/index.test.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
import { poseidon } from "circomlibjs"
|
||||
import { MerkleTree } from "../src"
|
||||
|
||||
describe("InterRep Merkle Tree", () => {
|
||||
const depth = 16
|
||||
|
||||
let tree: MerkleTree
|
||||
|
||||
describe("Merkle Tree class", () => {
|
||||
beforeEach(() => {
|
||||
tree = new MerkleTree(poseidon, depth, BigInt(0))
|
||||
})
|
||||
|
||||
it("Should not initialize a Merkle tree with wrong parameters", () => {
|
||||
expect(() => new MerkleTree(undefined as any, 33, 0)).toThrow("Parameter 'hash' is not defined")
|
||||
expect(() => new MerkleTree(1 as any, 33, 0)).toThrow("Parameter 'hash' is none of these types: function")
|
||||
})
|
||||
|
||||
it("Should not initialize a Merkle tree with depth > 32", () => {
|
||||
expect(() => new MerkleTree(poseidon, 33, BigInt(0))).toThrow("The tree depth must be between 1 and 32")
|
||||
})
|
||||
|
||||
it("Should initialize a Merkle tree", () => {
|
||||
expect(tree.depth).toEqual(depth)
|
||||
expect(tree.root).toEqual(
|
||||
BigInt("19217088683336594659449020493828377907203207941212636669271704950158751593251")
|
||||
)
|
||||
expect(tree.leaves).toHaveLength(0)
|
||||
expect(tree.zeroes).toHaveLength(depth)
|
||||
})
|
||||
|
||||
it("Should not insert a zero leaf", () => {
|
||||
expect(() => tree.insert(BigInt(0))).toThrow("The leaf cannot be a zero value")
|
||||
})
|
||||
|
||||
it("Should not insert a leaf in a full tree", () => {
|
||||
const fullTree = new MerkleTree(poseidon, 1, BigInt(0))
|
||||
|
||||
fullTree.insert(BigInt(1))
|
||||
fullTree.insert(BigInt(2))
|
||||
|
||||
expect(() => fullTree.insert(BigInt(3))).toThrow("The tree is full")
|
||||
})
|
||||
|
||||
it("Should insert a leaf", () => {
|
||||
tree.insert(BigInt(1))
|
||||
|
||||
expect(tree.root).toEqual(
|
||||
BigInt("16211261537006706331557500769845541584780950636316907182067421710925347020533")
|
||||
)
|
||||
expect(tree.leaves).toHaveLength(1)
|
||||
})
|
||||
|
||||
it("Should not delete a leaf that does not exist", () => {
|
||||
expect(() => tree.delete(0)).toThrow("The leaf does not exist in this tree")
|
||||
})
|
||||
|
||||
it("Should delete a leaf", () => {
|
||||
tree.insert(BigInt(1))
|
||||
|
||||
tree.delete(0)
|
||||
|
||||
expect(tree.root).toEqual(
|
||||
BigInt("19217088683336594659449020493828377907203207941212636669271704950158751593251")
|
||||
)
|
||||
expect(tree.leaves[0]).toEqual(BigInt(0))
|
||||
})
|
||||
|
||||
it("Should delete all the leaves of a tree", () => {
|
||||
tree.insert(BigInt(1))
|
||||
tree.insert(BigInt(2))
|
||||
tree.insert(BigInt(3))
|
||||
|
||||
tree.delete(0)
|
||||
tree.delete(1)
|
||||
tree.delete(2)
|
||||
|
||||
expect(tree.root).toEqual(
|
||||
BigInt("19217088683336594659449020493828377907203207941212636669271704950158751593251")
|
||||
)
|
||||
})
|
||||
|
||||
it("Should return the index of a leaf", () => {
|
||||
tree.insert(BigInt(1))
|
||||
tree.insert(BigInt(2))
|
||||
|
||||
const index = tree.indexOf(BigInt(2))
|
||||
|
||||
expect(index).toEqual(1)
|
||||
})
|
||||
|
||||
it("Should not create any proof if the leaf does not exist", () => {
|
||||
tree.insert(BigInt(1))
|
||||
|
||||
expect(() => tree.createProof(1)).toThrow("The leaf does not exist in this tree")
|
||||
})
|
||||
|
||||
it("Should create a valid proof", () => {
|
||||
tree.insert(BigInt(1))
|
||||
tree.insert(BigInt(2))
|
||||
tree.insert(BigInt(3))
|
||||
tree.insert(BigInt(4))
|
||||
tree.insert(BigInt(5))
|
||||
|
||||
tree.delete(0)
|
||||
tree.delete(2)
|
||||
|
||||
for (let i = 0; i < 5; i += 1) {
|
||||
const proof = tree.createProof(i)
|
||||
|
||||
expect(tree.verifyProof(proof)).toBeTruthy()
|
||||
}
|
||||
})
|
||||
|
||||
it("Should not verify any proof if the parameters are wrong", () => {
|
||||
expect(() => tree.verifyProof(1 as any)).toThrow("Parameter 'proof' is none of these types: object")
|
||||
expect(() => tree.verifyProof({ root: true } as any)).toThrow(
|
||||
"Parameter 'proof.root' is none of these types: number, string, bigint"
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
4
packages/merkle-tree/tsconfig.json
Normal file
4
packages/merkle-tree/tsconfig.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["src", "test", "types", "rollup.config.ts"]
|
||||
}
|
||||
895
packages/merkle-tree/types/circomlibjs/index.d.ts
vendored
Normal file
895
packages/merkle-tree/types/circomlibjs/index.d.ts
vendored
Normal file
@@ -0,0 +1,895 @@
|
||||
/** Declaration file generated by dts-gen */
|
||||
|
||||
declare module "circomlibjs" {
|
||||
export class evmasm {
|
||||
constructor(...args: any[])
|
||||
|
||||
add(...args: any[]): void
|
||||
|
||||
addmod(...args: any[]): void
|
||||
|
||||
address(...args: any[]): void
|
||||
|
||||
and(...args: any[]): void
|
||||
|
||||
balance(...args: any[]): void
|
||||
|
||||
blockhash(...args: any[]): void
|
||||
|
||||
byte(...args: any[]): void
|
||||
|
||||
call(...args: any[]): void
|
||||
|
||||
callcode(...args: any[]): void
|
||||
|
||||
calldatacopy(...args: any[]): void
|
||||
|
||||
calldataload(...args: any[]): void
|
||||
|
||||
calldatasize(...args: any[]): void
|
||||
|
||||
caller(...args: any[]): void
|
||||
|
||||
callvalue(...args: any[]): void
|
||||
|
||||
codecopy(...args: any[]): void
|
||||
|
||||
codesize(...args: any[]): void
|
||||
|
||||
coinbase(...args: any[]): void
|
||||
|
||||
create(...args: any[]): void
|
||||
|
||||
createTxData(...args: any[]): void
|
||||
|
||||
delegatecall(...args: any[]): void
|
||||
|
||||
difficulty(...args: any[]): void
|
||||
|
||||
div(...args: any[]): void
|
||||
|
||||
dup(...args: any[]): void
|
||||
|
||||
eq(...args: any[]): void
|
||||
|
||||
exp(...args: any[]): void
|
||||
|
||||
extcodecopy(...args: any[]): void
|
||||
|
||||
extcodesize(...args: any[]): void
|
||||
|
||||
gas(...args: any[]): void
|
||||
|
||||
gaslimit(...args: any[]): void
|
||||
|
||||
gasprice(...args: any[]): void
|
||||
|
||||
gt(...args: any[]): void
|
||||
|
||||
invalid(...args: any[]): void
|
||||
|
||||
iszero(...args: any[]): void
|
||||
|
||||
jmp(...args: any[]): void
|
||||
|
||||
jmpi(...args: any[]): void
|
||||
|
||||
keccak(...args: any[]): void
|
||||
|
||||
label(...args: any[]): void
|
||||
|
||||
log0(...args: any[]): void
|
||||
|
||||
log1(...args: any[]): void
|
||||
|
||||
log2(...args: any[]): void
|
||||
|
||||
log3(...args: any[]): void
|
||||
|
||||
log4(...args: any[]): void
|
||||
|
||||
lt(...args: any[]): void
|
||||
|
||||
mload(...args: any[]): void
|
||||
|
||||
mod(...args: any[]): void
|
||||
|
||||
msize(...args: any[]): void
|
||||
|
||||
mstore(...args: any[]): void
|
||||
|
||||
mstore8(...args: any[]): void
|
||||
|
||||
mul(...args: any[]): void
|
||||
|
||||
mulmod(...args: any[]): void
|
||||
|
||||
not(...args: any[]): void
|
||||
|
||||
number(...args: any[]): void
|
||||
|
||||
or(...args: any[]): void
|
||||
|
||||
origin(...args: any[]): void
|
||||
|
||||
pc(...args: any[]): void
|
||||
|
||||
pop(...args: any[]): void
|
||||
|
||||
push(...args: any[]): void
|
||||
|
||||
return(...args: any[]): void
|
||||
|
||||
returndatacopy(...args: any[]): void
|
||||
|
||||
returndatasize(...args: any[]): void
|
||||
|
||||
revert(...args: any[]): void
|
||||
|
||||
sdiv(...args: any[]): void
|
||||
|
||||
selfdestruct(...args: any[]): void
|
||||
|
||||
sgt(...args: any[]): void
|
||||
|
||||
sha3(...args: any[]): void
|
||||
|
||||
shor(...args: any[]): void
|
||||
|
||||
signextend(...args: any[]): void
|
||||
|
||||
sload(...args: any[]): void
|
||||
|
||||
slt(...args: any[]): void
|
||||
|
||||
smod(...args: any[]): void
|
||||
|
||||
sstore(...args: any[]): void
|
||||
|
||||
staticcall(...args: any[]): void
|
||||
|
||||
stop(...args: any[]): void
|
||||
|
||||
sub(...args: any[]): void
|
||||
|
||||
swap(...args: any[]): void
|
||||
|
||||
timestamp(...args: any[]): void
|
||||
}
|
||||
|
||||
export class smt_memdb {
|
||||
constructor(...args: any[])
|
||||
|
||||
get(...args: any[]): void
|
||||
|
||||
getRoot(...args: any[]): void
|
||||
|
||||
multiDel(...args: any[]): void
|
||||
|
||||
multiGet(...args: any[]): void
|
||||
|
||||
multiIns(...args: any[]): void
|
||||
|
||||
setRoot(...args: any[]): void
|
||||
}
|
||||
|
||||
export function poseidon(inputs: any): any
|
||||
|
||||
export function poseidon_slow(inputs: any): any
|
||||
|
||||
export namespace babyjub {
|
||||
const A: any
|
||||
|
||||
const Base8: any[]
|
||||
|
||||
const D: any
|
||||
|
||||
const Generator: any[]
|
||||
|
||||
const order: any
|
||||
|
||||
const p: any
|
||||
|
||||
const subOrder: any
|
||||
|
||||
function addPoint(a: any, b: any): any
|
||||
|
||||
function inCurve(P: any): any
|
||||
|
||||
function inSubgroup(P: any): any
|
||||
|
||||
function mulPointEscalar(base: any, e: any): any
|
||||
|
||||
function packPoint(P: any): any
|
||||
|
||||
function unpackPoint(_buff: any): any
|
||||
|
||||
namespace F {
|
||||
const R: any
|
||||
|
||||
const Ri: any
|
||||
|
||||
const bitLength: number
|
||||
|
||||
const half: any
|
||||
|
||||
const m: number
|
||||
|
||||
const mask: any
|
||||
|
||||
const n32: number
|
||||
|
||||
const n64: number
|
||||
|
||||
const n8: number
|
||||
|
||||
const negone: any
|
||||
|
||||
const nqr: any
|
||||
|
||||
const nqr_to_t: any
|
||||
|
||||
const one: any
|
||||
|
||||
const p: any
|
||||
|
||||
const s: number
|
||||
|
||||
const sqrt_q: any
|
||||
|
||||
const sqrt_s: number
|
||||
|
||||
const sqrt_t: any
|
||||
|
||||
const sqrt_tm1d2: any
|
||||
|
||||
const sqrt_z: any
|
||||
|
||||
const t: any
|
||||
|
||||
const two: any
|
||||
|
||||
const type: string
|
||||
|
||||
const zero: any
|
||||
|
||||
function add(...args: any[]): void
|
||||
|
||||
function band(...args: any[]): void
|
||||
|
||||
function bnot(...args: any[]): void
|
||||
|
||||
function bor(...args: any[]): void
|
||||
|
||||
function bxor(...args: any[]): void
|
||||
|
||||
function div(...args: any[]): void
|
||||
|
||||
function e(...args: any[]): void
|
||||
|
||||
function eq(...args: any[]): void
|
||||
|
||||
function exp(...args: any[]): void
|
||||
|
||||
function fromRng(...args: any[]): void
|
||||
|
||||
function fromRprBE(...args: any[]): void
|
||||
|
||||
function fromRprBEM(...args: any[]): void
|
||||
|
||||
function fromRprLE(...args: any[]): void
|
||||
|
||||
function fromRprLEM(...args: any[]): void
|
||||
|
||||
function geq(...args: any[]): void
|
||||
|
||||
function gt(...args: any[]): void
|
||||
|
||||
function idiv(...args: any[]): void
|
||||
|
||||
function inv(...args: any[]): void
|
||||
|
||||
function isZero(...args: any[]): void
|
||||
|
||||
function land(...args: any[]): void
|
||||
|
||||
function leq(...args: any[]): void
|
||||
|
||||
function lnot(...args: any[]): void
|
||||
|
||||
function lor(...args: any[]): void
|
||||
|
||||
function lt(...args: any[]): void
|
||||
|
||||
function mod(...args: any[]): void
|
||||
|
||||
function mul(...args: any[]): void
|
||||
|
||||
function mulScalar(...args: any[]): void
|
||||
|
||||
function neg(...args: any[]): void
|
||||
|
||||
function neq(...args: any[]): void
|
||||
|
||||
function normalize(...args: any[]): void
|
||||
|
||||
function pow(...args: any[]): void
|
||||
|
||||
function random(...args: any[]): void
|
||||
|
||||
function shl(...args: any[]): void
|
||||
|
||||
function shr(...args: any[]): void
|
||||
|
||||
function sqrt(a: any): any
|
||||
|
||||
function sqrt_old(...args: any[]): void
|
||||
|
||||
function square(...args: any[]): void
|
||||
|
||||
function sub(...args: any[]): void
|
||||
|
||||
function toRprBE(...args: any[]): void
|
||||
|
||||
function toRprBEM(...args: any[]): void
|
||||
|
||||
function toRprLE(...args: any[]): void
|
||||
|
||||
function toRprLEM(...args: any[]): void
|
||||
|
||||
function toString(...args: any[]): void
|
||||
}
|
||||
}
|
||||
|
||||
export namespace eddsa {
|
||||
function packSignature(sig: any): any
|
||||
|
||||
function pruneBuffer(_buff: any): any
|
||||
|
||||
function prv2pub(prv: any): any
|
||||
|
||||
function sign(prv: any, msg: any): any
|
||||
|
||||
function signMiMC(prv: any, msg: any): any
|
||||
|
||||
function signMiMCSponge(prv: any, msg: any): any
|
||||
|
||||
function signPoseidon(prv: any, msg: any): any
|
||||
|
||||
function unpackSignature(sigBuff: any): any
|
||||
|
||||
function verify(msg: any, sig: any, A: any): any
|
||||
|
||||
function verifyMiMC(msg: any, sig: any, A: any): any
|
||||
|
||||
function verifyMiMCSponge(msg: any, sig: any, A: any): any
|
||||
|
||||
function verifyPoseidon(msg: any, sig: any, A: any): any
|
||||
}
|
||||
|
||||
export namespace mimc7 {
|
||||
function getConstants(seed: any, nRounds: any): any
|
||||
|
||||
function getIV(seed: any): any
|
||||
|
||||
function hash(_x_in: any, _k: any): any
|
||||
|
||||
function multiHash(arr: any, key: any): any
|
||||
|
||||
namespace F {
|
||||
const R: any
|
||||
|
||||
const Ri: any
|
||||
|
||||
const bitLength: number
|
||||
|
||||
const half: any
|
||||
|
||||
const m: number
|
||||
|
||||
const mask: any
|
||||
|
||||
const n32: number
|
||||
|
||||
const n64: number
|
||||
|
||||
const n8: number
|
||||
|
||||
const negone: any
|
||||
|
||||
const nqr: any
|
||||
|
||||
const nqr_to_t: any
|
||||
|
||||
const one: any
|
||||
|
||||
const p: any
|
||||
|
||||
const s: number
|
||||
|
||||
const sqrt_q: any
|
||||
|
||||
const sqrt_s: number
|
||||
|
||||
const sqrt_t: any
|
||||
|
||||
const sqrt_tm1d2: any
|
||||
|
||||
const sqrt_z: any
|
||||
|
||||
const t: any
|
||||
|
||||
const two: any
|
||||
|
||||
const type: string
|
||||
|
||||
const zero: any
|
||||
|
||||
function add(...args: any[]): void
|
||||
|
||||
function band(...args: any[]): void
|
||||
|
||||
function bnot(...args: any[]): void
|
||||
|
||||
function bor(...args: any[]): void
|
||||
|
||||
function bxor(...args: any[]): void
|
||||
|
||||
function div(...args: any[]): void
|
||||
|
||||
function e(...args: any[]): void
|
||||
|
||||
function eq(...args: any[]): void
|
||||
|
||||
function exp(...args: any[]): void
|
||||
|
||||
function fromRng(...args: any[]): void
|
||||
|
||||
function fromRprBE(...args: any[]): void
|
||||
|
||||
function fromRprBEM(...args: any[]): void
|
||||
|
||||
function fromRprLE(...args: any[]): void
|
||||
|
||||
function fromRprLEM(...args: any[]): void
|
||||
|
||||
function geq(...args: any[]): void
|
||||
|
||||
function gt(...args: any[]): void
|
||||
|
||||
function idiv(...args: any[]): void
|
||||
|
||||
function inv(...args: any[]): void
|
||||
|
||||
function isZero(...args: any[]): void
|
||||
|
||||
function land(...args: any[]): void
|
||||
|
||||
function leq(...args: any[]): void
|
||||
|
||||
function lnot(...args: any[]): void
|
||||
|
||||
function lor(...args: any[]): void
|
||||
|
||||
function lt(...args: any[]): void
|
||||
|
||||
function mod(...args: any[]): void
|
||||
|
||||
function mul(...args: any[]): void
|
||||
|
||||
function mulScalar(...args: any[]): void
|
||||
|
||||
function neg(...args: any[]): void
|
||||
|
||||
function neq(...args: any[]): void
|
||||
|
||||
function normalize(...args: any[]): void
|
||||
|
||||
function pow(...args: any[]): void
|
||||
|
||||
function random(...args: any[]): void
|
||||
|
||||
function shl(...args: any[]): void
|
||||
|
||||
function shr(...args: any[]): void
|
||||
|
||||
function sqrt(a: any): any
|
||||
|
||||
function sqrt_old(...args: any[]): void
|
||||
|
||||
function square(...args: any[]): void
|
||||
|
||||
function sub(...args: any[]): void
|
||||
|
||||
function toRprBE(...args: any[]): void
|
||||
|
||||
function toRprBEM(...args: any[]): void
|
||||
|
||||
function toRprLE(...args: any[]): void
|
||||
|
||||
function toRprLEM(...args: any[]): void
|
||||
|
||||
function toString(...args: any[]): void
|
||||
}
|
||||
}
|
||||
|
||||
export namespace mimc_gencontract {
|
||||
const abi: {
|
||||
constant: boolean
|
||||
inputs: {
|
||||
name: string
|
||||
type: string
|
||||
}[]
|
||||
name: string
|
||||
outputs: {
|
||||
name: string
|
||||
type: string
|
||||
}[]
|
||||
payable: boolean
|
||||
stateMutability: string
|
||||
type: string
|
||||
}[]
|
||||
|
||||
function createCode(seed: any, n: any): any
|
||||
}
|
||||
|
||||
export namespace mimcsponge {
|
||||
function getConstants(seed: any, nRounds: any): any
|
||||
|
||||
function getIV(seed: any): any
|
||||
|
||||
function hash(_xL_in: any, _xR_in: any, _k: any): any
|
||||
|
||||
function multiHash(arr: any, key: any, numOutputs: any): any
|
||||
}
|
||||
|
||||
export namespace mimcsponge_gencontract {
|
||||
const abi: {
|
||||
constant: boolean
|
||||
inputs: {
|
||||
name: string
|
||||
type: string
|
||||
}[]
|
||||
name: string
|
||||
outputs: {
|
||||
name: string
|
||||
type: string
|
||||
}[]
|
||||
payable: boolean
|
||||
stateMutability: string
|
||||
type: string
|
||||
}[]
|
||||
|
||||
function createCode(seed: any, n: any): any
|
||||
}
|
||||
|
||||
export namespace pedersenHash {
|
||||
function getBasePoint(baseHashType: any, pointIdx: any): any
|
||||
|
||||
function hash(msg: any, options: any): any
|
||||
}
|
||||
|
||||
export namespace poseidon_gencontract {
|
||||
function createCode(nInputs: any): any
|
||||
|
||||
function generateABI(nInputs: any): any
|
||||
}
|
||||
|
||||
export namespace smt {
|
||||
class SMT {
|
||||
constructor(...args: any[])
|
||||
|
||||
delete(...args: any[]): void
|
||||
|
||||
find(...args: any[]): void
|
||||
|
||||
insert(...args: any[]): void
|
||||
|
||||
update(...args: any[]): void
|
||||
}
|
||||
|
||||
class SMTMemDB {
|
||||
constructor(...args: any[])
|
||||
|
||||
get(...args: any[]): void
|
||||
|
||||
getRoot(...args: any[]): void
|
||||
|
||||
multiDel(...args: any[]): void
|
||||
|
||||
multiGet(...args: any[]): void
|
||||
|
||||
multiIns(...args: any[]): void
|
||||
|
||||
setRoot(...args: any[]): void
|
||||
}
|
||||
|
||||
function loadFromFile(fileName: any): void
|
||||
|
||||
function newMemEmptyTrie(): any
|
||||
}
|
||||
|
||||
export namespace smt_hashes_mimc {
|
||||
function hash0(left: any, right: any): any
|
||||
|
||||
function hash1(key: any, value: any): any
|
||||
|
||||
namespace F {
|
||||
const R: any
|
||||
|
||||
const Ri: any
|
||||
|
||||
const bitLength: number
|
||||
|
||||
const half: any
|
||||
|
||||
const m: number
|
||||
|
||||
const mask: any
|
||||
|
||||
const n32: number
|
||||
|
||||
const n64: number
|
||||
|
||||
const n8: number
|
||||
|
||||
const negone: any
|
||||
|
||||
const nqr: any
|
||||
|
||||
const nqr_to_t: any
|
||||
|
||||
const one: any
|
||||
|
||||
const p: any
|
||||
|
||||
const s: number
|
||||
|
||||
const sqrt_q: any
|
||||
|
||||
const sqrt_s: number
|
||||
|
||||
const sqrt_t: any
|
||||
|
||||
const sqrt_tm1d2: any
|
||||
|
||||
const sqrt_z: any
|
||||
|
||||
const t: any
|
||||
|
||||
const two: any
|
||||
|
||||
const type: string
|
||||
|
||||
const zero: any
|
||||
|
||||
function add(...args: any[]): void
|
||||
|
||||
function band(...args: any[]): void
|
||||
|
||||
function bnot(...args: any[]): void
|
||||
|
||||
function bor(...args: any[]): void
|
||||
|
||||
function bxor(...args: any[]): void
|
||||
|
||||
function div(...args: any[]): void
|
||||
|
||||
function e(...args: any[]): void
|
||||
|
||||
function eq(...args: any[]): void
|
||||
|
||||
function exp(...args: any[]): void
|
||||
|
||||
function fromRng(...args: any[]): void
|
||||
|
||||
function fromRprBE(...args: any[]): void
|
||||
|
||||
function fromRprBEM(...args: any[]): void
|
||||
|
||||
function fromRprLE(...args: any[]): void
|
||||
|
||||
function fromRprLEM(...args: any[]): void
|
||||
|
||||
function geq(...args: any[]): void
|
||||
|
||||
function gt(...args: any[]): void
|
||||
|
||||
function idiv(...args: any[]): void
|
||||
|
||||
function inv(...args: any[]): void
|
||||
|
||||
function isZero(...args: any[]): void
|
||||
|
||||
function land(...args: any[]): void
|
||||
|
||||
function leq(...args: any[]): void
|
||||
|
||||
function lnot(...args: any[]): void
|
||||
|
||||
function lor(...args: any[]): void
|
||||
|
||||
function lt(...args: any[]): void
|
||||
|
||||
function mod(...args: any[]): void
|
||||
|
||||
function mul(...args: any[]): void
|
||||
|
||||
function mulScalar(...args: any[]): void
|
||||
|
||||
function neg(...args: any[]): void
|
||||
|
||||
function neq(...args: any[]): void
|
||||
|
||||
function normalize(...args: any[]): void
|
||||
|
||||
function pow(...args: any[]): void
|
||||
|
||||
function random(...args: any[]): void
|
||||
|
||||
function shl(...args: any[]): void
|
||||
|
||||
function shr(...args: any[]): void
|
||||
|
||||
function sqrt(a: any): any
|
||||
|
||||
function sqrt_old(...args: any[]): void
|
||||
|
||||
function square(...args: any[]): void
|
||||
|
||||
function sub(...args: any[]): void
|
||||
|
||||
function toRprBE(...args: any[]): void
|
||||
|
||||
function toRprBEM(...args: any[]): void
|
||||
|
||||
function toRprLE(...args: any[]): void
|
||||
|
||||
function toRprLEM(...args: any[]): void
|
||||
|
||||
function toString(...args: any[]): void
|
||||
}
|
||||
}
|
||||
|
||||
export namespace smt_hashes_poseidon {
|
||||
function hash0(left: any, right: any): any
|
||||
|
||||
function hash1(key: any, value: any): any
|
||||
|
||||
namespace F {
|
||||
const R: any
|
||||
|
||||
const Ri: any
|
||||
|
||||
const bitLength: number
|
||||
|
||||
const half: any
|
||||
|
||||
const m: number
|
||||
|
||||
const mask: any
|
||||
|
||||
const n32: number
|
||||
|
||||
const n64: number
|
||||
|
||||
const n8: number
|
||||
|
||||
const negone: any
|
||||
|
||||
const nqr: any
|
||||
|
||||
const nqr_to_t: any
|
||||
|
||||
const one: any
|
||||
|
||||
const p: any
|
||||
|
||||
const s: number
|
||||
|
||||
const sqrt_q: any
|
||||
|
||||
const sqrt_s: number
|
||||
|
||||
const sqrt_t: any
|
||||
|
||||
const sqrt_tm1d2: any
|
||||
|
||||
const sqrt_z: any
|
||||
|
||||
const t: any
|
||||
|
||||
const two: any
|
||||
|
||||
const type: string
|
||||
|
||||
const zero: any
|
||||
|
||||
function add(...args: any[]): void
|
||||
|
||||
function band(...args: any[]): void
|
||||
|
||||
function bnot(...args: any[]): void
|
||||
|
||||
function bor(...args: any[]): void
|
||||
|
||||
function bxor(...args: any[]): void
|
||||
|
||||
function div(...args: any[]): void
|
||||
|
||||
function e(...args: any[]): void
|
||||
|
||||
function eq(...args: any[]): void
|
||||
|
||||
function exp(...args: any[]): void
|
||||
|
||||
function fromRng(...args: any[]): void
|
||||
|
||||
function fromRprBE(...args: any[]): void
|
||||
|
||||
function fromRprBEM(...args: any[]): void
|
||||
|
||||
function fromRprLE(...args: any[]): void
|
||||
|
||||
function fromRprLEM(...args: any[]): void
|
||||
|
||||
function geq(...args: any[]): void
|
||||
|
||||
function gt(...args: any[]): void
|
||||
|
||||
function idiv(...args: any[]): void
|
||||
|
||||
function inv(...args: any[]): void
|
||||
|
||||
function isZero(...args: any[]): void
|
||||
|
||||
function land(...args: any[]): void
|
||||
|
||||
function leq(...args: any[]): void
|
||||
|
||||
function lnot(...args: any[]): void
|
||||
|
||||
function lor(...args: any[]): void
|
||||
|
||||
function lt(...args: any[]): void
|
||||
|
||||
function mod(...args: any[]): void
|
||||
|
||||
function mul(...args: any[]): void
|
||||
|
||||
function mulScalar(...args: any[]): void
|
||||
|
||||
function neg(...args: any[]): void
|
||||
|
||||
function neq(...args: any[]): void
|
||||
|
||||
function normalize(...args: any[]): void
|
||||
|
||||
function pow(...args: any[]): void
|
||||
|
||||
function random(...args: any[]): void
|
||||
|
||||
function shl(...args: any[]): void
|
||||
|
||||
function shr(...args: any[]): void
|
||||
|
||||
function sqrt(a: any): any
|
||||
|
||||
function sqrt_old(...args: any[]): void
|
||||
|
||||
function square(...args: any[]): void
|
||||
|
||||
function sub(...args: any[]): void
|
||||
|
||||
function toRprBE(...args: any[]): void
|
||||
|
||||
function toRprBEM(...args: any[]): void
|
||||
|
||||
function toRprLE(...args: any[]): void
|
||||
|
||||
function toRprLEM(...args: any[]): void
|
||||
|
||||
function toString(...args: any[]): void
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user