Commit 5ce6ae55 authored by Johnny's avatar Johnny
Browse files

initial commit

parents
Pipeline #43 canceled with stages
# Trees
UTXO_DEPTH=4
TX_DEPTH=4
STATE_DEPTH=9
# State Contract
STATE_CONTRACT_ADDRESS=0xEB615B6fB028519F9683087EAE95841482235F17
STATE_CONTRACT_ABI=./contracts/state.json
# Transaction Verifier
TX_CIRCUIT=./circuits/tx.json
TX_VK=./keys/tx_vk.json
TX_VK_HASH=0x29e4dd1bf210bfd15c9b1997a6339d61aa9612812cde9cf47ed0c2234512e613
# Recursion Verifier
REC_VERIFIER_ADDRESS=0xb7a2e5FcC324b669A57E7a920FAa8a5dAf5D638F
REC_VERIFIER_ABI=./contracts/ultraverifier.json
REC_CIRCUIT=./circuits/recursion.json
# Private key used for publishing
RPC_URL=
PRIVATE_KEY=
TIMEOUT=300000 # publish every 5 minutes if there's a tx
FROM node
RUN mkdir app
COPY . /app/
# Install npm production packages
WORKDIR /app
RUN npm install
CMD ["npm", "run", "start"]
\ No newline at end of file
# momiji-node
This node listens for Momiji transaction events sent to the state contract, rolls them up into a batch, and publishes the batch to the chain
Install package dependencies using
```
npm install momiji-node
```
Enter into the directory where it was installed.
Copy the .env.example file to .env
```
cp .env.example .env
```
Fill .env `RPC_URL` with a Sepolia RPC provider of choice. Make sure you have a STABLE provider with a HIGH quota that supports `eth_getLogs`. There is a *lot* of calldata to process.
Fill .env `PRIVATE_KEY` with a Sepolia wallet private key (0x...). This will be used to publish rollup transactions to chain.
To run the node
```
npm run start
```
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
[
{
"inputs": [
{
"internalType": "contract IVerifier",
"name": "_verifier",
"type": "address"
},
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "bytes32",
"name": "_keyHash",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "_oldRoot",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "_newRoot",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "_oracle",
"type": "bytes32"
}
],
"name": "BatchPublish",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes32[]",
"name": "_tx",
"type": "bytes32[]"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "_merkleRoot",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "_txId",
"type": "bytes32"
}
],
"name": "TransactionSent",
"type": "event"
},
{
"inputs": [],
"name": "MAX_FIELD_SIZE",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MAX_ITEMS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ZERO_VALUE",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "batch",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "batchNumber",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "batchTxIds",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "commitmentQueueHash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "commitments",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_preimage",
"type": "bytes"
},
{
"internalType": "bytes32[]",
"name": "_queuedCommitments",
"type": "bytes32[]"
}
],
"name": "dropQueue",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_proof",
"type": "bytes"
},
{
"internalType": "bytes32[]",
"name": "_tx",
"type": "bytes32[]"
}
],
"name": "eject",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "endBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32[]",
"name": "_tx",
"type": "bytes32[]"
}
],
"name": "enqueue",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_commitment",
"type": "bytes32"
}
],
"name": "getCommitment",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentBatch",
"outputs": [
{
"internalType": "bytes32[]",
"name": "",
"type": "bytes32[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_utxo",
"type": "bytes32"
}
],
"name": "getRootFromUtxo",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32[]",
"name": "_nullifierHashes",
"type": "bytes32[]"
}
],
"name": "getSpentNullifiers",
"outputs": [
{
"internalType": "bool[]",
"name": "spent",
"type": "bool[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_merkleRoot",
"type": "bytes32"
}
],
"name": "getTxIds",
"outputs": [
{
"internalType": "bytes32[]",
"name": "",
"type": "bytes32[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_root",
"type": "bytes32"
}
],
"name": "getUtxoFromRoot",
"outputs": [
{
"internalType": "bytes32[][]",
"name": "",
"type": "bytes32[][]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getValidRoots",
"outputs": [
{
"internalType": "bytes32[]",
"name": "",
"type": "bytes32[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_start",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_end",
"type": "uint256"
}
],
"name": "getValidRootsPaginated",
"outputs": [
{
"internalType": "bytes32[]",
"name": "",
"type": "bytes32[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32[]",
"name": "_inputs",
"type": "bytes32[]"
}
],
"name": "hash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32[]",
"name": "_tx",
"type": "bytes32[]"
}
],
"name": "hashPublicInputsForTx",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "_nullifierHash",
"type": "bytes32"
}
],
"name": "isSpent",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "keyHash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "merkleRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "nullifierHashes",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32[]",
"name": "input",
"type": "bytes32[]"
}
],
"name": "prepareBatchPublicInputs",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_proof",
"type": "bytes"
},
{
"internalType": "bytes32[]",
"name": "_aggregationObject",
"type": "bytes32[]"
},
{
"internalType": "bytes32[]",
"name": "_batch",
"type": "bytes32[]"
}
],
"name": "publish",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "startBlock",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "token",
"outputs": [
{
"internalType": "contract IElasticERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "txQueueHash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "utxo",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "utxoPrevRoots",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "validRoots",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "verifier",
"outputs": [
{
"internalType": "contract IVerifier",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_proof",
"type": "bytes"
},
{
"internalType": "bytes32[]",
"name": "_publicInputs",
"type": "bytes32[]"
}
],
"name": "verifyProof",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]
\ No newline at end of file
[
{
"inputs": [],
"name": "EC_SCALAR_MUL_FAILURE",
"type": "error"
},
{
"inputs": [],
"name": "MOD_EXP_FAILURE",
"type": "error"
},
{
"inputs": [],
"name": "PROOF_FAILURE",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "expected",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "actual",
"type": "uint256"
}
],
"name": "PUBLIC_INPUT_COUNT_INVALID",
"type": "error"
},
{
"inputs": [],
"name": "PUBLIC_INPUT_GE_P",
"type": "error"
},
{
"inputs": [],
"name": "PUBLIC_INPUT_INVALID_BN128_G1_POINT",
"type": "error"
},
{
"inputs": [],
"name": "getVerificationKeyHash",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "_proof",
"type": "bytes"
},
{
"internalType": "bytes32[]",
"name": "_publicInputs",
"type": "bytes32[]"
}
],
"name": "verify",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]
\ No newline at end of file
File added
~#쓈YD;2Nո7N0Qz5NX&QDžJ^U?΢VG[Ba^"c*A<j_FAQVrci
\ No newline at end of file
524289
\ No newline at end of file
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const momiji_1 = require("./modules/momiji");
const interfaces_1 = require("./lib/utils/interfaces");
const fs = __importStar(require("fs"));
require("dotenv/config");
require('dotenv').config({ path: "../.env" }); // TODO: Make sure this path is correct
// If process.env.RPC_URL is not set, use localhost
if (!process.env.RPC_URL) {
process.env.RPC_URL = "http://127.0.0.1:8545";
}
const main = async () => {
let publisher = new momiji_1.Publisher({
tree: {
utxoDepth: Number(process.env.UTXO_DEPTH),
txDepth: Number(process.env.TX_DEPTH),
stateDepth: Number(process.env.STATE_DEPTH),
treeSum: 0
},
stateContract: {
address: process.env.STATE_CONTRACT_ADDRESS,
abi: JSON.parse(fs.readFileSync(process.env.STATE_CONTRACT_ABI, 'utf8'))
},
recursionVerifier: {
address: process.env.REC_VERIFIER_ADDRESS,
abi: JSON.parse(fs.readFileSync(process.env.REC_VERIFIER_ABI, 'utf8'))
},
transactionCircuit: JSON.parse(fs.readFileSync(process.env.TX_CIRCUIT, 'utf8')),
recursionCircuit: JSON.parse(fs.readFileSync(process.env.REC_CIRCUIT, 'utf8')),
transactionVk: JSON.parse(fs.readFileSync(process.env.TX_VK, 'utf8')).vkAsFields,
transactionVkHash: JSON.parse(fs.readFileSync(process.env.TX_VK, 'utf8')).vkHash,
provider: process.env.RPC_URL,
PRIVATE_KEY: undefined
}, new interfaces_1.Wallet(process.env.PRIVATE_KEY, new interfaces_1.JsonRpcProvider(process.env.RPC_URL)));
await publisher.initialize();
};
console.log(`💫 Starting publisher...`);
main();
{
"vkAsFields": [
"0x1bf82deba7d74902c3708cc6e70e61f30512eca95655210e276e5858ce8f58e5",
"0x0000000000000000000000000000000000000000000000000000000000020000",
"0x0000000000000000000000000000000000000000000000000000000000000005",
"0x0000000000000000000000000000000000000000000000000000000000020000",
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000009537c571378a7a41c8082453de06d76481",
"0x000000000000000000000000000000000020af8849b8e51ce19a21b3ba0d8eec",
"0x000000000000000000000000000000f7d3608b6a7a9cc93125c2cd07b5ace6e7",
"0x00000000000000000000000000000000000154afe8b5497dd591f1fcd28cb59f",
"0x00000000000000000000000000000087efd7a9736e7bbdfd0747cfc7c469eafb",
"0x00000000000000000000000000000000002db88f0f14abcf912eb93a037537b9",
"0x00000000000000000000000000000002daa2459d5a3872bf295cceedf6f51c89",
"0x00000000000000000000000000000000000ae4760396baacb132edb530ec61b4",
"0x000000000000000000000000000000fa31ef5c567d3f2932995cfe48ad5cc4d4",
"0x0000000000000000000000000000000000067c4cfd6c7646c965c095899b117e",
"0x0000000000000000000000000000008b2caa070e7a4fc68f742875275287dc7d",
"0x00000000000000000000000000000000000cc1bdb7ce1c8f887fa26a9a398608",
"0x0000000000000000000000000000004de5e441920f9a656a9c4e468ab83d0c33",
"0x00000000000000000000000000000000001b914f49019e7a8287b96725d2e634",
"0x000000000000000000000000000000585bcffc21e823fbb152381b22e44d7a7e",
"0x00000000000000000000000000000000001b416f978d43b413cdc053a3c07896",
"0x000000000000000000000000000000ddea0bfa592f58799a485ac663056486c7",
"0x000000000000000000000000000000000028ff6bddc93f749d23464dff089b56",
"0x0000000000000000000000000000007abda48a7da486ee1caa969105ebdd605e",
"0x00000000000000000000000000000000000779acf0cf880b0ad17d8d60807790",
"0x0000000000000000000000000000000c228434220eebf9912b5818da1c6ddb06",
"0x0000000000000000000000000000000000267e56bac180bdcf3a8e53473af2d7",
"0x000000000000000000000000000000cf0fe32bbd4e37be40510f0b7df1e57cd1",
"0x000000000000000000000000000000000004127c9264afe86d5f9807d5840613",
"0x0000000000000000000000000000004393ae233f0416b612212bdb65f1577088",
"0x00000000000000000000000000000000001a8888f573927126d7fe94da48576a",
"0x000000000000000000000000000000bfea0ede436dc8bc01833a47369f83d7c8",
"0x0000000000000000000000000000000000269e52e488bf221c6ff67523a43cf9",
"0x0000000000000000000000000000002ba1024b5dd72178f188724cc7d4748961",
"0x000000000000000000000000000000000007697eeb3cb27b17d5d73e0c716a19",
"0x000000000000000000000000000000ae82078e9c2f1c87ab136907f4f424c69a",
"0x00000000000000000000000000000000000803dc70afea981657ca1460e6dc58",
"0x0000000000000000000000000000003190550e34b12fe616fb1b442769db05af",
"0x00000000000000000000000000000000000dbf59d295ec625279f6cbd7437268",
"0x0000000000000000000000000000004d49306c31f7313ddb89c0c3b1601a91d2",
"0x00000000000000000000000000000000001bbd45f63dafd1efe2e22c9b7cbcb3",
"0x0000000000000000000000000000009ae1021abb15b797963444cf2571714216",
"0x00000000000000000000000000000000001788eb1b7cb46af28f46b100471f1e",
"0x00000000000000000000000000000078a6d8bb9e6311cfe54f103472e4048301",
"0x00000000000000000000000000000000002f127563aa90c8312ddc2547313815",
"0x000000000000000000000000000000b88944c34463d5af818781d28f1980a4b5",
"0x00000000000000000000000000000000000bdea1caaf400f08232bf603fb0fcd",
"0x000000000000000000000000000000b31da663c387d3053d1663b83c66586e6f",
"0x00000000000000000000000000000000000923d606451c88c1de301b0bd1c22f",
"0x000000000000000000000000000000605fbcc14e712547f60dc4f3d6c6565d21",
"0x00000000000000000000000000000000000baa6d952497b500770ad0082953f1",
"0x0000000000000000000000000000006f1d74fc8574822813d3637e8140d51862",
"0x000000000000000000000000000000000026b484116a0ffbf8750e16b2867c7b",
"0x000000000000000000000000000000ae368c9d02575143672baa720a0d66bf59",
"0x0000000000000000000000000000000000125909c1470879ce9ba9f43313b106",
"0x0000000000000000000000000000008ebdf945ff0189be650db82dc3f9cf24c8",
"0x00000000000000000000000000000000000aaf599a5fff930188f52c5e1cc512",
"0x000000000000000000000000000000b60c4c5a08eae043aa3d9ce1aab3fd44c3",
"0x00000000000000000000000000000000001396a9e69bbb46317cf2c5e4463221",
"0x00000000000000000000000000000069c93b8d7a300da404fcf9234dc11ca8ef",
"0x00000000000000000000000000000000002ad1e283bc038ab68790e12ac308d8",
"0x00000000000000000000000000000066955f6a416d7ba509a6f0e87bb79d98b4",
"0x0000000000000000000000000000000000222f608ba717aacecff8cc0f6d5216",
"0x00000000000000000000000000000069b08a558fb5393644098ec898af3f267c",
"0x000000000000000000000000000000000020c09c9fa9fd04ea558af3a015c105",
"0x000000000000000000000000000000787eb02b4c60da924c054b3a3f2dee2c10",
"0x00000000000000000000000000000000000ca7c7bee074a875d03dd2d2ef8595",
"0x0000000000000000000000000000004c554640e02a9b40382c615d8434fca9bc",
"0x00000000000000000000000000000000001383e5e275da0d0535a37e719f0f72",
"0x00000000000000000000000000000038e52a83255773b559d41753eaf89658b7",
"0x00000000000000000000000000000000000692fcc741a1fc3d7b9672f090b8d8",
"0x00000000000000000000000000000067b767d5087fe95dbda8687bee8574936f",
"0x00000000000000000000000000000000000d3a6cde8eb9f9050b59b8ccfb1421",
"0x000000000000000000000000000000569d7bb6955e880f387b244197180a5b51",
"0x00000000000000000000000000000000002ddefd342b00474b2473682fe22ec5",
"0x000000000000000000000000000000e955d00da63770c8031b673b4c8bf462dc",
"0x00000000000000000000000000000000001fd976b7def713aa2bf17764839b82",
"0x00000000000000000000000000000022681b44fb063cdd34f27a49363e5d81e9",
"0x00000000000000000000000000000000002559f26a67a5e033b06b840382e3f6",
"0x000000000000000000000000000000afeea2bf861f05b4d99a8b232c2436460a",
"0x0000000000000000000000000000000000244f7f3bf9dd2c22c8d2e4f6dfdd72",
"0x000000000000000000000000000000a1f1bd5b858fe1284d82c703fc7d220d3c",
"0x00000000000000000000000000000000001f7d25e9b863e6a3df33daa0e56b88",
"0x0000000000000000000000000000008ef3e6035713a6b60f632bc05129b57997",
"0x000000000000000000000000000000000002023ae13b76b323bf66cc19f0c086",
"0x000000000000000000000000000000e25eb6b197ffa252297ca45b5ac7cff399",
"0x00000000000000000000000000000000000bff76118f79aa4860162ac21e02ab",
"0x00000000000000000000000000000051758340a9cd45b949c92591f6f4393502",
"0x000000000000000000000000000000000021b1867233a0d188499c17d2f71784",
"0x000000000000000000000000000000737a89e2ac36f136f4c4cb15eeea7703a4",
"0x000000000000000000000000000000000012005136a4ddad32d94a31aad8f61e",
"0x000000000000000000000000000000ec54a77c3636793a9811c84433445db6ba",
"0x0000000000000000000000000000000000018239c2a77d6c4eb8f42dd9d80f5d",
"0x000000000000000000000000000000202045250111fc09eff3358bc8ba44e089",
"0x00000000000000000000000000000000000c4ad8acf33d6d3775a8d337e8e7ee",
"0x000000000000000000000000000000002a5d25e967ef89885f77b237b32851d2",
"0x00000000000000000000000000000000000e4cc8515a225977f34f145c6b15c7"
],
"vkHash": "0x29e4dd1bf210bfd15c9b1997a6339d61aa9612812cde9cf47ed0c2234512e613"
}
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MerkleTree = exports.pedersenLeftRight = void 0;
// @ts-ignore
const bb_js_1 = require("@aztec/bb.js");
// @ts-ignore -- no types
async function pedersenLeftRight(barretenberg, left, right) {
let leftBuffer = bb_js_1.Fr.fromBufferReduce(Buffer.from(left.slice(2), 'hex'));
let rightBuffer = bb_js_1.Fr.fromBufferReduce(Buffer.from(right.slice(2), 'hex'));
let hashRes = await barretenberg.pedersenHashWithHashIndex([leftBuffer, rightBuffer], 0);
return hashRes.toString();
}
exports.pedersenLeftRight = pedersenLeftRight;
class MerkleTree {
constructor(levels, barretenberg, defaultLeaves = [], hashLeftRight = pedersenLeftRight) {
this.zeroValue = "0x016a430aa58685aba1311244a973a3bc358859da86784be51094368e8fb6f720"; // sha256("Momiji") % Fr.MODULUS
this.getAllLeaves = () => Array.from(this.storage.values()).slice(0, 2 ** this.levels);
this.levels = levels;
this.hashLeftRight = hashLeftRight;
this.storage = new Map();
this.zeros = [];
this.totalLeaves = 0;
this.barretenberg = barretenberg;
this.defaultLeaves = defaultLeaves;
}
async init() {
// build zeros depends on tree levels
let currentZero = this.zeroValue;
this.zeros.push(currentZero);
for (let i = 0; i < this.levels; i++) {
currentZero = await this.hashLeftRight(this.barretenberg, currentZero, currentZero);
this.zeros.push(currentZero);
}
if (this.defaultLeaves.length > 0) {
this.totalLeaves = this.defaultLeaves.length;
// store leaves with key value pair
let level = 0;
this.defaultLeaves.forEach((leaf, index) => {
this.storage.set(MerkleTree.indexToKey(level, index), leaf);
});
// build tree with initial leaves
level++;
let numberOfNodesInLevel = Math.ceil(this.totalLeaves / 2);
for (level; level <= this.levels; level++) {
for (let i = 0; i < numberOfNodesInLevel; i++) {
const leftKey = MerkleTree.indexToKey(level - 1, 2 * i);
const rightKey = MerkleTree.indexToKey(level - 1, 2 * i + 1);
const left = this.storage.get(leftKey);
const right = this.storage.get(rightKey) || this.zeros[level - 1];
if (!left)
throw new Error("leftKey not found");
const node = await this.hashLeftRight(this.barretenberg, left, right);
this.storage.set(MerkleTree.indexToKey(level, i), node);
}
numberOfNodesInLevel = Math.ceil(numberOfNodesInLevel / 2);
}
}
}
static indexToKey(level, index) {
return `${level}-${index}`;
}
getIndex(leaf) {
for (const [key, value] of this.storage) {
if (value === leaf) {
return Number(key.split("-")[1]);
}
}
return -1;
}
root() {
return this.storage.get(MerkleTree.indexToKey(this.levels, 0)) || this.zeros[this.levels];
}
async proof(indexOfLeaf) {
let pathElements = [];
let pathIndices = [];
const leaf = this.storage.get(MerkleTree.indexToKey(0, indexOfLeaf));
if (!leaf)
throw new Error("leaf not found");
// store sibling into pathElements and target's indices into pathIndices
const handleIndex = (level, currentIndex, siblingIndex) => {
const siblingValue = this.storage.get(MerkleTree.indexToKey(level, siblingIndex)) || this.zeros[level];
pathElements.push(siblingValue);
pathIndices.push(currentIndex % 2);
};
await this.traverse(indexOfLeaf, handleIndex);
return {
root: this.root(),
pathElements,
pathIndices,
leaf: leaf,
};
}
async insert(leaf) {
const index = this.totalLeaves;
await this.update(index, leaf, true);
this.totalLeaves++;
}
async update(index, newLeaf, isInsert = false) {
if (!isInsert && index >= this.totalLeaves) {
throw Error("Use insert method for new elements.");
}
else if (isInsert && index < this.totalLeaves) {
throw Error("Use update method for existing elements.");
}
let keyValueToStore = [];
let currentElement = newLeaf;
const handleIndex = async (level, currentIndex, siblingIndex) => {
const siblingElement = this.storage.get(MerkleTree.indexToKey(level, siblingIndex)) || this.zeros[level];
let left;
let right;
if (currentIndex % 2 === 0) {
left = currentElement;
right = siblingElement;
}
else {
left = siblingElement;
right = currentElement;
}
keyValueToStore.push({
key: MerkleTree.indexToKey(level, currentIndex),
value: currentElement,
});
currentElement = await this.hashLeftRight(this.barretenberg, left, right);
};
await this.traverse(index, handleIndex);
// push root to the end
keyValueToStore.push({
key: MerkleTree.indexToKey(this.levels, 0),
value: currentElement,
});
keyValueToStore.forEach((o) => {
this.storage.set(o.key, o.value);
});
}
// traverse from leaf to root with handler for target node and sibling node
async traverse(indexOfLeaf, handler) {
let currentIndex = indexOfLeaf;
for (let i = 0; i < this.levels; i++) {
let siblingIndex;
if (currentIndex % 2 === 0) {
siblingIndex = currentIndex + 1;
}
else {
siblingIndex = currentIndex - 1;
}
await handler(i, currentIndex, siblingIndex);
currentIndex = Math.floor(currentIndex / 2);
}
}
}
exports.MerkleTree = MerkleTree;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BatchBuilder = void 0;
const rover_1 = require("./rover");
class BatchBuilder extends rover_1.Prover {
constructor() {
super(...arguments);
this.zeroValue = "0x016a430aa58685aba1311244a973a3bc358859da86784be51094368e8fb6f720";
this.zeroHex = "0x0000000000000000000000000000000000000000000000000000000000000000";
this.withdrawals = [];
this.depositTotal = "0";
this.contractInputs = [];
this.enqueueQueue = [];
this.status = {
txs_hash: "",
tx_ids: [],
proof: "",
aggregation_object: []
};
this.fetchQueue = async () => {
const merkleRoot = await this.momiji.contract.merkleRoot();
const filter = this.momiji.contract.filters.TransactionSent(null, merkleRoot, null);
const txEvents = await this.momiji.contract.queryFilter(filter);
const txContractInputs = txEvents.map(e => this.resultToTransaction(this.toResult(e)));
this.clearQueue();
this.enqueueLocally(txContractInputs);
return txContractInputs;
};
this.addToStatus = (update) => {
this.status.tx_ids.push(update.id);
this.status.txs_hash = this.keccak256('0x' + this.status.tx_ids.map(tx => tx.slice(2)).join(''));
this.status.proof = update.proof;
this.status.aggregation_object = update.aggregation_object;
};
this.publishBatch = async (data) => {
if (!this.hasSigner())
throw new Error(`batchBuilder.publishBatch: Signer is undefined, but is required.`);
if (Array.isArray(data) && !this.status.proof) {
data = data;
console.log(`batchBuilder.publishBatch: No batch passed and no batch being generated, generating new proofs.`);
this.publishBatch(await this.proveValidBatch(undefined, data));
}
let publishTx = await this.momiji.contract.publish(data);
console.log(`batchBuilder.publishBatch: Batch published: ${publishTx.hash}.`);
console.log(publishTx);
};
this.createFinalPublisherInputs = async (batch) => {
let new_root = await this.calculateNewStateRoot(batch.transactions.map(tx => tx.tx_id), this.stateRoot.value, (await this.pedersen(this.toFixedHex(0, true))));
let _batch = [
this.config.transactionVkHash,
this.stateRoot.value,
new_root,
await this.pedersen(this.toFixedHex(0, true)),
...(batch.transactions.map(tx => [
tx.current_root,
tx.deposit,
tx.tx_id,
...tx.withdrawals,
...tx.commitment_out,
...tx.recipients,
...tx.nullifier_hashes,
...tx.proof,
tx.pi_contract_hash
])).flat()
];
return {
proof: this.status.proof,
aggregation_object: this.status.aggregation_object,
batch_calldata: _batch,
};
};
this.createBatchPublicInputs = async (transactions) => {
if (transactions === undefined)
transactions = this.mempool.queue;
if (!Array.isArray(transactions))
transactions = [transactions];
let _transactions = transactions;
return {
key_hash: this.config.transactionVkHash,
old_root: this.stateRoot.value,
new_root: await this.calculateNewStateRoot(_transactions.map(tx => tx.tx_id), this.stateRoot.value, (await this.pedersen(this.toFixedHex(0, true)))),
oracle: await this.pedersen(this.toFixedHex(0, true)),
tx_ids: new Array(16).fill(this.zeroValue).map((_, idx, _arr) => {
let thisTx = (_transactions[idx] !== undefined) ? _transactions[idx].tx_id : _arr[idx];
return thisTx;
})
};
};
this.addProvenTransaction = async (transaction, batch) => {
if (!batch)
batch = await this.initBatchCircuitInputs();
if (batch.tx_ids.filter(i => i == this.zeroValue).length >= 16) {
console.log(`batchBuilder.addTransaction: Batch is full. Tossing tx.`);
return batch;
}
if (!batch.tx_ids.includes(transaction.tx_id)) {
batch.tx_ids[batch.tx_ids.indexOf(this.zeroValue)] = transaction.tx_id;
}
batch.oracle = await this.pedersen(this.toFixedHex(0, true));
batch.new_root = await this.calculateNewStateRoot(batch.tx_ids, batch.old_root, batch.oracle);
batch.pi_contract_hash = this.keccak256([
"0x",
batch.key_hash.slice(2),
batch.old_root.slice(2),
batch.new_root.slice(2),
batch.oracle.slice(2),
...batch.tx_ids.map(tx => tx.slice(2))
].join(''));
batch.proof = transaction.proof;
batch.public_inputs = transaction.proof.slice(0, 1);
const recursiveProof = await this.momiji.recursion.final.generateFinalProof(batch);
const recursiveProofVerified = await this.momiji.recursion.final.verifyFinalProof(recursiveProof);
if (!recursiveProofVerified) {
console.log(`batchBuilder.addTransaction: Recursive proof failed verification on tx_id ${transaction.tx_id}. Tossing tx.`);
}
else {
const proofHex = '0x' + Buffer.from(recursiveProof.proof).toString('hex');
let publicInputsHex = [];
if (recursiveProof.publicInputs instanceof Array) {
publicInputsHex = recursiveProof.publicInputs.map(pi => `0x` + Buffer.from(pi).toString('hex'));
}
const batchStatusUpdate = {
id: transaction.tx_id,
proof: proofHex,
aggregation_object: publicInputsHex.slice(1)
};
this.addToStatus(batchStatusUpdate);
batch.input_aggregation_object = batchStatusUpdate.aggregation_object;
}
return batch;
};
this.calculateNewStateRoot = async (txs, old_root, oracle) => {
let txRoot = await this.MerkleTree(this.config.tree.txDepth, txs).then(result => result.root());
let batch = await this.pedersen([txRoot, oracle]);
let new_root = await this.pedersen([batch, old_root]);
return new_root;
};
this.proveBatch = () => {
};
this.proveValidBatch = async (batch, transactions) => {
if (!Array.isArray(transactions))
transactions = [transactions];
if (!transactions)
transactions = this.mempool.queue;
let _transactions = transactions;
let _batch = batch || await this.createBatchPublicInputs(transactions);
let batchCircuitInputs = await this.initBatchCircuitInputs(_batch);
let aggregate = await new Array(_transactions.length)
.reduce(async (acc, _, i) => await this.addProvenTransaction(_transactions[i], acc), batchCircuitInputs);
let finals = {
...aggregate,
proof: this.status.proof,
aggregation_object: this.status.aggregation_object,
transactions: transactions
};
console.log(`batchBuilder.proveValidBatch: Done proving batch.`);
return finals;
};
this.initBatchCircuitInputs = async (pi) => {
if (!pi)
pi = (await this.createBatchPublicInputs());
return {
...pi,
pi_contract_hash: this.keccak256([
"0x",
pi.key_hash.slice(2),
pi.old_root.slice(2),
pi.new_root.slice(2),
pi.oracle.slice(2),
...pi.tx_ids.map(tx => tx.slice(2))
].join('')),
verification_key: this.config.transactionVk,
proof: new Array(94).fill(this.toFixedHex(0, true)),
public_inputs: new Array(1).fill(this.toFixedHex(0, true)),
input_aggregation_object: new Array(16).fill(this.toFixedHex(0, true))
};
};
}
}
exports.BatchBuilder = BatchBuilder;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbiCoder = exports.randomBytes = exports.ethers = exports.JsonRpcProvider = exports.Log = exports.Result = exports.EventLog = exports.Wallet = exports.Contract = exports.MerkleTree = exports.Fr = exports.Noir = exports.Barretenberg = exports.BarretenbergBackend = void 0;
const backend_barretenberg_1 = require("@noir-lang/backend_barretenberg");
Object.defineProperty(exports, "BarretenbergBackend", { enumerable: true, get: function () { return backend_barretenberg_1.BarretenbergBackend; } });
const bb_js_1 = require("@aztec/bb.js");
Object.defineProperty(exports, "Barretenberg", { enumerable: true, get: function () { return bb_js_1.Barretenberg; } });
Object.defineProperty(exports, "Fr", { enumerable: true, get: function () { return bb_js_1.Fr; } });
const noir_js_1 = require("@noir-lang/noir_js");
Object.defineProperty(exports, "Noir", { enumerable: true, get: function () { return noir_js_1.Noir; } });
const MerkleTree_1 = require("./MerkleTree");
Object.defineProperty(exports, "MerkleTree", { enumerable: true, get: function () { return MerkleTree_1.MerkleTree; } });
const ethers_1 = require("ethers");
Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return ethers_1.Contract; } });
Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return ethers_1.Wallet; } });
Object.defineProperty(exports, "EventLog", { enumerable: true, get: function () { return ethers_1.EventLog; } });
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return ethers_1.Log; } });
Object.defineProperty(exports, "ethers", { enumerable: true, get: function () { return ethers_1.ethers; } });
Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: function () { return ethers_1.JsonRpcProvider; } });
Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function () { return ethers_1.AbiCoder; } });
Object.defineProperty(exports, "randomBytes", { enumerable: true, get: function () { return ethers_1.randomBytes; } });
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return ethers_1.Result; } });
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Prover = void 0;
const buffer_1 = require("buffer");
const os = __importStar(require("os"));
const interfaces = __importStar(require("./interfaces"));
class Prover {
constructor(config, signer) {
this.initialized = false;
this.momiji = {};
this.mempool = {
queue: [],
gossip: {}
};
this.stateRoot = {
value: "0x00",
index: 0
};
this.initialize = async () => {
const txCircuit = this.txCircuit;
const recCircuit = this.recCircuit;
this.momiji.api = await interfaces.Barretenberg.new(this.threads);
let _intermTx = new interfaces.BarretenbergBackend(this.txCircuit, { threads: this.threads });
let _intermRec = new interfaces.BarretenbergBackend(this.recCircuit, { threads: this.threads });
this.momiji = {
api: this.momiji.api,
contract: new interfaces.Contract(this.config.stateContract.address, JSON.stringify(this.config.stateContract.abi), this.provider),
tree: this.config.tree,
history: await this.MerkleTree(this.config.tree.stateDepth),
transaction: {
circuit: this.txCircuit,
intermediate: _intermTx,
final: new interfaces.Noir(this.txCircuit, _intermTx)
},
recursion: {
verifier: new interfaces.Contract(this.config.stateContract.address, JSON.stringify(this.config.recursionVerifier.abi), this.provider),
circuit: this.recCircuit,
intermediate: _intermRec,
final: new interfaces.Noir(this.recCircuit, _intermRec)
}
};
await this.refreshState();
this.momiji.contract.on('TransactionSent', async (e) => {
let thisTx = this.resultToTransaction(e);
if (!(thisTx.current_root == this.momiji.history.root()))
await this.fetchQueue();
this.enqueueLocally(thisTx);
});
this.momiji.contract.on('BatchPublish', (event) => {
this.clearQueue();
});
this.initialized = true;
};
this.pedersen = async (input) => {
const _bb = await interfaces.Barretenberg.new(32);
if (!Array.isArray(input))
input = [input];
const _input = input;
const _inputFr = _input.map(i => interfaces.Fr.fromBufferReduce(buffer_1.Buffer.from(i.slice(2), 'hex')));
let hash = await _bb.pedersenHashWithHashIndex(_inputFr, 0)
.then((response) => response.toString());
await _bb.destroy();
return hash;
};
this.randomBytesFr = (numBytes) => {
return interfaces.Fr.fromBufferReduce(interfaces.randomBytes(numBytes));
};
this.toFixedHex = (number, pad0x, length = 32) => {
let hexString = number.toString(16).padStart(length * 2, '0');
return (pad0x ? `0x` + hexString : hexString);
};
this.resultToTransaction = (event) => {
if (event) {
return {
current_root: event[0],
deposit: event[1],
tx_id: event[2],
withdrawals: event.slice(3, 19),
commitment_out: event.slice(19, 35),
recipients: event.slice(35, 51),
nullifier_hashes: event.slice(51, 67),
proof: event.slice(67, 161),
pi_contract_hash: event[161]
};
}
else {
return {
current_root: this.toFixedHex(0, true),
deposit: this.toFixedHex(0, true),
tx_id: this.toFixedHex(0, true),
withdrawals: new Array(16).fill(this.toFixedHex(0, true)),
commitment_out: new Array(16).fill(this.toFixedHex(0, true)),
recipients: new Array(16).fill(this.toFixedHex(0, true)),
nullifier_hashes: new Array(16).fill(this.toFixedHex(0, true)),
proof: new Array(94).fill(this.toFixedHex(0, true)),
pi_contract_hash: this.toFixedHex(0, true)
};
}
};
this.hasSigner = () => this.signer !== undefined;
this.keccak256 = (data) => {
let _dataBytes = new Uint8Array(buffer_1.Buffer.from(data.slice(2), 'hex'));
let _hashModulo = interfaces.Fr.fromBufferReduce(buffer_1.Buffer.from(interfaces.ethers.keccak256(_dataBytes).slice(2), 'hex'));
return _hashModulo.toString();
};
this.generateSecret = () => this.randomBytesFr(32);
this.MerkleTree = async (depth, leaves) => {
const _bb = await interfaces.Barretenberg.new(32);
const tree = new interfaces.MerkleTree(depth, _bb, leaves);
await tree.init();
await _bb.destroy();
return tree;
};
this.toResult = (e) => { return e.args[0]; };
this.fetchQueue = async () => {
const merkleRoot = await this.momiji.contract.merkleRoot();
const filter = this.momiji.contract.filters.TransactionSent(null, merkleRoot, null);
const txEvents = await this.momiji.contract.queryFilter(filter);
const txContractInputs = txEvents.map(e => this.resultToTransaction(this.toResult(e)));
this.clearQueue();
this.enqueueLocally(txContractInputs);
return txContractInputs;
};
this.refreshState = async () => {
let historic_roots = (await this.momiji.contract.getValidRoots());
this.stateRoot.value = (await this.momiji.contract.merkleRoot());
this.stateRoot.index = historic_roots.length - 1;
this.momiji.history = (await this.MerkleTree(this.config.tree.stateDepth, historic_roots));
await this.fetchQueue();
};
this.clearQueue = () => {
this.mempool.queue = [];
this.refreshState();
};
this.enqueue = async (transaction) => {
this.enqueueLocally(transaction);
if (this.signer)
for (let transaction of this.mempool.queue)
await this.momiji.contract.enqueue(transaction);
};
this.enqueueLocally = async (transaction) => {
if (!Array.isArray(transaction))
transaction = [transaction];
this.mempool.queue.push(...transaction);
};
if (!signer) {
if (config.PRIVATE_KEY)
this.signer = new interfaces.Wallet(config.PRIVATE_KEY, new interfaces.JsonRpcProvider(config.provider));
else
this.signer = undefined;
}
else {
this.signer = signer;
}
this.provider = new interfaces.JsonRpcProvider(config.provider);
this.config = config;
this.txCircuit = config.transactionCircuit;
this.recCircuit = config.recursionCircuit;
this.config.tree.treeSum = [this.config.tree.utxoDepth, this.config.tree.txDepth, this.config.tree.stateDepth].reduce((a, b) => a + b);
this.abi = interfaces.AbiCoder.defaultAbiCoder();
this.threads = os.cpus().length - 2;
}
keccakHashArray(data) {
}
}
exports.Prover = Prover;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionBuilder = void 0;
const rover_1 = require("./rover");
const interfaces = __importStar(require("./interfaces"));
class TransactionBuilder extends rover_1.Prover {
constructor() {
super(...arguments);
this.zeroValue = "0x016a430aa58685aba1311244a973a3bc358859da86784be51094368e8fb6f720";
this.zeroHex = "0x0000000000000000000000000000000000000000000000000000000000000000";
this.withdrawals = [];
this.utxoproofs = [];
this.utxos = [];
this.depositTotal = "0";
this.contractInputs = [];
this.getOracle = async (old_root) => await this.pedersen(this.toFixedHex(0, true));
this.fetchSiblings = async (utxo) => {
const utxoId = await this.pedersen([utxo.owner, utxo.amount, utxo.assetType]);
const merkleRoot = await this.momiji.contract.getRootFromUtxo(utxoId);
const filter = this.momiji.contract.filters.TransactionSent(null, merkleRoot, null);
const txEvents = await this.momiji.contract.queryFilter(filter);
let siblings = [];
for (let i = 0; i < txEvents.length; i++) {
let commitments = [];
let event = txEvents[i];
let args = event.topics;
for (let j = 19; j < 35; j++) {
if (args[0][j] !== this.toFixedHex(0, true))
commitments.push(args[0][j]);
else
commitments.push("0x016a430aa58685aba1311244a973a3bc358859da86784be51094368e8fb6f720");
}
if (commitments.includes(utxoId))
siblings = commitments;
}
return siblings;
};
this.makeUTXOTree = async (utxo) => {
if (!utxo)
utxo = this.utxos;
let commitments = [];
for (let i = 0; i < utxo.length; i++)
commitments[i] = await this.pedersen([utxo[i].owner, utxo[i].amount, utxo[i].assetType]);
let utxoTree = new interfaces.MerkleTree(this.config.tree.utxoDepth, this.momiji.api, commitments);
await utxoTree.init();
return utxoTree;
};
this.proveTransaction = async (transaction, public_inputs) => {
const _contract = new interfaces.Contract(this.config.stateContract.address, JSON.stringify(this.config.stateContract.abi), this.signer);
let txWitness = await this.momiji.transaction.final.execute(transaction);
let txProof = await this.momiji.transaction.intermediate.generateIntermediateProof(txWitness.witness);
let txProofArtifacts = await this.momiji.transaction.intermediate.generateIntermediateProofArtifacts(txProof, 1);
const pi = public_inputs;
const _contract_inputs = [
pi.current_root,
pi.deposit,
pi.tx_id,
pi.withdrawals,
pi.commitment_out,
pi.recipients,
pi.nullifier_hashes,
txProofArtifacts.proofAsFields,
transaction.pi_contract_hash
].flat();
_contract.enqueue.send(_contract_inputs).then((_tx) => console.log(_tx), (_r) => console.log(_r));
return {
proof: txProofArtifacts.proofAsFields,
pi_contract_hash: transaction.pi_contract_hash,
...public_inputs
};
};
this.hashPublicInputs = (public_inputs) => {
const inputsForHashing = [
"0x",
public_inputs.current_root.slice(2),
public_inputs.deposit.slice(2),
public_inputs.tx_id.slice(2),
[...public_inputs.withdrawals.map(w => w.slice(2))].join(''),
[...public_inputs.commitment_out.map(w => w.slice(2))].join(''),
[...public_inputs.recipients.map(w => w.slice(2))].join(''),
[...public_inputs.nullifier_hashes.map(w => w.slice(2))].join(''),
].join('');
return this.keccak256(inputsForHashing);
};
this.deposit = (amount) => this.depositTotal = this.toFixedHex(amount, true);
this.send = async (sends) => {
let utxos = await this.createUTXO(sends);
for (let i = 0; i < utxos.length; i++)
this.utxos.push(utxos[i]);
return utxos;
};
this.withdraw = (withdrawals) => Array.isArray(withdrawals) ? withdrawals.forEach(w => this.withdrawals.push(w)) : this.withdrawals.push(withdrawals);
this.createTransactions = async (transactions) => {
if (transactions === undefined) {
const _nullifier_hashes = new Array(16).fill(this.zeroValue);
for (let i = 0; i < this.utxoproofs.length; i++) {
let _hash = await this.pedersen([this.utxoproofs[i].secret, this.utxoproofs[i].secret]);
_nullifier_hashes[i] = _hash;
}
const _withdrawals = this.withdrawals;
const _utxoProofs = this.utxoproofs;
const _utxoOut = this.utxos;
const _commitmentOut = new Array(16).fill(this.zeroValue);
for (let u = 0; u < _utxoOut.length; u++) {
_commitmentOut[u] = await this.pedersen([_utxoOut[u].owner, _utxoOut[u].amount, _utxoOut[u].assetType]);
}
let utxoTree = await this.makeUTXOTree();
transactions = [{
current_root: this.momiji.history.root(),
deposit: this.depositTotal,
tx_id: utxoTree.root(),
withdrawals: new Array(16).fill(this.zeroHex).map(function (_, i, _w) {
if (_withdrawals[i] !== undefined)
return _withdrawals[i].amount;
else
return _w[i];
}),
commitment_out: _commitmentOut,
recipients: new Array(16).fill(this.zeroHex).map(function (_, i, _w) {
if (_withdrawals[i] !== undefined)
return _withdrawals[i].recipient;
else
return _w[i];
}),
nullifier_hashes: _nullifier_hashes,
utxo_in: new Array(16).fill(this.zeroHex).map(function (_, i, _ui) {
if (_utxoProofs[i] !== undefined)
return _utxoProofs[i];
else
return {
owner: "0x0000000000000000000000000000000000000000000000000000000000000000",
amount: "0x0000000000000000000000000000000000000000000000000000000000000000",
assetType: "0x0000000000000000000000000000000000000000000000000000000000000000"
};
}),
utxo_out: new Array(16).fill(this.zeroHex).map((_, i) => (_utxoOut[i] !== undefined)
? _utxoOut[i]
: _utxoOut[i])
}];
}
else {
if (!Array.isArray(transactions))
transactions = [transactions];
}
let provingQueue = Promise.resolve();
for (let i = 0; i < transactions.length; i++) {
let thisTx = transactions[i];
let public_inputs = thisTx;
let transaction = {
pi_contract_hash: this.hashPublicInputs(public_inputs),
current_root: thisTx.current_root,
deposit: thisTx.deposit,
withdrawals: thisTx.withdrawals,
commitment_out: thisTx.commitment_out,
recipients: thisTx.recipients,
nullifier_hashes: thisTx.nullifier_hashes,
tx_id: thisTx.tx_id,
oracle: new Array(2 ** this.momiji.tree.utxoDepth).fill(this.zeroHex)
.map((_, j, _oracle) => (thisTx.utxo_in[j].oracle !== undefined)
? thisTx.utxo_in[j].oracle
: _oracle[j]),
old_root_proof: new Array(2 ** this.momiji.tree.utxoDepth).fill(this.zeroHex)
.map((_, j, _old_root_proof) => (thisTx.utxo_in[j].old_root_proof !== undefined)
? thisTx.utxo_in[j].old_root_proof
: _old_root_proof[j]),
secrets: new Array(2 ** this.momiji.tree.utxoDepth).fill(this.zeroHex)
.map((_, j, _secrets) => thisTx.utxo_in[j].secret !== undefined ? thisTx.utxo_in[j].secret : _secrets[j]),
utxo_in: new Array(2 ** this.momiji.tree.utxoDepth).fill(this.zeroHex)
.map((_, j, _utxo_in) => [
thisTx.utxo_in[j].owner,
thisTx.utxo_in[j].amount,
thisTx.utxo_in[j].assetType
])
.flat(),
utxo_out: (new Array(2 ** this.momiji.tree.utxoDepth).fill(this.zeroHex)
.map((_, j) => thisTx.utxo_out[j] ?
[thisTx.utxo_out[j].owner, thisTx.utxo_out[j].amount, thisTx.utxo_out[j].assetType] :
new Array(3).fill(this.zeroHex)))
.flat(),
indexes: (new Array(2 ** this.momiji.tree.utxoDepth).fill(this.zeroHex)
.map((_, j) => thisTx.utxo_in[j].indexes ?
thisTx.utxo_in[j].indexes :
new Array(3).fill(this.zeroHex)))
.flat(),
hash_path: (new Array(2 ** this.momiji.tree.utxoDepth).fill(this.zeroHex)
.map((_, j) => thisTx.utxo_in[j].hash_path ?
thisTx.utxo_in[j].hash_path :
new Array(17).fill(this.zeroHex)))
.flat(),
};
provingQueue.then(async () => {
let transactionProof = await this.proveTransaction(transaction, public_inputs);
this.contractInputs.push(transactionProof);
});
await provingQueue;
}
console.log(this.contractInputs);
return this.contractInputs;
};
}
async spendUTXO(utxo) {
let provenUTXOs = await this.makeUTXOProof(utxo);
for (let i = 0; i < provenUTXOs.length; i++)
this.utxoproofs.push(provenUTXOs[i]);
return provenUTXOs;
}
async makeUTXOProof(utxo) {
if (!Array.isArray(utxo))
utxo = [utxo];
let utxoProofList = [];
for (let i = 0; i < utxo.length; i++) {
const siblings = await this.fetchSiblings(utxo[i]);
const commitment = await this.pedersen([utxo[i].owner, utxo[i].amount, utxo[i].assetType]);
const oldRoot = await this.momiji.contract.getRootFromUtxo(commitment);
const txBatch = await this.momiji.contract.getTxIds(oldRoot);
let trees = {
utxo_tree: await this.MerkleTree(this.momiji.tree.utxoDepth, siblings),
tx_tree: await this.MerkleTree(this.momiji.tree.txDepth, txBatch),
historic_tree: this.momiji.history,
};
await Promise.all([
trees.utxo_tree.init(),
trees.tx_tree.init(),
trees.historic_tree.init()
]);
let txId = trees.utxo_tree.root();
let txRoot = trees.tx_tree.root();
let oracle = await this.getOracle(oldRoot);
let batch = await this.pedersen([txRoot, oracle]);
let new_root = await this.pedersen([batch, oldRoot]);
const utxoMerkleIndex = trees.utxo_tree.getIndex(commitment);
const txMerkleIndex = trees.tx_tree.getIndex(txId);
const historicMerkleIndex = trees.historic_tree.getIndex(new_root);
const utxoMerkleProof = await trees.utxo_tree.proof(utxoMerkleIndex);
const txMerkleProof = await trees.utxo_tree.proof(txMerkleIndex);
const historicMerkleProof = await trees.utxo_tree.proof(historicMerkleIndex);
const utxoProof = {
secret: utxo[i].secret,
owner: utxo[i].owner,
amount: utxo[i].amount,
assetType: utxo[i].assetType,
nullifier_hash: await this.pedersen([utxo[i].secret, utxo[i].secret]),
oracle: oracle,
old_root_proof: oldRoot,
current_root: trees.historic_tree.root(),
indexes: [utxoMerkleIndex, txMerkleIndex, historicMerkleIndex].map(i => this.toFixedHex(i, true)),
hash_path: [
...utxoMerkleProof.pathElements,
...txMerkleProof.pathElements,
...historicMerkleProof.pathElements
]
};
utxoProofList.push(utxoProof);
}
return utxoProofList;
}
async createUTXO(utxo) {
if (!Array.isArray(utxo))
utxo = [utxo];
const utxoSet = [];
await Promise.all(utxo.map(async (utxo) => {
utxo.owner = (utxo.secret ? await this.pedersen(utxo.secret) : undefined);
if (utxo.owner)
utxoSet.push(utxo);
}));
return utxoSet;
}
viewBalance(assetType, token) {
if (token) {
}
if (assetType) {
}
}
}
exports.TransactionBuilder = TransactionBuilder;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Publisher = void 0;
const interfaces = __importStar(require("../lib/utils/interfaces"));
const rover_1 = require("../lib/utils/rover");
const batchBuilder_1 = require("../lib/utils/batchBuilder");
class Publisher {
constructor(config, signer) {
this.proofsStarted = 0;
this.proofsCompleted = 0;
this.initialize = async () => {
await this.prover.initialize();
await this.batchBuilder.initialize();
this.provingQueue = this.batchBuilder.initBatchCircuitInputs();
// Start watching for events
this.prover.momiji.contract.on('TransactionSent', async (res) => {
let tx = this.prover.resultToTransaction(res);
console.log(`🟢 Transaction enqueued: ${tx.tx_id}.`);
// This proves 1 tx and updates prover.status
this.queueToProve(tx);
});
this.prover.momiji.contract.on('BatchPublish', async (event) => {
// Someone else published (or we did? - check)
//console.log(`🎯 Batch published: ${event}.`);
// reset proving queue and mempool.queue
this.resetCounters();
this.batchBuilder.status = {
txs_hash: "",
tx_ids: [],
proof: "",
aggregation_object: []
};
await this.batchBuilder.fetchQueue();
await this.batchBuilder.refreshState();
this.provingQueue = this.batchBuilder.initBatchCircuitInputs();
this.printRoot();
this.publishTimeout = setInterval(this.publish, Number(process.env.TIMEOUT)); // every minute, publish (if there's a batch to publish)
return;
});
console.log(`⌚ Event watcher started.`);
this.printRoot();
console.log(`🟣 Welcome to the Offshift Prover Network.`);
this.signer && console.log(`🔑 Publisher Address: ${await this.signer.getAddress()}.`);
const _thisQueue = await this.prover.fetchQueue();
this.publishTimeout = setInterval(this.publish, Number(process.env.TIMEOUT)); // every minute, publish (if there's a batch to publish)
// for each item in queue, add it to the proving queue
if (_thisQueue.length > 0) {
console.log(`📃 Fetched ${_thisQueue.length} unpublished transactions from queue.`);
for (let i = 0; i < _thisQueue.length; i++) {
this.queueToProve(_thisQueue[i]); // queue every queued tx for proving
}
}
};
this.printRoot = () => console.log(`🌳 Current State Root: ${this.prover.stateRoot.value}`);
// compare this.batchBuilder.status to the state contract and see if the last non-zero tx_id matches
this.stillProving = () => this.proofsCompleted < this.proofsStarted;
this.queueToProve = async (tx) => {
this.proofsStarted++;
this.provingQueue = this.provingQueue.then(async (data) => {
return this.prove(data, tx);
}).catch(async (e) => {
console.log(e);
console.log(`❌ An error occured! Batch proofs reset.`); // TODO: Gracefully restart proving with the queue when this happens
return await this.batchBuilder.initBatchCircuitInputs(); // reset the batch
});
};
this.prove = async (d, tx) => {
return new Promise(async (res, rej) => {
// check to make sure a batch wasn't published during the time, and kick out if it was
if (await this.prover.momiji.contract.merkleRoot() != this.prover.stateRoot.value) {
// make batchBuilder dump the queue and start over
this.batchBuilder.clearQueue();
this.provingQueue = this.batchBuilder.initBatchCircuitInputs();
await this.provingQueue;
this.resetCounters();
return res(this.provingQueue);
}
console.log(`⏳ Proving ${tx.tx_id}.`);
const proof = await this.batchBuilder.addProvenTransaction(tx, d);
console.log(`✔️ Proved ${tx.tx_id}.`);
this.proofsCompleted++;
return res(proof);
});
};
this.publish = async () => {
if (this.stillProving()) {
//console.log(`⚠️ Still proving...`)
return; // If we're still proving something, don't publish right now
}
if (this.batchBuilder.status.proof === "") {
//console.log(`⚠️ No batch to publish...`)
return;
}
if (this.proofsCompleted == 0)
return; // nothing to submit
clearInterval(this.publishTimeout);
console.log(`🗞️ Publishing batch...`);
// Publish to chain
const merkleRoot = await this.prover.momiji.contract.merkleRoot();
const filter = this.prover.momiji.contract.filters.TransactionSent(null, merkleRoot, null);
const txEvents = await this.prover.momiji.contract.queryFilter(filter);
const txContractInputs = txEvents.map(e => this.prover.resultToTransaction(this.prover.toResult(e)));
let finals = await this.batchBuilder.createFinalPublisherInputs({
...(await this.provingQueue),
proof: this.batchBuilder.status.proof,
aggregation_object: this.batchBuilder.status.aggregation_object,
transactions: txContractInputs
});
const _contract = new interfaces.Contract(this.prover.config.stateContract.address, JSON.stringify(this.prover.config.stateContract.abi), this.signer);
await _contract.publish(finals.proof, finals.aggregation_object, finals.batch_calldata)
.then((tx) => console.log(`📡 Batch published: ${tx.hash}.`), (error) => console.log(error.message));
return;
};
this.resetCounters = () => {
// reset proof counters
this.proofsStarted = 0;
this.proofsCompleted = 0;
};
this.publishTimeout = {};
this.provingQueue = {};
this.prover = new rover_1.Prover(config);
this.batchBuilder = new batchBuilder_1.BatchBuilder(config);
this.signer = signer;
if (!this.signer)
throw new Error("momiji.constructor: Signer is undefined, but is required");
const address = config.stateContract.address;
if (!address)
throw new Error("momiji.constructor: State Contract address is not set, but is required.");
}
}
exports.Publisher = Publisher;
{
"name": "momiji-node",
"version": "0.1.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "momiji-node",
"version": "0.1.3",
"license": "MIT",
"dependencies": {
"@noir-lang/backend_barretenberg": "0.19.2",
"@noir-lang/noir_js": "0.19.2",
"ethers": "^6.8.1",
"reflect-metadata": "^0.1.14"
},
"devDependencies": {
"dotenv": "^16.3.1"
}
},
"node_modules/@adraffy/ens-normalize": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz",
"integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q=="
},
"node_modules/@aztec/bb.js": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/@aztec/bb.js/-/bb.js-0.12.0.tgz",
"integrity": "sha512-KBV1WHLvLo2foum3mzPkDtiLtedNSLAx4i3Oroex6X9OaP5ZF/KYKwCYo4vn4CJJgISoD4feC6D29D+CY1PY6w==",
"dependencies": {
"comlink": "^4.4.1",
"commander": "^10.0.1",
"debug": "^4.3.4",
"tslib": "^2.4.0"
},
"bin": {
"bb.js": "dest/node/main.js"
}
},
"node_modules/@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"dependencies": {
"@noble/hashes": "1.3.2"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/hashes": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noir-lang/acvm_js": {
"version": "0.33.0",
"resolved": "https://registry.npmjs.org/@noir-lang/acvm_js/-/acvm_js-0.33.0.tgz",
"integrity": "sha512-4e53SFUB7t05Q3n/0pLZ38LKDdvm7nhfmt2dFSnFgj9dgjRgzgDVSSWIoFWkAWC9oYlYVNJvHpeFyaDHVRFl0w=="
},
"node_modules/@noir-lang/backend_barretenberg": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/@noir-lang/backend_barretenberg/-/backend_barretenberg-0.19.2.tgz",
"integrity": "sha512-rsD7tGuAzOYsXQBlQrjc9HHO/l3TwH/0RPohhWmuba5MW9+j1rvttJk4Ve75ku/fkP6oLyBudwC4XWCvjZbGeQ==",
"dependencies": {
"@aztec/bb.js": "0.12.0",
"@noir-lang/types": "0.19.2",
"fflate": "^0.8.0"
}
},
"node_modules/@noir-lang/noir_js": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/@noir-lang/noir_js/-/noir_js-0.19.2.tgz",
"integrity": "sha512-Zp1dL4O43Q4sNMp13Ofu1a+oAL28d7ZG/Xy4LKnaWypHFu/abRgdk4VYrppEkGmmwWJSCkLBevDb9hXk3+TSwg==",
"dependencies": {
"@noir-lang/acvm_js": "0.33.0",
"@noir-lang/noirc_abi": "0.19.2",
"@noir-lang/types": "0.19.2"
}
},
"node_modules/@noir-lang/noirc_abi": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/@noir-lang/noirc_abi/-/noirc_abi-0.19.2.tgz",
"integrity": "sha512-G2Gl2TMhpkKmvJdcb6cqVMD0a/DkEETP7MkrV+WICU46GpwJqx32f4l0J/j185q20BABSssCc9ztfDtg1pwPWw=="
},
"node_modules/@noir-lang/types": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/@noir-lang/types/-/types-0.19.2.tgz",
"integrity": "sha512-I0seLib7v60BiTFuCRvztzmKy4TKEvCGx+m8pd1xHtnxAkm+9ISpHn/OoTZK8T4/kTsLhChP3ZiNEdtEvhrNlA==",
"dependencies": {
"@noir-lang/noirc_abi": "0.19.2"
}
},
"node_modules/@types/node": {
"version": "18.15.13",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz",
"integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q=="
},
"node_modules/aes-js": {
"version": "4.0.0-beta.5",
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz",
"integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q=="
},
"node_modules/comlink": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/comlink/-/comlink-4.4.1.tgz",
"integrity": "sha512-+1dlx0aY5Jo1vHy/tSsIGpSkN4tS9rZSW8FIhG0JH/crs9wwweswIo/POr451r7bZww3hFbPAKnTpimzL/mm4Q=="
},
"node_modules/commander": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",
"integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==",
"engines": {
"node": ">=14"
}
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/dotenv": {
"version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"node_modules/ethers": {
"version": "6.10.0",
"resolved": "https://registry.npmjs.org/ethers/-/ethers-6.10.0.tgz",
"integrity": "sha512-nMNwYHzs6V1FR3Y4cdfxSQmNgZsRj1RiTU25JwvnJLmyzw9z3SKxNc2XKDuiXXo/v9ds5Mp9m6HBabgYQQ26tA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/ethers-io/"
},
{
"type": "individual",
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"dependencies": {
"@adraffy/ens-normalize": "1.10.0",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"@types/node": "18.15.13",
"aes-js": "4.0.0-beta.5",
"tslib": "2.4.0",
"ws": "8.5.0"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/ethers/node_modules/tslib": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ=="
},
"node_modules/fflate": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.1.tgz",
"integrity": "sha512-/exOvEuc+/iaUm105QIiOt4LpBdMTWsXxqR0HDF35vx3fmaKzw7354gTilCh5rkzEt8WYyG//ku3h3nRmd7CHQ=="
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/reflect-metadata": {
"version": "0.1.14",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz",
"integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A=="
},
"node_modules/tslib": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
},
"node_modules/ws": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz",
"integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
}
}
{
"name": "momiji-node",
"version": "0.1.3",
"description": "This node listens for Momiji transaction events sent to the state contract and rolls them up into a batch to be published on chain",
"main": "index.js",
"keywords": [],
"author": "Offshift Team",
"license": "MIT",
"scripts": {
"start": "node index.js"
},
"devDependencies": {
"dotenv": "^16.3.1"
},
"dependencies": {
"@noir-lang/backend_barretenberg": "0.19.2",
"@noir-lang/noir_js": "0.19.2",
"ethers": "^6.8.1",
"reflect-metadata": "^0.1.14"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment