diff --git a/.gitignore b/.gitignore
index 31bda973..19d0ace3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,7 +25,7 @@ circuits/*.r1cs
circuits/*.vkey.json
circuits/*.wasm
circuits/*.zkey
-contracts/*Verifier.sol
+# contracts/*Verifier.sol
# contractData/12345-*
# contractData/ABI-12345*
@@ -47,7 +47,7 @@ public.json
verification_key.json
*_verification_key.json
# !public/*_verification_key.json
-*Verifier.sol
+# *Verifier.sol
*.sym
# Ignore all .zkey files except those inside the public folder
diff --git a/README.md b/README.md
index c90ee000..bfd4e27e 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,10 @@
# Anybody Problem
-Anybody Problem is a circom project that models the movement of any number of `n` bodies using classic newtonian-like physics over any number of `s` steps. There are two versions:
-
-## Anybody Problem NFT
-
-The Anybody Problem NFT is a simulation of the bodies moving in space over time. Proofs are generated over `s` steps with `n` bodies and verified on-chain. This version is represented in the top level `nft.circom` circuit [here](./circuits/nft.circom).
+Anybody Problem is a circom project that models the movement of any number of `n` bodies using classic newtonian-like physics over any number of `s` steps.
## Anybody Problem Game
-The Anybody Problem Game adds an additional `missiles` input that allows a user to fire missiles at the bodies in order to destroy them. This version is represented in the top level `stepState.circom` circuit [here](./circuits/stepState.circom). A very rough draft of the game can be played at https://okwme.github.io/anybody-problem.
+The Anybody Problem Game adds an additional `missiles` input that allows a user to fire missiles at the bodies in order to destroy them. This version is represented in the top level `stepState.circom` circuit [here](./circuits/stepState.circom). The game is live at [anybody.gg](https://anybody.gg)
## Circuits
@@ -98,15 +94,6 @@ This circuit limits the value of an input to a minimum value. It also accepts an
- `input rather` - The alternative value
- `output out` - The output value
-### [nft(totalBodies, steps)](./circuits/nft.circom)
-
-This circuit is the top level circuit for the NFT version of Anybody Problem. It takes in the initial state of the bodies and the number of steps to simulate and outputs the resulting bodies.
-
-- `totalBodies` - The total number of bodies in the simulation
-- `steps` - The total number of steps to simulate
-- `input bodies[totalBodies][5]` - An array of length `totalBodies` for each body. Each body has 5 inputs: `position_x`, `position_y`, `vector_x`, `vector_y` and `radius/mass`. These are all scaled up by a factor of 10\*\*8.
-- `output out_bodies[totalBodies][5]` - An array of length `totalBodies` for each body. Each body has 5 outputs: `position_x`, `position_y`, `vector_x`, `vector_y` and `radius/mass`. These are all scaled up by a factor of 10\*\*8.
-
### [StepState(totalBodies, steps)](./circuits/stepState.circom)
This is the top level circuit for the game version of Anybody Problem. It takes in the initial state of the bodies, the number of steps to simulate and the missiles to fire and outputs the resulting bodies.
@@ -117,6 +104,46 @@ This is the top level circuit for the game version of Anybody Problem. It takes
- `input missiles[steps + 1][5]` - An array of length `steps + 1` for each missile. Each missile has 5 inputs: `position_x`, `position_y`, `vector_x`, `vector_y` and `radius/mass`. These are all scaled up by a factor of 10\*\*8.
- `output out_bodies[totalBodies][5]` - An array of length `totalBodies` for each body. Each body has 5 outputs: `position_x`, `position_y`, `vector_x`, `vector_y` and `radius/mass`. These are all scaled up by a factor of 10\*\*8.
+## Compilation
+
+### Development
+
+In order to run tests you need to have compiled circuits generated. You can do this by running:
+
+```bash
+yarn circom:game-test
+```
+
+This will generate smaller versions of the circuits, each only covering 20 frames of gameplay at a time. These should allow you to run most tests, the exception being `stepstate.test.js` where there is a test used to check proofs generated from real games called "passes one off check input".
+
+### Production
+
+To prepare for production, run the following command:
+
+```bash
+yarn circom:game-prod
+```
+
+This might take a while to generate but it will only produce proofs for 4 bodies at 250 frames of gameplay and 6 bodies at 125 frames of gameplay. All levels can be proven with these two circuits because the missing bodies are added with radius of 0 so they don't impact the simulation.
+
+### Sindri
+
+While games can be proven in browser, the variation of hardware prevents accurate prognosis of which machines are capabale of doing so in a reasonable time. As such we are using the service [Sindri](https://sindri.app) to generate proofs reliably fast. To ensure Sindri is unable to generate valid but incorrect proofs, we generate the prover files locally and then upload them to Sindri. To do this ensure the `zkey` file is named the same as the circuit file and is referenced with the same name as that used in `circuitPath` in the `sindri.json` file. For example, when uploading the zkey for `game_4_250.circom` that contains the `StepState` circuit, the `sindri.json` looks like this:
+
+```json
+{
+ "$schema": "https://forge.sindri.app/api/v1/sindri-manifest-schema.json",
+ "name": "game_4_250_v7",
+ "circuitType": "circom",
+ "circuitPath": "./game_4_250.circom",
+ "curve": "bn254",
+ "provingScheme": "groth16",
+ "witnessCompiler": "c++"
+}
+```
+
+and the `zkey` is saved at `./circuits/game_4_250.zkey`.
+
## Tests
To run rudimentary tests on the various circuits use the following command:
@@ -128,6 +155,37 @@ yarn test
You should see something like:
```bash
+> yarn test
+yarn run v1.22.22
+$ hardhat test
+ ·------------------------|--------------------------------|--------------------------------·
+ | Solc version: 0.6.11 · Optimizer enabled: false · Runs: 200 │
+ ·························|································|·································
+ | Contract Name · Deployed size (KiB) (change) · Initcode size (KiB) (change) │
+ ·························|································|·································
+ | AnybodyProblem · 19.820 (0.000) · 21.935 (0.000) │
+ ·························|································|·································
+ | AnybodyProblemMock · 20.123 (0.000) · 22.237 (0.000) │
+ ·························|································|·································
+ | AnybodyProblemV0 · 18.953 (0.000) · 21.295 (0.000) │
+ ·························|································|·································
+ | AnybodyProblemV0Mock · 19.200 (0.000) · 21.542 (0.000) │
+ ·························|································|·································
+ | Assets1 · 19.754 (0.000) · 19.781 (0.000) │
+ ·························|································|·································
+ | Assets2 · 23.139 (0.000) · 23.167 (0.000) │
+ ·························|································|·································
+ | Assets3 · 20.617 (0.000) · 20.645 (0.000) │
+ ·························|································|·································
+ | Assets4 · 16.870 (0.000) · 16.897 (0.000) │
+ ·························|································|·································
+ | Assets5 · 16.719 (0.000) · 16.746 (0.000) │
+ ·························|································|·································
+ | ExternalMetadata · 18.384 (0.000) · 18.580 (0.000) │
+ ·························|································|·································
+ | Speedruns · 7.716 (0.000) · 8.009 (0.000) │
+ ·------------------------|--------------------------------|--------------------------------·
+
absoluteValueSubtraction circuit
✔ produces a witness with valid constraints
✔ has the correct output
@@ -136,25 +194,9 @@ You should see something like:
✔ produces a witness with valid constraints
✔ has the correct output
- Bodies Tests
- ✔ has the correct bodies, dust addresses
- ✔ onlyOwner functions are really only Owner
- ✔ updates dust price correctly
- ✔ has all the correct interfaces
- ✔ fallback and receive functions revert
- ✔ onlyProblem functions can only be called by Problems address
- ✔ matches seeds between Bodies and Problems contracts
- ✔ mints a new body after receiving Dust
- ✔ fails when you try to mint a body for a problem you do not own
- ✔ validate second mint event
- ✔ succeeds adding a body into a problem
- ✔ removes a body that was added into a problem
- ✔ mints a body, adds it to a problem, then mints another body
- - combines two bodies correctly
- ✔ fails to mint an 11th body
-
calculateForceMain circuit
✔ produces a witness with valid constraints
+ - can check the differnce in speed calculating with witness vs anybody.js
✔ has the correct output
detectCollisionMain circuit
@@ -162,7 +204,7 @@ You should see something like:
✔ has the correct output
forceAccumulatorMain circuit
- ✔ produces a witness with valid constraints
+ ✔ produces a witness with valid constraints (41ms)
✔ has the correct output
getDistanceMain circuit
@@ -177,65 +219,163 @@ You should see something like:
✔ produces a witness with valid constraints
✔ has the correct output
- ProblemMetadata Tests
- ✔ has the correct problems address
- ✔ onlyOwner functions are really only Owner
- ✔ creates an SVG
-
- BoodyMetadata Tests
- ✔ has the correct problems address
- ✔ onlyOwner functions are really only Owner
- ✔ creates an SVG
-
nft circuit
- ✔ produces a witness with valid constraints
- ✔ has the correct output
- ✔ NftVerifier.sol works
-
- Problem Tests
- ✔ has the correct verifiers problemMetadata, bodies, dust, solver addresses
- ✔ onlyOwner functions are really only Owner
- ✔ onlySolver functions are really only Solver
- ✔ has all the correct interfaces
- ✔ emits 'EthMoved' events when eth is moved
- ✔ fails when unitialized
- ✔ fails to adminMint when uninitialized
- ✔ fails to adminMint when not owner
- - sends money to splitter correctly
- ✔ must be unpaused
- ✔ succeeds to mint
- ✔ succeeds to mint with fallback method
- ✔ succeeds to mint with explicit recipient
- ✔ token ID is correctly correlated
- ✔ validate second mint event
- ✔ checks whether mint fails with wrong price and succeeds even when price = 0
- ✔ adminMint from owner address
- ✔ stores the verifiers in the correct order of the mapping
- ✔ mints bodies that contain valid values
- ✔ mints a body via mintBodyToProblem
-
- Solver Tests
- ✔ has the correct problems, dust addresses
- ✔ onlyOwner functions are really only Owner
- ✔ fallback and receive functions revert
- ✔ creates a proof for 3 bodies
- ✔ creates multiple proofs in a row
- ✔ creates proofs for multiple bodies
- ✔ has the correct body boost amount
- ✔ adds a body, removes a body, creates a proof
- - adds two bodies, removes first body, creates a proof
+ - produces a witness with valid constraints
+ - has the correct output
+ - NftVerifier.sol works
stepStateTest circuit
- ✔ produces a witness with valid constraints
- ✔ has the correct output
-
- Utilities work as expected
- ✔ should only allow valid seeds
-
- 66 passing (1m)
- 3 pending
-
-✨ Done in 64.01s.
+ ✔ produces a witness with valid constraints (277ms)
+ ✔ passes one off check input (24710ms)
+ ✔ has the correct output when one body and missile positioned to hit and it returns correct number of steps (70ms)
+
+ AnybodyProblem Tests
+ ✔ has the correct verifiers, externalMetadata, speedruns addresses (397ms)
+ ✔ stores the verifiers in the correct order of the mapping (300ms)
+ - starts week correctly
+ ✔ has the correct Speedruns addresses (303ms)
+ ✔ onlyOwner functions are really only Owner (397ms)
+ ✔ fallback and receive functions revert (312ms)
+ ✔ creates a proof for level 1 (2680ms)
+ ✔ solves the first level using mock (4518ms)
+ ✔ must be unpaused (334ms)
+ ✔ solves all levels async using mock (26775ms)
+ ✔ solves all levels in a single tx (14845ms)
+ ✔ has the same results for generateLevelData as anybody.js (392ms)
+ ✔ has correct getLevelFromInputs with no dummy (312ms)
+ ✔ has correct getLevelFromInputs with dummy (309ms)
+ ✔ returns correct currentLevel (4577ms)
+ ✔ performs an upgrade and the records are correct (29157ms)
+ - emits arbitrary events within Speedruns
+ - tests an arbitrary tx
+
+ ExternalMetadata Tests
+ ✔ has the correct anybodyProblem and speedruns addresses (355ms)
+ ✔ onlyOwner functions are really only Owner (339ms)
+ ✔ has valid json (17636ms)
+
+ Speedruns Tests
+ ✔ onlyAnybodyProblem functions can only be called by AnybodyProblem address (387ms)
+ ✔ has all the correct interfaces (354ms)
+
+
+ 39 passing (2m)
+ 7 pending
+
+······························································································································································································
+| Solidity and Network Configuration │
+·········································································································|·················|···············|·················|································
+| Solidity: 0.6.11 · Optim: false · Runs: 200 · viaIR: false · Block: 20,000,000 gas │
+·········································································································|·················|···············|·················|································
+| Network: ETHEREUM · L1: 0.10000 gwei · · 2521.10 usd/eth │
+·········································································································|·················|···············|·················|················|···············
+| Contracts / Methods · Min · Max · Avg · # calls · usd (avg) │
+·········································································································|·················|···············|·················|················|···············
+| AnybodyProblem · │
+·········································································································|·················|···············|·················|················|···············
+| batchSolve(uint256,bool,uint256,uint256[],uint256[2][],uint256[2][2][],uint256[2][],uint256[][]) · - · - · 1,263,522 · 2 · 0.32 │
+·········································································································|·················|···············|·················|················|···············
+| recoverUnsuccessfulPayment(address) · - · - · 30,247 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updateDiscount(uint256) · - · - · 24,462 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updatePaused(bool) · - · - · 45,769 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updatePriceToMint(uint256) · - · - · 24,924 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updatePriceToSave(uint256) · - · - · 27,232 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updateProceedRecipient(address) · - · - · 30,194 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updateSpeedrunsAddress(address) · - · - · 29,490 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updateVerifier(address,uint256,uint256) · - · - · 46,664 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| AnybodyProblemMock · │
+·········································································································|·················|···············|·················|················|···············
+| batchSolve(uint256,bool,uint256,uint256[],uint256[2][],uint256[2][2][],uint256[2][],uint256[][]) · 1,902,008 · 9,547,209 · 4,452,577 · 37 · 1.12 │
+·········································································································|·················|···············|·················|················|···············
+| setMockedBodyDataByLevel(uint256,(uint256,uint256,uint256,uint256,uint256,uint256,bytes32)[6]) · 124,905 · 942,401 · 556,054 · 28 · 0.14 │
+·········································································································|·················|···············|·················|················|···············
+| updatePaused(bool) · - · - · 45,763 · 1 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updateProceedRecipient(address) · - · - · 30,232 · 1 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| AnybodyProblemV0Mock · │
+·········································································································|·················|···············|·················|················|···············
+| batchSolve(uint256,bool,uint256,uint256[],uint256[2][],uint256[2][2][],uint256[2][],uint256[][]) · - · - · 8,031,319 · 3 · 2.02 │
+·········································································································|·················|···············|·················|················|···············
+| setMockedBodyDataByLevel(uint256,(uint256,uint256,uint256,uint256,uint256,uint256,bytes32)[6]) · 383,080 · 942,416 · 662,753 · 5 · 0.17 │
+·········································································································|·················|···············|·················|················|···············
+| ExternalMetadata · │
+·········································································································|·················|···············|·················|················|···············
+| setAssets(address[5]) · 137,001 · 137,013 · 137,011 · 20 · 0.03 │
+·········································································································|·················|···············|·················|················|···············
+| setupSVGPaths() · - · - · 1,806,648 · 40 · 0.46 │
+·········································································································|·················|···············|·················|················|···············
+| updateAnybodyProblemAddress(address) · 29,326 · 46,438 · 37,479 · 42 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updateSpeedrunsAddress(address) · 29,008 · 46,108 · 44,553 · 22 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| __burn(address,uint256,uint256) · - · - · 28,073 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| __mint(address,uint256,uint256,bytes) · - · - · 52,830 · 4 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| __safeTransferFrom(address,address,uint256,uint256,bytes) · - · - · 53,906 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| __setApprovalForAll(address,address,bool) · - · - · 48,789 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| Speedruns · │
+·········································································································|·················|···············|·················|················|···············
+| emitGenericEvent(bytes32[],bytes) · - · - · 25,003 · 2 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| updateAnybodyProblemAddress(address) · 29,172 · 46,284 · 37,524 · 41 · 0.01 │
+·········································································································|·················|···············|·················|················|···············
+| Deployments · · % of limit · │
+·········································································································|·················|···············|·················|················|···············
+| AnybodyProblem · 4,863,675 · 4,863,699 · 4,863,698 · 24.3 % · 1.23 │
+·········································································································|·················|···············|·················|················|···············
+| AnybodyProblemMock · 4,931,197 · 4,990,909 · 4,943,147 · 24.7 % · 1.25 │
+·········································································································|·················|···············|·················|················|···············
+| AnybodyProblemV0 · 4,688,531 · 4,688,543 · 4,688,539 · 23.4 % · 1.18 │
+·········································································································|·················|···············|·················|················|···············
+| AnybodyProblemV0Mock · 4,743,168 · 4,743,192 · 4,743,183 · 23.7 % · 1.20 │
+·········································································································|·················|···············|·················|················|···············
+| Assets1 · - · - · 4,427,169 · 22.1 % · 1.12 │
+·········································································································|·················|···············|·················|················|···············
+| Assets2 · - · - · 5,177,023 · 25.9 % · 1.31 │
+·········································································································|·················|···············|·················|················|···············
+| Assets3 · - · - · 4,618,748 · 23.1 % · 1.16 │
+·········································································································|·················|···············|·················|················|···············
+| Assets4 · - · - · 3,788,953 · 18.9 % · 0.96 │
+·········································································································|·················|···············|·················|················|···············
+| Assets5 · - · - · 3,755,434 · 18.8 % · 0.95 │
+·········································································································|·················|···············|·················|················|···············
+| ExternalMetadata · 4,170,569 · 4,170,581 · 4,170,580 · 20.9 % · 1.05 │
+·········································································································|·················|···············|·················|················|···············
+| Game_2_20Verifier.sol:Groth16Verifier · - · - · 1,389,269 · 6.9 % · 0.35 │
+·········································································································|·················|···············|·················|················|···············
+| Game_3_20Verifier.sol:Groth16Verifier · - · - · 1,739,395 · 8.7 % · 0.44 │
+·········································································································|·················|···············|·················|················|···············
+| Game_4_20Verifier.sol:Groth16Verifier · - · - · 2,089,585 · 10.4 % · 0.53 │
+·········································································································|·················|···············|·················|················|···············
+| Game_5_20Verifier.sol:Groth16Verifier · - · - · 2,440,280 · 12.2 % · 0.62 │
+·········································································································|·················|···············|·················|················|···············
+| Game_6_20Verifier.sol:Groth16Verifier · - · - · 2,790,971 · 14 % · 0.70 │
+·········································································································|·················|···············|·················|················|···············
+| Speedruns · - · - · 1,790,475 · 9 % · 0.45 │
+·········································································································|·················|···············|·················|················|···············
+| ThemeGroupBlues.sol:ThemeGroup · - · - · 1,002,009 · 5 % · 0.25 │
+·········································································································|·················|···············|·················|················|···············
+| Key │
+······························································································································································································
+| ◯ Execution gas for this method does not include intrinsic gas overhead │
+······························································································································································································
+| △ Cost was non-zero but below the precision setting for the currency display (see options) │
+······························································································································································································
+| Toolchain: hardhat │
+······························································································································································································
+✨ Done in 133.89s.
```
## Performance
@@ -252,120 +392,4 @@ Currently the project is targeting [powersOfTau28_hez_final_20.ptau](https://git
| getDistance(20) | 88 | 454.55 |
| limiter(252) | 254 | 157.48 |
| lowerLimiter(252) | 254 | 157.48 |
-| nft(3, 10) | 15_184 | 26.34 |
| stepState(3, 10) | 19_121 | 20.92 |
-| nft_3_20 | 33_060 | |
-| nft_4_20 | 55_480 | |
-
-### Tick to Dust Body Boost Chart
-
-```
-Generated proof in 0m 3s 121ms for 20 ticks with 3 bodies
-Tick rate: 6.41 ticks/s
-Tick rate per body: 2.14 ticks/s
-Dust rate: 6.41 dust/s
-Dust rate per body: 2.14 dust/s
-
-Generated proof in 0m 3s 894ms for 20 ticks with 4 bodies
-Tick rate: 5.14 ticks/s
-Tick rate per body: 1.28 ticks/s
-Dust rate: 10.27 dust/s
-Dust rate per body: 2.57 dust/s
-
-Generated proof in 0m 6s 701ms for 20 ticks with 5 bodies
-Tick rate: 2.98 ticks/s
-Tick rate per body: 0.60 ticks/s
-Dust rate: 11.94 dust/s
-Dust rate per body: 2.39 dust/s
-
-Generated proof in 0m 7s 910ms for 20 ticks with 6 bodies
-Tick rate: 2.53 ticks/s
-Tick rate per body: 0.42 ticks/s
-Dust rate: 20.23 dust/s
-Dust rate per body: 3.37 dust/s
-
-Generated proof in 0m 12s 961ms for 20 ticks with 7 bodies
-Tick rate: 1.54 ticks/s
-Tick rate per body: 0.22 ticks/s
-Dust rate: 24.69 dust/s
-Dust rate per body: 3.53 dust/s
-
-Generated proof in 0m 14s 497ms for 20 ticks with 8 bodies
-Tick rate: 1.38 ticks/s
-Tick rate per body: 0.17 ticks/s
-Dust rate: 44.15 dust/s
-Dust rate per body: 5.52 dust/s
-
-Generated proof in 0m 16s 339ms for 20 ticks with 9 bodies
-Tick rate: 1.22 ticks/s
-Tick rate per body: 0.14 ticks/s
-Dust rate: 78.34 dust/s
-Dust rate per body: 8.70 dust/s
-
-Generated proof in 0m 25s 522ms for 20 ticks with 10 bodies
-Tick rate: 0.78 ticks/s
-Tick rate per body: 0.08 ticks/s
-Dust rate: 100.31 dust/s
-Dust rate per body: 10.03 dust/s
-```
-
-# built using circom-starter
-
-A basic circom project using [Hardhat](https://github.com/nomiclabs/hardhat) and [hardhat-circom](https://github.com/projectsophon/hardhat-circom). This combines the multiple steps of the [Circom](https://github.com/iden3/circom) and [SnarkJS](https://github.com/iden3/snarkjs) workflow into your [Hardhat](https://hardhat.org) workflow.
-
-By providing configuration containing your Phase 1 Powers of Tau and circuits, this plugin will:
-
-1. Compile the circuits
-2. Apply the final beacon
-3. Output your `wasm` and `zkey` files
-4. Generate and output a `Verifier.sol`
-
-## Documentation
-
-See the source projects for full documentation and configuration
-
-# Circom + Contracts setup
-
-## Install
-
-`yarn` to install dependencies
-
-## Development builds
-
-`yarn circom:dev` to build deterministic development circuits.
-
-Further, for debugging purposes, you may wish to inspect the intermediate files. This is possible with the `--debug` flag which the `circom:dev` task enables by default. You'll find them (by default) in `artifacts/circom/`
-
-To build a single circuit during development, you can use the `--circuit` CLI parameter. For example, if you make a change to `hash.circom` and you want to _only_ rebuild that, you can run `yarn circom:dev --circuit hash`.
-
-## Production builds
-
-`yarn circom:prod` for production builds (using `Date.now()` as entropy)
-
-# Webapp setup
-
-```
-yarn install
-```
-
-### Compiles and hot-reloads for development
-
-```
-yarn serve
-```
-
-### Compiles and minifies for production
-
-```
-yarn build
-```
-
-### Lints and fixes files
-
-```
-yarn lint
-```
-
-### Customize configuration
-
-See [Configuration Reference](https://cli.vuejs.org/config/).
diff --git a/circuits/calculateMissile.circom b/circuits/calculateMissile.circom
index 8596a322..923083ae 100644
--- a/circuits/calculateMissile.circom
+++ b/circuits/calculateMissile.circom
@@ -96,18 +96,41 @@ template CalculateMissile() {
calcMissilePositionLimiterX.in <== new_pos[0]; // maxBits: 20 (maxNum: 1_030_000)
calcMissilePositionLimiterX.limit <== windowWidthScaled; // maxBits: 20 (maxNum: 1_030_000)
calcMissilePositionLimiterX.rather <== 0;
- // log("positionLimiterX out", calcMissilePositionLimiterX.out);
+ // log("calcMissilePositionLimiterX out", calcMissilePositionLimiterX.out);
// This is for the radius of the missile
- // If it went off screen in the x direction the radius should go to 0
- // if not then we want to use the real radius until it's checked
+ // If it went off screen in the x direction (x > windowWidth) the radius should go to 0.
+ // However it is also possible the actual position of x is 0 (vertical shot)
+ // so this must first be checked.
+ // If the missile is not off screen then we want to use the real radius until it's checked
// on the y dimension
+
+ // first confirm if the new position is 0
component calcMissileIsZeroX = IsZero();
calcMissileIsZeroX.in <== calcMissilePositionLimiterX.out;
+
+ // next confirm whether the original position was also 0
+ component originalXIsZero = IsZero();
+ originalXIsZero.in <== new_pos[0];
+
+ // save the result as a NOT
+ component originalXIsNotZero = NOT();
+ originalXIsNotZero.in <== originalXIsZero.out;
+
+ // if the new position is 0 and the original position is not 0 then the radius should go to 0
+ component makeRadiusZero = AND();
+ makeRadiusZero.a <== originalXIsNotZero.out;
+ makeRadiusZero.b <== calcMissileIsZeroX.out;
+
+ // radius should go to 0 if new x position is 0 BUT original X is NOT 0
+ // radius should go to 0 if new x position is 0 AND original X is NOT 0
+ // radius should NOT go to 0 if new x position is 0 AND original X is 0
+ // radius should go to 0 if new x posisiton is 0 AND new x position is 0
+
component muxXDecidesRadius = Mux1();
muxXDecidesRadius.c[0] <== in_missile[4];
muxXDecidesRadius.c[1] <== 0;
- muxXDecidesRadius.s <== calcMissileIsZeroX.out;
+ muxXDecidesRadius.s <== makeRadiusZero.out;
// Since the plane goes from 0 to windowWidthScaled on the y axis from top to bottom
// the missile will approach 0 after starting at windowWidthScaled
@@ -119,7 +142,6 @@ template CalculateMissile() {
// log("new_pos[1]", new_pos[1]);
// log("positionLowerLimiterY in", new_pos[1]);
// log("positionLowerLimiterY limit", maxMissileVectorScaled);
- // also check the general overboard logic. Would be an edge case but possible.
component positionLowerLimiterY = LowerLimiter(20); // TODO: confirm type matches bit limit
positionLowerLimiterY.in <== new_pos[1] + maxMissileVectorScaled; // maxBits: 20 (maxNum: 1_030_000)
positionLowerLimiterY.limit <== maxMissileVectorScaled; // maxBits: 15 (maxNum: 30_000)
diff --git a/circuits/sindri.json b/circuits/sindri.json
index 5d8d367c..005090a2 100644
--- a/circuits/sindri.json
+++ b/circuits/sindri.json
@@ -1,6 +1,6 @@
{
"$schema": "https://forge.sindri.app/api/v1/sindri-manifest-schema.json",
- "name": "game_6_125_v6",
+ "name": "game_6_125_v7",
"circuitType": "circom",
"circuitPath": "./game_6_125.circom",
"curve": "bn254",
diff --git a/contracts/AnybodyProblem.sol b/contracts/AnybodyProblem.sol
index 16bfe017..d62725d7 100644
--- a/contracts/AnybodyProblem.sol
+++ b/contracts/AnybodyProblem.sol
@@ -2,10 +2,7 @@
pragma solidity ^0.8.0;
-import {Groth16Verifier as Groth16Verifier2} from './Game_2_20Verifier.sol';
-import {Groth16Verifier as Groth16Verifier3} from './Game_3_20Verifier.sol';
import {Groth16Verifier as Groth16Verifier4} from './Game_4_20Verifier.sol';
-import {Groth16Verifier as Groth16Verifier5} from './Game_5_20Verifier.sol';
import {Groth16Verifier as Groth16Verifier6} from './Game_6_20Verifier.sol';
import '@openzeppelin/contracts/token/common/ERC2981.sol';
@@ -17,16 +14,20 @@ import './ExternalMetadata.sol';
contract AnybodyProblem is Ownable, ERC2981 {
uint256 public constant LEVELS = 5;
uint256 public constant SECONDS_IN_A_DAY = 86400;
- uint256 public constant SECONDS_IN_A_WEEK = SECONDS_IN_A_DAY * 7;
uint256 public constant FIRST_SUNDAY_AT_6_PM_UTC = 324000;
bool public paused = false;
uint256 public priceToMint = 0.0025 ether;
uint256 public priceToSave = 0 ether;
uint256 public discount = 2;
+
+ uint256 public constant FIRST_DAY = 1723766400;
+ uint256 public deployDay;
+ address payable public previousAB;
address payable public proceedRecipient;
address public externalMetadata;
address payable public speedruns;
+
// uint256 public constant maxTick = 25 * 60; // 25 fps * 60 sec = 1,500 ticks max
// level duration is numberOfBaddies * 10sec (multiplied by 25 because of 25 FPS)
uint256[5] public maxTicksByLevelIndex = [
@@ -51,6 +52,13 @@ contract AnybodyProblem is Ownable, ERC2981 {
uint256 day;
Level[] levels;
}
+ struct RunWithoutLevels {
+ address owner;
+ bool solved; // redundant by accumulating A
+ uint256 accumulativeTime; // redundant by accumulating C
+ bytes32 seed;
+ uint256 day;
+ }
struct Level {
bool solved; // redundant A
uint256 time; // redundant C
@@ -68,34 +76,76 @@ contract AnybodyProblem is Ownable, ERC2981 {
bytes32 seed;
}
- mapping(uint256 => uint256[3]) public fastestByDay; // day => [fastest, 2nd fastest, 3rd fastest runId]
- address[3] public mostGames;
- address[3] public longestStreak;
-
struct Record {
+ bool updated;
+ uint256 total;
+ uint256 lastPlayed;
+ uint256 streak;
+ }
+
+ struct OldRecordType {
uint256 total;
uint256 lastPlayed;
uint256 streak;
}
- mapping(address => Record) public gamesPlayed;
- mapping(address => mapping(uint256 => uint256[7])) public weeklyRecords;
- mapping(uint256 => address[3]) public fastestByWeek;
- // NOTE: initialize with length of 1 so Runs are not 0 indexed (runId == index of the run array)
- Run[] public runs = new Run[](1);
+ mapping(uint256 => uint256[3]) public fastestByDay_; // day => [fastest, 2nd fastest, 3rd fastest runId]
+ mapping(uint256 => uint256[3]) public slowestByDay_; // day => [slowest, 2nd slowest, 3rd slowest runId]
+ address[3] public mostGames;
+ address[3] public longestStreak;
+
+ mapping(uint256 => mapping(address => bool)) public claimedByLeader; // day => player => claimed
+ mapping(address => Record) public gamesPlayed_;
+ mapping(uint256 => Run) public runs_; // indexed on RunId
+ uint256 public totalRuns;
// mapping is body count to tickcount to address
mapping(uint256 => mapping(uint256 => address)) public verifiers;
mapping(bytes32 => bool) public usedProofs;
+ event RunCreated(uint256 runId, uint256 day, bytes32 seed);
+ event RunSolved(
+ address indexed player,
+ uint256 indexed runId,
+ uint256 accumulativeTime,
+ uint256 day
+ );
+ event LevelCreated(uint256 runId, uint256 level, bytes32 seed, uint256 day);
+ event LevelSolved(
+ address indexed player,
+ uint256 indexed runId,
+ uint256 indexed level,
+ uint256 time,
+ uint256 day
+ );
+ event EthMoved(
+ address indexed to,
+ bool indexed success,
+ bytes returnData,
+ uint256 amount
+ );
+
constructor(
address payable proceedRecipient_,
address payable speedruns_,
address externalMetadata_,
address[] memory verifiers_,
uint256[] memory verifiersTicks,
- uint256[] memory verifiersBodies
+ uint256[] memory verifiersBodies,
+ address payable previousAB_
) {
+ deployDay = currentDay();
+ updatePreviousAB(previousAB_);
+ if (previousAB != address(0)) {
+ totalRuns = AnybodyProblem(previousAB).runCount();
+ longestStreak[0] = AnybodyProblem(previousAB).longestStreak(0);
+ longestStreak[1] = AnybodyProblem(previousAB).longestStreak(1);
+ longestStreak[2] = AnybodyProblem(previousAB).longestStreak(2);
+ mostGames[0] = AnybodyProblem(previousAB).mostGames(0);
+ mostGames[1] = AnybodyProblem(previousAB).mostGames(1);
+ mostGames[2] = AnybodyProblem(previousAB).mostGames(2);
+ }
+
updateProceedRecipient(proceedRecipient_);
updateSpeedrunsAddress(speedruns_);
updateExternalMetadata(externalMetadata_);
@@ -114,87 +164,109 @@ contract AnybodyProblem is Ownable, ERC2981 {
revert('no fallback thank you');
}
- event RunCreated(uint256 runId, uint256 day, bytes32 seed);
- event RunSolved(
- address indexed player,
- uint256 indexed runId,
- uint256 accumulativeTime,
- uint256 day
- );
- event LevelCreated(uint256 runId, uint256 level, bytes32 seed, uint256 day);
- event LevelSolved(
- address indexed player,
- uint256 indexed runId,
- uint256 indexed level,
- uint256 time,
- uint256 day
- );
- event EthMoved(
- address indexed to,
- bool indexed success,
- bytes returnData,
- uint256 amount
- );
+ function runs(uint256 runId) public view returns (Run memory) {
+ if (runs_[runId].owner == address(0)) {
+ (bool success, bytes memory data) = previousAB.staticcall(
+ abi.encodeWithSignature('runs(uint256)', runId)
+ );
+ if (success && data.length > 0) {
+ RunWithoutLevels memory r = abi.decode(
+ data,
+ (RunWithoutLevels)
+ );
+ Run memory run = Run({
+ owner: r.owner,
+ solved: r.solved,
+ accumulativeTime: r.accumulativeTime,
+ seed: r.seed,
+ day: r.day,
+ levels: getLevelsData(runId)
+ });
+ return run;
+ } else {
+ return runs_[runId];
+ }
+ } else {
+ return runs_[runId];
+ }
+ }
- // NOTE: the only publicly available function that isn't protected by a modifier
- function batchSolve(
- uint256 runId,
- bool alsoMint,
- uint256 day,
- uint256[] memory tickCounts,
- uint[2][] memory a,
- uint[2][2][] memory b,
- uint[2][] memory c,
- uint[][] memory input
- ) public payable {
- if (day == 0) {
- day = currentDay();
+ function gamesPlayed(address player) public view returns (Record memory) {
+ Record memory record = gamesPlayed_[player];
+ if (!record.updated) {
+ (bool success, bytes memory data) = previousAB.staticcall(
+ abi.encodeWithSignature('gamesPlayed(address)', player)
+ );
+ OldRecordType memory previousRecord;
+ if (success && data.length > 0) {
+ previousRecord = abi.decode(data, (OldRecordType));
+ }
+ Record memory combinedRecord = Record({
+ updated: false,
+ total: record.total + previousRecord.total,
+ lastPlayed: previousRecord.lastPlayed,
+ streak: previousRecord.streak
+ });
+ return combinedRecord;
+ } else {
+ return record;
}
- require(
- day % SECONDS_IN_A_DAY == 0,
- 'One problem per day, invalid day'
- );
- require(day <= currentDay(), 'Cannot solve future problems');
- require(!paused, 'Contract is paused');
- if (runId == 0) {
- runId = addNewRun(day);
- addNewLevelData(runId);
+ }
+
+ function fastestByDay(
+ uint256 day
+ ) public view returns (uint256[3] memory fastest) {
+ uint256[3] memory localFastest = fastestByDay_[day];
+ for (uint256 i = 0; i < 3; i++) {
+ if (localFastest[i] == 0) {
+ (bool success, bytes memory data) = previousAB.staticcall(
+ abi.encodeWithSignature(
+ 'fastestByDay(uint256,uint256)',
+ day,
+ i
+ )
+ );
+ if (success && data.length > 0) {
+ fastest[i] = abi.decode(data, (uint256));
+ }
+ } else {
+ fastest[i] = localFastest[i];
+ }
}
- require(
- runs[runId].owner == msg.sender,
- 'Only the owner of the run can solve it'
- );
- require(!runs[runId].solved, 'Run already solved');
+ return fastest;
+ }
- require(
- day == runs[runId].day,
- 'Can only solve runs on the current day'
- );
+ function slowestByDay(uint256 day) public view returns (uint256[3] memory) {
+ return slowestByDay_[day];
+ }
- for (uint256 i = 0; i < input.length; i++) {
- verifyLevelChunk(
- runId,
- alsoMint,
- tickCounts[i],
- day,
- a[i],
- b[i],
- c[i],
- input[i]
- );
- }
- // TODO: decide whether this is necessary
- // require(runs[runId].solved, "Must solve all levels to complete run");
+ function nextRunId() public view returns (uint256) {
+ return runCount() + 1;
}
function runCount() public view returns (uint256) {
- return runs.length - 1;
+ return totalRuns;
}
function getLevelsData(
uint256 runId
) public view returns (Level[] memory levels) {
- return runs[runId].levels;
+ if (!runExists(runId)) {
+ (bool success, bytes memory data) = previousAB.staticcall(
+ abi.encodeWithSignature('getLevelsData(uint256)', runId)
+ );
+ if (success && data.length > 0) {
+ return abi.decode(data, (Level[]));
+ } else {
+ return runs_[runId].levels;
+ }
+ } else {
+ return runs_[runId].levels;
+ }
+ }
+
+ function runExists(uint256 runId) public view returns (bool) {
+ return runs_[runId].owner != address(0);
}
function generateLevelData(
@@ -290,7 +362,7 @@ contract AnybodyProblem is Ownable, ERC2981 {
}
function currentLevel(uint256 runId) public view returns (uint256) {
- return runs[runId].levels.length;
+ return getLevelsData(runId).length;
}
function generateSeed(
@@ -301,38 +373,31 @@ contract AnybodyProblem is Ownable, ERC2981 {
keccak256(abi.encodePacked(id, index, blockhash(block.number - 1)));
}
- // TODO: fix day and week so that days and week begin at same time
- function currentWeek() public view returns (uint256) {
- return
- block.timestamp -
- ((block.timestamp - FIRST_SUNDAY_AT_6_PM_UTC) % SECONDS_IN_A_WEEK);
- }
-
- function timeUntilEndOfWeek() public view returns (uint256) {
- return currentWeek() + SECONDS_IN_A_WEEK - block.timestamp;
- }
-
function currentDay() public view returns (uint256) {
return block.timestamp - (block.timestamp % SECONDS_IN_A_DAY);
}
function addNewLevelData(uint256 runId) internal {
- uint256 day = runs[runId].day;
+ uint256 day = runs(runId).day;
uint256 level = currentLevel(runId) + 1;
Level memory levelData;
levelData.seed = generateSeed(runId, level);
(levelData.tmpBodyData, ) = generateLevelData(day, level);
- runs[runId].levels.push(levelData);
+ runs_[runId].levels.push(levelData);
emit LevelCreated(runId, level, levelData.seed, day);
}
function addNewRun(uint256 day) internal returns (uint256 runId) {
- runId = runs.length;
+ // new Run ID is length of run array. at start it is 1. so first run is 1, then array is 2.
+ // After new deploy, the length of the initial deploy array will be 2. The new array should be 0
+ // and then the new ID will be previous length + new length (2)
+ runId = nextRunId();
Run memory run;
run.owner = msg.sender;
run.seed = generateSeed(runId, 0);
run.day = day;
- runs.push(run);
+ runs_[runId] = run;
+ totalRuns++;
emit RunCreated(runId, day, run.seed);
return runId;
}
@@ -353,11 +418,12 @@ contract AnybodyProblem is Ownable, ERC2981 {
(uint256 intendedLevel, uint256 dummyCount) = getLevelFromInputs(input);
uint256 level = currentLevel(runId);
-
require(intendedLevel == level, 'Previous level not yet complete');
+ Level[] memory levelsData = getLevelsData(runId);
+
uint256 levelIndex = level - 1;
- require(!runs[runId].levels[levelIndex].solved, 'Level already solved');
+ require(!levelsData[levelIndex].solved, 'Level already solved');
uint256 bodyCount = level + 1;
address verifier = verifiers[bodyCount + dummyCount][tickCount];
@@ -370,8 +436,7 @@ contract AnybodyProblem is Ownable, ERC2981 {
// confirm current inflightMissile == previous outflightMissile
// or confirm that curren inflightMissile (x, y) == (0, windowHeight)
- uint256[5] memory storedOutflightMissile = runs[runId]
- .levels[levelIndex]
+ uint256[5] memory storedOutflightMissile = levelsData[levelIndex]
.tmpInflightMissile;
uint256[5] memory newInflightMissile = [
input[5 + 2 * (bodyCount + dummyCount) * 5 + 2 + 0],
@@ -405,13 +470,16 @@ contract AnybodyProblem is Ownable, ERC2981 {
input[3],
input[4]
];
- runs[runId].levels[levelIndex].tmpInflightMissile = newOutflightMissile;
+ runs_[runId]
+ .levels[levelIndex]
+ .tmpInflightMissile = newOutflightMissile;
+ levelsData[levelIndex].tmpInflightMissile = newOutflightMissile;
uint256 time = input[5 + (bodyCount + dummyCount) * 5];
verifyProof((bodyCount + dummyCount), verifier, a, b, c, input);
- Level memory levelData = runs[runId].levels[levelIndex];
+ Level memory levelData = levelsData[levelIndex];
levelData.time += time;
require(
@@ -426,7 +494,6 @@ contract AnybodyProblem is Ownable, ERC2981 {
verifyBodyDataMatches(bodyData, input, (bodyCount + dummyCount), i);
bodyData = extractBodyData(bodyData, input, i);
-
if (i == 0) {
require(
bodyData.radius != 0,
@@ -438,26 +505,33 @@ contract AnybodyProblem is Ownable, ERC2981 {
}
levelData.tmpBodyData[i] = bodyData;
}
- runs[runId].levels[levelIndex] = levelData;
+ runs_[runId].levels[levelIndex] = levelData;
if (bodiesGone == level) {
- runs[runId].levels[levelIndex].solved = true;
+ runs_[runId].levels[levelIndex].solved = true;
emit LevelSolved(msg.sender, runId, level, levelData.time, day);
- runs[runId].accumulativeTime += levelData.time;
+ runs_[runId].accumulativeTime += levelData.time;
if (level == LEVELS) {
- runs[runId].solved = true;
- if (alsoMint) {
- mint(priceToSave + (priceToMint / discount), day);
- } else if (priceToSave > 0) {
- makePayment(priceToSave);
- }
+ runs_[runId].solved = true;
+ gamesPlayed_[msg.sender].total++;
+ addToLeaderboard(runId);
emit RunSolved(
msg.sender,
runId,
- runs[runId].accumulativeTime,
+ runs_[runId].accumulativeTime,
day
);
- gamesPlayed[msg.sender].total++;
- addToLeaderboard(runId);
+ if (alsoMint) {
+ bool playerIsLeader = isLeader(runId);
+ uint256 priceToPay = playerIsLeader
+ ? 0
+ : priceToSave + (priceToMint / discount);
+ if (playerIsLeader) {
+ claimedByLeader[day][msg.sender] = true;
+ }
+ mint(priceToPay, day);
+ } else if (priceToSave > 0) {
+ makePayment(priceToSave);
+ }
} else {
addNewLevelData(runId);
}
@@ -471,37 +545,178 @@ contract AnybodyProblem is Ownable, ERC2981 {
''
);
emit EthMoved(proceedRecipient, sent, data, payment);
+ if (msg.value > payment) {
+ (sent, data) = msg.sender.call{value: msg.value - payment}('');
+ emit EthMoved(msg.sender, sent, data, msg.value - payment);
+ }
}
function mint(uint256 payment, uint256 day) internal {
require(day == currentDay(), 'Can only mint on the current day');
- makePayment(payment);
Speedruns(speedruns).__mint(msg.sender, day, 1, '');
+ makePayment(payment);
}
+ // NOTE: mint and batchSolve are the only publicly available functions
+
function mint() public payable {
+ require(!paused, 'Contract is paused');
mint(priceToMint, currentDay());
}
+ function batchSolve(
+ uint256 runId,
+ bool alsoMint,
+ uint256 day,
+ uint256[] memory tickCounts,
+ uint[2][] memory a,
+ uint[2][2][] memory b,
+ uint[2][] memory c,
+ uint[][] memory input
+ ) public payable {
+ if (day == 0) {
+ day = currentDay();
+ }
+ require(
+ day % SECONDS_IN_A_DAY == 0,
+ 'One problem per day, invalid day'
+ );
+ // TODO: confirm whether we want to only allow range of days
+ // require(day >= FIRST_DAY, 'Day is too early');
+ require(day <= currentDay(), 'Cannot solve future problems');
+ require(!paused, 'Contract is paused');
+ if (runId == 0) {
+ runId = addNewRun(day);
+ addNewLevelData(runId);
+ }
+ require(
+ runs(runId).owner == msg.sender,
+ 'Only the owner of the run can solve it'
+ );
+ require(!runs(runId).solved, 'Run already solved');
+
+ require(
+ day == runs(runId).day,
+ 'Can only solve runs on the current day'
+ );
+
+ for (uint256 i = 0; i < input.length; i++) {
+ verifyLevelChunk(
+ runId,
+ alsoMint,
+ tickCounts[i],
+ day,
+ a[i],
+ b[i],
+ c[i],
+ input[i]
+ );
+ }
+ // NOTE: following line should be included for prod and removed for testing
+ require(runs(runId).solved, 'Must solve all levels to complete run');
+ }
+
function addToLeaderboard(uint256 runId) internal {
addToFastestByDay(runId);
addToLongestStreak(runId);
addToMostPlayed();
+ addToSlowestByDay(runId);
+ }
+
+ function isLeader(uint256 runId) public view returns (bool) {
+ if (claimedByLeader[runs(runId).day][msg.sender]) {
+ return false;
+ }
+ // fastest
+ uint256[3] memory f = fastestByDay(runs(runId).day);
+ if (f[0] == runId) {
+ return true;
+ }
+ // slowest
+ uint256[3] memory s = slowestByDay(runs(runId).day);
+ if (s[0] == runId) {
+ return true;
+ }
+ // TODO: decide if we want to add this?
+ // // most played
+ // if (mostGames[0] == msg.sender) {
+ // return true;
+ // }
+ // longest streak
+ if (longestStreak[0] == msg.sender) {
+ return true;
+ }
+ return false;
+ }
+
+ function addToSlowestByDay(uint256 runId) internal {
+ Run memory run = runs(runId);
+ uint256[3] memory s = slowestByDay(run.day);
+ bool recordBroken;
+ for (uint256 i = 0; i < 3; i++) {
+ Run memory recordRun = runs(s[i]);
+ // if run is slower, or if previous run is unset
+ if (run.accumulativeTime > recordRun.accumulativeTime) {
+ recordBroken = true;
+ for (uint256 j = slowestByDay(run.day).length - 1; j > i; j--) {
+ slowestByDay_[run.day][j] = slowestByDay(run.day)[j - 1];
+ }
+ slowestByDay_[run.day][i] = runId;
+ break;
+ }
+ }
+ if (recordBroken) {
+ emitMetadataUpdate(run.day);
+ }
+ }
+
+ function addToFastestByDay(uint256 runId) internal {
+ Run memory run = runs(runId);
+ uint256[3] memory f = fastestByDay(run.day);
+ bool recordBroken;
+ for (uint256 i = 0; i < 3; i++) {
+ Run memory recordRun = runs(f[i]);
+ // if run is faster, or if previous run is unset
+ if (
+ run.accumulativeTime < recordRun.accumulativeTime ||
+ recordRun.accumulativeTime == 0
+ ) {
+ recordBroken = true;
+ for (uint256 j = fastestByDay(run.day).length - 1; j > i; j--) {
+ fastestByDay_[run.day][j] = fastestByDay(run.day)[j - 1];
+ }
+ fastestByDay_[run.day][i] = runId;
+ break;
+ }
+ }
+ if (recordBroken) {
+ emitMetadataUpdate(run.day);
+ }
}
function addToLongestStreak(uint256 runId) internal {
- uint256 day = runs[runId].day;
- Record memory record = gamesPlayed[msg.sender];
+ uint256 day = runs(runId).day;
+ if (day != currentDay()) {
+ // if the run was not completed today, don't update the streak
+ return;
+ }
+ Record memory record = gamesPlayed(msg.sender);
if (record.lastPlayed + SECONDS_IN_A_DAY != day) {
record.streak = 1;
} else {
record.streak++;
}
record.lastPlayed = day;
- gamesPlayed[msg.sender] = record;
+ if (!record.updated) {
+ record.updated = true;
+ }
+ gamesPlayed_[msg.sender] = record;
+ bool recordBroken;
for (uint256 i = 0; i < longestStreak.length; i++) {
- if (record.streak > gamesPlayed[longestStreak[i]].streak) {
+ Record memory previousLongestStreak = gamesPlayed(longestStreak[i]);
+ if (record.streak > previousLongestStreak.streak) {
+ recordBroken = true;
for (uint256 j = longestStreak.length - 1; j > i; j--) {
longestStreak[j] = longestStreak[j - 1];
}
@@ -509,12 +724,18 @@ contract AnybodyProblem is Ownable, ERC2981 {
break;
}
}
+ if (recordBroken) {
+ emitMetadataUpdate(day);
+ }
}
function addToMostPlayed() internal {
- Record memory record = gamesPlayed[msg.sender];
+ Record memory record = gamesPlayed(msg.sender);
+ bool recordBroken;
for (uint256 i = 0; i < mostGames.length; i++) {
- if (record.total > gamesPlayed[mostGames[i]].total) {
+ address player = mostGames[i];
+ if (record.total > gamesPlayed(player).total) {
+ recordBroken = true;
for (uint256 j = mostGames.length - 1; j > i; j--) {
mostGames[j] = mostGames[j - 1];
}
@@ -522,24 +743,8 @@ contract AnybodyProblem is Ownable, ERC2981 {
break;
}
}
- }
-
- function addToFastestByDay(uint256 runId) internal {
- Run memory run = runs[runId];
- for (uint256 i = 0; i < fastestByDay[run.day].length; i++) {
- Run memory recordRun = runs[fastestByDay[run.day][i]];
- // if run is faster, or if previous run is unset
- if (
- run.accumulativeTime < recordRun.accumulativeTime ||
- recordRun.accumulativeTime == 0
- ) {
- for (uint256 j = fastestByDay[run.day].length - 1; j > i; j--) {
- fastestByDay[run.day][j] = fastestByDay[run.day][j - 1];
- }
- fastestByDay[run.day][i] = runId;
- emitMetadataUpdate(run.day);
- break;
- }
+ if (recordBroken) {
+ emitMetadataUpdate(currentDay());
}
}
@@ -607,26 +812,8 @@ contract AnybodyProblem is Ownable, ERC2981 {
uint[2] memory c,
uint[] memory input
) public view {
- if (bodyCount == 2) {
- require(
- Groth16Verifier2(verifier).verifyProof(
- a,
- b,
- c,
- convertTo32(input)
- ),
- 'Invalid 2 body proof'
- );
- } else if (bodyCount == 3) {
- require(
- Groth16Verifier3(verifier).verifyProof(
- a,
- b,
- c,
- convertTo42(input)
- ),
- 'Invalid 3 body proof'
- );
+ if (bodyCount == 2 || bodyCount == 3 || bodyCount == 5) {
+ revert('all proofs are 4 bodies or 6 bodies');
} else if (bodyCount == 4) {
require(
Groth16Verifier4(verifier).verifyProof(
@@ -637,16 +824,6 @@ contract AnybodyProblem is Ownable, ERC2981 {
),
'Invalid 4 body proof'
);
- } else if (bodyCount == 5) {
- require(
- Groth16Verifier5(verifier).verifyProof(
- a,
- b,
- c,
- convertTo62(input)
- ),
- 'Invalid 5 body proof'
- );
} else if (bodyCount == 6) {
require(
Groth16Verifier6(verifier).verifyProof(
@@ -701,36 +878,6 @@ contract AnybodyProblem is Ownable, ERC2981 {
return (bodyCount - dummyCount, dummyCount);
}
- function convertTo22(
- uint[] memory input
- ) public pure returns (uint[22] memory) {
- uint[22] memory input_;
- for (uint256 i = 0; i < 22; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
- function convertTo32(
- uint[] memory input
- ) public pure returns (uint[32] memory) {
- uint[32] memory input_;
- for (uint256 i = 0; i < 32; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
- function convertTo42(
- uint[] memory input
- ) public pure returns (uint[42] memory) {
- uint[42] memory input_;
- for (uint256 i = 0; i < 42; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
function convertTo52(
uint[] memory input
) public pure returns (uint[52] memory) {
@@ -741,16 +888,6 @@ contract AnybodyProblem is Ownable, ERC2981 {
return input_;
}
- function convertTo62(
- uint[] memory input
- ) public pure returns (uint[62] memory) {
- uint[62] memory input_;
- for (uint256 i = 0; i < 62; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
function convertTo72(
uint[] memory input
) public pure returns (uint[72] memory) {
@@ -761,46 +898,6 @@ contract AnybodyProblem is Ownable, ERC2981 {
return input_;
}
- function convertTo82(
- uint[] memory input
- ) public pure returns (uint[82] memory) {
- uint[82] memory input_;
- for (uint256 i = 0; i < 82; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
- function convertTo92(
- uint[] memory input
- ) public pure returns (uint[92] memory) {
- uint[92] memory input_;
- for (uint256 i = 0; i < 92; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
- function convertTo102(
- uint[] memory input
- ) public pure returns (uint[102] memory) {
- uint[102] memory input_;
- for (uint256 i = 0; i < 102; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
- function convertTo112(
- uint[] memory input
- ) public pure returns (uint[112] memory) {
- uint[112] memory input_;
- for (uint256 i = 0; i < 112; i++) {
- input_[i] = input[i];
- }
- return input_;
- }
-
// Speedruns NFT functions
function speedrunsSupportsInterface(
@@ -835,30 +932,16 @@ contract AnybodyProblem is Ownable, ERC2981 {
Speedruns(speedruns).emitGenericEvent(topics, data);
}
- // function emitBatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId) internal {
- // bytes32 topic = keccak256("BatchMetadataUpdate(uint256,uint256)");
- // bytes memory data = abi.encode(_fromTokenId, _toTokenId);
- // bytes32[] memory topics = new bytes32[](1);
- // topics[0] = topic;
- // Speedruns(speedruns).emitGenericEvent(topics, data);
- // }
- // function exampleEmitMultipleIndexEvent(uint256 _fromTokenId, uint256 _toTokenId, address who) internal {
- // bytes32 topic = keccak256("BatchMetadataUpdateIndexed(uint256,uint256,address)");
- // bytes32 topicFrom = bytes32(abi.encode(_fromTokenId));
- // bytes32 topicTo = bytes32(abi.encode(_toTokenId));
- // bytes memory data = abi.encode(who);
- // bytes32[] memory topics = new bytes32[](3);
- // topics[0] = topic;
- // topics[1] = topicFrom;
- // topics[2] = topicTo;
- // Speedruns(speedruns).emitGenericEvent(topics, data);
- // }
function updateExternalMetadata(
address externalMetadata_
) public onlyOwner {
externalMetadata = externalMetadata_;
}
+ function updatePreviousAB(address payable previousAB_) public onlyOwner {
+ previousAB = previousAB_;
+ }
+
function updateProceedRecipient(
address payable proceedRecipient_
) public onlyOwner {
diff --git a/contracts/AnybodyProblemMock.sol b/contracts/AnybodyProblemMock.sol
index 3155b9f5..66107981 100644
--- a/contracts/AnybodyProblemMock.sol
+++ b/contracts/AnybodyProblemMock.sol
@@ -2,30 +2,50 @@
pragma solidity ^0.8.0;
-import "./AnybodyProblem.sol";
+import './AnybodyProblem.sol';
contract AnybodyProblemMock is AnybodyProblem {
- constructor(
- address payable proceedRecipient_,
- address payable speedruns_,
- address externalMetadata_,
- address[] memory verifiers_,
- uint256[] memory verifiersTicks,
- uint256[] memory verifiersBodies)
- AnybodyProblem(proceedRecipient_,speedruns_,externalMetadata_,verifiers_,verifiersTicks,verifiersBodies)
- {}
+ constructor(
+ address payable proceedRecipient_,
+ address payable speedruns_,
+ address externalMetadata_,
+ address[] memory verifiers_,
+ uint256[] memory verifiersTicks,
+ uint256[] memory verifiersBodies,
+ address payable previousAB_
+ )
+ AnybodyProblem(
+ proceedRecipient_,
+ speedruns_,
+ externalMetadata_,
+ verifiers_,
+ verifiersTicks,
+ verifiersBodies,
+ previousAB_
+ )
+ {}
- Body[6][5] public mockedBodyDataByLevel;
+ Body[6][5] public mockedBodyDataByLevel;
- function setMockedBodyDataByLevel(uint256 level, Body[6] memory bodyData) public {
- mockedBodyDataByLevel[level - 1] = bodyData;
- }
-
- function generateLevelData(uint256 day, uint256 level) public view override(AnybodyProblem) returns(AnybodyProblem.Body[6] memory bodyData, uint256 bodyCount) {
- if (mockedBodyDataByLevel[level - 1][0].seed == bytes32(0)) {
- return super.generateLevelData(day, level);
+ function setMockedBodyDataByLevel(
+ uint256 level,
+ Body[6] memory bodyData
+ ) public {
+ mockedBodyDataByLevel[level - 1] = bodyData;
}
- return (mockedBodyDataByLevel[level - 1], level + 1);
- }
-}
\ No newline at end of file
+ function generateLevelData(
+ uint256 day,
+ uint256 level
+ )
+ public
+ view
+ override(AnybodyProblem)
+ returns (AnybodyProblem.Body[6] memory bodyData, uint256 bodyCount)
+ {
+ if (mockedBodyDataByLevel[level - 1][0].seed == bytes32(0)) {
+ return super.generateLevelData(day, level);
+ }
+ return (mockedBodyDataByLevel[level - 1], level + 1);
+ }
+}
diff --git a/contracts/AnybodyProblemV0.sol b/contracts/AnybodyProblemV0.sol
new file mode 100644
index 00000000..06a3ccab
--- /dev/null
+++ b/contracts/AnybodyProblemV0.sol
@@ -0,0 +1,906 @@
+// SPDX-License-Identifier: MIT
+
+pragma solidity ^0.8.0;
+
+import {Groth16Verifier as Groth16Verifier2} from './Game_2_20Verifier.sol';
+import {Groth16Verifier as Groth16Verifier3} from './Game_3_20Verifier.sol';
+import {Groth16Verifier as Groth16Verifier4} from './Game_4_20Verifier.sol';
+import {Groth16Verifier as Groth16Verifier5} from './Game_5_20Verifier.sol';
+import {Groth16Verifier as Groth16Verifier6} from './Game_6_20Verifier.sol';
+
+import '@openzeppelin/contracts/token/common/ERC2981.sol';
+import '@openzeppelin/contracts/access/Ownable.sol';
+import '@openzeppelin/contracts/token/ERC1155/ERC1155.sol';
+import './Speedruns.sol';
+import './ExternalMetadata.sol';
+
+contract AnybodyProblemV0 is Ownable, ERC2981 {
+ uint256 public constant LEVELS = 5;
+ uint256 public constant SECONDS_IN_A_DAY = 86400;
+ uint256 public constant SECONDS_IN_A_WEEK = SECONDS_IN_A_DAY * 7;
+ uint256 public constant FIRST_SUNDAY_AT_6_PM_UTC = 324000;
+
+ bool public paused = false;
+ uint256 public priceToMint = 0.0025 ether;
+ uint256 public priceToSave = 0 ether;
+ uint256 public discount = 2;
+ address payable public proceedRecipient;
+ address public externalMetadata;
+ address payable public speedruns;
+ // uint256 public constant maxTick = 25 * 60; // 25 fps * 60 sec = 1,500 ticks max
+ // level duration is numberOfBaddies * 10sec (multiplied by 25 because of 25 FPS)
+ uint256[5] public maxTicksByLevelIndex = [
+ 1 * 10 * 25,
+ 2 * 10 * 25,
+ 3 * 10 * 25,
+ 4 * 10 * 25,
+ 5 * 10 * 25
+ ];
+ uint256 public constant speedFactor = 2;
+ uint256 public constant scalingFactor = 10 ** 3;
+ uint256 public constant maxVector = 10 * speedFactor;
+ uint256 public constant maxVectorScaled = maxVector * scalingFactor;
+ uint256 public constant windowWidth = 1000 * scalingFactor;
+ uint256 public constant startingRadius = 2;
+
+ struct Run {
+ address owner;
+ bool solved; // redundant by accumulating A
+ uint256 accumulativeTime; // redundant by accumulating C
+ bytes32 seed;
+ uint256 day;
+ Level[] levels;
+ }
+ struct Level {
+ bool solved; // redundant A
+ uint256 time; // redundant C
+ bytes32 seed;
+ uint256[5] tmpInflightMissile;
+ Body[6] tmpBodyData;
+ }
+ struct Body {
+ uint256 bodyIndex;
+ uint256 px;
+ uint256 py;
+ uint256 vx;
+ uint256 vy;
+ uint256 radius;
+ bytes32 seed;
+ }
+
+ mapping(uint256 => uint256[3]) public fastestByDay; // day => [fastest, 2nd fastest, 3rd fastest runId]
+ address[3] public mostGames;
+ address[3] public longestStreak;
+
+ struct Record {
+ uint256 total;
+ uint256 lastPlayed;
+ uint256 streak;
+ }
+ mapping(address => Record) public gamesPlayed;
+ mapping(address => mapping(uint256 => uint256[7])) public weeklyRecords;
+ mapping(uint256 => address[3]) public fastestByWeek;
+
+ // NOTE: initialize with length of 1 so Runs are not 0 indexed (runId == index of the run array)
+ Run[] public runs = new Run[](1);
+
+ // mapping is body count to tickcount to address
+ mapping(uint256 => mapping(uint256 => address)) public verifiers;
+ mapping(bytes32 => bool) public usedProofs;
+
+ constructor(
+ address payable proceedRecipient_,
+ address payable speedruns_,
+ address externalMetadata_,
+ address[] memory verifiers_,
+ uint256[] memory verifiersTicks,
+ uint256[] memory verifiersBodies
+ ) {
+ updateProceedRecipient(proceedRecipient_);
+ updateSpeedrunsAddress(speedruns_);
+ updateExternalMetadata(externalMetadata_);
+ for (uint256 i = 0; i < verifiers_.length; i++) {
+ require(verifiersTicks[i] > 0, 'Invalid verifier');
+ require(verifiers_[i] != address(0), 'Invalid verifier');
+ verifiers[verifiersBodies[i]][verifiersTicks[i]] = verifiers_[i];
+ }
+ }
+
+ receive() external payable {
+ revert('no receive thank you');
+ }
+
+ fallback() external {
+ revert('no fallback thank you');
+ }
+
+ event RunCreated(uint256 runId, uint256 day, bytes32 seed);
+ event RunSolved(
+ address indexed player,
+ uint256 indexed runId,
+ uint256 accumulativeTime,
+ uint256 day
+ );
+ event LevelCreated(uint256 runId, uint256 level, bytes32 seed, uint256 day);
+ event LevelSolved(
+ address indexed player,
+ uint256 indexed runId,
+ uint256 indexed level,
+ uint256 time,
+ uint256 day
+ );
+ event EthMoved(
+ address indexed to,
+ bool indexed success,
+ bytes returnData,
+ uint256 amount
+ );
+
+ // NOTE: the only publicly available function that isn't protected by a modifier
+ function batchSolve(
+ uint256 runId,
+ bool alsoMint,
+ uint256 day,
+ uint256[] memory tickCounts,
+ uint[2][] memory a,
+ uint[2][2][] memory b,
+ uint[2][] memory c,
+ uint[][] memory input
+ ) public payable {
+ if (day == 0) {
+ day = currentDay();
+ }
+ require(
+ day % SECONDS_IN_A_DAY == 0,
+ 'One problem per day, invalid day'
+ );
+ require(day <= currentDay(), 'Cannot solve future problems');
+ require(!paused, 'Contract is paused');
+ if (runId == 0) {
+ runId = addNewRun(day);
+ addNewLevelData(runId);
+ }
+ require(
+ runs[runId].owner == msg.sender,
+ 'Only the owner of the run can solve it'
+ );
+ require(!runs[runId].solved, 'Run already solved');
+
+ require(
+ day == runs[runId].day,
+ 'Can only solve runs on the current day'
+ );
+
+ for (uint256 i = 0; i < input.length; i++) {
+ verifyLevelChunk(
+ runId,
+ alsoMint,
+ tickCounts[i],
+ day,
+ a[i],
+ b[i],
+ c[i],
+ input[i]
+ );
+ }
+ // TODO: decide whether this is necessary
+ // require(runs[runId].solved, "Must solve all levels to complete run");
+ }
+
+ function runCount() public view returns (uint256) {
+ return runs.length - 1;
+ }
+
+ function getLevelsData(
+ uint256 runId
+ ) public view returns (Level[] memory levels) {
+ return runs[runId].levels;
+ }
+
+ function generateLevelData(
+ uint256 day,
+ uint256 level
+ ) public view virtual returns (Body[6] memory bodyData, uint256 bodyCount) {
+ // NOTE: <= becuase level 5 has 6 bodies
+ for (uint256 i = 0; i <= level; i++) {
+ bytes32 dayLevelIndexSeed = getLevelSeed(day, level, i);
+ bodyData[i] = getRandomValues(dayLevelIndexSeed, i, day);
+ }
+ bodyCount = level + 1;
+ }
+
+ function getLevelSeed(
+ uint256 day,
+ uint256 level,
+ uint256 bodyIndex
+ ) public pure returns (bytes32) {
+ return keccak256(abi.encodePacked(day, level, bodyIndex));
+ }
+
+ function getRandomValues(
+ bytes32 dayLevelIndexSeed,
+ uint256 index,
+ uint256 day
+ ) public pure returns (Body memory) {
+ // NOTE: this function uses a seed consisting of the day + bodyIndex which means
+ // that all problems of the same level on the same day will have bodies with the same
+ // positions, velocities and radii.
+ Body memory body;
+
+ body.bodyIndex = index;
+ body.seed = dayLevelIndexSeed;
+
+ body.radius = genRadius(index);
+
+ bytes32 rand = keccak256(abi.encodePacked(dayLevelIndexSeed));
+ body.px = randomRange(0, windowWidth, rand, day);
+
+ rand = keccak256(abi.encodePacked(rand));
+ body.py = randomRange(0, windowWidth, rand, day);
+
+ rand = keccak256(abi.encodePacked(rand));
+ // this is actually a range of -1/2 to 1/2 of maxVector since negative offset
+ // -maxVector = 0
+ // 0 = maxVector
+ // maxVector = 2 * maxVector
+ body.vx = randomRange(
+ maxVectorScaled / 2,
+ (3 * maxVectorScaled) / 2,
+ rand,
+ day
+ );
+
+ rand = keccak256(abi.encodePacked(rand));
+ body.vy = randomRange(
+ maxVectorScaled / 2,
+ (3 * maxVectorScaled) / 2,
+ rand,
+ day
+ );
+
+ return body;
+ }
+
+ function genRadius(uint256 index) public pure returns (uint256) {
+ uint8[6] memory radii = [36, 27, 23, 19, 15, 11]; // n * 4 + 2
+ return radii[index % radii.length] * scalingFactor;
+ }
+
+ function randomRange(
+ uint256 min,
+ uint256 max,
+ bytes32 seed,
+ uint256 day
+ ) public pure returns (uint256) {
+ uint256 fuckup = day == 1723766400 ? 0 : 1;
+ if (min == max) {
+ return min;
+ } else if (min < max) {
+ uint256 range = max - min + fuckup;
+ return (uint256(seed) % range) + min;
+ } else {
+ uint256 range = 359 - (min - max + fuckup);
+ uint256 output = uint256(seed) % range;
+ if (output < max) {
+ return output;
+ } else {
+ return min - max + output;
+ }
+ }
+ }
+
+ function currentLevel(uint256 runId) public view returns (uint256) {
+ return runs[runId].levels.length;
+ }
+
+ function generateSeed(
+ uint256 id,
+ uint256 index
+ ) public view returns (bytes32) {
+ return
+ keccak256(abi.encodePacked(id, index, blockhash(block.number - 1)));
+ }
+
+ // TODO: fix day and week so that days and week begin at same time
+ function currentWeek() public view returns (uint256) {
+ return
+ block.timestamp -
+ ((block.timestamp - FIRST_SUNDAY_AT_6_PM_UTC) % SECONDS_IN_A_WEEK);
+ }
+
+ function timeUntilEndOfWeek() public view returns (uint256) {
+ return currentWeek() + SECONDS_IN_A_WEEK - block.timestamp;
+ }
+
+ function currentDay() public view returns (uint256) {
+ return block.timestamp - (block.timestamp % SECONDS_IN_A_DAY);
+ }
+
+ function addNewLevelData(uint256 runId) internal {
+ uint256 day = runs[runId].day;
+ uint256 level = currentLevel(runId) + 1;
+ Level memory levelData;
+ levelData.seed = generateSeed(runId, level);
+ (levelData.tmpBodyData, ) = generateLevelData(day, level);
+ runs[runId].levels.push(levelData);
+ emit LevelCreated(runId, level, levelData.seed, day);
+ }
+
+ function addNewRun(uint256 day) internal returns (uint256 runId) {
+ runId = runs.length;
+ Run memory run;
+ run.owner = msg.sender;
+ run.seed = generateSeed(runId, 0);
+ run.day = day;
+ runs.push(run);
+ emit RunCreated(runId, day, run.seed);
+ return runId;
+ }
+
+ function verifyLevelChunk(
+ uint256 runId,
+ bool alsoMint,
+ uint256 tickCount,
+ uint256 day,
+ uint[2] memory a,
+ uint[2][2] memory b,
+ uint[2] memory c,
+ uint[] memory input
+ ) internal {
+ bytes32 proofHash = keccak256(abi.encodePacked(a, b, c, input));
+ require(!usedProofs[proofHash], 'Proof already used');
+ usedProofs[proofHash] = true;
+
+ (uint256 intendedLevel, uint256 dummyCount) = getLevelFromInputs(input);
+ uint256 level = currentLevel(runId);
+
+ require(intendedLevel == level, 'Previous level not yet complete');
+
+ uint256 levelIndex = level - 1;
+ require(!runs[runId].levels[levelIndex].solved, 'Level already solved');
+
+ uint256 bodyCount = level + 1;
+ address verifier = verifiers[bodyCount + dummyCount][tickCount];
+ require(verifier != address(0), 'Invalid verifier, address == 0');
+ require(
+ address(uint160(input[5 + (bodyCount + dummyCount) * 5 + 1])) ==
+ msg.sender,
+ 'Owner of this proof is not the sender'
+ );
+
+ // confirm current inflightMissile == previous outflightMissile
+ // or confirm that curren inflightMissile (x, y) == (0, windowHeight)
+ uint256[5] memory storedOutflightMissile = runs[runId]
+ .levels[levelIndex]
+ .tmpInflightMissile;
+ uint256[5] memory newInflightMissile = [
+ input[5 + 2 * (bodyCount + dummyCount) * 5 + 2 + 0],
+ input[5 + 2 * (bodyCount + dummyCount) * 5 + 2 + 1],
+ input[5 + 2 * (bodyCount + dummyCount) * 5 + 2 + 2],
+ input[5 + 2 * (bodyCount + dummyCount) * 5 + 2 + 3],
+ input[5 + 2 * (bodyCount + dummyCount) * 5 + 2 + 4]
+ ];
+ // if there is an inflight missile, it either needs to match the outflight or start
+ // from the corner
+ if (newInflightMissile[4] != 0) {
+ bool matchesStoredOutflightMissile = storedOutflightMissile[0] ==
+ newInflightMissile[0] &&
+ storedOutflightMissile[1] == newInflightMissile[1] &&
+ storedOutflightMissile[2] == newInflightMissile[2] &&
+ storedOutflightMissile[3] == newInflightMissile[3] &&
+ storedOutflightMissile[4] == newInflightMissile[4];
+
+ bool newMissile = newInflightMissile[0] == 0 &&
+ newInflightMissile[1] == windowWidth;
+ require(
+ newMissile || matchesStoredOutflightMissile,
+ 'Invalid inflightMissile'
+ );
+ }
+ // update inflightMissile with new outflight missile
+ uint256[5] memory newOutflightMissile = [
+ input[0],
+ input[1],
+ input[2],
+ input[3],
+ input[4]
+ ];
+ runs[runId].levels[levelIndex].tmpInflightMissile = newOutflightMissile;
+
+ uint256 time = input[5 + (bodyCount + dummyCount) * 5];
+
+ verifyProof((bodyCount + dummyCount), verifier, a, b, c, input);
+
+ Level memory levelData = runs[runId].levels[levelIndex];
+
+ levelData.time += time;
+ require(
+ levelData.time <= maxTicksByLevelIndex[levelIndex],
+ 'Time limit exceeded'
+ );
+
+ uint256 bodiesGone;
+ Body memory bodyData;
+ for (uint256 i = 0; i < bodyCount; i++) {
+ bodyData = levelData.tmpBodyData[i];
+
+ verifyBodyDataMatches(bodyData, input, (bodyCount + dummyCount), i);
+ bodyData = extractBodyData(bodyData, input, i);
+
+ if (i == 0) {
+ require(
+ bodyData.radius != 0,
+ 'You shot the body you should protect'
+ );
+ }
+ if (bodyData.radius == 0) {
+ bodiesGone++;
+ }
+ levelData.tmpBodyData[i] = bodyData;
+ }
+ runs[runId].levels[levelIndex] = levelData;
+ if (bodiesGone == level) {
+ runs[runId].levels[levelIndex].solved = true;
+ emit LevelSolved(msg.sender, runId, level, levelData.time, day);
+ runs[runId].accumulativeTime += levelData.time;
+ if (level == LEVELS) {
+ runs[runId].solved = true;
+ if (alsoMint) {
+ mint(priceToSave + (priceToMint / discount), day);
+ } else if (priceToSave > 0) {
+ makePayment(priceToSave);
+ }
+ emit RunSolved(
+ msg.sender,
+ runId,
+ runs[runId].accumulativeTime,
+ day
+ );
+ gamesPlayed[msg.sender].total++;
+ addToLeaderboard(runId);
+ } else {
+ addNewLevelData(runId);
+ }
+ }
+ }
+
+ function makePayment(uint256 payment) internal {
+ require(msg.value >= payment, 'Incorrect payment');
+ require(proceedRecipient != address(0), 'Invalid recipient');
+ (bool sent, bytes memory data) = proceedRecipient.call{value: payment}(
+ ''
+ );
+ emit EthMoved(proceedRecipient, sent, data, payment);
+ }
+
+ function mint(uint256 payment, uint256 day) internal {
+ require(day == currentDay(), 'Can only mint on the current day');
+ makePayment(payment);
+ Speedruns(speedruns).__mint(msg.sender, day, 1, '');
+ }
+
+ function mint() public payable {
+ mint(priceToMint, currentDay());
+ }
+
+ function addToLeaderboard(uint256 runId) internal {
+ addToFastestByDay(runId);
+ addToLongestStreak(runId);
+ addToMostPlayed();
+ }
+
+ function addToLongestStreak(uint256 runId) internal {
+ uint256 day = runs[runId].day;
+ Record memory record = gamesPlayed[msg.sender];
+ if (record.lastPlayed + SECONDS_IN_A_DAY != day) {
+ record.streak = 1;
+ } else {
+ record.streak++;
+ }
+ record.lastPlayed = day;
+ gamesPlayed[msg.sender] = record;
+
+ for (uint256 i = 0; i < longestStreak.length; i++) {
+ if (record.streak > gamesPlayed[longestStreak[i]].streak) {
+ for (uint256 j = longestStreak.length - 1; j > i; j--) {
+ longestStreak[j] = longestStreak[j - 1];
+ }
+ longestStreak[i] = msg.sender;
+ break;
+ }
+ }
+ }
+
+ function addToMostPlayed() internal {
+ Record memory record = gamesPlayed[msg.sender];
+ for (uint256 i = 0; i < mostGames.length; i++) {
+ if (record.total > gamesPlayed[mostGames[i]].total) {
+ for (uint256 j = mostGames.length - 1; j > i; j--) {
+ mostGames[j] = mostGames[j - 1];
+ }
+ mostGames[i] = msg.sender;
+ break;
+ }
+ }
+ }
+
+ function addToFastestByDay(uint256 runId) internal {
+ Run memory run = runs[runId];
+ for (uint256 i = 0; i < fastestByDay[run.day].length; i++) {
+ Run memory recordRun = runs[fastestByDay[run.day][i]];
+ // if run is faster, or if previous run is unset
+ if (
+ run.accumulativeTime < recordRun.accumulativeTime ||
+ recordRun.accumulativeTime == 0
+ ) {
+ for (uint256 j = fastestByDay[run.day].length - 1; j > i; j--) {
+ fastestByDay[run.day][j] = fastestByDay[run.day][j - 1];
+ }
+ fastestByDay[run.day][i] = runId;
+ emitMetadataUpdate(run.day);
+ break;
+ }
+ }
+ }
+
+ function extractBodyData(
+ Body memory bodyData,
+ uint[] memory input,
+ uint256 i
+ ) public pure returns (Body memory) {
+ bodyData.px = input[5 + i * 5 + 0];
+ bodyData.py = input[5 + i * 5 + 1];
+ bodyData.vx = input[5 + i * 5 + 2];
+ bodyData.vy = input[5 + i * 5 + 3];
+ bodyData.radius = input[5 + i * 5 + 4];
+ return bodyData;
+ }
+
+ function verifyBodyDataMatches(
+ Body memory bodyData,
+ uint[] memory input,
+ uint256 bodyCount,
+ uint256 i
+ ) public pure {
+ // px
+ // confirm previously stored values were used as input to the proof
+ // uint256 pxIndex = 5 * bodyCount + i * 5 + 0 + 1 (for time);
+ require(
+ bodyData.px == input[5 + 5 * bodyCount + i * 5 + 0 + 2],
+ 'Invalid position x'
+ );
+ // py
+ // confirm previously stored values were used as input to the proof
+ // uint256 pyIndex = 5 * bodyCount + i * 5 + 1 + 1 (for time);
+ require(
+ bodyData.py == input[5 + 5 * bodyCount + i * 5 + 1 + 2],
+ 'Invalid position y'
+ );
+ // vx
+ // confirm previously stored values were used as input to the proof
+ // uint256 vxIndex = 5 * bodyCount + i * 5 + 2 + 1 (for time);
+ require(
+ bodyData.vx == input[5 + 5 * bodyCount + i * 5 + 2 + 2],
+ 'Invalid vector x'
+ );
+ // vy
+ // confirm previously stored values were used as input to the proof
+ // uint256 vyIndex = 5 * bodyCount + i * 5 + 3 + 1 (for time);
+ require(
+ bodyData.vy == input[5 + 5 * bodyCount + i * 5 + 3 + 2],
+ 'Invalid vector y'
+ );
+ // radius
+ // confirm previously stored values were used as input to the proof
+ // uint256 radiusIndex = 5 * bodyCount + i * 5 + 4 + 1 (for time);
+ require(
+ bodyData.radius == input[5 + 5 * bodyCount + i * 5 + 4 + 2],
+ 'Invalid radius'
+ );
+ }
+
+ function verifyProof(
+ uint256 bodyCount,
+ address verifier,
+ uint[2] memory a,
+ uint[2][2] memory b,
+ uint[2] memory c,
+ uint[] memory input
+ ) public view {
+ if (bodyCount == 2) {
+ require(
+ Groth16Verifier2(verifier).verifyProof(
+ a,
+ b,
+ c,
+ convertTo32(input)
+ ),
+ 'Invalid 2 body proof'
+ );
+ } else if (bodyCount == 3) {
+ require(
+ Groth16Verifier3(verifier).verifyProof(
+ a,
+ b,
+ c,
+ convertTo42(input)
+ ),
+ 'Invalid 3 body proof'
+ );
+ } else if (bodyCount == 4) {
+ require(
+ Groth16Verifier4(verifier).verifyProof(
+ a,
+ b,
+ c,
+ convertTo52(input)
+ ),
+ 'Invalid 4 body proof'
+ );
+ } else if (bodyCount == 5) {
+ require(
+ Groth16Verifier5(verifier).verifyProof(
+ a,
+ b,
+ c,
+ convertTo62(input)
+ ),
+ 'Invalid 5 body proof'
+ );
+ } else if (bodyCount == 6) {
+ require(
+ Groth16Verifier6(verifier).verifyProof(
+ a,
+ b,
+ c,
+ convertTo72(input)
+ ),
+ 'Invalid 6 body proof'
+ );
+ } else {
+ revert('Invalid number of bodies');
+ }
+ }
+
+ function getLevelFromInputs(
+ uint[] memory input
+ ) public pure returns (uint256 bodyCount, uint256 dummyCount) {
+ // 0—4: missile output
+ // 5—9: body 1 output
+ // 10—14: body 2 output
+ // 15: time output (5 + bodyCount * 5 + 1)
+ // 16: address input (5 + bodyCount * 5 + 2)
+ // 17—21: body 1 input
+ // 22—26: body 2 input
+ // 27—31: missile input (5 + 2 * bodyCount * 5 + 2)
+
+ // inputLength = bodyCount * 5 * 2 + 1 + 1 + 5 + 5;
+ // inputLength = 10 * bodyCount + 12;
+ // 10 * bodyCount = inputLength - 12;
+ bodyCount = ((input.length - 12) / 10) - 1;
+ dummyCount = 0;
+ uint256 tally = 0;
+ // start i at end of input array but before the final 5 elements of the missile input
+ // count backwards checking every 5 whether a body is completely empty
+ // if so consider this a "dummy" body and remove it from the count
+ for (uint256 i = input.length - 1 - 5; i > input.length / 2; i--) {
+ if (tally % 5 == 0) {
+ if (
+ input[i] == 0 && // radius
+ input[i - 1] == 20000 && // vy
+ input[i - 2] == 20000 && // vx
+ input[i - 3] == 0 && // py
+ input[i - 4] == 0 // px
+ ) {
+ dummyCount++;
+ }
+ }
+ tally++;
+ }
+
+ return (bodyCount - dummyCount, dummyCount);
+ }
+
+ function convertTo22(
+ uint[] memory input
+ ) public pure returns (uint[22] memory) {
+ uint[22] memory input_;
+ for (uint256 i = 0; i < 22; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo32(
+ uint[] memory input
+ ) public pure returns (uint[32] memory) {
+ uint[32] memory input_;
+ for (uint256 i = 0; i < 32; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo42(
+ uint[] memory input
+ ) public pure returns (uint[42] memory) {
+ uint[42] memory input_;
+ for (uint256 i = 0; i < 42; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo52(
+ uint[] memory input
+ ) public pure returns (uint[52] memory) {
+ uint[52] memory input_;
+ for (uint256 i = 0; i < 52; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo62(
+ uint[] memory input
+ ) public pure returns (uint[62] memory) {
+ uint[62] memory input_;
+ for (uint256 i = 0; i < 62; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo72(
+ uint[] memory input
+ ) public pure returns (uint[72] memory) {
+ uint[72] memory input_;
+ for (uint256 i = 0; i < 72; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo82(
+ uint[] memory input
+ ) public pure returns (uint[82] memory) {
+ uint[82] memory input_;
+ for (uint256 i = 0; i < 82; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo92(
+ uint[] memory input
+ ) public pure returns (uint[92] memory) {
+ uint[92] memory input_;
+ for (uint256 i = 0; i < 92; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo102(
+ uint[] memory input
+ ) public pure returns (uint[102] memory) {
+ uint[102] memory input_;
+ for (uint256 i = 0; i < 102; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ function convertTo112(
+ uint[] memory input
+ ) public pure returns (uint[112] memory) {
+ uint[112] memory input_;
+ for (uint256 i = 0; i < 112; i++) {
+ input_[i] = input[i];
+ }
+ return input_;
+ }
+
+ // Speedruns NFT functions
+
+ function speedrunsSupportsInterface(
+ bytes4 interfaceId
+ ) public pure returns (bool) {
+ return
+ interfaceId == type(IERC165).interfaceId ||
+ interfaceId == type(IERC1155).interfaceId ||
+ interfaceId == type(IERC1155MetadataURI).interfaceId ||
+ interfaceId == type(IERC2981).interfaceId ||
+ interfaceId == bytes4(0x49064906); // IERC4906 MetadataUpdate
+ }
+
+ function speedrunsTokenURI(uint256 id) public view returns (string memory) {
+ return ExternalMetadata(externalMetadata).getMetadata(id);
+ }
+
+ function emitBatchMetadataUpdate() public onlyOwner {
+ bytes32 topic = keccak256('BatchMetadataUpdate(uint256,uint256)');
+ uint256 today = currentDay();
+ bytes memory data = abi.encode(0, today);
+ bytes32[] memory topics = new bytes32[](1);
+ topics[0] = topic;
+ Speedruns(speedruns).emitGenericEvent(topics, data);
+ }
+
+ function emitMetadataUpdate(uint256 tokenId) internal {
+ bytes32 topic = keccak256('MetadataUpdate(uint256)');
+ bytes memory data = abi.encode(tokenId);
+ bytes32[] memory topics = new bytes32[](1);
+ topics[0] = topic;
+ Speedruns(speedruns).emitGenericEvent(topics, data);
+ }
+
+ // function emitBatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId) internal {
+ // bytes32 topic = keccak256("BatchMetadataUpdate(uint256,uint256)");
+ // bytes memory data = abi.encode(_fromTokenId, _toTokenId);
+ // bytes32[] memory topics = new bytes32[](1);
+ // topics[0] = topic;
+ // Speedruns(speedruns).emitGenericEvent(topics, data);
+ // }
+ // function exampleEmitMultipleIndexEvent(uint256 _fromTokenId, uint256 _toTokenId, address who) internal {
+ // bytes32 topic = keccak256("BatchMetadataUpdateIndexed(uint256,uint256,address)");
+ // bytes32 topicFrom = bytes32(abi.encode(_fromTokenId));
+ // bytes32 topicTo = bytes32(abi.encode(_toTokenId));
+ // bytes memory data = abi.encode(who);
+ // bytes32[] memory topics = new bytes32[](3);
+ // topics[0] = topic;
+ // topics[1] = topicFrom;
+ // topics[2] = topicTo;
+ // Speedruns(speedruns).emitGenericEvent(topics, data);
+ // }
+ function updateExternalMetadata(
+ address externalMetadata_
+ ) public onlyOwner {
+ externalMetadata = externalMetadata_;
+ }
+
+ function updateProceedRecipient(
+ address payable proceedRecipient_
+ ) public onlyOwner {
+ proceedRecipient = proceedRecipient_;
+ }
+
+ function updateSpeedrunsAddress(
+ address payable speedruns_
+ ) public onlyOwner {
+ speedruns = speedruns_;
+ }
+
+ function updateVerifier(
+ address verifier_,
+ uint256 verifierBodies,
+ uint256 verifierTicks
+ ) public onlyOwner {
+ verifiers[verifierBodies][verifierTicks] = verifier_;
+ }
+
+ /// @dev if mint fails to send eth to splitter, admin can recover
+ // This should not be necessary but Berlin hardfork broke split before so this
+ // is extra precaution.
+ function recoverUnsuccessfulPayment(address payable _to) public onlyOwner {
+ uint256 amount = address(this).balance;
+ (bool sent, bytes memory data) = _to.call{value: amount}('');
+ emit EthMoved(_to, sent, data, amount);
+ }
+
+ function updateDiscount(uint256 discount_) public onlyOwner {
+ discount = discount_;
+ }
+
+ function updatePriceToSave(uint256 priceToSave_) public onlyOwner {
+ priceToSave = priceToSave_;
+ }
+
+ function updatePriceToMint(uint256 priceToMint_) public onlyOwner {
+ priceToMint = priceToMint_;
+ }
+
+ function updatePaused(bool paused_) public onlyOwner {
+ paused = paused_;
+ }
+}
diff --git a/contracts/AnybodyProblemV0Mock.sol b/contracts/AnybodyProblemV0Mock.sol
new file mode 100644
index 00000000..252d35f6
--- /dev/null
+++ b/contracts/AnybodyProblemV0Mock.sol
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: MIT
+
+pragma solidity ^0.8.0;
+
+import './AnybodyProblemV0.sol';
+
+contract AnybodyProblemV0Mock is AnybodyProblemV0 {
+ constructor(
+ address payable proceedRecipient_,
+ address payable speedruns_,
+ address externalMetadata_,
+ address[] memory verifiers_,
+ uint256[] memory verifiersTicks,
+ uint256[] memory verifiersBodies
+ )
+ AnybodyProblemV0(
+ proceedRecipient_,
+ speedruns_,
+ externalMetadata_,
+ verifiers_,
+ verifiersTicks,
+ verifiersBodies
+ )
+ {}
+
+ Body[6][5] public mockedBodyDataByLevel;
+
+ function setMockedBodyDataByLevel(
+ uint256 level,
+ Body[6] memory bodyData
+ ) public {
+ mockedBodyDataByLevel[level - 1] = bodyData;
+ }
+
+ function generateLevelData(
+ uint256 day,
+ uint256 level
+ )
+ public
+ view
+ override(AnybodyProblemV0)
+ returns (AnybodyProblemV0.Body[6] memory bodyData, uint256 bodyCount)
+ {
+ if (mockedBodyDataByLevel[level - 1][0].seed == bytes32(0)) {
+ return super.generateLevelData(day, level);
+ }
+ return (mockedBodyDataByLevel[level - 1], level + 1);
+ }
+}
diff --git a/contracts/ExternalMetadata.sol b/contracts/ExternalMetadata.sol
index 532418f5..f3654ddc 100644
--- a/contracts/ExternalMetadata.sol
+++ b/contracts/ExternalMetadata.sol
@@ -211,10 +211,9 @@ contract ExternalMetadata is Ownable {
function getBestTimeEncoded(
uint256 date
) public view returns (string memory) {
- uint256 bestRunId = AnybodyProblem(anybodyProblem).fastestByDay(
- date,
+ uint256 bestRunId = AnybodyProblem(anybodyProblem).fastestByDay(date)[
0
- );
+ ];
AnybodyProblem.Level[] memory levels = AnybodyProblem(anybodyProblem)
.getLevelsData(bestRunId);
@@ -558,13 +557,14 @@ contract ExternalMetadata is Ownable {
uint256 date,
uint256 placeIndex
) public view returns (address, string memory sec) {
- uint256 runId = AnybodyProblem(anybodyProblem).fastestByDay(
- date,
+ uint256 runId = AnybodyProblem(anybodyProblem).fastestByDay(date)[
placeIndex
+ ];
+ AnybodyProblem.Run memory run = AnybodyProblem(anybodyProblem).runs(
+ runId
);
- (address player, , uint256 timeCompleted, , ) = AnybodyProblem(
- anybodyProblem
- ).runs(runId);
+ address player = run.owner;
+ uint256 timeCompleted = run.accumulativeTime;
uint256 precision = 1000;
uint256 fps = 25;
diff --git a/contracts/Game_2_20Verifier.sol b/contracts/Game_2_20Verifier.sol
new file mode 100644
index 00000000..a4241159
--- /dev/null
+++ b/contracts/Game_2_20Verifier.sol
@@ -0,0 +1,387 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 5241995662068367475869136892256844692416140110302636519962844740126938063875;
+ uint256 constant deltax2 = 134096951853892381062173916331467634468678914515686281760882443472775903462;
+ uint256 constant deltay1 = 5082542945570806761361141222881120515536499021823086838758958385921235466607;
+ uint256 constant deltay2 = 14106809006210128871806172156714596647611808038359174452475826441046628667758;
+
+
+ uint256 constant IC0x = 882582390271793403901797277838325683600014642836231700369383898679847315738;
+ uint256 constant IC0y = 18415457004671385882127643099806919622189579256621415773570750159719324200452;
+
+ uint256 constant IC1x = 6864267804466485132506866126031217731827531200444869761107779301202468759878;
+ uint256 constant IC1y = 21030215671032859160585663535808263709469743231116912784733577789021155502859;
+
+ uint256 constant IC2x = 14686745220850934028799013491617909752302187469976719311574167160396992637170;
+ uint256 constant IC2y = 17888723658611387013237114755784289433617528388864099427717407766615571963350;
+
+ uint256 constant IC3x = 19483529945723091033014165967402891087356282885133349560706935685460833758750;
+ uint256 constant IC3y = 4167954629404853592600785827701202056664524263978672526412316596661794843513;
+
+ uint256 constant IC4x = 1982912745465683578785699473197995131873150152490754003542112198247164160787;
+ uint256 constant IC4y = 14031626155710995502723367931538078791362746400362496147959792422502768587103;
+
+ uint256 constant IC5x = 20195741606542597816678757802026164151461732798053822503256465341835485222527;
+ uint256 constant IC5y = 17515656407953121975768596327850901311282981198513957429599286145607496545043;
+
+ uint256 constant IC6x = 4214403601882378221999337897403236459401492213009094967965528559818889012305;
+ uint256 constant IC6y = 17154705499179853070222391919625058633294441309771023454702986755139031404628;
+
+ uint256 constant IC7x = 2723210008018412250413254669082625555445077830119626716225419689292911301526;
+ uint256 constant IC7y = 6067403293947856778121338763812241062399860804111449765146110562851056626640;
+
+ uint256 constant IC8x = 5488261249653079915693819360213585958004137206571969833806721174199282395177;
+ uint256 constant IC8y = 16685015257271826587362130694513688360539837685085473914163414233427417187653;
+
+ uint256 constant IC9x = 4220322879192056646800159854659282415097230923694878017169084079041844003574;
+ uint256 constant IC9y = 13492203282240101592667087541926124194321282937780883036797391223701011062613;
+
+ uint256 constant IC10x = 15656559141458858055663930616390479923517497200306158544034712083706854441867;
+ uint256 constant IC10y = 16647849542270215717851764567880787123801689122802416295227383053653354248858;
+
+ uint256 constant IC11x = 10008840631783444674508080263114468967746505985887996910178896501934853112277;
+ uint256 constant IC11y = 16936570667799938576720674672020880352745864020685762112062389878811942670453;
+
+ uint256 constant IC12x = 5011295541785917253841138526393801554674138828598767265499922645012524973706;
+ uint256 constant IC12y = 16349216152175104304359703013765160891794704624846039150494873367554395977639;
+
+ uint256 constant IC13x = 7548817140284270024767897095191300906429628627848190048017422197184039345468;
+ uint256 constant IC13y = 20572758876763961487189667745519827916441861261830008380795433287292668839436;
+
+ uint256 constant IC14x = 9310202658901625130511022582678086202713821448286182983011894770178982336942;
+ uint256 constant IC14y = 21508777100401785479849873114458695414378605252394186900598351725717526189557;
+
+ uint256 constant IC15x = 12260964548592658396424901582131881359751554819427162177504443841765368321876;
+ uint256 constant IC15y = 21301736234596282752590600516446149129316093334303375321673322411077259438655;
+
+ uint256 constant IC16x = 14642487363334277771490793825005030053584080377788315143303114375684681938542;
+ uint256 constant IC16y = 20664977713650680750281838383025238525713415094304945120004730449262488384022;
+
+ uint256 constant IC17x = 11155558253783912280558999944178193173511187318050816746725717529951328284540;
+ uint256 constant IC17y = 20270918106701838044029414642792178094661951548884991533905436418966923621204;
+
+ uint256 constant IC18x = 15899525433604586299489303087397381627434708234565178521593785046668203550489;
+ uint256 constant IC18y = 21824016866807150124015517974279411199130449789566947749017632765310230599399;
+
+ uint256 constant IC19x = 18206298059099796998974980567851170868688661505006528917161885629028844273319;
+ uint256 constant IC19y = 20205998420522370530015175567631937864564619951339244121274820768541699589312;
+
+ uint256 constant IC20x = 16716732700347822216950736885335171256457458830095360382818581195245277662844;
+ uint256 constant IC20y = 12620671344632097624479873273828489108167233217154355804270325218144715019625;
+
+ uint256 constant IC21x = 15451727379452733529849866073401124935472505715724949099913064752553869375841;
+ uint256 constant IC21y = 2158494354079555870408740408982601623248951309670788939773173665188999849514;
+
+ uint256 constant IC22x = 12284916869162366603591536277341724694924567911001518117085010691159285217781;
+ uint256 constant IC22y = 3593671237360147483394250564233844289003151048424309908847155770077900837396;
+
+ uint256 constant IC23x = 5927916390106185710893591001482753681189190586739932433136759979576724457076;
+ uint256 constant IC23y = 17599435048350890672110626193872822768209035418359930522010561240756721388640;
+
+ uint256 constant IC24x = 10357931868184807162454228167040519777998312209268559210853555352156575979574;
+ uint256 constant IC24y = 7417675271573989779085236286148208506480849672089795015947641449389114925808;
+
+ uint256 constant IC25x = 3010789866507807199683295818137797298080293342308826284772296511624361032693;
+ uint256 constant IC25y = 10883029039185081070287331826150260206804255483544441222181904381405366832480;
+
+ uint256 constant IC26x = 14052810950992555814041035499198803453618213826282303164838796899766080803853;
+ uint256 constant IC26y = 13787869378104349961875860786635600848608758857173989070700650448142243716915;
+
+ uint256 constant IC27x = 4438184814904840719569729577942594719817707257590154686812204242033175243682;
+ uint256 constant IC27y = 5293847823520586332773082241381604595409933105388054257434812639571372785033;
+
+ uint256 constant IC28x = 12426062767280270413342564662359518141997462288241284017438655608080553101284;
+ uint256 constant IC28y = 19934796116095975190501818026905984121241074331801352805708937025636092233315;
+
+ uint256 constant IC29x = 19917477943324844916255800210447108539265540349330009748325835880239261186569;
+ uint256 constant IC29y = 20607661626672167285897710278861348562213926060181371585376730941172539197897;
+
+ uint256 constant IC30x = 15663529529817851445495805724697116793551842073110287348267972672089330537604;
+ uint256 constant IC30y = 2990047183788148120908377069775001819299541212105999741830773738506267779547;
+
+ uint256 constant IC31x = 15746021759002488832254562055094342761945226213397302973215346129252929703330;
+ uint256 constant IC31y = 1779679476764911275724775229006921806747299080350306600219370216496476532009;
+
+ uint256 constant IC32x = 5100443297376737166922471551514878258594598922375103842765986165975972291703;
+ uint256 constant IC32y = 19717758233413391570700701720187644271680987013060568697606415012050381861288;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[32] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_2_250Verifier.sol b/contracts/Game_2_250Verifier.sol
new file mode 100644
index 00000000..de56061b
--- /dev/null
+++ b/contracts/Game_2_250Verifier.sol
@@ -0,0 +1,387 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 4846814382002903765905858700302108529726000251863399623020028490066027905407;
+ uint256 constant deltax2 = 14777258313374547526762970266482263123811425470563086585212698332167883284655;
+ uint256 constant deltay1 = 19174341975253118603610410588866055152869804185609421839108014645284713130222;
+ uint256 constant deltay2 = 1647592398709578228687049021414087807822780800925504875013600448292475949371;
+
+
+ uint256 constant IC0x = 1492009021922040319433019921862173729470162302213834207479381221409571853705;
+ uint256 constant IC0y = 21222477757584347468705155283562862973771640088478805798363675952468324232855;
+
+ uint256 constant IC1x = 2310649769198900837828050336765392015360970792180928468190678690050772299285;
+ uint256 constant IC1y = 7187610815530919800625432971634534328846844288610247755282602672749238549247;
+
+ uint256 constant IC2x = 10474109080666281714190871123936051336465380897163747958508011116760817430993;
+ uint256 constant IC2y = 21514028730682210131540420607079727523460371702812399285379441694325841374825;
+
+ uint256 constant IC3x = 12450863301092422317619137059188225041982584983528089944629972754079634389901;
+ uint256 constant IC3y = 20670227234944982435021195060676726283104053349293120644705548376682210006391;
+
+ uint256 constant IC4x = 2722115588294114301623096965709538752787263586098908045857453915609281707389;
+ uint256 constant IC4y = 18565658023823915114193020147544632938814620766753552481519376124784907421219;
+
+ uint256 constant IC5x = 7512330660750913228629021229252600129894027467958042502050471784284488637215;
+ uint256 constant IC5y = 12526052837340734801031590573992781782000025103610301144737636630426645963827;
+
+ uint256 constant IC6x = 5903574859737937164640751469993174924075139700422585051000170856645909236182;
+ uint256 constant IC6y = 12576481033247607036031111294359629814434680380796311577819805850290926651594;
+
+ uint256 constant IC7x = 8003099007443146298323220942931240639529916997992708347683331866740091519344;
+ uint256 constant IC7y = 6583926029100114318177168679937186463826274522717006882842896213406434580661;
+
+ uint256 constant IC8x = 15794594866548667165976282540844159039609112048081418534071927871377851031648;
+ uint256 constant IC8y = 13529889323369529537758458536772245531164843241323866053726657201569503665017;
+
+ uint256 constant IC9x = 15462070426842867059230061224713838731609102913222541642024046052022355594793;
+ uint256 constant IC9y = 13652497609039367086428834414039976639548668872444095499226549373532032572982;
+
+ uint256 constant IC10x = 1642924194484354135795859838752106292483413397500868676057206594306006827521;
+ uint256 constant IC10y = 18879431054009145897250707089427601768908269588348793803884993181471026312794;
+
+ uint256 constant IC11x = 14884618644816019439872463873013833807433929012796802001539409546730605890170;
+ uint256 constant IC11y = 14100004196694811705433108631267943249572860492766986671110350989512311269286;
+
+ uint256 constant IC12x = 3710762792923029747926905384381544579587487733937100656987885408254036303232;
+ uint256 constant IC12y = 8582118809646583236338820079153727745615355145620322792605694275201338627557;
+
+ uint256 constant IC13x = 8816617452003199163011664347369217564210017388841489641218707248328353079844;
+ uint256 constant IC13y = 4528445733084315878403039587539021850242436275210925473314659307438081702129;
+
+ uint256 constant IC14x = 10425595217981184146295434388506851093873110515086887155170824408397468547418;
+ uint256 constant IC14y = 15024268747597288185250640729898280305216987063261312353188239805473873091708;
+
+ uint256 constant IC15x = 18947377496571261912089565174422354232937068891579147374434997993033249151262;
+ uint256 constant IC15y = 21819793326014828925124659728283680963972360542914950669904078389771273402232;
+
+ uint256 constant IC16x = 1529519490689852841463953198724937973863359181042109563762036940130294337843;
+ uint256 constant IC16y = 11454579482302497128849591449199390719783377233162840393219588962622341578379;
+
+ uint256 constant IC17x = 8614664967750532920572502253943492237919813472192895582735350764723254199364;
+ uint256 constant IC17y = 5904329575607467822084887737799304451854791866690489547252020595096337220318;
+
+ uint256 constant IC18x = 184492608264596809300134839195039818931040574067557857108223254705983002234;
+ uint256 constant IC18y = 6581995997224263740795875580129487153048689574027652528532646166806527585114;
+
+ uint256 constant IC19x = 15641501022857283778867661709219414545686840044184499228977638477222642139997;
+ uint256 constant IC19y = 2915195711426072441748440390487806164273106369331682492486567468031414496374;
+
+ uint256 constant IC20x = 9018709072514436250011562827507780647977689862886289569654046900361570713183;
+ uint256 constant IC20y = 10711934310252769794238537773152919781009782684206465398610893031262324401648;
+
+ uint256 constant IC21x = 14332420856613594379354211215954889874351733026631918157106152169997144742757;
+ uint256 constant IC21y = 2700813970642167997004923600809058206821143559593320101072294540950803737448;
+
+ uint256 constant IC22x = 8708801078972290474010335468813253786239096205350902547636418474707908223874;
+ uint256 constant IC22y = 385368664723247737999843809712925190193018995464383689595761167005805426616;
+
+ uint256 constant IC23x = 14812356269653592877097897793954435971803896922584761270856409822228013456110;
+ uint256 constant IC23y = 7486815020056934570126526272871143594729205981916769221320435268408702585367;
+
+ uint256 constant IC24x = 10898493728807476067805607786399101506280130278787443000488366312710448216595;
+ uint256 constant IC24y = 17163762543938470468298881376287272612407670196697729533758120297369054856675;
+
+ uint256 constant IC25x = 15411317849775912773360873744136356105322548495499761455810125704206180255016;
+ uint256 constant IC25y = 7135183139154752259093768679200085064788790590101719348029031127710380860342;
+
+ uint256 constant IC26x = 5778224990907212691370433041090963869034874923978119280037640312920648854523;
+ uint256 constant IC26y = 9949614970028926645243912373572507966121566640432031641156864924424708533858;
+
+ uint256 constant IC27x = 1376591970430891605210968209371580706384766465390155907135338565929863913482;
+ uint256 constant IC27y = 17211560057101896760374550125788922694201807201814264331378352838159879795590;
+
+ uint256 constant IC28x = 4881040663286908625609784831989999849621490407261598994794811196648190896557;
+ uint256 constant IC28y = 4326799435218308735503680783954082367161106495676363842477951224076185442080;
+
+ uint256 constant IC29x = 1250427819173358204376257347323536224307648337697985536010044205360562525592;
+ uint256 constant IC29y = 17574505504376966375281017139831623418569219814076001845777101804211057515275;
+
+ uint256 constant IC30x = 8537573027874432017845458444707190587620291153693446509283861833335990513446;
+ uint256 constant IC30y = 4603833505656545606276230916515588659455431978416059169074573817116703903949;
+
+ uint256 constant IC31x = 21795213898443173578448942854041061222875565070029372220449579953630737008554;
+ uint256 constant IC31y = 4294952670186394380997318018000425858675731725502800780593534703129664695729;
+
+ uint256 constant IC32x = 20197513323890922552438448277835081614424691640110043501517395178059892029277;
+ uint256 constant IC32y = 5902049325825209418172944807376544192427301619057987718397588614826930462642;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[32] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_3_20Verifier.sol b/contracts/Game_3_20Verifier.sol
new file mode 100644
index 00000000..7a77a9f5
--- /dev/null
+++ b/contracts/Game_3_20Verifier.sol
@@ -0,0 +1,457 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 16701836507290398565728365620726995004022259902973634467609383012178168768759;
+ uint256 constant deltax2 = 2497047295857239390853043588452982794402175693406484183300981010727065857118;
+ uint256 constant deltay1 = 14506082775736690595642225701007251089257484585990424106994486801065709544661;
+ uint256 constant deltay2 = 3036146790876975545294881983098206119683303665922633426484343092099027423461;
+
+
+ uint256 constant IC0x = 6275415528249071190283048506147700421096788402639167837799061998123311578802;
+ uint256 constant IC0y = 11125713476328307246600837885641515831429100063579970807946753578614701715674;
+
+ uint256 constant IC1x = 8921885145249331708349148909390219955122494651018034641630342116208288960390;
+ uint256 constant IC1y = 12682565675336705012838405899693262401002855668927554680364481746606629590691;
+
+ uint256 constant IC2x = 8784020164083237660713793774242105936757316664411874024272485235977976039522;
+ uint256 constant IC2y = 3215215518552606703390792194596952198736910909955208830491424326655501144762;
+
+ uint256 constant IC3x = 207226448510784384854359267515827600801935958099920888234849869803077899693;
+ uint256 constant IC3y = 12343086164937297671424840499354513949170033949732174159988138873793959518653;
+
+ uint256 constant IC4x = 18666274037896845236515191173801470674430322459212041278907787696394401676412;
+ uint256 constant IC4y = 15759811872963487770676587858832716623191848631686759852427792168673159742155;
+
+ uint256 constant IC5x = 9861649372263698226548219871019747372856829178951633824587069171723846067595;
+ uint256 constant IC5y = 9325772416705352081404383455649183697191691085311138081090987974171467561334;
+
+ uint256 constant IC6x = 16640210295139910216498364691857153660989098839220968642895371144567452795531;
+ uint256 constant IC6y = 16638753001802792150948124490382129531173337005363975272186722798149999950988;
+
+ uint256 constant IC7x = 9111877592285170961274955032909482806669909734004900837309819386953373146041;
+ uint256 constant IC7y = 19998289148613787693805169516992098780645673695487943747355848884348989424438;
+
+ uint256 constant IC8x = 20541764001822819608892052141011251455112727226682012806000948177920350904101;
+ uint256 constant IC8y = 18701638987169872310475633364666243571867267569850070989567715166101994263905;
+
+ uint256 constant IC9x = 12830320145266205020345180090743969005418496137014162680176943299106332124676;
+ uint256 constant IC9y = 1820475766701375410826146160254603625245557432810935819141253813996742425542;
+
+ uint256 constant IC10x = 21450281248220390228159374888468695181013626213454604304980718874579030711818;
+ uint256 constant IC10y = 870741312596995787526550136252886843110653871222775347373904039332441553491;
+
+ uint256 constant IC11x = 20166446337472415055774013539923098412726886473073765832551363682749523801900;
+ uint256 constant IC11y = 1907743556310933834382911683380069679789376760130721203854737656005085241060;
+
+ uint256 constant IC12x = 14708624602081471656922832031968517825804173144063519574238963236938428112306;
+ uint256 constant IC12y = 15722526895061349469055406398442431683802279667419081061206405579758742320804;
+
+ uint256 constant IC13x = 4136259535555310961230513927049596558460231273233038058677438331990661708574;
+ uint256 constant IC13y = 18232402976485915292316368921826851250660966436099433858310126826646356469021;
+
+ uint256 constant IC14x = 5523395165052304893641472559663779987781976380484909297012356414239901966071;
+ uint256 constant IC14y = 5898408079236511818614789651057743546261910824133231886357116833060882961287;
+
+ uint256 constant IC15x = 4462121788795337563850767782432382748481864146737013675070449537420603191515;
+ uint256 constant IC15y = 11329825476899049448160818669265387152497692321770415437639982345935013747732;
+
+ uint256 constant IC16x = 81952475250543084804743986355606361447233659624925727019171748976254274320;
+ uint256 constant IC16y = 1487528778482135961433270276943297154528242599231400161363070928742097104584;
+
+ uint256 constant IC17x = 7248509061377142823901511348965342713293982699894306396409232382162657459440;
+ uint256 constant IC17y = 16810681879364048070817284096833495989233872590658055159870105845411777842750;
+
+ uint256 constant IC18x = 15428849131807000119106004912126668621561530068528373463555465783764939115309;
+ uint256 constant IC18y = 19211115881334697833896713355003628600430115895403258685780181202860999264704;
+
+ uint256 constant IC19x = 19992705982769858372820970086337666528153873079174844248350681344597563383627;
+ uint256 constant IC19y = 14019996142159169234397116086216863491125665342819335957592814934121798322864;
+
+ uint256 constant IC20x = 1487916360940553929433735254433837774988566299776833972205981355639052812102;
+ uint256 constant IC20y = 10737000757521294965637608151446228423324348105464668451079557787749136506520;
+
+ uint256 constant IC21x = 11475511825818844655104542570576972039983623303352980540870815375635735708764;
+ uint256 constant IC21y = 20029098672741380238326745236114898016228999999830565023824383296435326779230;
+
+ uint256 constant IC22x = 1590765857735657809654561198095772546088732622220191728012345798903946795781;
+ uint256 constant IC22y = 2497594830035962353950277151089776710455133999594397119575137923899271405883;
+
+ uint256 constant IC23x = 8324400304098483514498496388937306235321012785199506948744941461651986012347;
+ uint256 constant IC23y = 12978422788645716703129800090258941005903145393738282503430230544838550284795;
+
+ uint256 constant IC24x = 7135802963576493429196878003230671115064118480230016211470527996990596203675;
+ uint256 constant IC24y = 2096914902303980181257894152731081403690346392939161312158532673047186576424;
+
+ uint256 constant IC25x = 14936375353543880595649108650524704553124976280911816168526431957385782088667;
+ uint256 constant IC25y = 16309788022937248708652779808046069188045155551731636141565712576645511947081;
+
+ uint256 constant IC26x = 10351884541227614348962370982772634561467340000992704265985359138299051115437;
+ uint256 constant IC26y = 21320257374687919624044855223412023334812678443187448003356508624393857079411;
+
+ uint256 constant IC27x = 6043803339541942597541917374643357598652738753013781665725152561059425990400;
+ uint256 constant IC27y = 13572043235235523708640185505079020839251604736055151441085934268121904232423;
+
+ uint256 constant IC28x = 7349825421289298757915517611991700024346868649575331977401634595332937793475;
+ uint256 constant IC28y = 15569627827581362891438649105427480058968842916483805814266369236303736460977;
+
+ uint256 constant IC29x = 7606567106931611457435574053898355937401673710750267491820860536855024941408;
+ uint256 constant IC29y = 10551939947074055561082852255337067703994528068171719600922064880276588029769;
+
+ uint256 constant IC30x = 9460453646476845374323974080326953632335818666746477761406817842307318288253;
+ uint256 constant IC30y = 8640133752658737666612987852938541835040589502160006127293337418896834087988;
+
+ uint256 constant IC31x = 16705338777315901947461689530494351281041870147801405359338468790296357227022;
+ uint256 constant IC31y = 3973939785824964727126550752434126202957020321279136206288831265924932981013;
+
+ uint256 constant IC32x = 9664684065781221463516385856766771112287449886875674393936109549384946202655;
+ uint256 constant IC32y = 953574230056987320889486542725323389738784397211796370394807548894171921486;
+
+ uint256 constant IC33x = 16242332056729207698533440040624804021369877641850066883352705734000010798621;
+ uint256 constant IC33y = 14326147954759386916869706762056061150423859574237380683238424782263690810784;
+
+ uint256 constant IC34x = 12563987512905249736935500575077017309558029644307042311044692438823646542816;
+ uint256 constant IC34y = 2340429932978753624320372751962789675280244868602371256459681011896310843808;
+
+ uint256 constant IC35x = 1631268488145874879835132441905334955062365447702296727242075005734092144869;
+ uint256 constant IC35y = 5866807800084592891342437976885274524947726265544758921213473711825180631079;
+
+ uint256 constant IC36x = 15282075656509434562692804752829152936100745034448956800179999665275412796186;
+ uint256 constant IC36y = 1973880773192532166644218545534698579265127104769462812849994476606869176075;
+
+ uint256 constant IC37x = 7213395820429814494045210678747800168797906103072257089791421157380099307278;
+ uint256 constant IC37y = 5644075943075029315867659700146303964653496985336507009127496761360146950030;
+
+ uint256 constant IC38x = 18710721780329988392865044871039807453148543120081801705470724681583169401095;
+ uint256 constant IC38y = 5669598551411689063529143598817788899845443458013152731725070025801063805010;
+
+ uint256 constant IC39x = 21093223225218837362989937055124789406777218925071767518983490927229818548475;
+ uint256 constant IC39y = 18903417437630939982750817792708185191527271751287319830889231905703005351066;
+
+ uint256 constant IC40x = 12925492742484174889114674255159163212831191217974586053219831615407743851637;
+ uint256 constant IC40y = 5007461461092826491823058669972734069139165496390812247681554949655316921247;
+
+ uint256 constant IC41x = 1797433402678975283103335151259585613338185888186042889316433980141079278936;
+ uint256 constant IC41y = 9706282411948234757299973078793649588781553584355534551579060060873141359676;
+
+ uint256 constant IC42x = 18982141795519009504263716906233467318693824861416118169289666617947703044572;
+ uint256 constant IC42y = 19330341050177775309166101290462905047669369648196205256611231734349671761266;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[42] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_3_250Verifier.sol b/contracts/Game_3_250Verifier.sol
new file mode 100644
index 00000000..a31b56d3
--- /dev/null
+++ b/contracts/Game_3_250Verifier.sol
@@ -0,0 +1,457 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 14560134422850237747592194898693654827173300180073442225203599163069524991237;
+ uint256 constant deltax2 = 5776246509577523990659767304848586525129454388389588232610734862788804082212;
+ uint256 constant deltay1 = 16070273647082707108744104620433651969265854621837986230578506531264264645468;
+ uint256 constant deltay2 = 5310240859043101628565507760367382129934402578608720584038355498640734144910;
+
+
+ uint256 constant IC0x = 7764365361902581414174581791208190254122591292215263171446355957179845670810;
+ uint256 constant IC0y = 1364297700847308560358738199429346008003686480180511662436077734076800487857;
+
+ uint256 constant IC1x = 10342165055229139335537257482781119112958130570254855837749649905088987485638;
+ uint256 constant IC1y = 6040592508593962743992145771719890979225790616605307716103557068259956875703;
+
+ uint256 constant IC2x = 8650267867056716291510205591656410924812957687228182614917603496437329919292;
+ uint256 constant IC2y = 18009216660085264202270021080169075333824966654115800809615718047127787775828;
+
+ uint256 constant IC3x = 19344175667798260480280203670482890737317507341873492603782359610124726334471;
+ uint256 constant IC3y = 7762731375425659417320528237905084369144052546808475983936000805839594791810;
+
+ uint256 constant IC4x = 2828584596907523590450509980137158013789142280650821293310503769187816107119;
+ uint256 constant IC4y = 19234243138752305903446633295476279093186466813819164416676099281151936216170;
+
+ uint256 constant IC5x = 5164905385182366544762962055628517212535242206942670054900907959012806665592;
+ uint256 constant IC5y = 15511010145785403670599031537349695082548564433763922004552903526384722018852;
+
+ uint256 constant IC6x = 6013179347351702024287866314657727737798584098964427110856705983373634491041;
+ uint256 constant IC6y = 19401019681649934127449235416623117641367469217112084462719221468645329393148;
+
+ uint256 constant IC7x = 11248480752765863614767205198660031081217299016374235647625012493817742980024;
+ uint256 constant IC7y = 3180453039353599340380187754410295036290444472595393063399144769424980926658;
+
+ uint256 constant IC8x = 8901054949418154197815079469635474599270075374416655943389776504868600592825;
+ uint256 constant IC8y = 19399404651349043198640595259813591266698472163740846969581911313211320283702;
+
+ uint256 constant IC9x = 3741218395543883259960155038035394865594443822650010293124159840873245794382;
+ uint256 constant IC9y = 19009931343243016163433927641130943195336090702883301707326551470069486358758;
+
+ uint256 constant IC10x = 18621071902864452168251266956399221947203642722637848227146892409642896552707;
+ uint256 constant IC10y = 8861425868294754898632089805767349351200651628368930640213891170247291664762;
+
+ uint256 constant IC11x = 11527835760140601230788566923601457106888093234926600235829480267327165810428;
+ uint256 constant IC11y = 10267138280007018763993545005524061951177114416921653596769189069901790199509;
+
+ uint256 constant IC12x = 11259709604178476954746077273030736760506714999128475794256797777539224415207;
+ uint256 constant IC12y = 11249908955122515117541331737980347826235443459878026123850741912362285065964;
+
+ uint256 constant IC13x = 275703561852492400963180778351885451387447525666170748457010194742624650369;
+ uint256 constant IC13y = 17579354490901430420547969022001042284095841392597127078025900046447678918324;
+
+ uint256 constant IC14x = 16099241818704386353696733092661985938083569084683004937807173578903769790939;
+ uint256 constant IC14y = 2577136082686515648914775742697882145849009921008656980941080716494004589449;
+
+ uint256 constant IC15x = 8169614266292109260935252984018250410790577824610575926900417380615784653551;
+ uint256 constant IC15y = 8172584766921008370417538341671445057305633455495774135775130020187536796707;
+
+ uint256 constant IC16x = 20495258347187820156753552386605567894925036471767426286759183689057299900626;
+ uint256 constant IC16y = 17737296639281589724805726000031273001473199686246605551433145601015049579190;
+
+ uint256 constant IC17x = 3945672037218351373848318931547389211056185174652874576505840389858342629135;
+ uint256 constant IC17y = 11606666909489144289391648840594881110081775712820625195673613711384235526188;
+
+ uint256 constant IC18x = 21759317421408459673587152563104855892625389910340470568546706731862556781910;
+ uint256 constant IC18y = 6957935020385239654548924469795899673711490377719661730300960231243159179943;
+
+ uint256 constant IC19x = 9219492569038127367088018452595346912304193711110633079962224342547764385688;
+ uint256 constant IC19y = 15232376992146455320344933576880142538036706178984995492897470349913655354859;
+
+ uint256 constant IC20x = 14881753207585855477875030972512959837905079386832898867579063099932117892567;
+ uint256 constant IC20y = 11963325384231398852247824837796668421614540920368457599482830660356475113943;
+
+ uint256 constant IC21x = 5578085861914725625868251045278861974265268945964360642550511344112333554367;
+ uint256 constant IC21y = 18949456617436060980128818226231996834685515515142147858699815282758541480465;
+
+ uint256 constant IC22x = 19657404122193625504807579140077329890041482458087705136670972360137733880130;
+ uint256 constant IC22y = 4224376660457253081313751608368384016277673807240105116469373251892353428596;
+
+ uint256 constant IC23x = 15451840103591058923657402766143650281133349389856474474584596908845457596400;
+ uint256 constant IC23y = 19313971429226923324857828812962372535499868378036137710492930391618838579401;
+
+ uint256 constant IC24x = 11960246640814361266244266590713501526133289233769509744088903156525710861407;
+ uint256 constant IC24y = 6065169358998432516802827476930045910445997393153043558185382099828582169900;
+
+ uint256 constant IC25x = 18538648572039179373032263424964326479189123661117473409978081218418774387848;
+ uint256 constant IC25y = 9374769248242531457590449591955740239595412391921078393855903496860039439081;
+
+ uint256 constant IC26x = 6863171843975376491569777638133034064079551554511291727939853484077319562875;
+ uint256 constant IC26y = 20264747018233566226082962328279489442921507549151982749402465860293372057098;
+
+ uint256 constant IC27x = 6661618114942670580095462137063384405582406916735399898031742396934065324476;
+ uint256 constant IC27y = 8612285024979391018552308095102944215299147106074356895110232369218432734689;
+
+ uint256 constant IC28x = 867859844478025481508074098989229887891937682797675756601239781832389926814;
+ uint256 constant IC28y = 15681075001390320571268244993746404400198173774524565428472442266277027242601;
+
+ uint256 constant IC29x = 1463644038548776002484899509800380534490947176642973721022080805377116067188;
+ uint256 constant IC29y = 17338037987187754983578381065999940582455047076265154201969295146309495175677;
+
+ uint256 constant IC30x = 12081441984953089514813577922235533793574337946152041911820762756644996845217;
+ uint256 constant IC30y = 6069955891030643072159035171366576363660066357856145404470261974758109006692;
+
+ uint256 constant IC31x = 1920404109506705801563978256166309718527447299747131989979371620571009743723;
+ uint256 constant IC31y = 16945710011659352209169364503055998784296001867037664208770791931443006732356;
+
+ uint256 constant IC32x = 18989183762427117901950528589768646852504295462839798136990535354340822015033;
+ uint256 constant IC32y = 16677785597563249523885213403445550720268411446385895041381842534903943205240;
+
+ uint256 constant IC33x = 14398914459712370771003121290174055266462800089950035418416815180339958705592;
+ uint256 constant IC33y = 15663533987819366157429439407256779566922023545642324487538974056547534129986;
+
+ uint256 constant IC34x = 16809491323222372917997013256184579311187014753457926856308720987023561726009;
+ uint256 constant IC34y = 16026654519753576989808437617424018526525603036624908730012013439848438665455;
+
+ uint256 constant IC35x = 11820149797053488159512731789344636251560649829679571594130334217893258831702;
+ uint256 constant IC35y = 13018643523700060338130090606807988193439312060447009520917029061656716078712;
+
+ uint256 constant IC36x = 16701927882988474481696432298962475308105167811776648714021495137375758770273;
+ uint256 constant IC36y = 2157845812257396911420293782173883794499880901615939577106233968376627878984;
+
+ uint256 constant IC37x = 6451119276871031376649271999025228480451163682141558414154065914352548499035;
+ uint256 constant IC37y = 4025873613188505505049719021435219043546168078722230607192620138805138135153;
+
+ uint256 constant IC38x = 4738888243639478075502505487349906111730540096000861686089331238801086330111;
+ uint256 constant IC38y = 3730180131618305084132911890270788648836100637360275791723540673224588042995;
+
+ uint256 constant IC39x = 21255556294962407012733173522732172552036085045187512047870715960117262972686;
+ uint256 constant IC39y = 15972177292201014700466277151564496962518307810380215353187825448832867560194;
+
+ uint256 constant IC40x = 20241962120163128182919219381539950881842331207482801408983956664796117625928;
+ uint256 constant IC40y = 8050115223626749005965157826272152363466541472992729327118006239069520043131;
+
+ uint256 constant IC41x = 18669928206349659224354730730399850634240421193769476717079939628073239836765;
+ uint256 constant IC41y = 14499140870244636820635101481418128874885338000168798453844121746102792170353;
+
+ uint256 constant IC42x = 13524776280948979459976540773708351285368380212002562477833026483657827316415;
+ uint256 constant IC42y = 16959498043432446543150443446075052748542924944276711688839081456945511614027;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[42] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_4_20Verifier.sol b/contracts/Game_4_20Verifier.sol
new file mode 100644
index 00000000..c567222f
--- /dev/null
+++ b/contracts/Game_4_20Verifier.sol
@@ -0,0 +1,527 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 6582808995186572554712453396739685223518070769299445922907784448024708451535;
+ uint256 constant deltax2 = 16220871310876092658521630549238389230186082651148042369844538423518205776454;
+ uint256 constant deltay1 = 14255457773866568217128700180401295470441528872252453431230752410101618825365;
+ uint256 constant deltay2 = 4687690264269662847657605567053563247514065983919766593063418027155774959506;
+
+
+ uint256 constant IC0x = 2828902839578276038193443186349470102672747282669648817598101646414229983357;
+ uint256 constant IC0y = 1404539186166986767794827392794039462229846802403070263555767290721378908930;
+
+ uint256 constant IC1x = 2103280060569099471838407333425245144620170198756789991901050575559489772945;
+ uint256 constant IC1y = 20716851890558972080189981761375430324040285553323864626662004159273295506736;
+
+ uint256 constant IC2x = 13641459169670747811750405982169522918979653150789571718817479141849780940186;
+ uint256 constant IC2y = 7776125843420229904612383223976003659294151947158657099694823043540284213713;
+
+ uint256 constant IC3x = 4956326181587586226751737320087806850515737218207455835647082321656553222480;
+ uint256 constant IC3y = 3145177280894542035168453203026811934471603785730978165435540758401915112683;
+
+ uint256 constant IC4x = 14099325584884870626972894221491208620847903583868342622396987227140443286079;
+ uint256 constant IC4y = 11135004328085481825981671887964578214940136916574750104789040824563030185051;
+
+ uint256 constant IC5x = 3917024054125833185355491484181302502216517916486173232878383955246897494168;
+ uint256 constant IC5y = 9578484157897281459465283286269502235786943413614104786709285235473245305876;
+
+ uint256 constant IC6x = 19331728913857774388748753051144411927178286347348356049776981343167217679170;
+ uint256 constant IC6y = 12730763478717426511635762965443918833873329705076306049508838722250499332796;
+
+ uint256 constant IC7x = 4075537215457920695970931089044392708771828849000213557275639650398406315562;
+ uint256 constant IC7y = 6941920847438224689716257046093940630139179576603620212318073419444306485459;
+
+ uint256 constant IC8x = 9059408547107184485916992873362932869300288000640935822969788845229609582078;
+ uint256 constant IC8y = 12670645025926652039672308615395886027423207712811217940510566624905047943317;
+
+ uint256 constant IC9x = 15787179468769483549653187536786081354771127282698955226107558810736697133603;
+ uint256 constant IC9y = 9079272647737505180344341391689837632978168033408889682185721072509304157986;
+
+ uint256 constant IC10x = 16310541427761545765111701953869724650295378884615765370721536606907542888253;
+ uint256 constant IC10y = 18466199608670281342411044235503754757550035380442648390125953871390260340266;
+
+ uint256 constant IC11x = 85647471650775009036792002984621026676473840950996306668069424094024393451;
+ uint256 constant IC11y = 14893882381265789936335863806177267940857752118239495046908829633476573902258;
+
+ uint256 constant IC12x = 20717120037410694864383155813149851098914063340540871742727133486645389256899;
+ uint256 constant IC12y = 7268161190323924083689884512315033732501430444026105779199374780553238005069;
+
+ uint256 constant IC13x = 2823990268313472553935134917893044309634597563860106122767989347385009118569;
+ uint256 constant IC13y = 15538117454636378448381088765342008120177152317674307154923671349605024710130;
+
+ uint256 constant IC14x = 7114180163146596275192474135609287230382986145467430624860962742508136150319;
+ uint256 constant IC14y = 17634887659227141298612290061793595387906406524785090775295351332432470588472;
+
+ uint256 constant IC15x = 3020261246489071998543709084739257393174561282016715874992960263547170216348;
+ uint256 constant IC15y = 28510467536706649938890578771292275325622118196282815271407195357822575437;
+
+ uint256 constant IC16x = 14763751490551605207714216411591455511793381895656744082522874280872530308671;
+ uint256 constant IC16y = 5901185292118202355255422286943175354137320221186133549678911320168484429005;
+
+ uint256 constant IC17x = 5351194280710830083089910928410679344446978849746172012558905434079081044560;
+ uint256 constant IC17y = 6225899924215180771666108569912844152406857923426110093219525518808030155525;
+
+ uint256 constant IC18x = 1945924107049911535730571834499773335832503739815483448803151142255951147848;
+ uint256 constant IC18y = 4655517686568512890184768598313892953254924834291602769313537167620718867318;
+
+ uint256 constant IC19x = 14886649837804672059649860425546877762784825978936923661902816286478060014929;
+ uint256 constant IC19y = 18792002790886066135821689608400386323092888002754078737319002566708861840061;
+
+ uint256 constant IC20x = 3006402280118820744942935618784447664160314795537305780151346437199669514169;
+ uint256 constant IC20y = 16173079763625715819863367118637103096712607825052967459322611294925466279417;
+
+ uint256 constant IC21x = 17285343239588721907255340181082272075587762720976933836007812676087052495294;
+ uint256 constant IC21y = 6694454313480976961368894941570100405853963326723123934470671427211764546002;
+
+ uint256 constant IC22x = 1371864796551355018095793081822678031591029889105360545730657777261117150304;
+ uint256 constant IC22y = 5035940640665292479047698099581862779279187118104105274553537105534504256998;
+
+ uint256 constant IC23x = 14652054951878581804278918243874143748040228660400601992965461708511847559093;
+ uint256 constant IC23y = 1472379801643689241873483817662947161181840990640443368507104826378715523978;
+
+ uint256 constant IC24x = 20072748604377995989936904296395745850877793917740362980743992393228024739686;
+ uint256 constant IC24y = 10145353081802762925125704388255195981151936131018091985309712936366084131030;
+
+ uint256 constant IC25x = 13619054108941145666675309020045257577673106189652071839704443264659101767108;
+ uint256 constant IC25y = 12330585367391214941864456708314367566527962882089267604751022722329279290138;
+
+ uint256 constant IC26x = 8305900796285755633384356168107121729585262588053042412812986294887404565258;
+ uint256 constant IC26y = 1515520174131892976578253156117714734143754499866320754051827832656585875803;
+
+ uint256 constant IC27x = 4557777697796746242730682726299039106592954383395222280648674678429765907633;
+ uint256 constant IC27y = 4473521648256234732142690248690261438706938425526557338376991377077304735282;
+
+ uint256 constant IC28x = 9770472826692646517807385325142998432565267911322833514440248613070225159809;
+ uint256 constant IC28y = 3718700672944604421357506479942428208220768978273235778676598005883278544017;
+
+ uint256 constant IC29x = 16060797312843869376086632406513882999523664141450656458646783980101471850277;
+ uint256 constant IC29y = 21552037803353580033501535682109565753580630786608976256631405888208713041442;
+
+ uint256 constant IC30x = 15148463067713313370680332718323967695668882099820066366901714082618379615597;
+ uint256 constant IC30y = 10828858852135617340531169653042878697066969722153089942402748227220520864776;
+
+ uint256 constant IC31x = 561205430223439591375222937612736217359274483328906249562168429675883661092;
+ uint256 constant IC31y = 10081015954203664630752507912472932476800443963486248735066105288855937750562;
+
+ uint256 constant IC32x = 490245103788052703520789245559002764283838703323070153797731359948427553521;
+ uint256 constant IC32y = 8386084497369910609594014959861196406332971984167281222076843173544555313733;
+
+ uint256 constant IC33x = 6646081547480432575330364774726770799557412101629242113169345575147343531639;
+ uint256 constant IC33y = 786617492704568576237265843644318845057151585635086772665718210272274387581;
+
+ uint256 constant IC34x = 8466414591840663582632937060612829320807314382058569806907226703648675529861;
+ uint256 constant IC34y = 16017774390411956785290354913233887246850864631355385533633990913029178817862;
+
+ uint256 constant IC35x = 19699065114238503168741082459165865156248463869564395204010373417705455228553;
+ uint256 constant IC35y = 14409922346129459163972034558169676994418217718572457401314143844229342204328;
+
+ uint256 constant IC36x = 6067251916952919288294750916524984095088205970969091231589543437079606714108;
+ uint256 constant IC36y = 3143807825764393566937772935955207159216747055021926737424333176252291777070;
+
+ uint256 constant IC37x = 11415003593937818341215556237202919418585855978744310918639649181632436688823;
+ uint256 constant IC37y = 16952102429497837724034425451639701988019247948534843958532496334978169919811;
+
+ uint256 constant IC38x = 13657666092148640299194309957776245537824008186538535231343856947649706053941;
+ uint256 constant IC38y = 9396382668207068347504143231098658017769198239867014344996022721779129777858;
+
+ uint256 constant IC39x = 1785732522703216728186899506074353645836819654839322314560102718450566588999;
+ uint256 constant IC39y = 6865821372139813677931601350630634066223121919224225211794507609952506145071;
+
+ uint256 constant IC40x = 10224248468051684750733216773458459636401100720145327972778500450556659682865;
+ uint256 constant IC40y = 10566133765670173958024011028569329400824865276098440655575551064996597591942;
+
+ uint256 constant IC41x = 12573568622104763042076223589269386384785210975810788299746880705422245957998;
+ uint256 constant IC41y = 5905051912104255687075722305649570843897103991317334620617109271426921023263;
+
+ uint256 constant IC42x = 20528379922667167770500268639035257294112152606376294973458699510095603183217;
+ uint256 constant IC42y = 14901263441614774257075397065767671166366537929050445836947801147242159243480;
+
+ uint256 constant IC43x = 14490917941141935812476557381894841059099362760468573405188400394061435681763;
+ uint256 constant IC43y = 13086916293381779450382830741998263738709519528392967936103784446259217816245;
+
+ uint256 constant IC44x = 15822567680088944280083487637482474157167612532311122817337820530925337213000;
+ uint256 constant IC44y = 19621931177509926716993072851044888313944300121694838525877979244467852084275;
+
+ uint256 constant IC45x = 8823741225783963795535104586756138900194365311859941903335075950592287167238;
+ uint256 constant IC45y = 114986791286051485742711052496708834424959940924423673484904368157377216423;
+
+ uint256 constant IC46x = 11785402127796751780783924367854752699926087307579903799473102555885312164513;
+ uint256 constant IC46y = 5483169917567693783277007997962390689567401507471725291421969416466886025653;
+
+ uint256 constant IC47x = 13947985717330982063307929155632276384062573893549688035100012571136118463005;
+ uint256 constant IC47y = 2508226307428280774915887341688514952442388534598204736775048181486860199501;
+
+ uint256 constant IC48x = 8198456789695313551902168876725077990778480123652607171846007279593831680347;
+ uint256 constant IC48y = 979943406311504652621464041575448800148844120339790871232781609004674880104;
+
+ uint256 constant IC49x = 9836943313679713646679947339360386193227948076582311028934064193234287196165;
+ uint256 constant IC49y = 11765581428724323207668807735060154943342601722223709980866508450161113409674;
+
+ uint256 constant IC50x = 2449926140775964627258368443906516902899149823933252694060018538135300359508;
+ uint256 constant IC50y = 15143849783681472175139610700218614529971577450167146472229608375198159987580;
+
+ uint256 constant IC51x = 4845738079177155541174775573126292783963887360269814564786509372259046164659;
+ uint256 constant IC51y = 5582120346752015209883795116966208366218705718254403308244186381039635043940;
+
+ uint256 constant IC52x = 9427221810137184898363561534534333813879313854851313277835738534855410760807;
+ uint256 constant IC52y = 11254684797363946925852754365408799665126282895862547580899855308711381951037;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[52] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+ g1_mulAccC(_pVk, IC43x, IC43y, calldataload(add(pubSignals, 1344)))
+
+ g1_mulAccC(_pVk, IC44x, IC44y, calldataload(add(pubSignals, 1376)))
+
+ g1_mulAccC(_pVk, IC45x, IC45y, calldataload(add(pubSignals, 1408)))
+
+ g1_mulAccC(_pVk, IC46x, IC46y, calldataload(add(pubSignals, 1440)))
+
+ g1_mulAccC(_pVk, IC47x, IC47y, calldataload(add(pubSignals, 1472)))
+
+ g1_mulAccC(_pVk, IC48x, IC48y, calldataload(add(pubSignals, 1504)))
+
+ g1_mulAccC(_pVk, IC49x, IC49y, calldataload(add(pubSignals, 1536)))
+
+ g1_mulAccC(_pVk, IC50x, IC50y, calldataload(add(pubSignals, 1568)))
+
+ g1_mulAccC(_pVk, IC51x, IC51y, calldataload(add(pubSignals, 1600)))
+
+ g1_mulAccC(_pVk, IC52x, IC52y, calldataload(add(pubSignals, 1632)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+ checkField(calldataload(add(_pubSignals, 1376)))
+
+ checkField(calldataload(add(_pubSignals, 1408)))
+
+ checkField(calldataload(add(_pubSignals, 1440)))
+
+ checkField(calldataload(add(_pubSignals, 1472)))
+
+ checkField(calldataload(add(_pubSignals, 1504)))
+
+ checkField(calldataload(add(_pubSignals, 1536)))
+
+ checkField(calldataload(add(_pubSignals, 1568)))
+
+ checkField(calldataload(add(_pubSignals, 1600)))
+
+ checkField(calldataload(add(_pubSignals, 1632)))
+
+ checkField(calldataload(add(_pubSignals, 1664)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_4_250Verifier.sol b/contracts/Game_4_250Verifier.sol
new file mode 100644
index 00000000..4ed97f8a
--- /dev/null
+++ b/contracts/Game_4_250Verifier.sol
@@ -0,0 +1,527 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 5137157611818670835725647271320937935994388117477222893339623043284884773704;
+ uint256 constant deltax2 = 8407292432571930426062926624456247001485816745969413442907518378117804992860;
+ uint256 constant deltay1 = 6540977956938744964694955090974443619330540824368621120516518605333150228228;
+ uint256 constant deltay2 = 5620417415999685736545556511682056306845400486021131559002657689167549972736;
+
+
+ uint256 constant IC0x = 11199469645057225056944539572014065189511362223621035502681503095514035604212;
+ uint256 constant IC0y = 18583615368301161913622084879219149110704290175492562623330496512017209789108;
+
+ uint256 constant IC1x = 1630918334837363726717502450719997651503554123011513571151346500099107338561;
+ uint256 constant IC1y = 7421774727316813189570193930218394462907294041461166872021892849629156485324;
+
+ uint256 constant IC2x = 16229237199267753537681313714618484368212346065149532178840677382788596164878;
+ uint256 constant IC2y = 2249830745060257187860629685339770062148571244704834639917639111849544986806;
+
+ uint256 constant IC3x = 16823445275477789105062263606600950854743412948359474770428651266836963258186;
+ uint256 constant IC3y = 12638629598071126310994285946614219227478809801964500300811756483316295259279;
+
+ uint256 constant IC4x = 15743183801662391180864064118425910445761354160381620157220978701567655943810;
+ uint256 constant IC4y = 8021185759316388460638397577791344789497719574808179052928480217693839097449;
+
+ uint256 constant IC5x = 7308277071157582572167728413106243456873071237435126458286544852633232348844;
+ uint256 constant IC5y = 6639800055638603822218098712285504061930947336701879742272075353449604390402;
+
+ uint256 constant IC6x = 18400570734383946835101415508891613107073822155363244807845090463520159495360;
+ uint256 constant IC6y = 5575999929268318254745552255325038565997316984680283475139616582855372712957;
+
+ uint256 constant IC7x = 611793944428100142214551067907275034894385546838353703425048881873866644298;
+ uint256 constant IC7y = 14548774246011634679916323058201441349972952016811161279285803990843423713220;
+
+ uint256 constant IC8x = 8566770307158959236779688069673516995678906791590235481229525312525699061583;
+ uint256 constant IC8y = 19478079738782759428858247257642902194553392277747398319957048631738144740369;
+
+ uint256 constant IC9x = 10922162551889316280482290919026872841812340637518023730052286384659157428300;
+ uint256 constant IC9y = 1208058448213963509310177022771340150711165943888173734487878128891608319888;
+
+ uint256 constant IC10x = 8432646542846868247562447249901025591033996731875300958483323990994199709303;
+ uint256 constant IC10y = 13789999420996161469473633463662031143630573221554537579141487196084731694413;
+
+ uint256 constant IC11x = 6479835712434731595294901134078030156660211689797159702535227256081316408912;
+ uint256 constant IC11y = 4881073172406015702828560714752785537144936253008045112499797887190467285867;
+
+ uint256 constant IC12x = 409076764243788295340800402358184748160300302921784616142024032627031423062;
+ uint256 constant IC12y = 9225109599582410846473529944847835475788888278245405097944973719909070213044;
+
+ uint256 constant IC13x = 10210048648316190237678021201666303732771777938177999013302069590895139577020;
+ uint256 constant IC13y = 20525079268346116354270022689983985519378233161316532095451077009040050767462;
+
+ uint256 constant IC14x = 1150836082434379685420104246742924889089444807552557539687124464510733867424;
+ uint256 constant IC14y = 20680271604672561677371150995907457483166132210953280866459507868545331358778;
+
+ uint256 constant IC15x = 11040388165387687147608013087510770575381138555672790580967177043160730794006;
+ uint256 constant IC15y = 9352100146784348902961417644973184635686439742975730037190088818035451898485;
+
+ uint256 constant IC16x = 19248806202378311929977293483626413692039203808846375943401245358426797968588;
+ uint256 constant IC16y = 18596417217279096871323902804205454368006061591592606397450724076066646617002;
+
+ uint256 constant IC17x = 11018067378686696371259317005543809660048851987433237837161018137880242326328;
+ uint256 constant IC17y = 14586162197251117409444615643312345616167363014852454803621085087811518038587;
+
+ uint256 constant IC18x = 3901469706044346706722185734637780246594848941351171204943912945375733510368;
+ uint256 constant IC18y = 8295774162472086908119201998078289951688284544772758151690435197670462935077;
+
+ uint256 constant IC19x = 21773718738682793690390383463308734080460916659043955736483585818741189342341;
+ uint256 constant IC19y = 496864844074889454541606348462091378138881962678843451864992395636843102182;
+
+ uint256 constant IC20x = 10696323253013036239336608275699984247602490211549345620448293763573737702636;
+ uint256 constant IC20y = 18320456101888780563655546509497648355898631691472602485716660699401677653868;
+
+ uint256 constant IC21x = 10304839964734197345407359608786800294069519124265055946921149856264499082147;
+ uint256 constant IC21y = 3920909044385434763565126222389717258720694065353917502229878902120367180493;
+
+ uint256 constant IC22x = 15359483438300540859315412423166405732250661012084235448852090147710230400291;
+ uint256 constant IC22y = 16572283166685359511480781948324490461889056581043464088797898191961036538591;
+
+ uint256 constant IC23x = 16091872136696528953412221602094913465152494328587047353566788661855657464443;
+ uint256 constant IC23y = 14405375431627146940035852580739252100276408652055860660638451611632005441210;
+
+ uint256 constant IC24x = 21076195881247047110912325180660071223419655868566465254233348424963630396308;
+ uint256 constant IC24y = 9525974977337505626200079848822885215380277991322609843279165101314618980878;
+
+ uint256 constant IC25x = 4506298608525340437387331626279207341371156847848025494854950356233636363929;
+ uint256 constant IC25y = 21485422580509440678456229207843742069113355148588407918952174350527584238782;
+
+ uint256 constant IC26x = 14479218060049969338381799565462582209333100892792389034556958933725911896501;
+ uint256 constant IC26y = 4179434539696017017240215241447382409180559607571357952675706252732276642933;
+
+ uint256 constant IC27x = 2460971820550153577004049662202201106309179833969856953926769913135176118220;
+ uint256 constant IC27y = 8408637174635572464104962169617051649203626983650362262517698402506825507622;
+
+ uint256 constant IC28x = 9420482864238695131557671569515153809350574757808253871934264743995354915034;
+ uint256 constant IC28y = 605322626891841329529431714312154127414728259836335720133212700300294801158;
+
+ uint256 constant IC29x = 19712867421736831770145602440489500562331789418956769197255110653106956475985;
+ uint256 constant IC29y = 1234355859568408801506146287758461147706440675436194404831812465217427065082;
+
+ uint256 constant IC30x = 15804507825830102937369146534259500887541094184694931896867955799548677756533;
+ uint256 constant IC30y = 8488403074641659531294492524510059960506275969348701531951956437419984049293;
+
+ uint256 constant IC31x = 14440470227524506271080102748006398717144016033960844952084553825325797713170;
+ uint256 constant IC31y = 4662944163101883280323962677796815165206673687721895794109167344475967830244;
+
+ uint256 constant IC32x = 15799677223439562776757846849298920295129771308081920213036634386461287898105;
+ uint256 constant IC32y = 14996675077606455481682143834303491798304251403225365531902785970019540531048;
+
+ uint256 constant IC33x = 2863731875626688223837871721465113598906104856680431073461380354611558347341;
+ uint256 constant IC33y = 19518663927787341671332283128774599667530081274781486933510957632687655667937;
+
+ uint256 constant IC34x = 10355360054606868056324184883777045514756793071641577537524120129987812394293;
+ uint256 constant IC34y = 5394747944992890586276420743103218759751296304970173065515882998366942637391;
+
+ uint256 constant IC35x = 296881867877831741499799792870571896049879333890611828946068346276697989761;
+ uint256 constant IC35y = 17582837546175487152427654532037808141370710694220730135134670778861094254426;
+
+ uint256 constant IC36x = 20217270082391948121157869080804495767265289194614527623478337873600736775238;
+ uint256 constant IC36y = 9524456507295372313821861511887379696599947872161051511768518649460409935552;
+
+ uint256 constant IC37x = 17212036215192813996087030921928514843041929053269515968331596204681379349973;
+ uint256 constant IC37y = 17480795202351155566168104480852831487075386011437816580340515065538390655281;
+
+ uint256 constant IC38x = 21815730873277583811096276594444398619218987672402596106496385786832174532814;
+ uint256 constant IC38y = 7840211772897951044660638381440591272120501539858275554230004313032881221329;
+
+ uint256 constant IC39x = 10800007036997671120578994750275474468903493995330037209572283183933825983328;
+ uint256 constant IC39y = 12901612336059202748661538171473664498430712947797826387831733716900906195863;
+
+ uint256 constant IC40x = 15791386201220933566198035323542311268493013331815950970816140158646236956338;
+ uint256 constant IC40y = 6127554307202213399988984303935013861421855836154807079361923548261643100211;
+
+ uint256 constant IC41x = 13898263123490180787409441035719528351351983193931993386951581800143073613527;
+ uint256 constant IC41y = 19020744251310409766689145749688025758548431289383982232050753791968238369672;
+
+ uint256 constant IC42x = 20505310648133051256899437174483692744155882498773622186074519461534030147643;
+ uint256 constant IC42y = 17945167563726643283778497800359216027219796008929564332784772008862379288267;
+
+ uint256 constant IC43x = 16464835543930849529802209723717707198205699962622034198247311245914066503381;
+ uint256 constant IC43y = 7146706300189558098880083068482163424474762346040735801233669165459999595441;
+
+ uint256 constant IC44x = 13876466699469375196717037837966091662045884884711252314177001633877820936556;
+ uint256 constant IC44y = 4958809069487069757658972127379351538457225782342394753562950938278198438579;
+
+ uint256 constant IC45x = 716494602496335636384560929447172545909794556338031660323535615315197455943;
+ uint256 constant IC45y = 2119987637872816845880811104352854067758262977376106806433161750239701257743;
+
+ uint256 constant IC46x = 5326227916591495894693509720254372049727680882886883474915360031572123636724;
+ uint256 constant IC46y = 17652121187938469425255029719435929376167855492046593969409049000855614352871;
+
+ uint256 constant IC47x = 16605143956649072843994023691603947255104919975923379872628789072181162520550;
+ uint256 constant IC47y = 18043404731499170973535528639961146174034481978068728273916453105002300162139;
+
+ uint256 constant IC48x = 1307036267933839625153265275143904089303258863245813293952349425823776229589;
+ uint256 constant IC48y = 4968775773064407453286732184813671924754950404598507606287494923411009972176;
+
+ uint256 constant IC49x = 7035213593926325268059435067385004716250646284249831536181984808613377649735;
+ uint256 constant IC49y = 14096245776460606810221486218303556498336027772521469022655061876711200677090;
+
+ uint256 constant IC50x = 3397724063466077632558277264834337251250613672639489676058286639992556870295;
+ uint256 constant IC50y = 5279422289283142246717097480408967677164707086340653337956071688498078740128;
+
+ uint256 constant IC51x = 19029258283012038124021779851803272594260458913598938568118560160072535906745;
+ uint256 constant IC51y = 10946426943859613213309572388011785804387100357426801155339615265285837817903;
+
+ uint256 constant IC52x = 14027721292825071352341242520063075115055331059522188694311270765522433666656;
+ uint256 constant IC52y = 10228819750700122303841152180095973433047984693287069513756443095679556456041;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[52] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+ g1_mulAccC(_pVk, IC43x, IC43y, calldataload(add(pubSignals, 1344)))
+
+ g1_mulAccC(_pVk, IC44x, IC44y, calldataload(add(pubSignals, 1376)))
+
+ g1_mulAccC(_pVk, IC45x, IC45y, calldataload(add(pubSignals, 1408)))
+
+ g1_mulAccC(_pVk, IC46x, IC46y, calldataload(add(pubSignals, 1440)))
+
+ g1_mulAccC(_pVk, IC47x, IC47y, calldataload(add(pubSignals, 1472)))
+
+ g1_mulAccC(_pVk, IC48x, IC48y, calldataload(add(pubSignals, 1504)))
+
+ g1_mulAccC(_pVk, IC49x, IC49y, calldataload(add(pubSignals, 1536)))
+
+ g1_mulAccC(_pVk, IC50x, IC50y, calldataload(add(pubSignals, 1568)))
+
+ g1_mulAccC(_pVk, IC51x, IC51y, calldataload(add(pubSignals, 1600)))
+
+ g1_mulAccC(_pVk, IC52x, IC52y, calldataload(add(pubSignals, 1632)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+ checkField(calldataload(add(_pubSignals, 1376)))
+
+ checkField(calldataload(add(_pubSignals, 1408)))
+
+ checkField(calldataload(add(_pubSignals, 1440)))
+
+ checkField(calldataload(add(_pubSignals, 1472)))
+
+ checkField(calldataload(add(_pubSignals, 1504)))
+
+ checkField(calldataload(add(_pubSignals, 1536)))
+
+ checkField(calldataload(add(_pubSignals, 1568)))
+
+ checkField(calldataload(add(_pubSignals, 1600)))
+
+ checkField(calldataload(add(_pubSignals, 1632)))
+
+ checkField(calldataload(add(_pubSignals, 1664)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_5_125Verifier.sol b/contracts/Game_5_125Verifier.sol
new file mode 100644
index 00000000..0a010416
--- /dev/null
+++ b/contracts/Game_5_125Verifier.sol
@@ -0,0 +1,597 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 16917939319533639033905906830382289971887862525362224529676404659291144550116;
+ uint256 constant deltax2 = 18765461185213949420049264448733379590972052650478791931654018597412919351098;
+ uint256 constant deltay1 = 5712293378830819223875806445866045618443731001734933600378415641998020223602;
+ uint256 constant deltay2 = 18911492584096800608957481359012436477027397758682701067026887045533769701498;
+
+
+ uint256 constant IC0x = 19078512625388927704828690063330620922375395404872927619758529744564249791247;
+ uint256 constant IC0y = 12719561926853135444293139752461643469028601984263451289098742735487507212660;
+
+ uint256 constant IC1x = 9130001238863704857921691170160043102089094735862511153947092666368575693668;
+ uint256 constant IC1y = 17170255394106001801056982845033671857356922397691300602823773817593584379826;
+
+ uint256 constant IC2x = 10774177704917788704719403144860328873609315968436244614867158416771694712062;
+ uint256 constant IC2y = 17815427645177310380541961290232881173262213727628556251132397203197931188660;
+
+ uint256 constant IC3x = 14559218746862032213298649054116797845984942479286185168446682796175583502156;
+ uint256 constant IC3y = 14790897541045846754063817211963345457419646815972593740549102953560728110308;
+
+ uint256 constant IC4x = 17892666742377416907845778309232127435446142612979690168162520045637509271205;
+ uint256 constant IC4y = 17366248965612923998859471869827551754132894549901012382748704025647275143762;
+
+ uint256 constant IC5x = 5715363708553419584526905739951090732528531168440165099755728793078721456234;
+ uint256 constant IC5y = 5342485145645491408887250140378099343167791147933802153732215456294318550915;
+
+ uint256 constant IC6x = 4862783642675781423025768496405199600424087990592685173611610816878859915916;
+ uint256 constant IC6y = 869584502413634186095160013625018231832369308599864305212218755890369303432;
+
+ uint256 constant IC7x = 15018264942853052119126841307993026349905082342390194534436763430382949652769;
+ uint256 constant IC7y = 14515775334429651249123211277086670475481883213554588512859473586323363707351;
+
+ uint256 constant IC8x = 2424340040398092677770462430457690575299303776007020244550324628583363787340;
+ uint256 constant IC8y = 4734778465461961321504805018458879099366733226813599223642225653754291057830;
+
+ uint256 constant IC9x = 8157826627839201911925674833383918780645892439037987909190108090244257057770;
+ uint256 constant IC9y = 1436197399039885314894172037113300286827447948478440387172918156716251311541;
+
+ uint256 constant IC10x = 9789317472864573819887959471096587052865274429099173420765210178039441862988;
+ uint256 constant IC10y = 14944519506299063255582348685526186844339048179311055960116154257742709873842;
+
+ uint256 constant IC11x = 9716137981059100404002096774127417944654618371351003631625302029298256441871;
+ uint256 constant IC11y = 5859430396863885762503812355624757192334883591689131990684307726053283496352;
+
+ uint256 constant IC12x = 3843212750384807131444681083107990961178253313858266559376723190642074079995;
+ uint256 constant IC12y = 2703750133276803849702477407039365039431047171781424040761311230577361311900;
+
+ uint256 constant IC13x = 14644209001555905819864577731865172979391678069806955863039554655782570122211;
+ uint256 constant IC13y = 16559306724612808154890110800835948246052720733782468053779510874420443751713;
+
+ uint256 constant IC14x = 13365634568497689118847804350376106616366782140232147586347620031641572939334;
+ uint256 constant IC14y = 13444786690892818084725936905187474594314320732540536315763545531184153543731;
+
+ uint256 constant IC15x = 15040594960087785978746215274308035734096716348407203495103217883955650595711;
+ uint256 constant IC15y = 4705744210311831632311648126459703815023716984707436479701730696209915456570;
+
+ uint256 constant IC16x = 20416146435755543764914496094244852227338246339555631744295317739568391106957;
+ uint256 constant IC16y = 689215034331079894021908538915551363823019493917101838470685636513383122371;
+
+ uint256 constant IC17x = 17883123920170023570107787478975117249160795363790691118889887524661916783716;
+ uint256 constant IC17y = 20003845600351524661509551617960989688173552121544857291219502208694449732718;
+
+ uint256 constant IC18x = 16993190517476457200325560660462304174105469783551019279159915415995600238859;
+ uint256 constant IC18y = 8282317897638735536739246985964021013111592001185170816868898918494107662014;
+
+ uint256 constant IC19x = 21354467242021692125084534816786661714158326206836699952982241511749908312435;
+ uint256 constant IC19y = 1257477240841559054232121636052061502906722525298447729212704046277636615830;
+
+ uint256 constant IC20x = 17355749903561018961274499653110251888083999496717634030810343840302927531462;
+ uint256 constant IC20y = 741994989208023327366293250087423183409462600526706085786721137502248800031;
+
+ uint256 constant IC21x = 12247783365175089861216995971044119149055629661044763397317440792978866634701;
+ uint256 constant IC21y = 14286539500901221991540522021952287477512876014647590428582285958444876983726;
+
+ uint256 constant IC22x = 795217076412900201546504050330078727067367546971231285284086658077088315449;
+ uint256 constant IC22y = 21837490373552923621775496887382459348548903175131097229857290254881215665145;
+
+ uint256 constant IC23x = 7766470638841969355268925932096606406660238669666315678232346566760167040662;
+ uint256 constant IC23y = 17412883458608298691399602659588762607409499067347316228632766956386335525546;
+
+ uint256 constant IC24x = 17431537522198056629413798846973020648139335388505067069249713306307321186285;
+ uint256 constant IC24y = 7097618044294650629266075972347690885619343942379444158617767982426101165189;
+
+ uint256 constant IC25x = 3155681218236750597379112829924709045990923867321235410268579680335256789090;
+ uint256 constant IC25y = 1033376757343194025753187207617798707806476392932116941427743417375045465955;
+
+ uint256 constant IC26x = 3931115808050748055429523237297252010822682625409973659634754447730167469327;
+ uint256 constant IC26y = 4731597992170562450795311947046159697243146199643539869671347544000297508190;
+
+ uint256 constant IC27x = 12806320909352991918035855547739108234309859364075855364859611861899206495946;
+ uint256 constant IC27y = 3506678489010210329415241670651863814560712943204305501728886061259480241417;
+
+ uint256 constant IC28x = 1130904219324136713466066267844041249459454982454903301853233517729769638771;
+ uint256 constant IC28y = 14481461561971719078753915635829888750976751375948344404477005532550979991195;
+
+ uint256 constant IC29x = 19564529635901790075150033345215786019478755932310662530892848038639349100178;
+ uint256 constant IC29y = 19779966454081759515861861772145142057783463046949927922738801415925692144548;
+
+ uint256 constant IC30x = 10531202208158220207119845857061598166247411590136664898797467999342785443126;
+ uint256 constant IC30y = 557299773904683522822999603582531390038154058556612834493840012874423481021;
+
+ uint256 constant IC31x = 21072954121751659891371703298673003923549960131883040806225695038230180178368;
+ uint256 constant IC31y = 2445426393592615171314003432316981511343343671195241811122478736150627853301;
+
+ uint256 constant IC32x = 8214734030189827699545215810521443854076532807479657205281815070904826422514;
+ uint256 constant IC32y = 9207359836150468051460573709800765626555800781286571469308031224581556588372;
+
+ uint256 constant IC33x = 12501617256812802379822915741285774174617363402624808721081058438531842605171;
+ uint256 constant IC33y = 566574592441257103357412176551082897350697442987485814329327377472200208673;
+
+ uint256 constant IC34x = 887518416062692548306936799736348742279569750142903828669090452013515948523;
+ uint256 constant IC34y = 13596840658015551803749264365214379671210981923174367092275997008597656120475;
+
+ uint256 constant IC35x = 4071843302050042505655379603208408433023165704414902480015206550975099095589;
+ uint256 constant IC35y = 21515418626493000232508382768494869876060083783723979021921612691740615184350;
+
+ uint256 constant IC36x = 158277893168242752068645014231354609763136777603098933737103904238038329217;
+ uint256 constant IC36y = 10556279831720780891794707536502932554206507696283146257824160644728662357538;
+
+ uint256 constant IC37x = 2225006997040619393980278516785676980540278954911325253482629039206458490303;
+ uint256 constant IC37y = 15572174899099989160487992025143696617715798812869802752164996570815140749936;
+
+ uint256 constant IC38x = 14468002244959496315360459289877865369298797901051404952101316073070450511956;
+ uint256 constant IC38y = 14262974196152350021524962845366603971180759644688816988330868636408475969185;
+
+ uint256 constant IC39x = 2012190539933564433998158983186848837091942565878686860523614372039609304410;
+ uint256 constant IC39y = 6078644476853555304835602345646318133540578170099170027981614887917140040485;
+
+ uint256 constant IC40x = 16918397882155889078551894158330136437565891936471636766023559003132093576559;
+ uint256 constant IC40y = 7998087503224446508030204838930387681361977435182384172795536828847472946276;
+
+ uint256 constant IC41x = 7485913331931669537048267019200086325286301726722509470799975057309320764420;
+ uint256 constant IC41y = 3920851256303151869530955140672113124528092905347213306617890299213885497044;
+
+ uint256 constant IC42x = 21403548638074022156640097047881698940120920413951357592928446505875797636461;
+ uint256 constant IC42y = 3063143217952495889973600481920784557594824321853472167220270936143053665521;
+
+ uint256 constant IC43x = 5610402660102624893298804285801672150119047070922424813586454323761391704001;
+ uint256 constant IC43y = 16651359344489960865554360957544516559249438584846330639006639822299574023258;
+
+ uint256 constant IC44x = 17134056002014118405741045923185142049188089050284616414806858313130048785053;
+ uint256 constant IC44y = 8176927193990954032843605506698069580026557675579426297532626250038359963995;
+
+ uint256 constant IC45x = 4528418017985567411162089831543541194490598812134584127428751444274581017357;
+ uint256 constant IC45y = 4755991391093924598380357624805048386622774830623180649009033361428228727901;
+
+ uint256 constant IC46x = 15663428252685696637563034735020357595662232298715732747439625035609252608354;
+ uint256 constant IC46y = 20988053896534258020130691024447730952163684796126530980499836371325540056488;
+
+ uint256 constant IC47x = 21731168240246216954433090175291232228700938825081700811368287521087861116729;
+ uint256 constant IC47y = 8603712911370177334295045186469079555085396468100520686442431841058290317604;
+
+ uint256 constant IC48x = 6894837932869563135160929949882404062988090075127071915278850211864152541706;
+ uint256 constant IC48y = 7975062133710504939517476392062225442161144110675187708567127038672113011697;
+
+ uint256 constant IC49x = 455355439697885599380207291792345305749181703663466352681352210575422352048;
+ uint256 constant IC49y = 2419038405431256210745412711089159961778493112431894516545803919393689308729;
+
+ uint256 constant IC50x = 4918460143477613278483763307934738527257315174731265467022051952429052840137;
+ uint256 constant IC50y = 674810866807544038086179479078108763835903034365757734354913135102122006246;
+
+ uint256 constant IC51x = 16181413484492933492808014797317530098221309619749169290590579541498540405453;
+ uint256 constant IC51y = 4963358555272322180998150530998104278863581297611611655262606235390175673108;
+
+ uint256 constant IC52x = 5307332838370317766774656039241132968171768794801521082934676071672574349536;
+ uint256 constant IC52y = 12949954456246082508793213526120140544981244357283598245912073023110348296471;
+
+ uint256 constant IC53x = 6438221534112503353711616446390166858199602893501137180721320635345545756401;
+ uint256 constant IC53y = 19573073710253156335643862507987822385987381693120402434038893318062676304419;
+
+ uint256 constant IC54x = 16414743275543491668754686840035485867394693171576648411640073205610543674139;
+ uint256 constant IC54y = 10868762208972555326698582928267962073086094108123260964750491201248097436934;
+
+ uint256 constant IC55x = 8633904979198980901137037809121883869555174643703377052934497631223676380331;
+ uint256 constant IC55y = 9318756750020663202783502293766656162268317336527333419757359355466856897380;
+
+ uint256 constant IC56x = 16447204875003246182189435998521034376712135608145528651388232176740283394230;
+ uint256 constant IC56y = 17779183074402941006255235006005122130434139553322430698351499498487083725653;
+
+ uint256 constant IC57x = 11333885504628770483048975830137908138461371174192501205048565307722836122792;
+ uint256 constant IC57y = 21812585373117845382323921901120955407203395368678525583406277845734974904754;
+
+ uint256 constant IC58x = 18824877939343106111442231987742639227851287503135535141752751221469146789506;
+ uint256 constant IC58y = 1700644350384366128844585514187714230573339186228446557064562924741541969704;
+
+ uint256 constant IC59x = 10399338676398783901710453785094479843503355092668295515695769879269907159740;
+ uint256 constant IC59y = 20165222580487898689766126946947016768299566746980436215253594167954870330880;
+
+ uint256 constant IC60x = 8760959157773189770895947517759244647702987232072759475306272328521946398654;
+ uint256 constant IC60y = 3990080934855098725832349509698755422881228673044122768017345853198814910350;
+
+ uint256 constant IC61x = 21675399341410965421763531157488279112743487963218116097825943678172057665817;
+ uint256 constant IC61y = 4451817341110184021557965737926251757682279374362307515196087770233921969505;
+
+ uint256 constant IC62x = 14301792351366550949727247127245670717202407632333226849893756498979929606274;
+ uint256 constant IC62y = 19647967857750127084533236086340970161409642487642164354403796870586001024704;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[62] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+ g1_mulAccC(_pVk, IC43x, IC43y, calldataload(add(pubSignals, 1344)))
+
+ g1_mulAccC(_pVk, IC44x, IC44y, calldataload(add(pubSignals, 1376)))
+
+ g1_mulAccC(_pVk, IC45x, IC45y, calldataload(add(pubSignals, 1408)))
+
+ g1_mulAccC(_pVk, IC46x, IC46y, calldataload(add(pubSignals, 1440)))
+
+ g1_mulAccC(_pVk, IC47x, IC47y, calldataload(add(pubSignals, 1472)))
+
+ g1_mulAccC(_pVk, IC48x, IC48y, calldataload(add(pubSignals, 1504)))
+
+ g1_mulAccC(_pVk, IC49x, IC49y, calldataload(add(pubSignals, 1536)))
+
+ g1_mulAccC(_pVk, IC50x, IC50y, calldataload(add(pubSignals, 1568)))
+
+ g1_mulAccC(_pVk, IC51x, IC51y, calldataload(add(pubSignals, 1600)))
+
+ g1_mulAccC(_pVk, IC52x, IC52y, calldataload(add(pubSignals, 1632)))
+
+ g1_mulAccC(_pVk, IC53x, IC53y, calldataload(add(pubSignals, 1664)))
+
+ g1_mulAccC(_pVk, IC54x, IC54y, calldataload(add(pubSignals, 1696)))
+
+ g1_mulAccC(_pVk, IC55x, IC55y, calldataload(add(pubSignals, 1728)))
+
+ g1_mulAccC(_pVk, IC56x, IC56y, calldataload(add(pubSignals, 1760)))
+
+ g1_mulAccC(_pVk, IC57x, IC57y, calldataload(add(pubSignals, 1792)))
+
+ g1_mulAccC(_pVk, IC58x, IC58y, calldataload(add(pubSignals, 1824)))
+
+ g1_mulAccC(_pVk, IC59x, IC59y, calldataload(add(pubSignals, 1856)))
+
+ g1_mulAccC(_pVk, IC60x, IC60y, calldataload(add(pubSignals, 1888)))
+
+ g1_mulAccC(_pVk, IC61x, IC61y, calldataload(add(pubSignals, 1920)))
+
+ g1_mulAccC(_pVk, IC62x, IC62y, calldataload(add(pubSignals, 1952)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+ checkField(calldataload(add(_pubSignals, 1376)))
+
+ checkField(calldataload(add(_pubSignals, 1408)))
+
+ checkField(calldataload(add(_pubSignals, 1440)))
+
+ checkField(calldataload(add(_pubSignals, 1472)))
+
+ checkField(calldataload(add(_pubSignals, 1504)))
+
+ checkField(calldataload(add(_pubSignals, 1536)))
+
+ checkField(calldataload(add(_pubSignals, 1568)))
+
+ checkField(calldataload(add(_pubSignals, 1600)))
+
+ checkField(calldataload(add(_pubSignals, 1632)))
+
+ checkField(calldataload(add(_pubSignals, 1664)))
+
+ checkField(calldataload(add(_pubSignals, 1696)))
+
+ checkField(calldataload(add(_pubSignals, 1728)))
+
+ checkField(calldataload(add(_pubSignals, 1760)))
+
+ checkField(calldataload(add(_pubSignals, 1792)))
+
+ checkField(calldataload(add(_pubSignals, 1824)))
+
+ checkField(calldataload(add(_pubSignals, 1856)))
+
+ checkField(calldataload(add(_pubSignals, 1888)))
+
+ checkField(calldataload(add(_pubSignals, 1920)))
+
+ checkField(calldataload(add(_pubSignals, 1952)))
+
+ checkField(calldataload(add(_pubSignals, 1984)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_5_20Verifier.sol b/contracts/Game_5_20Verifier.sol
new file mode 100644
index 00000000..37415b3b
--- /dev/null
+++ b/contracts/Game_5_20Verifier.sol
@@ -0,0 +1,597 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 17826910205698822274646094233194463481593699482141118453179477495631972769434;
+ uint256 constant deltax2 = 14708131736652443458715979613193900350503322673449245006486532909645507531014;
+ uint256 constant deltay1 = 9493962061625049181067489344293692882544602896527856995216804924048936776316;
+ uint256 constant deltay2 = 5134342065890847500269564112309581522865885620455495376586054491398962451607;
+
+
+ uint256 constant IC0x = 4243810872987081053756653602891721935992813259724441002761333081566676344178;
+ uint256 constant IC0y = 6668530910088280021134197136804336179237342943242594773567896531592226464085;
+
+ uint256 constant IC1x = 11930911982252107267501700238674980403871984933873509454663460090608691880316;
+ uint256 constant IC1y = 4789061611889264923348492092970225683652571667484420355448201782371786132649;
+
+ uint256 constant IC2x = 6313594382981520870539587289189409365059994049061270224296039754561631135768;
+ uint256 constant IC2y = 9522299368574252560054674504785429648330582857581236644661875986329658649530;
+
+ uint256 constant IC3x = 10162959771807558740323459247830318543912822502971511702667912260909372388917;
+ uint256 constant IC3y = 11375446936534704613643322628952317864481602645163870427411583248034190592087;
+
+ uint256 constant IC4x = 15235071510307580592403192828503319647321065833954579886799299439132883670098;
+ uint256 constant IC4y = 9057719258841569995820285627157977452194012637037542315372743640308556489855;
+
+ uint256 constant IC5x = 16916256572838047442103894182331762161240227180469704839208699691999141634791;
+ uint256 constant IC5y = 14086278028588554094443873083400518441764510282767097713770187573739488785319;
+
+ uint256 constant IC6x = 8703429292921127305223072831654076866696218630192428990119095920661022689757;
+ uint256 constant IC6y = 13946254375819927741935183158562748923258696339209505223275804425470897040063;
+
+ uint256 constant IC7x = 11539894247730359980186519435475562714051778057561814471132364470592508090894;
+ uint256 constant IC7y = 14322948809248300096793955429855791842472504077308238978882185590044942008689;
+
+ uint256 constant IC8x = 5123658305898628261391356579829975553286615816068310877510550309717006851433;
+ uint256 constant IC8y = 10612887348817896583921973047508044794649366635277148943386052155105378482925;
+
+ uint256 constant IC9x = 21162407449024431927169299357246223781830434746986089268261393534064025702682;
+ uint256 constant IC9y = 19147597056513986440429992938320102140738656067625681118244690982793467391610;
+
+ uint256 constant IC10x = 8453128278198871987834230716342320140094927617896909354140259203202995602513;
+ uint256 constant IC10y = 21016104149726652047895619212930067391330218812491350776512431691204518833817;
+
+ uint256 constant IC11x = 905964741386234651563945920269684959456106085023479861973830311377961205662;
+ uint256 constant IC11y = 3262774820139319231201003370834818927048024469063071579755447227137952404285;
+
+ uint256 constant IC12x = 21286052291245636666785175110095426572969485512660740061295717690240956654009;
+ uint256 constant IC12y = 9758698646687714850741645754962495559372855557610415875271861219806739979382;
+
+ uint256 constant IC13x = 9984466426688427867484563042877285941705261656386343761278338839531892330575;
+ uint256 constant IC13y = 2034170369085086621866757065704003172574280243390947447779504371045208168124;
+
+ uint256 constant IC14x = 13886398730336104956499327668037758148687146806782187494420998166956257268077;
+ uint256 constant IC14y = 8459791130583158547795372641509284661529889268685814678745732365076579352544;
+
+ uint256 constant IC15x = 7273261755145777493081279548820290471133755954759240244543460958972148349824;
+ uint256 constant IC15y = 456174651164043493988753661215832088080987564246405195442866886559339093673;
+
+ uint256 constant IC16x = 14989057877398133012933380965774614050482676473237521608956568142948317414199;
+ uint256 constant IC16y = 2448161473511073004334436262160184400150188878538630174405825507586017892295;
+
+ uint256 constant IC17x = 2097455282856132736502049061937106215697810803813240490916486830108438691954;
+ uint256 constant IC17y = 2901246186275715733042632820410244866852127469265509904835394021915448778603;
+
+ uint256 constant IC18x = 18375931025649281328117798839442547094656236163121626880582780225421140958676;
+ uint256 constant IC18y = 18295885893507166299986025157589644838338391455557155600968874958516489334826;
+
+ uint256 constant IC19x = 5706064366751364424825913677091240182206133800227119454118610310238482716688;
+ uint256 constant IC19y = 13773505931231331595957778633616376173826697493420604919162530544033793443901;
+
+ uint256 constant IC20x = 19293420215467041880140855981659352137970084879181873334394456253047297005209;
+ uint256 constant IC20y = 18333221144262693268645678602844948425370935947019801791270485051700299493670;
+
+ uint256 constant IC21x = 20081418089048695760674942593296657120427488650487659847991920205858390153799;
+ uint256 constant IC21y = 728093075860257324886449682954691409345725605078112323069498002628449221305;
+
+ uint256 constant IC22x = 7823439965560129521917212263740406722743112015251393443684921625323766149408;
+ uint256 constant IC22y = 18693611606702584393160789104459150038026032900698161645031695188309633086247;
+
+ uint256 constant IC23x = 18330183283452366248087424550012237750860381486478943978719693303244343537786;
+ uint256 constant IC23y = 14883509095305137773064487482165403128960869407445653520092771219665670916840;
+
+ uint256 constant IC24x = 6776810811638402646943544720950830488031463220850330097998484828089344629853;
+ uint256 constant IC24y = 13737101873031976694102812621310496459946720422122865271840812511994743143323;
+
+ uint256 constant IC25x = 8135766480134772167668722364770540474001973355231221024661054784996005791892;
+ uint256 constant IC25y = 4335901104901569793964762548880271642655990511810559703323509431047801621434;
+
+ uint256 constant IC26x = 21038017705741876530274373262431594750824536153674916729768704577102122491277;
+ uint256 constant IC26y = 9127772190019830212297447684815455568830279925169256081098640823150906074018;
+
+ uint256 constant IC27x = 1811928396473291431231694612181485100186675399842752764408319544446255125114;
+ uint256 constant IC27y = 12955947007848229235526395614906318973747249331763621101008179936899644826408;
+
+ uint256 constant IC28x = 21117828956264176827764153353351161948359973852521334015849568001525989642755;
+ uint256 constant IC28y = 6858657286330051150800236533351417715939349959921917522705961255948495296878;
+
+ uint256 constant IC29x = 16443940633249550210035837326543613279301333913638553405773587292789922712072;
+ uint256 constant IC29y = 20045298832420844112875129496012135682747445702956957663388887897737588252044;
+
+ uint256 constant IC30x = 1413920774507214570803050401290153125569493455043629017804882827382379825138;
+ uint256 constant IC30y = 9122513250246627154779369240775121568410330671621733415963496139451937348501;
+
+ uint256 constant IC31x = 6218504001813559228145791440677021778665427367853524182287107096966764612648;
+ uint256 constant IC31y = 16870164591076295481368652501118470598103297869314283718866042065083544125001;
+
+ uint256 constant IC32x = 14755235917031969569317661402492230808044800818746862339370671642986863873257;
+ uint256 constant IC32y = 17657117405037673424712324134760419653413230635883723182263638708665987443653;
+
+ uint256 constant IC33x = 14660498635826893997579950123284831266689113873508367531323556547504366528226;
+ uint256 constant IC33y = 1528402575945374194856117818821825245205959236831634723931996163891185464254;
+
+ uint256 constant IC34x = 14854305518626321349967855337884769520281844861337884006705881188124783207822;
+ uint256 constant IC34y = 19843127789577718788855855304856975039045063374415702303447009677427196553840;
+
+ uint256 constant IC35x = 1908722067774164858056464778910212000320649067403213021372190704180480894890;
+ uint256 constant IC35y = 17281139762603836356043117147651798837019946221122531502005676967276857083296;
+
+ uint256 constant IC36x = 15590135898504266294605886075826079531702444116301380012659422448811579930113;
+ uint256 constant IC36y = 19580598694575460471530686010269002040921948388355071306546311534618552631212;
+
+ uint256 constant IC37x = 12906086048817901851426136908666007756779245808714703204632518311075307430061;
+ uint256 constant IC37y = 15420344625692378567086596188460540310775011791274683128625261707083283639867;
+
+ uint256 constant IC38x = 16176262007464831511765834871068269745117516398627661142164136081986773457274;
+ uint256 constant IC38y = 4031595546479849651423360234628188241623668461898578308803116217606170951081;
+
+ uint256 constant IC39x = 11921793710485613540617860300360204745568092564820253192600068485245267168377;
+ uint256 constant IC39y = 6089207725369865343602407450669810566323262033519834082912718357230449318924;
+
+ uint256 constant IC40x = 13147091462542808889052270281426283114593128367968926095218984521301248138921;
+ uint256 constant IC40y = 13956536896756761271920328473593407395693262674068810999193964199032858118557;
+
+ uint256 constant IC41x = 3021985722562712220130428786831341742926976323169371611615255314510196170477;
+ uint256 constant IC41y = 8356218987256183647891586863265094920190847885135000974672411446682489531470;
+
+ uint256 constant IC42x = 3080765951182315086685860387794118033511820680684723850045273304356439861970;
+ uint256 constant IC42y = 1072500294153698425874574252370707573482459564858633728886167472957349233203;
+
+ uint256 constant IC43x = 2392426998321975924118245482637780994885170197233083594157620937976101186891;
+ uint256 constant IC43y = 4681118849275808228948867888956559101718058762818131005826852277386088580337;
+
+ uint256 constant IC44x = 8307670675842401800771492222165537660212982961517901250946137659621790028805;
+ uint256 constant IC44y = 10627394786779688511084294501784769089268804219764838008913792500589061949985;
+
+ uint256 constant IC45x = 446422637715027939843988798882644266330381384172888101795229203953905755408;
+ uint256 constant IC45y = 1056824247502062354611168826951692401652923672779909393059425596783059537833;
+
+ uint256 constant IC46x = 15292780228385252106277054772601277668424169137517966235930185534060386102730;
+ uint256 constant IC46y = 12189546653774541426888258085886068250727281700141884355816543681754530576268;
+
+ uint256 constant IC47x = 8454151180955466188579989370970249503781363798634161285203497725466012439274;
+ uint256 constant IC47y = 13231841782460487123967056529545037517649805715772306626990608937114689527344;
+
+ uint256 constant IC48x = 6186223535689336230535665036095256059743446734166987924446753436907253928271;
+ uint256 constant IC48y = 13576122607581429827154860600236839804850729025402017231586141770697188692494;
+
+ uint256 constant IC49x = 5562006980120364201944308307060710480541506491455947368390676241337173871447;
+ uint256 constant IC49y = 2894423142138720245819933347398245709150341153431930171996765414583675620139;
+
+ uint256 constant IC50x = 6970948301709525025276865821069183227460266071932849696463460703512356436707;
+ uint256 constant IC50y = 17546783598803244953007192096116702121397938391739438455683797394039700897143;
+
+ uint256 constant IC51x = 2102806671830695468586921955288293427530514497688547810302645090629085375087;
+ uint256 constant IC51y = 5085670459709357471506791194856721948779316371444669335351071071467173354823;
+
+ uint256 constant IC52x = 6102836027533308097375770886631521989082942274606991907762553712402711374602;
+ uint256 constant IC52y = 21853381517044520239250052688234735161058361162376235593693585907275816037437;
+
+ uint256 constant IC53x = 12712802884208276336229934747841858184937980936109910137377886177294861433140;
+ uint256 constant IC53y = 6187369864717917896753218258706902288857244113202657182988738439640937622116;
+
+ uint256 constant IC54x = 9673233911704509414509485891486689934323839092988731664280425005022283148531;
+ uint256 constant IC54y = 11148500866011489531591191555972210794102285849725269159098799343134885442011;
+
+ uint256 constant IC55x = 4784262475232152911872704521200438546747046945920739361504683039160389836935;
+ uint256 constant IC55y = 12604446335277393149565337300068105044707665599983646901213065435137378583541;
+
+ uint256 constant IC56x = 16028433264512454424836338766911116549942428998561346767160450717517031675697;
+ uint256 constant IC56y = 5712114559903699352248047039221706255619672607208564820006301698426976392682;
+
+ uint256 constant IC57x = 7274754892876371970393905318646437084168200742604211482294156009267362084846;
+ uint256 constant IC57y = 10554495739865481226870654691759301617783095234160575307383973852082701992139;
+
+ uint256 constant IC58x = 17097373980336321214935484370211947361500002542334564767771526133484141721022;
+ uint256 constant IC58y = 10902486404953423251323715367124676830174666499986158463555006879884723674628;
+
+ uint256 constant IC59x = 7782323759288910924688051931789949431198393767253103674776947960919530526173;
+ uint256 constant IC59y = 9751281276124730379485401531251341020261569634456509421261275186120184619542;
+
+ uint256 constant IC60x = 4217497065892781021864933304762955911614225023699743624660188905706351368902;
+ uint256 constant IC60y = 16124861623951416863525689510645162811790232091427451071914737036702442029253;
+
+ uint256 constant IC61x = 3462686458037660095386309077719656248024855958545561316581318137461570107916;
+ uint256 constant IC61y = 6235224441381052161932453925994222988768726689720208456317955938833431789117;
+
+ uint256 constant IC62x = 9203122259643950079087943415315089368494610843178191997672766780662693326225;
+ uint256 constant IC62y = 13609151265820556496015169052777486707863836529672753982987991279201106475494;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[62] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+ g1_mulAccC(_pVk, IC43x, IC43y, calldataload(add(pubSignals, 1344)))
+
+ g1_mulAccC(_pVk, IC44x, IC44y, calldataload(add(pubSignals, 1376)))
+
+ g1_mulAccC(_pVk, IC45x, IC45y, calldataload(add(pubSignals, 1408)))
+
+ g1_mulAccC(_pVk, IC46x, IC46y, calldataload(add(pubSignals, 1440)))
+
+ g1_mulAccC(_pVk, IC47x, IC47y, calldataload(add(pubSignals, 1472)))
+
+ g1_mulAccC(_pVk, IC48x, IC48y, calldataload(add(pubSignals, 1504)))
+
+ g1_mulAccC(_pVk, IC49x, IC49y, calldataload(add(pubSignals, 1536)))
+
+ g1_mulAccC(_pVk, IC50x, IC50y, calldataload(add(pubSignals, 1568)))
+
+ g1_mulAccC(_pVk, IC51x, IC51y, calldataload(add(pubSignals, 1600)))
+
+ g1_mulAccC(_pVk, IC52x, IC52y, calldataload(add(pubSignals, 1632)))
+
+ g1_mulAccC(_pVk, IC53x, IC53y, calldataload(add(pubSignals, 1664)))
+
+ g1_mulAccC(_pVk, IC54x, IC54y, calldataload(add(pubSignals, 1696)))
+
+ g1_mulAccC(_pVk, IC55x, IC55y, calldataload(add(pubSignals, 1728)))
+
+ g1_mulAccC(_pVk, IC56x, IC56y, calldataload(add(pubSignals, 1760)))
+
+ g1_mulAccC(_pVk, IC57x, IC57y, calldataload(add(pubSignals, 1792)))
+
+ g1_mulAccC(_pVk, IC58x, IC58y, calldataload(add(pubSignals, 1824)))
+
+ g1_mulAccC(_pVk, IC59x, IC59y, calldataload(add(pubSignals, 1856)))
+
+ g1_mulAccC(_pVk, IC60x, IC60y, calldataload(add(pubSignals, 1888)))
+
+ g1_mulAccC(_pVk, IC61x, IC61y, calldataload(add(pubSignals, 1920)))
+
+ g1_mulAccC(_pVk, IC62x, IC62y, calldataload(add(pubSignals, 1952)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+ checkField(calldataload(add(_pubSignals, 1376)))
+
+ checkField(calldataload(add(_pubSignals, 1408)))
+
+ checkField(calldataload(add(_pubSignals, 1440)))
+
+ checkField(calldataload(add(_pubSignals, 1472)))
+
+ checkField(calldataload(add(_pubSignals, 1504)))
+
+ checkField(calldataload(add(_pubSignals, 1536)))
+
+ checkField(calldataload(add(_pubSignals, 1568)))
+
+ checkField(calldataload(add(_pubSignals, 1600)))
+
+ checkField(calldataload(add(_pubSignals, 1632)))
+
+ checkField(calldataload(add(_pubSignals, 1664)))
+
+ checkField(calldataload(add(_pubSignals, 1696)))
+
+ checkField(calldataload(add(_pubSignals, 1728)))
+
+ checkField(calldataload(add(_pubSignals, 1760)))
+
+ checkField(calldataload(add(_pubSignals, 1792)))
+
+ checkField(calldataload(add(_pubSignals, 1824)))
+
+ checkField(calldataload(add(_pubSignals, 1856)))
+
+ checkField(calldataload(add(_pubSignals, 1888)))
+
+ checkField(calldataload(add(_pubSignals, 1920)))
+
+ checkField(calldataload(add(_pubSignals, 1952)))
+
+ checkField(calldataload(add(_pubSignals, 1984)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_6_125Verifier.sol b/contracts/Game_6_125Verifier.sol
new file mode 100644
index 00000000..3bd5107f
--- /dev/null
+++ b/contracts/Game_6_125Verifier.sol
@@ -0,0 +1,667 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 17542214800284618289252434614794539475392343496739968826720588811991106794058;
+ uint256 constant deltax2 = 7241714775968178843962304211051408366629995207668323275676571451988594993262;
+ uint256 constant deltay1 = 20134737641020816829650885723044097128185374551670570401214571372922594649121;
+ uint256 constant deltay2 = 4281523330911512852145371100880891761319835754263809350870418262091765734847;
+
+
+ uint256 constant IC0x = 8960515414065762439175951891980527771624902743267644525114045224533904987076;
+ uint256 constant IC0y = 10134167436360489905716559169811263259859415983996943671351818913255191208104;
+
+ uint256 constant IC1x = 20079118957177375799511284213409827221410441183283075032374579134464188080328;
+ uint256 constant IC1y = 10754846190670136322469379726974512506836080842778196879038725075177076682978;
+
+ uint256 constant IC2x = 3277718835876942805737693034583619890348959716216865559787476559484375464729;
+ uint256 constant IC2y = 7794067658453175733988197924488211469648364102137194721780416296871683865931;
+
+ uint256 constant IC3x = 8994043257028266571704850838303711988266088210552030778398676985729442361919;
+ uint256 constant IC3y = 14437552612488246305156715594639263511662605175550684803054103490318902497015;
+
+ uint256 constant IC4x = 14297120099402618566667179561991224541163425367298836355770983265490151823673;
+ uint256 constant IC4y = 11131751569460475183212442802256876626465014964628559338262446269468800271259;
+
+ uint256 constant IC5x = 7593646596672700455654127338055257845236822551763941138218491857799219320719;
+ uint256 constant IC5y = 16633474002030946812683232514852162907871037493091320017607837350129422853737;
+
+ uint256 constant IC6x = 2402463069485642312189911767355838548582134348643864820282469509075264632785;
+ uint256 constant IC6y = 10329915799745230882073503903199049536905193354100612863453997320223036678258;
+
+ uint256 constant IC7x = 19856743836295041060212152877938730156954708680765824545169839595965235526985;
+ uint256 constant IC7y = 19746591877749059692749959316585486850326372249938800068786404926533320489735;
+
+ uint256 constant IC8x = 17924509742057807067461031696115500203291211675900250430486983582393795836050;
+ uint256 constant IC8y = 19883831081171852633011516337567238020673254890024240448281478237088835265950;
+
+ uint256 constant IC9x = 12597439127866522903945787998276699526372568298528945076500465471315753621284;
+ uint256 constant IC9y = 8943517591989824968100217902871052654727852539500734153866364406773628438170;
+
+ uint256 constant IC10x = 18491633904301956420928739635974264038312335338088499279586416399247878725383;
+ uint256 constant IC10y = 14241503822598104384401078832167541520866177504153012941577672496441938926839;
+
+ uint256 constant IC11x = 5276209340182563871512598757623253990082411028434596774061021129048816253892;
+ uint256 constant IC11y = 20369564339563175380604348321973069442273673244669259082362423748841224503767;
+
+ uint256 constant IC12x = 15176927876859366825702732195648900090793436399138178193001596441638927168581;
+ uint256 constant IC12y = 14211546704733303059280244709551627683793809347505254003404484231418610378124;
+
+ uint256 constant IC13x = 19215586839281070402184208840812765888657824744591584632659359436643238381418;
+ uint256 constant IC13y = 13069460933523426588802761686870485792974517203422764573818323289309693191540;
+
+ uint256 constant IC14x = 4785401114547322778832709325217944089240070809843296952658300093515019931407;
+ uint256 constant IC14y = 8934512877694446562004413859509579678986294963103052081556842352508519347043;
+
+ uint256 constant IC15x = 4224557107502775762909725352863338643408728952992821245943856203103144958557;
+ uint256 constant IC15y = 10604001264755757741282523337684769079306123645409951506600885836674578757473;
+
+ uint256 constant IC16x = 15967213936129735639859408030218061522706340767159412825214591946409444572428;
+ uint256 constant IC16y = 19357077642585333981143422257548820195755919744772559464445771655759976422074;
+
+ uint256 constant IC17x = 3229620647586330154469861599881590973415099669118610923562802420391593034249;
+ uint256 constant IC17y = 19843207051887536964615042794290003122238951013103681085718260643690340254991;
+
+ uint256 constant IC18x = 18124985091892231596847098852212878742803534328515681126127871275783951825248;
+ uint256 constant IC18y = 13611468876641575287519803042842008021993366538877879180739395269501414881561;
+
+ uint256 constant IC19x = 1745957264441020390840456758410348359891735094430394391176312552398560806608;
+ uint256 constant IC19y = 12136326584390334454747642064245000909850126195043942094976563768579186350563;
+
+ uint256 constant IC20x = 18517491835789696906407855869649668463113398643698255938917056544717396219257;
+ uint256 constant IC20y = 6483727746632302259753263455037726220922005556421452645724239394252421077587;
+
+ uint256 constant IC21x = 18237713973697643353962044406639874348543209487556364575963654596409747585888;
+ uint256 constant IC21y = 5402331047908245870765227409872450539704784559122062844269929108002604020079;
+
+ uint256 constant IC22x = 13803101470801554504727511290499788742327820692366606904463503189917844922953;
+ uint256 constant IC22y = 900687246166530849751448717751254567174054550048128449255088591936586545538;
+
+ uint256 constant IC23x = 6496889034187632403762473984983303766731594975135299445504907496059810539505;
+ uint256 constant IC23y = 8796303644606473029590202427693990622887417769514524443922495416239474646319;
+
+ uint256 constant IC24x = 9426365995781912907914972463960943564290104572173339972511911660489922835596;
+ uint256 constant IC24y = 19756536197118509080313465551261765483535186189247418265957958252407026435430;
+
+ uint256 constant IC25x = 7554897715539461288728435800609596540207483411250828442638868032720475081387;
+ uint256 constant IC25y = 16635586317427330535380591768221868984576291529950326721997391244717908914327;
+
+ uint256 constant IC26x = 18848219594413934823565002397265325213380153645597077036465166536877325194171;
+ uint256 constant IC26y = 5519074327817892052387543639443092964882492604217910989340257137648793565210;
+
+ uint256 constant IC27x = 1184855051386123825127389309939064749693926366975410375065390007141472649184;
+ uint256 constant IC27y = 9021222897430626912955144987695404512855164586232217055145027970111677548285;
+
+ uint256 constant IC28x = 18369548573283161236137131556744434649038419494934144122927004021458558277277;
+ uint256 constant IC28y = 10901539766607669389495007340525353568164438548793173517642584989938210423518;
+
+ uint256 constant IC29x = 853497424575824796484899734665261745583443250149842813360262629167544591142;
+ uint256 constant IC29y = 10036810902562338811055170374827206707139348168794528713649508118000004316674;
+
+ uint256 constant IC30x = 18553964889722959321691408019844984008738320800507043959472352487123348151513;
+ uint256 constant IC30y = 16439347602868388555194177303343814325978524965297167319969282909842241587146;
+
+ uint256 constant IC31x = 12059045053612794212944299244347505795022227596802286959795145179897163521771;
+ uint256 constant IC31y = 17132551574007062349340388036051763226994273635237717067339735342171854362096;
+
+ uint256 constant IC32x = 13874702273737686802125753222326502674704077739429782572669323722654534706606;
+ uint256 constant IC32y = 19601173631611648161350994248991646212179513464312482156492158794964829929571;
+
+ uint256 constant IC33x = 11351445678833448155452314688236951573694933503826452527837433294912260590789;
+ uint256 constant IC33y = 17090956337004437118319782873501441852138868674054245182941047044042514522762;
+
+ uint256 constant IC34x = 3322541883270592383622655959789076472700059600524034799063518564382443958323;
+ uint256 constant IC34y = 14124045962770303688683803628872404157251436190755608204888492913244684462467;
+
+ uint256 constant IC35x = 14167575554106970785520708156246534291103873761223597901866247007929645780912;
+ uint256 constant IC35y = 3560057810483406531130782801780003420363796508026733852919740923994534622420;
+
+ uint256 constant IC36x = 17837633581930605721071477087984378886275701119225163583587817025607365680262;
+ uint256 constant IC36y = 3129825740105264423575255799262843457078836695680095704957634401332321345638;
+
+ uint256 constant IC37x = 1380009537177004712039971718269969273309909881040381364195978776841579639881;
+ uint256 constant IC37y = 2300580780974085544351922974807011245972195506042270605464870753951532652825;
+
+ uint256 constant IC38x = 19746893526139114965605313955530266207020693501455387988741045739454399561704;
+ uint256 constant IC38y = 13830330821593606478485787957126576318124613255938831041586688091006355037802;
+
+ uint256 constant IC39x = 12987148621778397019257836546060396198693476913262857169672835916646303089701;
+ uint256 constant IC39y = 8483379304933007754230773823604829266986415547669781487512445900603074221963;
+
+ uint256 constant IC40x = 4289132875586818819198024484398060519844441403516306652769600824516626712804;
+ uint256 constant IC40y = 7060107803326146003865440122560813406740112944197160267845118391004783960682;
+
+ uint256 constant IC41x = 16715113330845607747859032172788597557883770848581868621537056469192247097880;
+ uint256 constant IC41y = 16729058938077022334900033162345841805360458284013342085945620713929944296220;
+
+ uint256 constant IC42x = 14445517999898513555443144826304079231577916727284079863438766247097250660902;
+ uint256 constant IC42y = 16211123525373657113449653175274903518403068749910472388046820193748552521187;
+
+ uint256 constant IC43x = 16434833035593137198916734250219336976523157104628099047034617850358784055008;
+ uint256 constant IC43y = 16413354659051866028949718005181755331075278800781153971438486575439722150833;
+
+ uint256 constant IC44x = 2370751464023792537531789355119119599688178075932952878809093686911655994457;
+ uint256 constant IC44y = 14736931532702606470350650835306773682818783301108709352437441761029680837967;
+
+ uint256 constant IC45x = 5452437795103120158358040015671488811395963008117301428890331127328184562587;
+ uint256 constant IC45y = 2217803826978140060568019551329319945652649729686403417091343888082430378808;
+
+ uint256 constant IC46x = 812004984233735145912370081482457433310200104488713730167942712343750541670;
+ uint256 constant IC46y = 2219176944027938815987804816758424304932069692007751319692547167013087180347;
+
+ uint256 constant IC47x = 9317676028592664416370412385082706974720627204610742963181023434265666348655;
+ uint256 constant IC47y = 14075141049309514411225064064932183962617391821600566690573972539044637553842;
+
+ uint256 constant IC48x = 13980444113743797576678295575111539759153391266619462610459042812823682307386;
+ uint256 constant IC48y = 19668205335681951506436187862182951804267024643375738955143376603726987826256;
+
+ uint256 constant IC49x = 8246067710312721337919822422597969793857889801652034217208244597014715139965;
+ uint256 constant IC49y = 11412224146766897888666052220895278667657359280919500650586871436354840370409;
+
+ uint256 constant IC50x = 6311677667185802051549104744924527857629290942858764040600490454467135368779;
+ uint256 constant IC50y = 9560839192636604940001934305339297478719132538481441988317578829553915279538;
+
+ uint256 constant IC51x = 14468957706809380443357148660799017812129411043973856633562235792288916588221;
+ uint256 constant IC51y = 12928070042431977120653557196434352372586244468026746556591653915825938534825;
+
+ uint256 constant IC52x = 21413984586995685790819005753673626025673620787086529443652154931673347409419;
+ uint256 constant IC52y = 14419541702349819466277807388575636539409219235383764413489841152478354756046;
+
+ uint256 constant IC53x = 20887436196938439620156447806793661825454888284691460156433167742201726553501;
+ uint256 constant IC53y = 8209541081592351320643688053075850383507362178296515561294347758463851535949;
+
+ uint256 constant IC54x = 12569891059599868420812267755979383937579658161789177943447339234173019698903;
+ uint256 constant IC54y = 1968690439799300251254341152761179836190953855772267186675960668496861403638;
+
+ uint256 constant IC55x = 112795166247687775828281460094487748113630954569024356128926731987415103400;
+ uint256 constant IC55y = 7053500326626568658948813207374423131288822233258666284852666198152223886933;
+
+ uint256 constant IC56x = 9275349155803899488265651030564420009167056673643438624506888629506262534516;
+ uint256 constant IC56y = 1175797542509073464662860121528389410250533865115589351964920068782989862392;
+
+ uint256 constant IC57x = 825877147770165664757272723111011088772215172305671495782425372606046501519;
+ uint256 constant IC57y = 7387784438775828495274151555974911222483052051962421040238174184317585061218;
+
+ uint256 constant IC58x = 13908071530643107315028557119942320379190951415777034501792375197633900552263;
+ uint256 constant IC58y = 13925105185388434412730127739927940828604646101509874217903425308713912692928;
+
+ uint256 constant IC59x = 20584446007391946789265830513218551278835033536687794980312711362657201549696;
+ uint256 constant IC59y = 14447421857756152431643694507480218385563037547196285584034164283293351568228;
+
+ uint256 constant IC60x = 13971891661513138448918361370856502804016053619792329837503807542693288069885;
+ uint256 constant IC60y = 8885248403479150835263558334801389748825793105848148873200095155863115107961;
+
+ uint256 constant IC61x = 844976624504844709651139000972125039861885970864873697332581727732591091183;
+ uint256 constant IC61y = 12454342167036928867358090897955984507522445070598055645202965984407056280277;
+
+ uint256 constant IC62x = 3488989273938250687211333459953592091141631409705431286458806574052772406429;
+ uint256 constant IC62y = 21019255424925481531279058185868850059870923752574605825507890439233329029961;
+
+ uint256 constant IC63x = 17181048418757047933858773684665271255522133487770996326544743781115263029928;
+ uint256 constant IC63y = 4274045665240061876281082423570379580335252131737441176787632905926489506741;
+
+ uint256 constant IC64x = 899470774570512377366153676685405356468352058150616520427762210072856439767;
+ uint256 constant IC64y = 10198360198106815324199208718967459676504050660515798146928909234026907814833;
+
+ uint256 constant IC65x = 2263247641920921231066082623354973922904647868125449213710549482797114230214;
+ uint256 constant IC65y = 13989539308941778258744067058159186232600287220898661819044387823930273631333;
+
+ uint256 constant IC66x = 19974290791628905098072012942830547180274943158463886572425408132322198225745;
+ uint256 constant IC66y = 1317557771721240817394023184128626464491831623838446324104612150077665980144;
+
+ uint256 constant IC67x = 5609793208626319120444447195501537876427312030929354216368959669187781867640;
+ uint256 constant IC67y = 327458065216465160882667196448161954020092779938184321968102480795761328035;
+
+ uint256 constant IC68x = 21691817818906961076062374936247780248535035098468704226325213010775366772018;
+ uint256 constant IC68y = 20607303897258147625709406869088630875305053474225609566343337860292823911698;
+
+ uint256 constant IC69x = 4029115376959344663864148087053078933700445261581283223482410608262385344012;
+ uint256 constant IC69y = 4802783714498058001293847797986855313339201255234112005832558889368100021012;
+
+ uint256 constant IC70x = 6330361547479029045697063510065339608147213111431780962522506459265442570953;
+ uint256 constant IC70y = 14249209321399588069541119026033300656038401278671190646630935102543980943125;
+
+ uint256 constant IC71x = 13523838381675356984701542976305883383530585987932386241195056964489365350821;
+ uint256 constant IC71y = 15975416009985995446804134987281378490855636078889654367906956523909261973580;
+
+ uint256 constant IC72x = 9395825003401660764532850673892069361794350604163128607157605106438294285508;
+ uint256 constant IC72y = 535977957856547964504786609681257116473316362370580821188216224996765063479;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[72] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+ g1_mulAccC(_pVk, IC43x, IC43y, calldataload(add(pubSignals, 1344)))
+
+ g1_mulAccC(_pVk, IC44x, IC44y, calldataload(add(pubSignals, 1376)))
+
+ g1_mulAccC(_pVk, IC45x, IC45y, calldataload(add(pubSignals, 1408)))
+
+ g1_mulAccC(_pVk, IC46x, IC46y, calldataload(add(pubSignals, 1440)))
+
+ g1_mulAccC(_pVk, IC47x, IC47y, calldataload(add(pubSignals, 1472)))
+
+ g1_mulAccC(_pVk, IC48x, IC48y, calldataload(add(pubSignals, 1504)))
+
+ g1_mulAccC(_pVk, IC49x, IC49y, calldataload(add(pubSignals, 1536)))
+
+ g1_mulAccC(_pVk, IC50x, IC50y, calldataload(add(pubSignals, 1568)))
+
+ g1_mulAccC(_pVk, IC51x, IC51y, calldataload(add(pubSignals, 1600)))
+
+ g1_mulAccC(_pVk, IC52x, IC52y, calldataload(add(pubSignals, 1632)))
+
+ g1_mulAccC(_pVk, IC53x, IC53y, calldataload(add(pubSignals, 1664)))
+
+ g1_mulAccC(_pVk, IC54x, IC54y, calldataload(add(pubSignals, 1696)))
+
+ g1_mulAccC(_pVk, IC55x, IC55y, calldataload(add(pubSignals, 1728)))
+
+ g1_mulAccC(_pVk, IC56x, IC56y, calldataload(add(pubSignals, 1760)))
+
+ g1_mulAccC(_pVk, IC57x, IC57y, calldataload(add(pubSignals, 1792)))
+
+ g1_mulAccC(_pVk, IC58x, IC58y, calldataload(add(pubSignals, 1824)))
+
+ g1_mulAccC(_pVk, IC59x, IC59y, calldataload(add(pubSignals, 1856)))
+
+ g1_mulAccC(_pVk, IC60x, IC60y, calldataload(add(pubSignals, 1888)))
+
+ g1_mulAccC(_pVk, IC61x, IC61y, calldataload(add(pubSignals, 1920)))
+
+ g1_mulAccC(_pVk, IC62x, IC62y, calldataload(add(pubSignals, 1952)))
+
+ g1_mulAccC(_pVk, IC63x, IC63y, calldataload(add(pubSignals, 1984)))
+
+ g1_mulAccC(_pVk, IC64x, IC64y, calldataload(add(pubSignals, 2016)))
+
+ g1_mulAccC(_pVk, IC65x, IC65y, calldataload(add(pubSignals, 2048)))
+
+ g1_mulAccC(_pVk, IC66x, IC66y, calldataload(add(pubSignals, 2080)))
+
+ g1_mulAccC(_pVk, IC67x, IC67y, calldataload(add(pubSignals, 2112)))
+
+ g1_mulAccC(_pVk, IC68x, IC68y, calldataload(add(pubSignals, 2144)))
+
+ g1_mulAccC(_pVk, IC69x, IC69y, calldataload(add(pubSignals, 2176)))
+
+ g1_mulAccC(_pVk, IC70x, IC70y, calldataload(add(pubSignals, 2208)))
+
+ g1_mulAccC(_pVk, IC71x, IC71y, calldataload(add(pubSignals, 2240)))
+
+ g1_mulAccC(_pVk, IC72x, IC72y, calldataload(add(pubSignals, 2272)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+ checkField(calldataload(add(_pubSignals, 1376)))
+
+ checkField(calldataload(add(_pubSignals, 1408)))
+
+ checkField(calldataload(add(_pubSignals, 1440)))
+
+ checkField(calldataload(add(_pubSignals, 1472)))
+
+ checkField(calldataload(add(_pubSignals, 1504)))
+
+ checkField(calldataload(add(_pubSignals, 1536)))
+
+ checkField(calldataload(add(_pubSignals, 1568)))
+
+ checkField(calldataload(add(_pubSignals, 1600)))
+
+ checkField(calldataload(add(_pubSignals, 1632)))
+
+ checkField(calldataload(add(_pubSignals, 1664)))
+
+ checkField(calldataload(add(_pubSignals, 1696)))
+
+ checkField(calldataload(add(_pubSignals, 1728)))
+
+ checkField(calldataload(add(_pubSignals, 1760)))
+
+ checkField(calldataload(add(_pubSignals, 1792)))
+
+ checkField(calldataload(add(_pubSignals, 1824)))
+
+ checkField(calldataload(add(_pubSignals, 1856)))
+
+ checkField(calldataload(add(_pubSignals, 1888)))
+
+ checkField(calldataload(add(_pubSignals, 1920)))
+
+ checkField(calldataload(add(_pubSignals, 1952)))
+
+ checkField(calldataload(add(_pubSignals, 1984)))
+
+ checkField(calldataload(add(_pubSignals, 2016)))
+
+ checkField(calldataload(add(_pubSignals, 2048)))
+
+ checkField(calldataload(add(_pubSignals, 2080)))
+
+ checkField(calldataload(add(_pubSignals, 2112)))
+
+ checkField(calldataload(add(_pubSignals, 2144)))
+
+ checkField(calldataload(add(_pubSignals, 2176)))
+
+ checkField(calldataload(add(_pubSignals, 2208)))
+
+ checkField(calldataload(add(_pubSignals, 2240)))
+
+ checkField(calldataload(add(_pubSignals, 2272)))
+
+ checkField(calldataload(add(_pubSignals, 2304)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/contracts/Game_6_20Verifier.sol b/contracts/Game_6_20Verifier.sol
new file mode 100644
index 00000000..40e14a38
--- /dev/null
+++ b/contracts/Game_6_20Verifier.sol
@@ -0,0 +1,667 @@
+// SPDX-License-Identifier: GPL-3.0
+/*
+ Copyright 2021 0KIMS association.
+
+ This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
+
+ snarkJS is a free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ snarkJS is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with snarkJS. If not, see .
+*/
+
+pragma solidity >=0.7.0 <0.9.0;
+
+contract Groth16Verifier {
+ // Scalar field size
+ uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
+ // Base field size
+ uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
+
+ // Verification Key data
+ uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
+ uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
+ uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
+ uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
+ uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
+ uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
+ uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
+ uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
+ uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
+ uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
+ uint256 constant deltax1 = 10822563506981134671186004169307698867084491152273610325788807657327060327909;
+ uint256 constant deltax2 = 19799304242938578016746445292829309671519348584970999777288072887633378839498;
+ uint256 constant deltay1 = 21675960213992728327978924875492472387904177905601630779816420279126165861815;
+ uint256 constant deltay2 = 3272188712442877466069474247969049179914426739701578920091785157647647647806;
+
+
+ uint256 constant IC0x = 20941078105862902640672324322664284540959543274013772300709623117610023640286;
+ uint256 constant IC0y = 2914632583948321609824843326100267881344633326331399340484341487974336237963;
+
+ uint256 constant IC1x = 11104702129212425077381153330960826384803013121590100936276945994771944185057;
+ uint256 constant IC1y = 8052352468811360894339492197067788325487336790046018322889345534299167005105;
+
+ uint256 constant IC2x = 4435267008133121512071650901561661204868164198063043849869425387323641471505;
+ uint256 constant IC2y = 10834090578527492670474171800732566147054035155886868898669736196239928213140;
+
+ uint256 constant IC3x = 15663324809542285738111879862394594121187750853481267369829239510312351723767;
+ uint256 constant IC3y = 3884241917787059862544717675894741133873140832888740737111969067908906451147;
+
+ uint256 constant IC4x = 18295986215524867293581685835700041431396596012322480510382954552923920021712;
+ uint256 constant IC4y = 10696075483615887985590161356245954413660602118732941596612969334388376911820;
+
+ uint256 constant IC5x = 1616739655302156193198725461449939427137858442002525846913863439864550849909;
+ uint256 constant IC5y = 3563984851132693212130682518416361654584520795237418909428278442645779143086;
+
+ uint256 constant IC6x = 5232835108689322769423402965446856160571797257560875532308390888144411643128;
+ uint256 constant IC6y = 2505132840778846732175606069232607894470533776048535662307434909751316957500;
+
+ uint256 constant IC7x = 16393289592812950417966655940253314002382113387231903316793358956996087576590;
+ uint256 constant IC7y = 18174914870097588535802988210053503315638724518211200073561211542759352086983;
+
+ uint256 constant IC8x = 11540135278510143336496685850174167706899187516262424960180129311521942731845;
+ uint256 constant IC8y = 15319321830602275789036695934578026924566691110518377935487495806657308393630;
+
+ uint256 constant IC9x = 13619161389053391730500275210426698199773876064974511680579000033527024226976;
+ uint256 constant IC9y = 9042051300073356482889663944119355021613851802883689075896223624587351642715;
+
+ uint256 constant IC10x = 18109007556977420986361126729485718440226703668603904938180044437137140968016;
+ uint256 constant IC10y = 10809561532950217440191810966542245701300899672541333694011520501525887130566;
+
+ uint256 constant IC11x = 3272351704635588023133927909939426139305676809549286071661053125467319719344;
+ uint256 constant IC11y = 6087703614494848127901670468540106236265812921231746345427433535428877024903;
+
+ uint256 constant IC12x = 11573457639286400199855958526134032112134681879250089311732394845289706184923;
+ uint256 constant IC12y = 5606173245866893728244099136293302853399900279182401633716599723818047988730;
+
+ uint256 constant IC13x = 6690589698763252094769332601507328340625062664564380681881173738785476140264;
+ uint256 constant IC13y = 2804325635274643182335141526576759626418665523590629023817894226764027798040;
+
+ uint256 constant IC14x = 13852493502932636791787646798069531863880879624497154566164226241231709737539;
+ uint256 constant IC14y = 16476412546636021593658119775291920251793465423736550162154403287255624614952;
+
+ uint256 constant IC15x = 6761363128030860199893404069059762279101115809819001881545114395342891740822;
+ uint256 constant IC15y = 17080515551561050395839243330469047135825176022005604248169554713456257872126;
+
+ uint256 constant IC16x = 9110272419850879935347201750948190096425710240041655982489875652666518525197;
+ uint256 constant IC16y = 17103708926566817324834687229754477522811905989565980114700634173438466332302;
+
+ uint256 constant IC17x = 1479987346801906994710512032735983740786678553629977729748280967426455731196;
+ uint256 constant IC17y = 6964737511006588077961567785534911077955242932777930966630895790399140953019;
+
+ uint256 constant IC18x = 21779225890762036147544323486987079004595936582896215659536539504090660012740;
+ uint256 constant IC18y = 14671878214696577910084356605811130219582107741538403154652236656889236097642;
+
+ uint256 constant IC19x = 6661653097834435541515495806548177369833589983927987170787434501557793277537;
+ uint256 constant IC19y = 14887823754062326714465185357564788271753449988651250121493959663987451336833;
+
+ uint256 constant IC20x = 4761238007730529105770421862431068683892688492750629871208711601926817914089;
+ uint256 constant IC20y = 5369403063057757151092150179875217622554159335638945089550445420359253079060;
+
+ uint256 constant IC21x = 2104520663775961894149268996862295509420949090404322620146182446263578893167;
+ uint256 constant IC21y = 19986049142289083266502492943127542171257134623066342789295269770913632955835;
+
+ uint256 constant IC22x = 12500017317060789299529311029846712844371309578324383009128711494122814771540;
+ uint256 constant IC22y = 15081646320542747072958763305201821218371737532804053503131533421793616289582;
+
+ uint256 constant IC23x = 16121813701906797416265175844412556427216698793293738485917239641945088217246;
+ uint256 constant IC23y = 17485686152009653185881989837830363760483927433519510041625850015571705342571;
+
+ uint256 constant IC24x = 4438695095513437455030022217793574382421303196339647841247096380114779929724;
+ uint256 constant IC24y = 2825944803952065212208519910608940691742155811484437223516495301495698166145;
+
+ uint256 constant IC25x = 9360715362336817583371347543695294493071522926221190369848578331802832740249;
+ uint256 constant IC25y = 20214181511286210809144905751837078779492148081616446913715977526512111233600;
+
+ uint256 constant IC26x = 1538524231524763432498433332074742634720833050975279198626149747751538174007;
+ uint256 constant IC26y = 18698969325533972815132398614662057521213914537054684228180712591851251630352;
+
+ uint256 constant IC27x = 9922640554794206623344258636626741668813193313888861891654373167684204944414;
+ uint256 constant IC27y = 15657900199358708123784620432363019716931878435778184251883469643565483853348;
+
+ uint256 constant IC28x = 14126095475218972193058740640964921870678203905908731888544444460088195554579;
+ uint256 constant IC28y = 16453621068881131865725856202276033779511890620856597319140069599835962150840;
+
+ uint256 constant IC29x = 18200493865800409861131639629426420869696340862158694042568061308183947060845;
+ uint256 constant IC29y = 4870201017714883665239228565128791974732203605720506604076434880872093964655;
+
+ uint256 constant IC30x = 12031663614037320777246314816478988031211414569808779582403519960251620943034;
+ uint256 constant IC30y = 21157712074700749298411830520924792572392894361024532832950086949222616963666;
+
+ uint256 constant IC31x = 645817279334097822709577245849759462939813139142398324516912805142666733613;
+ uint256 constant IC31y = 1501528927381430074489634582462016772108390740851525183885941647423607768000;
+
+ uint256 constant IC32x = 6764341231329176796786287419791754734553398980118423452734634261537530571526;
+ uint256 constant IC32y = 16172208098460802134266374531389138426561404799479946129059926402691992730901;
+
+ uint256 constant IC33x = 1268808520303406106714443507812397149467833191981530708476379464393631102447;
+ uint256 constant IC33y = 20896280437436107023929098452582586075100193147026527217740972074346638294786;
+
+ uint256 constant IC34x = 12661124786792205938577184468138266444885879442518346870039409583307200083656;
+ uint256 constant IC34y = 13922232898668186834422016022441396260376473601887187408532667798933258517502;
+
+ uint256 constant IC35x = 3044318513496047929952247265321473723184044835501974118360065338285181181073;
+ uint256 constant IC35y = 8212387945590564627600898859823078914023751169635089797963017736082786908275;
+
+ uint256 constant IC36x = 7770925458301604078788517515611840938023168925703342265977736137795641067357;
+ uint256 constant IC36y = 18120201495755211944561271044717601861420293905898281077955893062573423221038;
+
+ uint256 constant IC37x = 12931527800899365381340197882548090327937190556652321638143083002320673383759;
+ uint256 constant IC37y = 10041166919114907104517900225363487433936646619571826542188972255130352432250;
+
+ uint256 constant IC38x = 5669115465376604813056849358069112130588258666310420575439667895663363153069;
+ uint256 constant IC38y = 21661997612986953630502352336625828627751714548191209720378245196809198255054;
+
+ uint256 constant IC39x = 6359011361545178253028612668068052654008349152681739247690926777351450063755;
+ uint256 constant IC39y = 13322135351879559896296656643914077187774082877155434940125120268843328982097;
+
+ uint256 constant IC40x = 17278597462650802226149007664379695150844747868461498829195188694317350874947;
+ uint256 constant IC40y = 16831789710428775622107399756558221633171448728212315852188273756266645651128;
+
+ uint256 constant IC41x = 4061157211112218840314494561186352550733907217631108427638809111495264845634;
+ uint256 constant IC41y = 4268460078904706136619793281526544222979975734187084276171010518331468204442;
+
+ uint256 constant IC42x = 3930597052321448015713971929934707318602354848214967393205557520698027608598;
+ uint256 constant IC42y = 15665055745809428299094874805484774185007327843064653200645735945871788277114;
+
+ uint256 constant IC43x = 19464287973348087960216653011823743377430123154139163233991948109171115695424;
+ uint256 constant IC43y = 17951707391895501001218905724358812875871027981216961926312862928216260647921;
+
+ uint256 constant IC44x = 13960925145313947503841961975874441756287938544728010146203312720691316608499;
+ uint256 constant IC44y = 13908192597294832448898812588319385708583412468255426020407645850979998019609;
+
+ uint256 constant IC45x = 7288687885986843207735100046816686579637520126658057803382017703119386287163;
+ uint256 constant IC45y = 2811892151871940636442020760423622356880516736515000099911369633214282438451;
+
+ uint256 constant IC46x = 14294252953320748370186767374717973932416015196053563100122425649481071260031;
+ uint256 constant IC46y = 1888301226143590620353949860993674229199371435713273053506748125821641632592;
+
+ uint256 constant IC47x = 13938220524104013390780380931786807397840833709344217934263226657398109438220;
+ uint256 constant IC47y = 12472362527267990684915225675414495615435733870335193168767372263283504512429;
+
+ uint256 constant IC48x = 7310617460129232658689434854220551799393530096930183963071014510845217191702;
+ uint256 constant IC48y = 5038165405878834822322272177261113172400634069047261907340399821285442046752;
+
+ uint256 constant IC49x = 21688561409767943514705181152648008638137515581103450501557707226632520515242;
+ uint256 constant IC49y = 15243847221447813685597142292023090971896164657895357497807859421302956546906;
+
+ uint256 constant IC50x = 4381275006947016398081801803761378342902509022112334606606206261734167988407;
+ uint256 constant IC50y = 1184158640544108346332394272350813101751014913855962905537502025962418229826;
+
+ uint256 constant IC51x = 8527958281301109825361112189725925840894808592248460596156688848034658288497;
+ uint256 constant IC51y = 17216552915349956123663433226208551812987694260796860034246434355578542051923;
+
+ uint256 constant IC52x = 4653080921232098134178885691727497977095296685213214546940457714064605196608;
+ uint256 constant IC52y = 16787786506480682011007340520417105717623466624422566001182110043590983305416;
+
+ uint256 constant IC53x = 1399748240405655391463119646973704563380329947182604529324210089706449804558;
+ uint256 constant IC53y = 20217509538122811703370851086336004302646797439059028787612493994266801622420;
+
+ uint256 constant IC54x = 2876138564665295293741690965395641479254747333360802414052106112801654525002;
+ uint256 constant IC54y = 16122922086572348809151484125514140316187620672206386750124292790482758125572;
+
+ uint256 constant IC55x = 1176580347155966895799949196851313986526669092270256269261813683011056390138;
+ uint256 constant IC55y = 12752214120405293036258888325380040489433827592827642675874256062200463986813;
+
+ uint256 constant IC56x = 11984323391640990420630104940902741752545616738389586803362286569641860791693;
+ uint256 constant IC56y = 12640217710321112865382274017229362881915865327954203080143085401891229192340;
+
+ uint256 constant IC57x = 21311232166959192271620824226003329923100425401527566043681519539000863384044;
+ uint256 constant IC57y = 3217034342263295620637409874495570213005969063834154480283201634980772461280;
+
+ uint256 constant IC58x = 16245149022297201249729265020080170278050832525659524254177897727260338143130;
+ uint256 constant IC58y = 12480623895414923470078997814550421498583309539704136504030003787953113665069;
+
+ uint256 constant IC59x = 8464668840407681371916064543263307811859052253545186416404831176501305875803;
+ uint256 constant IC59y = 7310768658756284110350993507613550069522491855370723516757326365351535572561;
+
+ uint256 constant IC60x = 5501389890829293234027407469684774510243204275224533576335464053076824794311;
+ uint256 constant IC60y = 12337898237484681416029174610279232711835638061156206415155615305014650107903;
+
+ uint256 constant IC61x = 18838419662768938287145972241232509494065885660077053639461870280774415180802;
+ uint256 constant IC61y = 8764003657847095385204278695262207147070460141826122357640065533158481139785;
+
+ uint256 constant IC62x = 3983841355019051380561911717288625755097304261743378446047321836350095613000;
+ uint256 constant IC62y = 11323377434671158654655961163722262732451668320547750748455493955492857594343;
+
+ uint256 constant IC63x = 14985723843988359924728559017182799673866053026717198390909686609792803417922;
+ uint256 constant IC63y = 3534947220704065418227203925861594944401473661587914389547568389087944118038;
+
+ uint256 constant IC64x = 1668775315137187335226097332156002014639378906246277614665268044701267542538;
+ uint256 constant IC64y = 13451917482698438555489744892861768453631827995159700148055789941288940953213;
+
+ uint256 constant IC65x = 11668595695855797242915059650124911218592680774810778046268384780052757264388;
+ uint256 constant IC65y = 12325337971953154277311093617903584389864513177447366819077785871191820619604;
+
+ uint256 constant IC66x = 11115964637123814576089601101553151446829303438375817787290174904795538374538;
+ uint256 constant IC66y = 12910305956779569342046436149240795259979714884188430053910681237979232835705;
+
+ uint256 constant IC67x = 2358006689582629001827418213579209771555122942258925078779659621280501236106;
+ uint256 constant IC67y = 15289385209707192015018768725044312308005048287972792996479573028437345156235;
+
+ uint256 constant IC68x = 2096115463046861142463931647602903725346218409221769530002842614855530484445;
+ uint256 constant IC68y = 10699005461760254779313445117974027528500212208336157729145531495639631586002;
+
+ uint256 constant IC69x = 14343736227313621392137153612991821987312138596979624467782996438152399540940;
+ uint256 constant IC69y = 20319645031152949773591204407867823010114552031683296109508601076773914540679;
+
+ uint256 constant IC70x = 14268479103312300416993344050797654779316045979211821318270193174552381306470;
+ uint256 constant IC70y = 19721585362825205600226615079405136246547348409582451175875740774645327421132;
+
+ uint256 constant IC71x = 12207777244183555090068216667186866057777927082356277564116013176722369208112;
+ uint256 constant IC71y = 1925872307968689178138524851973915697580014772393601945456083418656802695228;
+
+ uint256 constant IC72x = 5461340537114890688265484592297274505841823304971667609933528986699681793393;
+ uint256 constant IC72y = 7150701002949089510360114401222317524711430462217780904403650280755624921577;
+
+
+ // Memory data
+ uint16 constant pVk = 0;
+ uint16 constant pPairing = 128;
+
+ uint16 constant pLastMem = 896;
+
+ function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[72] calldata _pubSignals) public view returns (bool) {
+ assembly {
+ function checkField(v) {
+ if iszero(lt(v, q)) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ // G1 function to multiply a G1 value(x,y) to value in an address
+ function g1_mulAccC(pR, x, y, s) {
+ let success
+ let mIn := mload(0x40)
+ mstore(mIn, x)
+ mstore(add(mIn, 32), y)
+ mstore(add(mIn, 64), s)
+
+ success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+
+ mstore(add(mIn, 64), mload(pR))
+ mstore(add(mIn, 96), mload(add(pR, 32)))
+
+ success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
+
+ if iszero(success) {
+ mstore(0, 0)
+ return(0, 0x20)
+ }
+ }
+
+ function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
+ let _pPairing := add(pMem, pPairing)
+ let _pVk := add(pMem, pVk)
+
+ mstore(_pVk, IC0x)
+ mstore(add(_pVk, 32), IC0y)
+
+ // Compute the linear combination vk_x
+
+ g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
+
+ g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
+
+ g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
+
+ g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
+
+ g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
+
+ g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
+
+ g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
+
+ g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
+
+ g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
+
+ g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
+
+ g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
+
+ g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
+
+ g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
+
+ g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
+
+ g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
+
+ g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
+
+ g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
+
+ g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
+
+ g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
+
+ g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
+
+ g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
+
+ g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
+
+ g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
+
+ g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
+
+ g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
+
+ g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
+
+ g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
+
+ g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
+
+ g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
+
+ g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
+
+ g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
+
+ g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
+
+ g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
+
+ g1_mulAccC(_pVk, IC34x, IC34y, calldataload(add(pubSignals, 1056)))
+
+ g1_mulAccC(_pVk, IC35x, IC35y, calldataload(add(pubSignals, 1088)))
+
+ g1_mulAccC(_pVk, IC36x, IC36y, calldataload(add(pubSignals, 1120)))
+
+ g1_mulAccC(_pVk, IC37x, IC37y, calldataload(add(pubSignals, 1152)))
+
+ g1_mulAccC(_pVk, IC38x, IC38y, calldataload(add(pubSignals, 1184)))
+
+ g1_mulAccC(_pVk, IC39x, IC39y, calldataload(add(pubSignals, 1216)))
+
+ g1_mulAccC(_pVk, IC40x, IC40y, calldataload(add(pubSignals, 1248)))
+
+ g1_mulAccC(_pVk, IC41x, IC41y, calldataload(add(pubSignals, 1280)))
+
+ g1_mulAccC(_pVk, IC42x, IC42y, calldataload(add(pubSignals, 1312)))
+
+ g1_mulAccC(_pVk, IC43x, IC43y, calldataload(add(pubSignals, 1344)))
+
+ g1_mulAccC(_pVk, IC44x, IC44y, calldataload(add(pubSignals, 1376)))
+
+ g1_mulAccC(_pVk, IC45x, IC45y, calldataload(add(pubSignals, 1408)))
+
+ g1_mulAccC(_pVk, IC46x, IC46y, calldataload(add(pubSignals, 1440)))
+
+ g1_mulAccC(_pVk, IC47x, IC47y, calldataload(add(pubSignals, 1472)))
+
+ g1_mulAccC(_pVk, IC48x, IC48y, calldataload(add(pubSignals, 1504)))
+
+ g1_mulAccC(_pVk, IC49x, IC49y, calldataload(add(pubSignals, 1536)))
+
+ g1_mulAccC(_pVk, IC50x, IC50y, calldataload(add(pubSignals, 1568)))
+
+ g1_mulAccC(_pVk, IC51x, IC51y, calldataload(add(pubSignals, 1600)))
+
+ g1_mulAccC(_pVk, IC52x, IC52y, calldataload(add(pubSignals, 1632)))
+
+ g1_mulAccC(_pVk, IC53x, IC53y, calldataload(add(pubSignals, 1664)))
+
+ g1_mulAccC(_pVk, IC54x, IC54y, calldataload(add(pubSignals, 1696)))
+
+ g1_mulAccC(_pVk, IC55x, IC55y, calldataload(add(pubSignals, 1728)))
+
+ g1_mulAccC(_pVk, IC56x, IC56y, calldataload(add(pubSignals, 1760)))
+
+ g1_mulAccC(_pVk, IC57x, IC57y, calldataload(add(pubSignals, 1792)))
+
+ g1_mulAccC(_pVk, IC58x, IC58y, calldataload(add(pubSignals, 1824)))
+
+ g1_mulAccC(_pVk, IC59x, IC59y, calldataload(add(pubSignals, 1856)))
+
+ g1_mulAccC(_pVk, IC60x, IC60y, calldataload(add(pubSignals, 1888)))
+
+ g1_mulAccC(_pVk, IC61x, IC61y, calldataload(add(pubSignals, 1920)))
+
+ g1_mulAccC(_pVk, IC62x, IC62y, calldataload(add(pubSignals, 1952)))
+
+ g1_mulAccC(_pVk, IC63x, IC63y, calldataload(add(pubSignals, 1984)))
+
+ g1_mulAccC(_pVk, IC64x, IC64y, calldataload(add(pubSignals, 2016)))
+
+ g1_mulAccC(_pVk, IC65x, IC65y, calldataload(add(pubSignals, 2048)))
+
+ g1_mulAccC(_pVk, IC66x, IC66y, calldataload(add(pubSignals, 2080)))
+
+ g1_mulAccC(_pVk, IC67x, IC67y, calldataload(add(pubSignals, 2112)))
+
+ g1_mulAccC(_pVk, IC68x, IC68y, calldataload(add(pubSignals, 2144)))
+
+ g1_mulAccC(_pVk, IC69x, IC69y, calldataload(add(pubSignals, 2176)))
+
+ g1_mulAccC(_pVk, IC70x, IC70y, calldataload(add(pubSignals, 2208)))
+
+ g1_mulAccC(_pVk, IC71x, IC71y, calldataload(add(pubSignals, 2240)))
+
+ g1_mulAccC(_pVk, IC72x, IC72y, calldataload(add(pubSignals, 2272)))
+
+
+ // -A
+ mstore(_pPairing, calldataload(pA))
+ mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
+
+ // B
+ mstore(add(_pPairing, 64), calldataload(pB))
+ mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
+ mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
+ mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
+
+ // alpha1
+ mstore(add(_pPairing, 192), alphax)
+ mstore(add(_pPairing, 224), alphay)
+
+ // beta2
+ mstore(add(_pPairing, 256), betax1)
+ mstore(add(_pPairing, 288), betax2)
+ mstore(add(_pPairing, 320), betay1)
+ mstore(add(_pPairing, 352), betay2)
+
+ // vk_x
+ mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
+ mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
+
+
+ // gamma2
+ mstore(add(_pPairing, 448), gammax1)
+ mstore(add(_pPairing, 480), gammax2)
+ mstore(add(_pPairing, 512), gammay1)
+ mstore(add(_pPairing, 544), gammay2)
+
+ // C
+ mstore(add(_pPairing, 576), calldataload(pC))
+ mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
+
+ // delta2
+ mstore(add(_pPairing, 640), deltax1)
+ mstore(add(_pPairing, 672), deltax2)
+ mstore(add(_pPairing, 704), deltay1)
+ mstore(add(_pPairing, 736), deltay2)
+
+
+ let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
+
+ isOk := and(success, mload(_pPairing))
+ }
+
+ let pMem := mload(0x40)
+ mstore(0x40, add(pMem, pLastMem))
+
+ // Validate that all evaluations ∈ F
+
+ checkField(calldataload(add(_pubSignals, 0)))
+
+ checkField(calldataload(add(_pubSignals, 32)))
+
+ checkField(calldataload(add(_pubSignals, 64)))
+
+ checkField(calldataload(add(_pubSignals, 96)))
+
+ checkField(calldataload(add(_pubSignals, 128)))
+
+ checkField(calldataload(add(_pubSignals, 160)))
+
+ checkField(calldataload(add(_pubSignals, 192)))
+
+ checkField(calldataload(add(_pubSignals, 224)))
+
+ checkField(calldataload(add(_pubSignals, 256)))
+
+ checkField(calldataload(add(_pubSignals, 288)))
+
+ checkField(calldataload(add(_pubSignals, 320)))
+
+ checkField(calldataload(add(_pubSignals, 352)))
+
+ checkField(calldataload(add(_pubSignals, 384)))
+
+ checkField(calldataload(add(_pubSignals, 416)))
+
+ checkField(calldataload(add(_pubSignals, 448)))
+
+ checkField(calldataload(add(_pubSignals, 480)))
+
+ checkField(calldataload(add(_pubSignals, 512)))
+
+ checkField(calldataload(add(_pubSignals, 544)))
+
+ checkField(calldataload(add(_pubSignals, 576)))
+
+ checkField(calldataload(add(_pubSignals, 608)))
+
+ checkField(calldataload(add(_pubSignals, 640)))
+
+ checkField(calldataload(add(_pubSignals, 672)))
+
+ checkField(calldataload(add(_pubSignals, 704)))
+
+ checkField(calldataload(add(_pubSignals, 736)))
+
+ checkField(calldataload(add(_pubSignals, 768)))
+
+ checkField(calldataload(add(_pubSignals, 800)))
+
+ checkField(calldataload(add(_pubSignals, 832)))
+
+ checkField(calldataload(add(_pubSignals, 864)))
+
+ checkField(calldataload(add(_pubSignals, 896)))
+
+ checkField(calldataload(add(_pubSignals, 928)))
+
+ checkField(calldataload(add(_pubSignals, 960)))
+
+ checkField(calldataload(add(_pubSignals, 992)))
+
+ checkField(calldataload(add(_pubSignals, 1024)))
+
+ checkField(calldataload(add(_pubSignals, 1056)))
+
+ checkField(calldataload(add(_pubSignals, 1088)))
+
+ checkField(calldataload(add(_pubSignals, 1120)))
+
+ checkField(calldataload(add(_pubSignals, 1152)))
+
+ checkField(calldataload(add(_pubSignals, 1184)))
+
+ checkField(calldataload(add(_pubSignals, 1216)))
+
+ checkField(calldataload(add(_pubSignals, 1248)))
+
+ checkField(calldataload(add(_pubSignals, 1280)))
+
+ checkField(calldataload(add(_pubSignals, 1312)))
+
+ checkField(calldataload(add(_pubSignals, 1344)))
+
+ checkField(calldataload(add(_pubSignals, 1376)))
+
+ checkField(calldataload(add(_pubSignals, 1408)))
+
+ checkField(calldataload(add(_pubSignals, 1440)))
+
+ checkField(calldataload(add(_pubSignals, 1472)))
+
+ checkField(calldataload(add(_pubSignals, 1504)))
+
+ checkField(calldataload(add(_pubSignals, 1536)))
+
+ checkField(calldataload(add(_pubSignals, 1568)))
+
+ checkField(calldataload(add(_pubSignals, 1600)))
+
+ checkField(calldataload(add(_pubSignals, 1632)))
+
+ checkField(calldataload(add(_pubSignals, 1664)))
+
+ checkField(calldataload(add(_pubSignals, 1696)))
+
+ checkField(calldataload(add(_pubSignals, 1728)))
+
+ checkField(calldataload(add(_pubSignals, 1760)))
+
+ checkField(calldataload(add(_pubSignals, 1792)))
+
+ checkField(calldataload(add(_pubSignals, 1824)))
+
+ checkField(calldataload(add(_pubSignals, 1856)))
+
+ checkField(calldataload(add(_pubSignals, 1888)))
+
+ checkField(calldataload(add(_pubSignals, 1920)))
+
+ checkField(calldataload(add(_pubSignals, 1952)))
+
+ checkField(calldataload(add(_pubSignals, 1984)))
+
+ checkField(calldataload(add(_pubSignals, 2016)))
+
+ checkField(calldataload(add(_pubSignals, 2048)))
+
+ checkField(calldataload(add(_pubSignals, 2080)))
+
+ checkField(calldataload(add(_pubSignals, 2112)))
+
+ checkField(calldataload(add(_pubSignals, 2144)))
+
+ checkField(calldataload(add(_pubSignals, 2176)))
+
+ checkField(calldataload(add(_pubSignals, 2208)))
+
+ checkField(calldataload(add(_pubSignals, 2240)))
+
+ checkField(calldataload(add(_pubSignals, 2272)))
+
+ checkField(calldataload(add(_pubSignals, 2304)))
+
+
+ // Validate all evaluations
+ let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
+
+ mstore(0, isValid)
+ return(0, 0x20)
+ }
+ }
+ }
diff --git a/dist/index.html b/dist/index.html
index 350b6081..8894700d 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -217,7 +217,7 @@
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
- */function(){var F="input is invalid type",A="object"==typeof window,t=A?window:{};t.JS_SHA3_NO_WINDOW&&(A=!1);var B=!A&&"object"==typeof self;!t.JS_SHA3_NO_NODE_JS&&"object"==typeof na&&na.versions&&na.versions.node?t=AL:B&&(t=self);var i=!t.JS_SHA3_NO_COMMON_JS&&nh,e="function"==typeof define&&define.amd,V=!t.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,o="0123456789abcdef".split(""),s=[4,1024,262144,67108864],q=[0,8,16,24],h=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],r=[128,256],n=["hex","buffer","arrayBuffer","array","digest"],M={128:168,256:136};(t.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(F){return"[object Array]"===Object.prototype.toString.call(F)}),V&&(t.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(F){return"object"==typeof F&&F.buffer&&F.buffer.constructor===ArrayBuffer});for(var g=function(F,A,t){return function(B){return new k(F,A,F).update(B)[t]()}},l=function(F,A,t){return function(B,i){return new k(F,A,i).update(B)[t]()}},C=function(F,A,t){return function(A,B,i,e){return c["cshake"+F].update(A,B,i,e)[t]()}},I=function(F,A,t){return function(A,B,i,e){return c["kmac"+F].update(A,B,i,e)[t]()}},w=function(F,A,t,B){for(var i=0;i>5,this.byteCount=this.blockCount<<2,this.outputBlocks=t>>5,this.extraBytes=(31&t)>>3;for(var B=0;B<50;++B)this.s[B]=0}function U(F,A,t){k.call(this,F,A,t)}k.prototype.update=function(A){if(this.finalized)throw Error("finalize already called");var t,B=typeof A;if("string"!==B){if("object"===B){if(null===A)throw Error(F);if(V&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!V||!ArrayBuffer.isView(A)))throw Error(F)}else throw Error(F);t=!0}for(var i,e,o=this.blocks,s=this.byteCount,h=A.length,a=this.blockCount,r=0,n=this.s;r>2]|=A[r]<>2]|=e<>2]|=(192|e>>6)<=57344?o[i>>2]|=(224|e>>12)<>2]|=(240|e>>18)<>2]|=(128|e>>12&63)<>2]|=(128|e>>6&63)<>2]|=(128|63&e)<=s){for(this.start=i-s,this.block=o[a],i=0;i>=8,t=255&F;t>0;)i.unshift(t),F>>=8,t=255&F,++B;return A?i.push(B):i.unshift(B),this.update(i),i.length},k.prototype.encodeString=function(A){var t,B=typeof A;if("string"!==B){if("object"===B){if(null===A)throw Error(F);if(V&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!V||!ArrayBuffer.isView(A)))throw Error(F)}else throw Error(F);t=!0}var i=0,e=A.length;if(t)i=e;else for(var o=0;o=57344?i+=3:(s=65536+((1023&s)<<10|1023&A.charCodeAt(++o)),i+=4)}return i+=this.encode(8*i),this.update(A),i},k.prototype.bytepad=function(F,A){for(var t=this.encode(A),B=0;B>2]|=this.padding[3&A],this.lastByteIndex===this.byteCount)for(A=1,F[0]=F[t];A>4&15]+o[15&F]+o[F>>12&15]+o[F>>8&15]+o[F>>20&15]+o[F>>16&15]+o[F>>28&15]+o[F>>24&15];V%A==0&&(y(t),e=0)}return i&&(s+=o[(F=t[e])>>4&15]+o[15&F],i>1&&(s+=o[F>>12&15]+o[F>>8&15]),i>2&&(s+=o[F>>20&15]+o[F>>16&15])),s},k.prototype.arrayBuffer=function(){this.finalize();for(var F,A=this.blockCount,t=this.s,B=this.outputBlocks,i=this.extraBytes,e=0,V=0,o=this.outputBits>>3,s=new Uint32Array(F=new ArrayBuffer(i?B+1<<2:o));V>8&255,s[F+2]=A>>16&255,s[F+3]=A>>24&255;o%t==0&&y(B)}return e&&(F=o<<2,A=B[V],s[F]=255&A,e>1&&(s[F+1]=A>>8&255),e>2&&(s[F+2]=A>>16&255)),s},U.prototype=new k,U.prototype.finalize=function(){return this.encode(this.outputBits,!0),k.prototype.finalize.call(this)};var y=function(F){var A,t,B,i,e,V,o,s,q,a,r,n,M,g,l,C,I,w,Q,E,c,m,Y,D,p,u,G,S,k,U,y,K,Z,J,R,d,x,T,L,N,j,W,O,z,f,v,H,b,P,X,$,FF,FA,Ft,FB,Fi,Fe,FV,Fo,Fs,Fq,Fh,Fa;for(B=0;B<48;B+=2)i=F[0]^F[10]^F[20]^F[30]^F[40],e=F[1]^F[11]^F[21]^F[31]^F[41],V=F[2]^F[12]^F[22]^F[32]^F[42],o=F[3]^F[13]^F[23]^F[33]^F[43],s=F[4]^F[14]^F[24]^F[34]^F[44],q=F[5]^F[15]^F[25]^F[35]^F[45],a=F[6]^F[16]^F[26]^F[36]^F[46],r=F[7]^F[17]^F[27]^F[37]^F[47],n=F[8]^F[18]^F[28]^F[38]^F[48],M=F[9]^F[19]^F[29]^F[39]^F[49],A=n^(V<<1|o>>>31),t=M^(o<<1|V>>>31),F[0]^=A,F[1]^=t,F[10]^=A,F[11]^=t,F[20]^=A,F[21]^=t,F[30]^=A,F[31]^=t,F[40]^=A,F[41]^=t,A=i^(s<<1|q>>>31),t=e^(q<<1|s>>>31),F[2]^=A,F[3]^=t,F[12]^=A,F[13]^=t,F[22]^=A,F[23]^=t,F[32]^=A,F[33]^=t,F[42]^=A,F[43]^=t,A=V^(a<<1|r>>>31),t=o^(r<<1|a>>>31),F[4]^=A,F[5]^=t,F[14]^=A,F[15]^=t,F[24]^=A,F[25]^=t,F[34]^=A,F[35]^=t,F[44]^=A,F[45]^=t,A=s^(n<<1|M>>>31),t=q^(M<<1|n>>>31),F[6]^=A,F[7]^=t,F[16]^=A,F[17]^=t,F[26]^=A,F[27]^=t,F[36]^=A,F[37]^=t,F[46]^=A,F[47]^=t,A=a^(i<<1|e>>>31),t=r^(e<<1|i>>>31),F[8]^=A,F[9]^=t,F[18]^=A,F[19]^=t,F[28]^=A,F[29]^=t,F[38]^=A,F[39]^=t,F[48]^=A,F[49]^=t,g=F[0],l=F[1],v=F[11]<<4|F[10]>>>28,H=F[10]<<4|F[11]>>>28,S=F[20]<<3|F[21]>>>29,k=F[21]<<3|F[20]>>>29,Fs=F[31]<<9|F[30]>>>23,Fq=F[30]<<9|F[31]>>>23,W=F[40]<<18|F[41]>>>14,O=F[41]<<18|F[40]>>>14,J=F[2]<<1|F[3]>>>31,R=F[3]<<1|F[2]>>>31,C=F[13]<<12|F[12]>>>20,I=F[12]<<12|F[13]>>>20,b=F[22]<<10|F[23]>>>22,P=F[23]<<10|F[22]>>>22,U=F[33]<<13|F[32]>>>19,y=F[32]<<13|F[33]>>>19,Fh=F[42]<<2|F[43]>>>30,Fa=F[43]<<2|F[42]>>>30,Ft=F[5]<<30|F[4]>>>2,FB=F[4]<<30|F[5]>>>2,d=F[14]<<6|F[15]>>>26,x=F[15]<<6|F[14]>>>26,w=F[25]<<11|F[24]>>>21,Q=F[24]<<11|F[25]>>>21,X=F[34]<<15|F[35]>>>17,$=F[35]<<15|F[34]>>>17,K=F[45]<<29|F[44]>>>3,Z=F[44]<<29|F[45]>>>3,D=F[6]<<28|F[7]>>>4,p=F[7]<<28|F[6]>>>4,Fi=F[17]<<23|F[16]>>>9,Fe=F[16]<<23|F[17]>>>9,T=F[26]<<25|F[27]>>>7,L=F[27]<<25|F[26]>>>7,E=F[36]<<21|F[37]>>>11,c=F[37]<<21|F[36]>>>11,FF=F[47]<<24|F[46]>>>8,FA=F[46]<<24|F[47]>>>8,z=F[8]<<27|F[9]>>>5,f=F[9]<<27|F[8]>>>5,u=F[18]<<20|F[19]>>>12,G=F[19]<<20|F[18]>>>12,FV=F[29]<<7|F[28]>>>25,Fo=F[28]<<7|F[29]>>>25,N=F[38]<<8|F[39]>>>24,j=F[39]<<8|F[38]>>>24,m=F[48]<<14|F[49]>>>18,Y=F[49]<<14|F[48]>>>18,F[0]=g^~C&w,F[1]=l^~I&Q,F[10]=D^~u&S,F[11]=p^~G&k,F[20]=J^~d&T,F[21]=R^~x&L,F[30]=z^~v&b,F[31]=f^~H&P,F[40]=Ft^~Fi&FV,F[41]=FB^~Fe&Fo,F[2]=C^~w&E,F[3]=I^~Q&c,F[12]=u^~S&U,F[13]=G^~k&y,F[22]=d^~T&N,F[23]=x^~L&j,F[32]=v^~b&X,F[33]=H^~P&$,F[42]=Fi^~FV&Fs,F[43]=Fe^~Fo&Fq,F[4]=w^~E&m,F[5]=Q^~c&Y,F[14]=S^~U&K,F[15]=k^~y&Z,F[24]=T^~N&W,F[25]=L^~j&O,F[34]=b^~X&FF,F[35]=P^~$&FA,F[44]=FV^~Fs&Fh,F[45]=Fo^~Fq&Fa,F[6]=E^~m&g,F[7]=c^~Y&l,F[16]=U^~K&D,F[17]=y^~Z&p,F[26]=N^~W&J,F[27]=j^~O&R,F[36]=X^~FF&z,F[37]=$^~FA&f,F[46]=Fs^~Fh&Ft,F[47]=Fq^~Fa&FB,F[8]=m^~g&C,F[9]=Y^~l&I,F[18]=K^~D&u,F[19]=Z^~p&G,F[28]=W^~J&d,F[29]=O^~R&x,F[38]=FF^~z&v,F[39]=FA^~f&H,F[48]=Fh^~Ft&Fi,F[49]=Fa^~FB&Fe,F[0]^=h[B],F[1]^=h[B+1]};if(i)nh=c;else{for(Y=0;Y>=8;return A}function nu(F,A,t){let B=0;for(let i=0;iA+1+B&&nD.throwError("child data too short",rp.errors.BUFFER_OVERRUN,{})}return{consumed:1+B,result:i}}function nk(F,A){if(0===F.length&&nD.throwError("data too short",rp.errors.BUFFER_OVERRUN,{}),F[A]>=248){let t=F[A]-247;A+1+t>F.length&&nD.throwError("data short segment too short",rp.errors.BUFFER_OVERRUN,{});let B=nu(F,A+1,t);return A+1+t+B>F.length&&nD.throwError("data long segment too short",rp.errors.BUFFER_OVERRUN,{}),nS(F,A,A+1+t,t+B)}if(F[A]>=192){let t=F[A]-192;return A+1+t>F.length&&nD.throwError("data array too short",rp.errors.BUFFER_OVERRUN,{}),nS(F,A,A+1,t)}if(F[A]>=184){let t=F[A]-183;A+1+t>F.length&&nD.throwError("data array too short",rp.errors.BUFFER_OVERRUN,{});let B=nu(F,A+1,t);A+1+t+B>F.length&&nD.throwError("data array too short",rp.errors.BUFFER_OVERRUN,{});let i=rT(F.slice(A+1+t,A+1+t+B));return{consumed:1+t+B,result:i}}if(F[A]>=128){let t=F[A]-128;A+1+t>F.length&&nD.throwError("data too short",rp.errors.BUFFER_OVERRUN,{});let B=rT(F.slice(A+1,A+1+t));return{consumed:1+t,result:B}}return{consumed:1,result:rT(F[A])}}function nU(F){let A=rK(F),t=nk(A,0);return t.consumed!==A.length&&nD.throwArgumentError("invalid rlp data","data",F),t.result}let ny=new rp("address/5.7.0");function nK(F){rd(F,20)||ny.throwArgumentError("invalid address","address",F);let A=(F=F.toLowerCase()).substring(2).split(""),t=new Uint8Array(40);for(let F=0;F<40;F++)t[F]=A[F].charCodeAt(0);let B=rK(nm(t));for(let F=0;F<40;F+=2)B[F>>1]>>4>=8&&(A[F]=A[F].toUpperCase()),(15&B[F>>1])>=8&&(A[F+1]=A[F+1].toUpperCase());return"0x"+A.join("")}let nZ={};for(let F=0;F<10;F++)nZ[String(F)]=String(F);for(let F=0;F<26;F++)nZ[String.fromCharCode(65+F)]=String(10+F);let nJ=Math.floor(Math.log10?Math.log10(9007199254740991):Math.log(9007199254740991)/Math.LN10);function nR(F){let A=(F=(F=F.toUpperCase()).substring(4)+F.substring(0,2)+"00").split("").map(F=>nZ[F]).join("");for(;A.length>=nJ;){let F=A.substring(0,nJ);A=parseInt(F,10)%97+A.substring(F.length)}let t=String(98-parseInt(A,10)%97);for(;t.length<2;)t="0"+t;return t}function nd(F){let A=null;if("string"!=typeof F&&ny.throwArgumentError("invalid address","address",F),F.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==F.substring(0,2)&&(F="0x"+F),A=nK(F),F.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&A!==F&&ny.throwArgumentError("bad address checksum","address",F);else if(F.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(F.substring(2,4)!==nR(F)&&ny.throwArgumentError("bad icap checksum","address",F),A=new r6(F.substring(4),36).toString(16);A.length<40;)A="0"+A;A=nK("0x"+A)}else ny.throwArgumentError("invalid address","address",F);return A}function nx(F){try{return nd(F),!0}catch(F){}return!1}function nT(F){let A=new r6(nd(F).substring(2),16).toString(36).toUpperCase();for(;A.length<30;)A="0"+A;return"XE"+nR("XE00"+A)+A}function nL(F){let A=null;try{A=nd(F.from)}catch(A){ny.throwArgumentError("missing from address","transaction",F)}return nd(rN(nm(nG([A,rJ(rK(nF.from(F.nonce).toHexString()))])),12))}function nN(F,A,t){return 32!==rL(A)&&ny.throwArgumentError("salt must be 32 bytes","salt",A),32!==rL(t)&&ny.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",t),nd(rN(nm(rZ(["0xff",nd(F),A,t])),12))}class nj extends no{constructor(F){super("address","address",F,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(F,A){try{A=nd(A)}catch(F){this._throwError(F.message,A)}return F.writeValue(A)}decode(F){return nd(rz(F.readValue().toHexString(),20))}}class nW extends no{constructor(F){super(F.name,F.type,void 0,F.dynamic),this.coder=F}defaultValue(){return this.coder.defaultValue()}encode(F,A){return this.coder.encode(F,A)}decode(F){return this.coder.decode(F)}}let nO=new rp(r4);function nz(F,A,t){let B=null;if(Array.isArray(t))B=t;else if(t&&"object"==typeof t){let F={};B=A.map(A=>{let B=A.localName;return B||nO.throwError("cannot encode object for signature with missing names",rp.errors.INVALID_ARGUMENT,{argument:"values",coder:A,value:t}),F[B]&&nO.throwError("cannot encode object for signature with duplicate names",rp.errors.INVALID_ARGUMENT,{argument:"values",coder:A,value:t}),F[B]=!0,t[B]})}else nO.throwArgumentError("invalid tuple value","tuple",t);A.length!==B.length&&nO.throwArgumentError("types/value length mismatch","tuple",t);let i=new ns(F.wordSize),e=new ns(F.wordSize),V=[];return A.forEach((F,A)=>{let t=B[A];if(F.dynamic){let A=e.length;F.encode(e,t);let B=i.writeUpdatableValue();V.push(F=>{B(F+A)})}else F.encode(i,t)}),V.forEach(F=>{F(i.length)}),F.appendWriter(i)+F.appendWriter(e)}function nf(F,A){let t=[],B=F.subReader(0);A.forEach(A=>{let i=null;if(A.dynamic){let t=F.readValue(),e=B.subReader(t.toNumber());try{i=A.decode(e)}catch(F){if(F.code===rp.errors.BUFFER_OVERRUN)throw F;(i=F).baseType=A.name,i.name=A.localName,i.type=A.type}}else try{i=A.decode(F)}catch(F){if(F.code===rp.errors.BUFFER_OVERRUN)throw F;(i=F).baseType=A.name,i.name=A.localName,i.type=A.type}void 0!=i&&t.push(i)});let i=A.reduce((F,A)=>{let t=A.localName;return t&&(F[t]||(F[t]=0),F[t]++),F},{});A.forEach((F,A)=>{let B=F.localName;if(!B||1!==i[B]||("length"===B&&(B="_length"),null!=t[B]))return;let e=t[A];e instanceof Error?Object.defineProperty(t,B,{enumerable:!0,get:()=>{throw e}}):t[B]=e});for(let F=0;F{throw A}})}return Object.freeze(t)}class nv extends no{constructor(F,A,t){super("array",F.type+"["+(A>=0?A:"")+"]",t,-1===A||F.dynamic),this.coder=F,this.length=A}defaultValue(){let F=this.coder.defaultValue(),A=[];for(let t=0;tF._data.length&&nO.throwError("insufficient data length",rp.errors.BUFFER_OVERRUN,{length:F._data.length,count:A});let t=[];for(let F=0;F>6==2;B++)F++;return F}return F===AK.OVERRUN?t.length-A-1:0}(Am=Ay||(Ay={})).current="",Am.NFC="NFC",Am.NFD="NFD",Am.NFKC="NFKC",Am.NFKD="NFKD",(AY=AK||(AK={})).UNEXPECTED_CONTINUE="unexpected continuation byte",AY.BAD_PREFIX="bad codepoint prefix",AY.OVERRUN="string overrun",AY.MISSING_CONTINUE="missing continuation byte",AY.OUT_OF_RANGE="out of UTF-8 range",AY.UTF16_SURROGATE="UTF-16 surrogate",AY.OVERLONG="overlong representation";let n6=Object.freeze({error:function(F,A,t,B,i){return n5.throwArgumentError(`invalid codepoint at offset ${A}; ${F}`,"bytes",t)},ignore:n8,replace:function(F,A,t,B,i){return F===AK.OVERLONG?(B.push(i),0):(B.push(65533),n8(F,A,t,B,i))}});function n3(F,A){null==A&&(A=n6.error),F=rK(F);let t=[],B=0;for(;B>7==0){t.push(i);continue}let e=null,V=null;if((224&i)==192)e=1,V=127;else if((240&i)==224)e=2,V=2047;else if((248&i)==240)e=3,V=65535;else{(192&i)==128?B+=A(AK.UNEXPECTED_CONTINUE,B-1,F,t):B+=A(AK.BAD_PREFIX,B-1,F,t);continue}if(B-1+e>=F.length){B+=A(AK.OVERRUN,B-1,F,t);continue}let o=i&(1<<8-e-1)-1;for(let i=0;i1114111){B+=A(AK.OUT_OF_RANGE,B-1-e,F,t,o);continue}if(o>=55296&&o<=57343){B+=A(AK.UTF16_SURROGATE,B-1-e,F,t,o);continue}if(o<=V){B+=A(AK.OVERLONG,B-1-e,F,t,o);continue}t.push(o)}}return t}function n9(F,A=Ay.current){A!=Ay.current&&(n5.checkNormalize(),F=F.normalize(A));let t=[];for(let A=0;A>6|192),t.push(63&B|128);else if((64512&B)==55296){A++;let i=F.charCodeAt(A);if(A>=F.length||(64512&i)!=56320)throw Error("invalid utf-8 string");let e=65536+((1023&B)<<10)+(1023&i);t.push(e>>18|240),t.push(e>>12&63|128),t.push(e>>6&63|128),t.push(63&e|128)}else t.push(B>>12|224),t.push(B>>6&63|128),t.push(63&B|128)}return rK(t)}function n7(F){let A="0000"+F.toString(16);return"\\u"+A.substring(A.length-4)}function MF(F,A){return'"'+n3(F,A).map(F=>{if(F<256){switch(F){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(F>=32&&F<127)return String.fromCharCode(F)}return F<=65535?n7(F):n7(((F-=65536)>>10&1023)+55296)+n7((1023&F)+56320)}).join("")+'"'}function MA(F){return F.map(F=>F<=65535?String.fromCharCode(F):String.fromCharCode(((F-=65536)>>10&1023)+55296,(1023&F)+56320)).join("")}function Mt(F,A){return MA(n3(F,A))}function MB(F,A=Ay.current){return n3(n9(F,A))}class Mi extends nb{constructor(F){super("string",F)}defaultValue(){return""}encode(F,A){return super.encode(F,n9(A))}decode(F){return Mt(super.decode(F))}}class Me extends no{constructor(F,A){let t=!1,B=[];F.forEach(F=>{F.dynamic&&(t=!0),B.push(F.type)}),super("tuple","tuple("+B.join(",")+")",A,t),this.coders=F}defaultValue(){let F=[];this.coders.forEach(A=>{F.push(A.defaultValue())});let A=this.coders.reduce((F,A)=>{let t=A.localName;return t&&(F[t]||(F[t]=0),F[t]++),F},{});return this.coders.forEach((t,B)=>{let i=t.localName;i&&1===A[i]&&("length"===i&&(i="_length"),null==F[i]&&(F[i]=F[B]))}),Object.freeze(F)}encode(F,A){return nz(F,this.coders,A)}decode(F){return F.coerce(this.name,nf(F,this.coders))}}let MV=new rp(r4),Mo={},Ms={calldata:!0,memory:!0,storage:!0},Mq={calldata:!0,memory:!0};function Mh(F,A){if("bytes"===F||"string"===F){if(Ms[A])return!0}else if("address"===F){if("payable"===A)return!0}else if((F.indexOf("[")>=0||"tuple"===F)&&Mq[A])return!0;return(Ms[A]||"payable"===A)&&MV.throwArgumentError("invalid modifier","name",A),!1}function Ma(F,A){for(let t in A)rb(F,t,A[t])}let Mr=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),Mn=new RegExp(/^(.*)\[([0-9]*)\]$/);class MM{constructor(F,A){F!==Mo&&MV.throwError("use fromString",rp.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),Ma(this,A);let t=this.type.match(Mn);t?Ma(this,{arrayLength:parseInt(t[2]||"-1"),arrayChildren:MM.fromObject({type:t[1],components:this.components}),baseType:"array"}):Ma(this,{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json){let A={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(A.indexed=this.indexed),this.components&&(A.components=this.components.map(A=>JSON.parse(A.format(F)))),JSON.stringify(A)}let A="";return"array"===this.baseType?A+=this.arrayChildren.format(F)+"["+(this.arrayLength<0?"":String(this.arrayLength))+"]":"tuple"===this.baseType?(F!==Mr.sighash&&(A+=this.type),A+="("+this.components.map(A=>A.format(F)).join(F===Mr.full?", ":",")+")"):A+=this.type,F!==Mr.sighash&&(!0===this.indexed&&(A+=" indexed"),F===Mr.full&&this.name&&(A+=" "+this.name)),A}static from(F,A){return"string"==typeof F?MM.fromString(F,A):MM.fromObject(F)}static fromObject(F){return MM.isParamType(F)?F:new MM(Mo,{name:F.name||null,type:MD(F.type),indexed:null==F.indexed?null:!!F.indexed,components:F.components?F.components.map(MM.fromObject):null})}static fromString(F,A){var t;return t=function(F,A){let t=F;function B(A){MV.throwArgumentError(`unexpected character at position ${A}`,"param",F)}function i(F){let t={type:"",name:"",parent:F,state:{allowType:!0}};return A&&(t.indexed=!1),t}F=F.replace(/\s/g," ");let e={type:"",name:"",state:{allowType:!0}},V=e;for(let t=0;tMM.fromString(F,A))}class Ml{constructor(F,A){F!==Mo&&MV.throwError("use a static from method",rp.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Ma(this,A),this._isFragment=!0,Object.freeze(this)}static from(F){return Ml.isFragment(F)?F:"string"==typeof F?Ml.fromString(F):Ml.fromObject(F)}static fromObject(F){if(Ml.isFragment(F))return F;switch(F.type){case"function":return Mc.fromObject(F);case"event":return MC.fromObject(F);case"constructor":return ME.fromObject(F);case"error":return MY.fromObject(F);case"fallback":case"receive":return null}return MV.throwArgumentError("invalid fragment object","value",F)}static fromString(F){return"event"===(F=(F=(F=F.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?MC.fromString(F.substring(5).trim()):"function"===F.split(" ")[0]?Mc.fromString(F.substring(8).trim()):"constructor"===F.split("(")[0].trim()?ME.fromString(F.trim()):"error"===F.split(" ")[0]?MY.fromString(F.substring(5).trim()):MV.throwArgumentError("unsupported fragment","value",F)}static isFragment(F){return!!(F&&F._isFragment)}}class MC extends Ml{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(A=>JSON.parse(A.format(F)))});let A="";return F!==Mr.sighash&&(A+="event "),A+=this.name+"("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ",F!==Mr.sighash&&this.anonymous&&(A+="anonymous "),A.trim()}static from(F){return"string"==typeof F?MC.fromString(F):MC.fromObject(F)}static fromObject(F){return MC.isEventFragment(F)?F:("event"!==F.type&&MV.throwArgumentError("invalid event object","value",F),new MC(Mo,{name:Mu(F.name),anonymous:F.anonymous,inputs:F.inputs?F.inputs.map(MM.fromObject):[],type:"event"}))}static fromString(F){let A=F.match(MG);A||MV.throwArgumentError("invalid event string","value",F);let t=!1;return A[3].split(" ").forEach(F=>{switch(F.trim()){case"anonymous":t=!0;break;case"":break;default:MV.warn("unknown modifier: "+F)}}),MC.fromObject({name:A[1].trim(),anonymous:t,inputs:Mg(A[2],!0),type:"event"})}static isEventFragment(F){return F&&F._isFragment&&"event"===F.type}}function MI(F,A){A.gas=null;let t=F.split("@");return 1!==t.length?(t.length>2&&MV.throwArgumentError("invalid human-readable ABI signature","value",F),t[1].match(/^[0-9]+$/)||MV.throwArgumentError("invalid human-readable ABI signature gas","value",F),A.gas=nF.from(t[1]),t[0]):F}function Mw(F,A){A.constant=!1,A.payable=!1,A.stateMutability="nonpayable",F.split(" ").forEach(F=>{switch(F.trim()){case"constant":A.constant=!0;break;case"payable":A.payable=!0,A.stateMutability="payable";break;case"nonpayable":A.payable=!1,A.stateMutability="nonpayable";break;case"pure":A.constant=!0,A.stateMutability="pure";break;case"view":A.constant=!0,A.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+F)}})}function MQ(F){let A={constant:!1,payable:!0,stateMutability:"payable"};return null!=F.stateMutability?(A.stateMutability=F.stateMutability,A.constant="view"===A.stateMutability||"pure"===A.stateMutability,null!=F.constant&&!!F.constant!==A.constant&&MV.throwArgumentError("cannot have constant function with mutability "+A.stateMutability,"value",F),A.payable="payable"===A.stateMutability,null!=F.payable&&!!F.payable!==A.payable&&MV.throwArgumentError("cannot have payable function with mutability "+A.stateMutability,"value",F)):null!=F.payable?(A.payable=!!F.payable,null!=F.constant||A.payable||"constructor"===F.type||MV.throwArgumentError("unable to determine stateMutability","value",F),A.constant=!!F.constant,A.constant?A.stateMutability="view":A.stateMutability=A.payable?"payable":"nonpayable",A.payable&&A.constant&&MV.throwArgumentError("cannot have constant payable function","value",F)):null!=F.constant?(A.constant=!!F.constant,A.payable=!A.constant,A.stateMutability=A.constant?"view":"payable"):"constructor"!==F.type&&MV.throwArgumentError("unable to determine stateMutability","value",F),A}class ME extends Ml{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(A=>JSON.parse(A.format(F)))});F===Mr.sighash&&MV.throwError("cannot format a constructor for sighash",rp.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let A="constructor("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(A+=this.stateMutability+" "),A.trim()}static from(F){return"string"==typeof F?ME.fromString(F):ME.fromObject(F)}static fromObject(F){if(ME.isConstructorFragment(F))return F;"constructor"!==F.type&&MV.throwArgumentError("invalid constructor object","value",F);let A=MQ(F);return A.constant&&MV.throwArgumentError("constructor cannot be constant","value",F),new ME(Mo,{name:null,type:F.type,inputs:F.inputs?F.inputs.map(MM.fromObject):[],payable:A.payable,stateMutability:A.stateMutability,gas:F.gas?nF.from(F.gas):null})}static fromString(F){let A={type:"constructor"},t=(F=MI(F,A)).match(MG);return t&&"constructor"===t[1].trim()||MV.throwArgumentError("invalid constructor string","value",F),A.inputs=Mg(t[2].trim(),!1),Mw(t[3].trim(),A),ME.fromObject(A)}static isConstructorFragment(F){return F&&F._isFragment&&"constructor"===F.type}}class Mc extends ME{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(A=>JSON.parse(A.format(F))),outputs:this.outputs.map(A=>JSON.parse(A.format(F)))});let A="";return F!==Mr.sighash&&(A+="function "),A+=this.name+"("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ",F!==Mr.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(A+=this.stateMutability+" "):this.constant&&(A+="view "),this.outputs&&this.outputs.length&&(A+="returns ("+this.outputs.map(A=>A.format(F)).join(", ")+") "),null!=this.gas&&(A+="@"+this.gas.toString()+" ")),A.trim()}static from(F){return"string"==typeof F?Mc.fromString(F):Mc.fromObject(F)}static fromObject(F){if(Mc.isFunctionFragment(F))return F;"function"!==F.type&&MV.throwArgumentError("invalid function object","value",F);let A=MQ(F);return new Mc(Mo,{type:F.type,name:Mu(F.name),constant:A.constant,inputs:F.inputs?F.inputs.map(MM.fromObject):[],outputs:F.outputs?F.outputs.map(MM.fromObject):[],payable:A.payable,stateMutability:A.stateMutability,gas:F.gas?nF.from(F.gas):null})}static fromString(F){let A={type:"function"},t=(F=MI(F,A)).split(" returns ");t.length>2&&MV.throwArgumentError("invalid function string","value",F);let B=t[0].match(MG);if(B||MV.throwArgumentError("invalid function signature","value",F),A.name=B[1].trim(),A.name&&Mu(A.name),A.inputs=Mg(B[2],!1),Mw(B[3].trim(),A),t.length>1){let B=t[1].match(MG);(""!=B[1].trim()||""!=B[3].trim())&&MV.throwArgumentError("unexpected tokens","value",F),A.outputs=Mg(B[2],!1)}else A.outputs=[];return Mc.fromObject(A)}static isFunctionFragment(F){return F&&F._isFragment&&"function"===F.type}}function Mm(F){let A=F.format();return("Error(string)"===A||"Panic(uint256)"===A)&&MV.throwArgumentError(`cannot specify user defined ${A} error`,"fragment",F),F}class MY extends Ml{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(A=>JSON.parse(A.format(F)))});let A="";return F!==Mr.sighash&&(A+="error "),(A+=this.name+"("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ").trim()}static from(F){return"string"==typeof F?MY.fromString(F):MY.fromObject(F)}static fromObject(F){return MY.isErrorFragment(F)?F:("error"!==F.type&&MV.throwArgumentError("invalid error object","value",F),Mm(new MY(Mo,{type:F.type,name:Mu(F.name),inputs:F.inputs?F.inputs.map(MM.fromObject):[]})))}static fromString(F){let A={type:"error"},t=F.match(MG);return t||MV.throwArgumentError("invalid error signature","value",F),A.name=t[1].trim(),A.name&&Mu(A.name),A.inputs=Mg(t[2],!1),Mm(MY.fromObject(A))}static isErrorFragment(F){return F&&F._isFragment&&"error"===F.type}}function MD(F){return F.match(/^uint($|[^1-9])/)?F="uint256"+F.substring(4):F.match(/^int($|[^1-9])/)&&(F="int256"+F.substring(3)),F}let Mp=RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Mu(F){return F&&F.match(Mp)||MV.throwArgumentError(`invalid identifier "${F}"`,"value",F),F}let MG=RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),MS=new rp(r4),Mk=new RegExp(/^bytes([0-9]*)$/),MU=new RegExp(/^(u?int)([0-9]*)$/);class My{constructor(F){rb(this,"coerceFunc",F||null)}_getCoder(F){switch(F.baseType){case"address":return new nj(F.name);case"bool":return new nH(F.name);case"string":return new Mi(F.name);case"bytes":return new nP(F.name);case"array":return new nv(this._getCoder(F.arrayChildren),F.arrayLength,F.name);case"tuple":return new Me((F.components||[]).map(F=>this._getCoder(F)),F.name);case"":return new n_(F.name)}let A=F.type.match(MU);if(A){let t=parseInt(A[2]||"256");return(0===t||t>256||t%8!=0)&&MS.throwArgumentError("invalid "+A[1]+" bit length","param",F),new n4(t/8,"int"===A[1],F.name)}if(A=F.type.match(Mk)){let t=parseInt(A[1]);return(0===t||t>32)&&MS.throwArgumentError("invalid bytes length","param",F),new nX(t,F.name)}return MS.throwArgumentError("invalid type","type",F.type)}_getWordSize(){return 32}_getReader(F,A){return new nq(F,this._getWordSize(),this.coerceFunc,A)}_getWriter(){return new ns(this._getWordSize())}getDefaultValue(F){return new Me(F.map(F=>this._getCoder(MM.from(F))),"_").defaultValue()}encode(F,A){F.length!==A.length&&MS.throwError("types/values length mismatch",rp.errors.INVALID_ARGUMENT,{count:{types:F.length,values:A.length},value:{types:F,values:A}});let t=new Me(F.map(F=>this._getCoder(MM.from(F))),"_"),B=this._getWriter();return t.encode(B,A),B.data}decode(F,A,t){return new Me(F.map(F=>this._getCoder(MM.from(F))),"_").decode(this._getReader(rK(A),t))}}let MK=new My;function MZ(F){return nm(n9(F))}let MJ=new rp(r4);class MR extends r1{}class Md extends r1{}class Mx extends r1{}class MT extends r1{static isIndexed(F){return!!(F&&F._isIndexed)}}let ML={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function MN(F,A){let t=Error(`deferred error during ABI decoding triggered accessing ${F}`);return t.error=A,t}class Mj{constructor(F){rb(this,"fragments",("string"==typeof F?JSON.parse(F):F).map(F=>Ml.from(F)).filter(F=>null!=F)),rb(this,"_abiCoder",rP(new.target,"getAbiCoder")()),rb(this,"functions",{}),rb(this,"errors",{}),rb(this,"events",{}),rb(this,"structs",{}),this.fragments.forEach(F=>{let A=null;switch(F.type){case"constructor":if(this.deploy){MJ.warn("duplicate definition - constructor");return}rb(this,"deploy",F);return;case"function":A=this.functions;break;case"event":A=this.events;break;case"error":A=this.errors;break;default:return}let t=F.format();if(A[t]){MJ.warn("duplicate definition - "+t);return}A[t]=F}),this.deploy||rb(this,"deploy",ME.from({payable:!1,type:"constructor"})),rb(this,"_isInterface",!0)}format(F){F||(F=Mr.full),F===Mr.sighash&&MJ.throwArgumentError("interface does not support formatting sighash","format",F);let A=this.fragments.map(A=>A.format(F));return F===Mr.json?JSON.stringify(A.map(F=>JSON.parse(F))):A}static getAbiCoder(){return MK}static getAddress(F){return nd(F)}static getSighash(F){return rN(MZ(F.format()),0,4)}static getEventTopic(F){return MZ(F.format())}getFunction(F){if(rd(F)){for(let A in this.functions)if(F===this.getSighash(A))return this.functions[A];MJ.throwArgumentError("no matching function","sighash",F)}if(-1===F.indexOf("(")){let A=F.trim(),t=Object.keys(this.functions).filter(F=>F.split("(")[0]===A);return 0===t.length?MJ.throwArgumentError("no matching function","name",A):t.length>1&&MJ.throwArgumentError("multiple matching functions","name",A),this.functions[t[0]]}let A=this.functions[Mc.fromString(F).format()];return A||MJ.throwArgumentError("no matching function","signature",F),A}getEvent(F){if(rd(F)){let A=F.toLowerCase();for(let F in this.events)if(A===this.getEventTopic(F))return this.events[F];MJ.throwArgumentError("no matching event","topichash",A)}if(-1===F.indexOf("(")){let A=F.trim(),t=Object.keys(this.events).filter(F=>F.split("(")[0]===A);return 0===t.length?MJ.throwArgumentError("no matching event","name",A):t.length>1&&MJ.throwArgumentError("multiple matching events","name",A),this.events[t[0]]}let A=this.events[MC.fromString(F).format()];return A||MJ.throwArgumentError("no matching event","signature",F),A}getError(F){if(rd(F)){let A=rP(this.constructor,"getSighash");for(let t in this.errors)if(F===A(this.errors[t]))return this.errors[t];MJ.throwArgumentError("no matching error","sighash",F)}if(-1===F.indexOf("(")){let A=F.trim(),t=Object.keys(this.errors).filter(F=>F.split("(")[0]===A);return 0===t.length?MJ.throwArgumentError("no matching error","name",A):t.length>1&&MJ.throwArgumentError("multiple matching errors","name",A),this.errors[t[0]]}let A=this.errors[Mc.fromString(F).format()];return A||MJ.throwArgumentError("no matching error","signature",F),A}getSighash(F){if("string"==typeof F)try{F=this.getFunction(F)}catch(A){try{F=this.getError(F)}catch(F){throw A}}return rP(this.constructor,"getSighash")(F)}getEventTopic(F){return"string"==typeof F&&(F=this.getEvent(F)),rP(this.constructor,"getEventTopic")(F)}_decodeParams(F,A){return this._abiCoder.decode(F,A)}_encodeParams(F,A){return this._abiCoder.encode(F,A)}encodeDeploy(F){return this._encodeParams(this.deploy.inputs,F||[])}decodeErrorResult(F,A){"string"==typeof F&&(F=this.getError(F));let t=rK(A);return rT(t.slice(0,4))!==this.getSighash(F)&&MJ.throwArgumentError(`data signature does not match error ${F.name}.`,"data",rT(t)),this._decodeParams(F.inputs,t.slice(4))}encodeErrorResult(F,A){return"string"==typeof F&&(F=this.getError(F)),rT(rZ([this.getSighash(F),this._encodeParams(F.inputs,A||[])]))}decodeFunctionData(F,A){"string"==typeof F&&(F=this.getFunction(F));let t=rK(A);return rT(t.slice(0,4))!==this.getSighash(F)&&MJ.throwArgumentError(`data signature does not match function ${F.name}.`,"data",rT(t)),this._decodeParams(F.inputs,t.slice(4))}encodeFunctionData(F,A){return"string"==typeof F&&(F=this.getFunction(F)),rT(rZ([this.getSighash(F),this._encodeParams(F.inputs,A||[])]))}decodeFunctionResult(F,A){"string"==typeof F&&(F=this.getFunction(F));let t=rK(A),B=null,i="",e=null,V=null,o=null;switch(t.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(F.outputs,t)}catch(F){}break;case 4:{let F=rT(t.slice(0,4)),A=ML[F];if(A)e=this._abiCoder.decode(A.inputs,t.slice(4)),V=A.name,o=A.signature,A.reason&&(B=e[0]),"Error"===V?i=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(e[0])}`:"Panic"===V&&(i=`; VM Exception while processing transaction: reverted with panic code ${e[0]}`);else try{let A=this.getError(F);e=this._abiCoder.decode(A.inputs,t.slice(4)),V=A.name,o=A.format()}catch(F){}}}return MJ.throwError("call revert exception"+i,rp.errors.CALL_EXCEPTION,{method:F.format(),data:rT(A),errorArgs:e,errorName:V,errorSignature:o,reason:B})}encodeFunctionResult(F,A){return"string"==typeof F&&(F=this.getFunction(F)),rT(this._abiCoder.encode(F.outputs,A||[]))}encodeFilterTopics(F,A){"string"==typeof F&&(F=this.getEvent(F)),A.length>F.inputs.length&&MJ.throwError("too many arguments for "+F.format(),rp.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:A});let t=[];F.anonymous||t.push(this.getEventTopic(F));let B=(F,A)=>"string"===F.type?MZ(A):"bytes"===F.type?nm(rT(A)):("bool"===F.type&&"boolean"==typeof A&&(A=A?"0x01":"0x00"),F.type.match(/^u?int/)&&(A=nF.from(A).toHexString()),"address"===F.type&&this._abiCoder.encode(["address"],[A]),rz(rT(A),32));for(A.forEach((A,i)=>{let e=F.inputs[i];if(!e.indexed){null!=A&&MJ.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+e.name,A);return}null==A?t.push(null):"array"===e.baseType||"tuple"===e.baseType?MJ.throwArgumentError("filtering with tuples or arrays not supported","contract."+e.name,A):Array.isArray(A)?t.push(A.map(F=>B(e,F))):t.push(B(e,A))});t.length&&null===t[t.length-1];)t.pop();return t}encodeEventLog(F,A){"string"==typeof F&&(F=this.getEvent(F));let t=[],B=[],i=[];return F.anonymous||t.push(this.getEventTopic(F)),A.length!==F.inputs.length&&MJ.throwArgumentError("event arguments/values mismatch","values",A),F.inputs.forEach((F,e)=>{let V=A[e];if(F.indexed){if("string"===F.type)t.push(MZ(V));else if("bytes"===F.type)t.push(nm(V));else if("tuple"===F.baseType||"array"===F.baseType)throw Error("not implemented");else t.push(this._abiCoder.encode([F.type],[V]))}else B.push(F),i.push(V)}),{data:this._abiCoder.encode(B,i),topics:t}}decodeEventLog(F,A,t){if("string"==typeof F&&(F=this.getEvent(F)),null!=t&&!F.anonymous){let A=this.getEventTopic(F);rd(t[0],32)&&t[0].toLowerCase()===A||MJ.throwError("fragment/topic mismatch",rp.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:A,value:t[0]}),t=t.slice(1)}let B=[],i=[],e=[];F.inputs.forEach((F,A)=>{F.indexed?"string"===F.type||"bytes"===F.type||"tuple"===F.baseType||"array"===F.baseType?(B.push(MM.fromObject({type:"bytes32",name:F.name})),e.push(!0)):(B.push(F),e.push(!1)):(i.push(F),e.push(!1))});let V=null!=t?this._abiCoder.decode(B,rZ(t)):null,o=this._abiCoder.decode(i,A,!0),s=[],q=0,h=0;F.inputs.forEach((F,A)=>{if(F.indexed){if(null==V)s[A]=new MT({_isIndexed:!0,hash:null});else if(e[A])s[A]=new MT({_isIndexed:!0,hash:V[h++]});else try{s[A]=V[h++]}catch(F){s[A]=F}}else try{s[A]=o[q++]}catch(F){s[A]=F}if(F.name&&null==s[F.name]){let t=s[A];t instanceof Error?Object.defineProperty(s,F.name,{enumerable:!0,get:()=>{throw MN(`property ${JSON.stringify(F.name)}`,t)}}):s[F.name]=t}});for(let F=0;F{throw MN(`index ${F}`,A)}})}return Object.freeze(s)}parseTransaction(F){let A=this.getFunction(F.data.substring(0,10).toLowerCase());return A?new Md({args:this._abiCoder.decode(A.inputs,"0x"+F.data.substring(10)),functionFragment:A,name:A.name,signature:A.format(),sighash:this.getSighash(A),value:nF.from(F.value||"0")}):null}parseLog(F){let A=this.getEvent(F.topics[0]);return!A||A.anonymous?null:new MR({eventFragment:A,name:A.name,signature:A.format(),topic:this.getEventTopic(A),args:this.decodeEventLog(A,F.data,F.topics)})}parseError(F){let A=rT(F),t=this.getError(A.substring(0,10).toLowerCase());return t?new Mx({args:this._abiCoder.decode(t.inputs,"0x"+A.substring(10)),errorFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t)}):null}static isInterface(F){return!!(F&&F._isInterface)}}var MW={};function MO(F){F=atob(F);let A=[];for(let t=0;t0;)t.push(B%this.base),B=B/this.base|0}let B="";for(let F=0;0===A[F]&&F=0;--F)B+=this.alphabet[t[F]];return B}decode(F){if("string"!=typeof F)throw TypeError("Expected String");let A=[];if(0===F.length)return new Uint8Array(A);A.push(0);for(let t=0;t>=8;for(;i>0;)A.push(255&i),i>>=8}for(let t=0;F[t]===this._leader&&t256||A[2]&&A[2]!==String(B))&&Mb.throwArgumentError("invalid numeric width","type",F);let i=M2.mask(t?B-1:B),e=t?i.add(M$).mul(MX):M_;return function(A){let t=nF.from(A);return(t.lt(e)||t.gt(i))&&Mb.throwArgumentError(`value out-of-bounds for ${F}`,"value",A),rz(t.toTwos(256).toHexString(),32)}}}{let A=F.match(/^bytes(\d+)$/);if(A){let t=parseInt(A[1]);return(0===t||t>32||A[1]!==String(t))&&Mb.throwArgumentError("invalid bytes width","type",F),function(A){return rK(A).length!==t&&Mb.throwArgumentError(`invalid length for ${F}`,"value",A),function(F){let A=rK(F),t=A.length%32;return t?rj([A,MP.slice(t)]):rT(A)}(A)}}}switch(F){case"address":return function(F){return rz(nd(F),32)};case"bool":return function(F){return F?M0:M1};case"bytes":return function(F){return nm(F)};case"string":return function(F){return MZ(F)}}return null}function M9(F,A){return`${F}(${A.map(({name:F,type:A})=>A+" "+F).join(",")})`}class M7{constructor(F){rb(this,"types",Object.freeze(r0(F))),rb(this,"_encoderCache",{}),rb(this,"_types",{});let A={},t={},B={};for(let i in Object.keys(F).forEach(F=>{A[F]={},t[F]=[],B[F]={}}),F){let B={};F[i].forEach(e=>{B[e.name]&&Mb.throwArgumentError(`duplicate variable name ${JSON.stringify(e.name)} in ${JSON.stringify(i)}`,"types",F),B[e.name]=!0;let V=e.type.match(/^([^\x5b]*)(\x5b|$)/)[1];V===i&&Mb.throwArgumentError(`circular type reference to ${JSON.stringify(V)}`,"types",F),M3(V)||(t[V]||Mb.throwArgumentError(`unknown type ${JSON.stringify(V)}`,"types",F),t[V].push(i),A[i][V]=!0)})}let i=Object.keys(t).filter(F=>0===t[F].length);for(let e in 0===i.length?Mb.throwArgumentError("missing primary type","types",F):i.length>1&&Mb.throwArgumentError(`ambiguous primary types or unused types: ${i.map(F=>JSON.stringify(F)).join(", ")}`,"types",F),rb(this,"primaryType",i[0]),!function i(e,V){V[e]&&Mb.throwArgumentError(`circular type reference to ${JSON.stringify(e)}`,"types",F),V[e]=!0,Object.keys(A[e]).forEach(F=>{t[F]&&(i(F,V),Object.keys(V).forEach(A=>{B[A][F]=!0}))}),delete V[e]}(this.primaryType,{}),B){let A=Object.keys(B[e]);A.sort(),this._types[e]=M9(e,F[e])+A.map(A=>M9(A,F[A])).join("")}}getEncoder(F){let A=this._encoderCache[F];return A||(A=this._encoderCache[F]=this._getEncoder(F)),A}_getEncoder(F){{let A=M3(F);if(A)return A}let A=F.match(/^(.*)(\x5b(\d*)\x5d)$/);if(A){let F=A[1],t=this.getEncoder(F),B=parseInt(A[3]);return A=>{B>=0&&A.length!==B&&Mb.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",A);let i=A.map(t);return this._types[F]&&(i=i.map(nm)),nm(rj(i))}}let t=this.types[F];if(t){let A=MZ(this._types[F]);return F=>{let B=t.map(({name:A,type:t})=>{let B=this.getEncoder(t)(F[A]);return this._types[t]?nm(B):B});return B.unshift(A),rj(B)}}return Mb.throwArgumentError(`unknown type: ${F}`,"type",F)}encodeType(F){let A=this._types[F];return A||Mb.throwArgumentError(`unknown type: ${JSON.stringify(F)}`,"name",F),A}encodeData(F,A){return this.getEncoder(F)(A)}hashStruct(F,A){return nm(this.encodeData(F,A))}encode(F){return this.encodeData(this.primaryType,F)}hash(F){return this.hashStruct(this.primaryType,F)}_visit(F,A,t){if(M3(F))return t(F,A);let B=F.match(/^(.*)(\x5b(\d*)\x5d)$/);if(B){let F=B[1],i=parseInt(B[3]);return i>=0&&A.length!==i&&Mb.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",A),A.map(A=>this._visit(F,A,t))}let i=this.types[F];return i?i.reduce((F,{name:B,type:i})=>(F[B]=this._visit(i,A[B],t),F),{}):Mb.throwArgumentError(`unknown type: ${F}`,"type",F)}visit(F,A){return this._visit(this.primaryType,F,A)}static from(F){return new M7(F)}static getPrimaryType(F){return M7.from(F).primaryType}static hashStruct(F,A,t){return M7.from(A).hashStruct(F,t)}static hashDomain(F){let A=[];for(let t in F){let B=M4[t];B||Mb.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",F),A.push({name:t,type:B})}return A.sort((F,A)=>M5.indexOf(F.name)-M5.indexOf(A.name)),M7.hashStruct("EIP712Domain",{EIP712Domain:A},F)}static encode(F,A,t){return rj(["0x1901",M7.hashDomain(F),M7.from(A).hash(t)])}static hash(F,A,t){return nm(M7.encode(F,A,t))}static resolveNames(F,A,t,B){var i,e,V,o;return i=this,e=void 0,V=void 0,o=function*(){F=r$(F);let i={};F.verifyingContract&&!rd(F.verifyingContract,20)&&(i[F.verifyingContract]="0x");let e=M7.from(A);for(let F in e.visit(t,(F,A)=>("address"!==F||rd(A,20)||(i[A]="0x"),A)),i)i[F]=yield B(F);return F.verifyingContract&&i[F.verifyingContract]&&(F.verifyingContract=i[F.verifyingContract]),t=e.visit(t,(F,A)=>"address"===F&&i[A]?i[A]:A),{domain:F,value:t}},new(V||(V=Promise))(function(F,A){function t(F){try{s(o.next(F))}catch(F){A(F)}}function B(F){try{s(o.throw(F))}catch(F){A(F)}}function s(A){var i;A.done?F(A.value):((i=A.value)instanceof V?i:new V(function(F){F(i)})).then(t,B)}s((o=o.apply(i,e||[])).next())})}static getPayload(F,A,t){M7.hashDomain(F);let B={},i=[];M5.forEach(A=>{let t=F[A];null!=t&&(B[A]=M6[A](t),i.push({name:A,type:M4[A]}))});let e=M7.from(A),V=r$(A);return V.EIP712Domain?Mb.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",A):V.EIP712Domain=i,e.encode(t),{types:V,domain:B,primaryType:e.primaryType,message:e.visit(t,(F,A)=>{if(F.match(/^bytes(\d*)/))return rT(rK(A));if(F.match(/^u?int/))return nF.from(A).toString();switch(F){case"address":return A.toLowerCase();case"bool":return!!A;case"string":return"string"!=typeof A&&Mb.throwArgumentError("invalid string","value",A),A}return Mb.throwArgumentError("unsupported type","type",F)})}}}function gF(F,A){null==A&&(A=1);let t=[],B=t.forEach,i=function(F,A){B.call(F,function(F){A>0&&Array.isArray(F)?i(F,A-1):t.push(F)})};return i(F,A),t}function gA(F,A){let t=Array(F);for(let B=0,i=-1;BA[F]):t}function gB(F,A,t){let B=Array(F).fill(void 0).map(()=>[]);for(let i=0;i>1:B>>1}return t})(F,t).forEach((F,A)=>B[A].push(F));return B}let gi=(Ah=function(F){let A=0;function t(){return F[A++]<<8|F[A++]}let B=t(),i=1,e=[0,1];for(let F=1;F>--s&1}let a=0;for(let F=0;F<31;F++)a=a<<1|h();let r=[],n=0,M=2147483648;for(;;){let F=Math.floor(((a-n+1)*i-1)/M),A=0,t=B;for(;t-A>1;){let B=A+t>>>1;F{switch(A-g){case 3:return g+65792+(F[o++]<<16|F[o++]<<8|F[o++]);case 2:return g+256+(F[o++]<<8|F[o++]);case 1:return g+F[o++];default:return A-1}})}(MO("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")),Ff=0,()=>Ah[Ff++]),ge=new Set(gt(gi)),gV=new Set(gt(gi)),go=function(F){let A=[];for(;;){let t=F();if(0==t)break;A.push(function(F,A){let t=1+A(),B=A(),i=function(F){let A=[];for(;;){let t=F();if(0==t)break;A.push(t)}return A}(A);return gF(gB(i.length,1+F,A).map((F,A)=>{let e=F[0],V=F.slice(1);return Array(i[A]).fill(void 0).map((F,A)=>{let i=A*B;return[e+A*t,V.map(F=>F+i)]})}))}(t,F))}for(;;){let t=F()-1;if(t<0)break;A.push(gB(1+F(),1+t,F).map(F=>[F[0],F.slice(1)]))}return function(F){let A={};for(let t=0;tF-A),function F(){let A=[];for(;;){let t=gt(gi,Fz);if(0==t.length)break;A.push({set:new Set(t),node:F()})}A.sort((F,A)=>A.set.size-F.set.size);let t=gi();return{branches:A,valid:t%3,fe0f:!!(1&(t=t/3|0)),save:1==(t>>=1),check:2==t}}());function gq(F){return F.filter(F=>65039!=F)}function gh(F){for(let A of F.split(".")){let F=MB(A);try{for(let A=F.lastIndexOf(95)-1;A>=0;A--)if(95!==F[A])throw Error("underscore only allowed at start");if(F.length>=4&&F.every(F=>F<128)&&45===F[2]&&45===F[3])throw Error("invalid label extension")}catch(F){throw Error(`Invalid label "${A}": ${F.message}`)}}return F}let ga=new rp(MH),gr=new Uint8Array(32);function gn(F){if(0===F.length)throw Error("invalid ENS name; empty component");return F}function gM(F){let A=n9(gh(function(F,A){let t=MB(F).reverse(),B=[];for(;t.length;){let F=function(F,A){var t;let B,i;let e=gs,V=[],o=F.length;for(;o;){let A=F[--o];if(!(e=null===(t=e.branches.find(F=>F.set.has(A)))||void 0===t?void 0:t.node))break;if(e.save)i=A;else if(e.check&&A===i)break;V.push(A),e.fe0f&&(V.push(65039),o>0&&65039==F[o-1]&&o--),e.valid&&(B=V.slice(),2==e.valid&&B.splice(1,1),F.length=o)}return B}(t);if(F){B.push(...A(F));continue}let i=t.pop();if(ge.has(i)){B.push(i);continue}if(gV.has(i))continue;let e=go[i];if(e){B.push(...e);continue}throw Error(`Disallowed codepoint: 0x${i.toString(16).toUpperCase()}`)}return gh(String.fromCodePoint(...B).normalize("NFC"))}(F,gq))),t=[];if(0===F.length)return t;let B=0;for(let F=0;F=A.length)throw Error("invalid ENS name; empty component");return t.push(gn(A.slice(B))),t}function gg(F){try{return 0!==gM(F).length}catch(F){}return!1}function gl(F){"string"!=typeof F&&ga.throwArgumentError("invalid ENS name; not a string","name",F);let A=gr,t=gM(F);for(;t.length;)A=nm(rZ([A,nm(t.pop())]));return rT(A)}function gC(F){return rT(rZ(gM(F).map(F=>{if(F.length>63)throw Error("invalid DNS encoded entry; length exceeds 63 bytes");let A=new Uint8Array(F.length+1);return A.set(F,1),A[0]=A.length-1,A})))+"00"}function gI(F){return"string"==typeof F&&(F=n9(F)),nm(rZ([n9("\x19Ethereum Signed Message:\n"),n9(String(F.length)),F]))}gr.fill(0);var gw={};gw.utils=AW("hjPlJ"),gw.common=AW("853Y9"),gw.sha=AW("7ItNj"),gw.ripemd=AW("Eozyl"),gw.hmac=AW("bZxkF"),gw.sha1=gw.sha.sha1,gw.sha256=gw.sha.sha256,gw.sha224=gw.sha.sha224,gw.sha384=gw.sha.sha384,gw.sha512=gw.sha.sha512,gw.ripemd160=gw.ripemd.ripemd160,(AD=AZ||(AZ={})).sha256="sha256",AD.sha512="sha512";let gQ=new rp("sha2/5.7.0");function gE(F){return"0x"+FH(gw).ripemd160().update(rK(F)).digest("hex")}function gc(F){return"0x"+FH(gw).sha256().update(rK(F)).digest("hex")}function gm(F){return"0x"+FH(gw).sha512().update(rK(F)).digest("hex")}function gY(F,A,t){return AZ[F]||gQ.throwError("unsupported algorithm "+F,rp.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:F}),"0x"+FH(gw).hmac(FH(gw)[F],rK(A)).update(rK(t)).digest("hex")}var gD=AW("l59t0");function gp(F,A,t){return F(t={path:A,exports:{},require:function(F,A){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(F,null==A?t.path:A)}},t.exports),t.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==AL||"undefined"!=typeof self&&self;var gu=gG;function gG(F,A){if(!F)throw Error(A||"Assertion failed")}gG.equal=function(F,A,t){if(F!=A)throw Error(t||"Assertion failed: "+F+" != "+A)};var gS=gp(function(F,A){function t(F){return 1===F.length?"0"+F:F}function B(F){for(var A="",B=0;B>8,V=255&i;e?t.push(e,V):t.push(V)}return t},A.zero2=t,A.toHex=B,A.encode=function(F,A){return"hex"===A?B(F):F}}),gk=gp(function(F,A){A.assert=gu,A.toArray=gS.toArray,A.zero2=gS.zero2,A.toHex=gS.toHex,A.encode=gS.encode,A.getNAF=function(F,A,t){var B=Array(Math.max(F.bitLength(),t)+1);B.fill(0);for(var i=1<(i>>1)-1?(i>>1)-s:s,e.isubn(o)):o=0,B[V]=o,e.iushrn(1)}return B},A.getJSF=function(F,A){var t=[[],[]];F=F.clone(),A=A.clone();for(var B=0,i=0;F.cmpn(-B)>0||A.cmpn(-i)>0;){var e,V,o,s=F.andln(3)+B&3,q=A.andln(3)+i&3;3===s&&(s=-1),3===q&&(q=-1),V=(1&s)==0?0:(3==(e=F.andln(7)+B&7)||5===e)&&2===q?-s:s,t[0].push(V),o=(1&q)==0?0:(3==(e=A.andln(7)+i&7)||5===e)&&2===s?-q:q,t[1].push(o),2*B===V+1&&(B=1-B),2*i===o+1&&(i=1-i),F.iushrn(1),A.iushrn(1)}return t},A.cachedProperty=function(F,A,t){var B="_"+A;F.prototype[A]=function(){return void 0!==this[B]?this[B]:this[B]=t.call(this)}},A.parseBytes=function(F){return"string"==typeof F?A.toArray(F,"hex"):F},A.intFromLE=function(F){return new(FH(gD))(F,"hex","le")}}),gU=gk.getNAF,gy=gk.getJSF,gK=gk.assert;function gZ(F,A){this.type=F,this.p=new(FH(gD))(A.p,16),this.red=A.prime?FH(gD).red(A.prime):FH(gD).mont(this.p),this.zero=new(FH(gD))(0).toRed(this.red),this.one=new(FH(gD))(1).toRed(this.red),this.two=new(FH(gD))(2).toRed(this.red),this.n=A.n&&new(FH(gD))(A.n,16),this.g=A.g&&this.pointFromJSON(A.g,A.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,],this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function gJ(F,A){this.curve=F,this.type=A,this.precomputed=null}gZ.prototype.point=function(){throw Error("Not implemented")},gZ.prototype.validate=function(){throw Error("Not implemented")},gZ.prototype._fixedNafMul=function(F,A){gK(F.precomputed);var t,B,i=F._getDoubles(),e=gU(A,1,this._bitLength),V=(1<=t;s--)B=(B<<1)+e[s];o.push(B)}for(var q=this.jpoint(null,null,null),h=this.jpoint(null,null,null),a=V;a>0;a--){for(t=0;t=0;o--){for(var s=0;o>=0&&0===e[o];o--)s++;if(o>=0&&s++,V=V.dblp(s),o<0)break;var q=e[o];gK(0!==q),V="affine"===F.type?q>0?V.mixedAdd(i[q-1>>1]):V.mixedAdd(i[-q-1>>1].neg()):q>0?V.add(i[q-1>>1]):V.add(i[-q-1>>1].neg())}return"affine"===F.type?V.toP():V},gZ.prototype._wnafMulAdd=function(F,A,t,B,i){var e,V,o,s=this._wnafT1,q=this._wnafT2,h=this._wnafT3,a=0;for(e=0;e=1;e-=2){var n=e-1,M=e;if(1!==s[n]||1!==s[M]){h[n]=gU(t[n],s[n],this._bitLength),h[M]=gU(t[M],s[M],this._bitLength),a=Math.max(h[n].length,a),a=Math.max(h[M].length,a);continue}var g=[A[n],null,null,A[M]];0===A[n].y.cmp(A[M].y)?(g[1]=A[n].add(A[M]),g[2]=A[n].toJ().mixedAdd(A[M].neg())):0===A[n].y.cmp(A[M].y.redNeg())?(g[1]=A[n].toJ().mixedAdd(A[M]),g[2]=A[n].add(A[M].neg())):(g[1]=A[n].toJ().mixedAdd(A[M]),g[2]=A[n].toJ().mixedAdd(A[M].neg()));var l=[-3,-1,-5,-7,0,7,5,1,3],C=gy(t[n],t[M]);for(V=0,a=Math.max(C[0].length,a),h[n]=Array(a),h[M]=Array(a);V=0;e--){for(var c=0;e>=0;){var m=!0;for(V=0;V=0&&c++,Q=Q.dblp(c),e<0)break;for(V=0;V0?o=q[V][Y-1>>1]:Y<0&&(o=q[V][-Y-1>>1].neg()),Q="affine"===o.type?Q.mixedAdd(o):Q.add(o))}}for(e=0;e=Math.ceil((F.bitLength()+1)/A.step)},gJ.prototype._getDoubles=function(F,A){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],B=this,i=0;ii[0].cmp(i[1])?i[0]:i[1]).toRed(this.red)}if(F.lambda)t=new(FH(gD))(F.lambda,16);else{var e=this._getEndoRoots(this.n);0===this.g.mul(e[0]).x.cmp(this.g.x.redMul(A))?t=e[0]:(t=e[1],gd(0===this.g.mul(t).x.cmp(this.g.x.redMul(A))))}return B=F.basis?F.basis.map(function(F){return{a:new(FH(gD))(F.a,16),b:new(FH(gD))(F.b,16)}}):this._getEndoBasis(t),{beta:A,lambda:t,basis:B}}},gx.prototype._getEndoRoots=function(F){var A=F===this.p?this.red:FH(gD).mont(F),t=new(FH(gD))(2).toRed(A).redInvm(),B=t.redNeg(),i=new(FH(gD))(3).toRed(A).redNeg().redSqrt().redMul(t);return[B.redAdd(i).fromRed(),B.redSub(i).fromRed()]},gx.prototype._getEndoBasis=function(F){for(var A,t,B,i,e,V,o,s,q,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),a=F,r=this.n.clone(),n=new(FH(gD))(1),M=new(FH(gD))(0),g=new(FH(gD))(0),l=new(FH(gD))(1),C=0;0!==a.cmpn(0);){var I=r.div(a);s=r.sub(I.mul(a)),q=g.sub(I.mul(n));var w=l.sub(I.mul(M));if(!B&&0>s.cmp(h))A=o.neg(),t=n,B=s.neg(),i=q;else if(B&&2==++C)break;o=s,r=a,a=s,g=n,n=q,l=M,M=w}e=s.neg(),V=q;var Q=B.sqr().add(i.sqr());return e.sqr().add(V.sqr()).cmp(Q)>=0&&(e=A,V=t),B.negative&&(B=B.neg(),i=i.neg()),e.negative&&(e=e.neg(),V=V.neg()),[{a:B,b:i},{a:e,b:V}]},gx.prototype._endoSplit=function(F){var A=this.endo.basis,t=A[0],B=A[1],i=B.b.mul(F).divRound(this.n),e=t.b.neg().mul(F).divRound(this.n),V=i.mul(t.a),o=e.mul(B.a),s=i.mul(t.b),q=e.mul(B.b);return{k1:F.sub(V).sub(o),k2:s.add(q).neg()}},gx.prototype.pointFromX=function(F,A){(F=new(FH(gD))(F,16)).red||(F=F.toRed(this.red));var t=F.redSqr().redMul(F).redIAdd(F.redMul(this.a)).redIAdd(this.b),B=t.redSqrt();if(0!==B.redSqr().redSub(t).cmp(this.zero))throw Error("invalid point");var i=B.fromRed().isOdd();return(A&&!i||!A&&i)&&(B=B.redNeg()),this.point(F,B)},gx.prototype.validate=function(F){if(F.inf)return!0;var A=F.x,t=F.y,B=this.a.redMul(A),i=A.redSqr().redMul(A).redIAdd(B).redIAdd(this.b);return 0===t.redSqr().redISub(i).cmpn(0)},gx.prototype._endoWnafMulAdd=function(F,A,t){for(var B=this._endoWnafT1,i=this._endoWnafT2,e=0;e":""},gT.prototype.isInfinity=function(){return this.inf},gT.prototype.add=function(F){if(this.inf)return F;if(F.inf)return this;if(this.eq(F))return this.dbl();if(this.neg().eq(F)||0===this.x.cmp(F.x))return this.curve.point(null,null);var A=this.y.redSub(F.y);0!==A.cmpn(0)&&(A=A.redMul(this.x.redSub(F.x).redInvm()));var t=A.redSqr().redISub(this.x).redISub(F.x),B=A.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,B)},gT.prototype.dbl=function(){if(this.inf)return this;var F=this.y.redAdd(this.y);if(0===F.cmpn(0))return this.curve.point(null,null);var A=this.curve.a,t=this.x.redSqr(),B=F.redInvm(),i=t.redAdd(t).redIAdd(t).redIAdd(A).redMul(B),e=i.redSqr().redISub(this.x.redAdd(this.x)),V=i.redMul(this.x.redSub(e)).redISub(this.y);return this.curve.point(e,V)},gT.prototype.getX=function(){return this.x.fromRed()},gT.prototype.getY=function(){return this.y.fromRed()},gT.prototype.mul=function(F){return(F=new(FH(gD))(F,16),this.isInfinity())?this:this._hasDoubles(F)?this.curve._fixedNafMul(this,F):this.curve.endo?this.curve._endoWnafMulAdd([this],[F]):this.curve._wnafMul(this,F)},gT.prototype.mulAdd=function(F,A,t){var B=[this,A],i=[F,t];return this.curve.endo?this.curve._endoWnafMulAdd(B,i):this.curve._wnafMulAdd(1,B,i,2)},gT.prototype.jmulAdd=function(F,A,t){var B=[this,A],i=[F,t];return this.curve.endo?this.curve._endoWnafMulAdd(B,i,!0):this.curve._wnafMulAdd(1,B,i,2,!0)},gT.prototype.eq=function(F){return this===F||this.inf===F.inf&&(this.inf||0===this.x.cmp(F.x)&&0===this.y.cmp(F.y))},gT.prototype.neg=function(F){if(this.inf)return this;var A=this.curve.point(this.x,this.y.redNeg());if(F&&this.precomputed){var t=this.precomputed,B=function(F){return F.neg()};A.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(B)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(B)}}}return A},gT.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},gR(gL,gZ.BasePoint),gx.prototype.jpoint=function(F,A,t){return new gL(this,F,A,t)},gL.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var F=this.z.redInvm(),A=F.redSqr(),t=this.x.redMul(A),B=this.y.redMul(A).redMul(F);return this.curve.point(t,B)},gL.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},gL.prototype.add=function(F){if(this.isInfinity())return F;if(F.isInfinity())return this;var A=F.z.redSqr(),t=this.z.redSqr(),B=this.x.redMul(A),i=F.x.redMul(t),e=this.y.redMul(A.redMul(F.z)),V=F.y.redMul(t.redMul(this.z)),o=B.redSub(i),s=e.redSub(V);if(0===o.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var q=o.redSqr(),h=q.redMul(o),a=B.redMul(q),r=s.redSqr().redIAdd(h).redISub(a).redISub(a),n=s.redMul(a.redISub(r)).redISub(e.redMul(h)),M=this.z.redMul(F.z).redMul(o);return this.curve.jpoint(r,n,M)},gL.prototype.mixedAdd=function(F){if(this.isInfinity())return F.toJ();if(F.isInfinity())return this;var A=this.z.redSqr(),t=this.x,B=F.x.redMul(A),i=this.y,e=F.y.redMul(A).redMul(this.z),V=t.redSub(B),o=i.redSub(e);if(0===V.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var s=V.redSqr(),q=s.redMul(V),h=t.redMul(s),a=o.redSqr().redIAdd(q).redISub(h).redISub(h),r=o.redMul(h.redISub(a)).redISub(i.redMul(q)),n=this.z.redMul(V);return this.curve.jpoint(a,r,n)},gL.prototype.dblp=function(F){if(0===F||this.isInfinity())return this;if(!F)return this.dbl();if(this.curve.zeroA||this.curve.threeA){var A,t=this;for(A=0;A=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},gL.prototype.inspect=function(){return this.isInfinity()?"":""},gL.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var gN=gp(function(F,A){A.base=gZ,A.short=gx,A.mont=null,A.edwards=null}),gj=gp(function(F,A){var t,B=gk.assert;function i(F){"short"===F.type?this.curve=new gN.short(F):"edwards"===F.type?this.curve=new gN.edwards(F):this.curve=new gN.mont(F),this.g=this.curve.g,this.n=this.curve.n,this.hash=F.hash,B(this.g.validate(),"Invalid curve"),B(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function e(F,t){Object.defineProperty(A,F,{configurable:!0,enumerable:!0,get:function(){var B=new i(t);return Object.defineProperty(A,F,{configurable:!0,enumerable:!0,value:B}),B}})}A.PresetCurve=i,e("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:FH(gw).sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),e("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:FH(gw).sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),e("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:FH(gw).sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),e("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:FH(gw).sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),e("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:FH(gw).sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),e("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:FH(gw).sha256,gRed:!1,g:["9"]}),e("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:FH(gw).sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{t=null.crash()}catch(F){t=void 0}e("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:FH(gw).sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",t]})});function gW(F){if(!(this instanceof gW))return new gW(F);this.hash=F.hash,this.predResist=!!F.predResist,this.outLen=this.hash.outSize,this.minEntropy=F.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var A=gS.toArray(F.entropy,F.entropyEnc||"hex"),t=gS.toArray(F.nonce,F.nonceEnc||"hex"),B=gS.toArray(F.pers,F.persEnc||"hex");gu(A.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(A,t,B)}gW.prototype._init=function(F,A,t){var B=F.concat(A).concat(t);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(F.concat(t||[])),this._reseed=1},gW.prototype.generate=function(F,A,t,B){if(this._reseed>this.reseedInterval)throw Error("Reseed is required");"string"!=typeof A&&(B=t,t=A,A=null),t&&(t=gS.toArray(t,B||"hex"),this._update(t));for(var i=[];i.length"};var gf=gk.assert;function gv(F,A){if(F instanceof gv)return F;this._importDER(F,A)||(gf(F.r&&F.s,"Signature without r or s"),this.r=new(FH(gD))(F.r,16),this.s=new(FH(gD))(F.s,16),void 0===F.recoveryParam?this.recoveryParam=null:this.recoveryParam=F.recoveryParam)}function gH(){this.place=0}function gb(F,A){var t=F[A.place++];if(!(128&t))return t;var B=15&t;if(0===B||B>4)return!1;for(var i=0,e=0,V=A.place;e>>=0;return!(i<=127)&&(A.place=V,i)}function gP(F){for(var A=0,t=F.length-1;!F[A]&&!(128&F[A+1])&&A>>3);for(F.push(128|t);--t;)F.push(A>>>(t<<3)&255);F.push(A)}gv.prototype._importDER=function(F,A){F=gk.toArray(F,A);var t=new gH;if(48!==F[t.place++])return!1;var B=gb(F,t);if(!1===B||B+t.place!==F.length||2!==F[t.place++])return!1;var i=gb(F,t);if(!1===i)return!1;var e=F.slice(t.place,i+t.place);if(t.place+=i,2!==F[t.place++])return!1;var V=gb(F,t);if(!1===V||F.length!==V+t.place)return!1;var o=F.slice(t.place,V+t.place);if(0===e[0]){if(!(128&e[1]))return!1;e=e.slice(1)}if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}return this.r=new(FH(gD))(e),this.s=new(FH(gD))(o),this.recoveryParam=null,!0},gv.prototype.toDER=function(F){var A=this.r.toArray(),t=this.s.toArray();for(128&A[0]&&(A=[0].concat(A)),128&t[0]&&(t=[0].concat(t)),A=gP(A),t=gP(t);!t[0]&&!(128&t[1]);)t=t.slice(1);var B=[2];gX(B,A.length),(B=B.concat(A)).push(2),gX(B,t.length);var i=B.concat(t),e=[48];return gX(e,i.length),e=e.concat(i),gk.encode(e,F)};var g_=function(){throw Error("unsupported")},g$=gk.assert;function g2(F){if(!(this instanceof g2))return new g2(F);"string"==typeof F&&(g$(Object.prototype.hasOwnProperty.call(gj,F),"Unknown curve "+F),F=gj[F]),F instanceof gj.PresetCurve&&(F={curve:F}),this.curve=F.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=F.curve.g,this.g.precompute(F.curve.n.bitLength()+1),this.hash=F.hash||F.curve.hash}g2.prototype.keyPair=function(F){return new gz(this,F)},g2.prototype.keyFromPrivate=function(F,A){return gz.fromPrivate(this,F,A)},g2.prototype.keyFromPublic=function(F,A){return gz.fromPublic(this,F,A)},g2.prototype.genKeyPair=function(F){F||(F={});for(var A=new gW({hash:this.hash,pers:F.pers,persEnc:F.persEnc||"utf8",entropy:F.entropy||g_(this.hash.hmacStrength),entropyEnc:F.entropy&&F.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),B=this.n.sub(new(FH(gD))(2));;){var i=new(FH(gD))(A.generate(t));if(!(i.cmp(B)>0))return i.iaddn(1),this.keyFromPrivate(i)}},g2.prototype._truncateToN=function(F,A){var t=8*F.byteLength()-this.n.bitLength();return(t>0&&(F=F.ushrn(t)),!A&&F.cmp(this.n)>=0)?F.sub(this.n):F},g2.prototype.sign=function(F,A,t,B){"object"==typeof t&&(B=t,t=null),B||(B={}),A=this.keyFromPrivate(A,t),F=this._truncateToN(new(FH(gD))(F,16));for(var i=this.n.byteLength(),e=A.getPrivate().toArray("be",i),V=F.toArray("be",i),o=new gW({hash:this.hash,entropy:e,nonce:V,pers:B.pers,persEnc:B.persEnc||"utf8"}),s=this.n.sub(new(FH(gD))(1)),q=0;;q++){var h=B.k?B.k(q):new(FH(gD))(o.generate(this.n.byteLength()));if(!(0>=(h=this._truncateToN(h,!0)).cmpn(1)||h.cmp(s)>=0)){var a=this.g.mul(h);if(!a.isInfinity()){var r=a.getX(),n=r.umod(this.n);if(0!==n.cmpn(0)){var M=h.invm(this.n).mul(n.mul(A.getPrivate()).iadd(F));if(0!==(M=M.umod(this.n)).cmpn(0)){var g=(a.getY().isOdd()?1:0)|(0!==r.cmp(n)?2:0);return B.canonical&&M.cmp(this.nh)>0&&(M=this.n.sub(M),g^=1),new gv({r:n,s:M,recoveryParam:g})}}}}}},g2.prototype.verify=function(F,A,t,B){F=this._truncateToN(new(FH(gD))(F,16)),t=this.keyFromPublic(t,B);var i,e=(A=new gv(A,"hex")).r,V=A.s;if(0>e.cmpn(1)||e.cmp(this.n)>=0||0>V.cmpn(1)||V.cmp(this.n)>=0)return!1;var o=V.invm(this.n),s=o.mul(F).umod(this.n),q=o.mul(e).umod(this.n);return this.curve._maxwellTrick?!(i=this.g.jmulAdd(s,t.getPublic(),q)).isInfinity()&&i.eqXToP(e):!(i=this.g.mulAdd(s,t.getPublic(),q)).isInfinity()&&0===i.getX().umod(this.n).cmp(e)},g2.prototype.recoverPubKey=function(F,A,t,B){g$((3&t)===t,"The recovery param is more than two bits"),A=new gv(A,B);var i=this.n,e=new(FH(gD))(F),V=A.r,o=A.s,s=1&t,q=t>>1;if(V.cmp(this.curve.p.umod(this.curve.n))>=0&&q)throw Error("Unable to find sencond key candinate");V=q?this.curve.pointFromX(V.add(this.curve.n),s):this.curve.pointFromX(V,s);var h=A.r.invm(i),a=i.sub(e).mul(h).umod(i),r=o.mul(h).umod(i);return this.g.mulAdd(a,V,r)},g2.prototype.getKeyRecoveryParam=function(F,A,t,B){if(null!==(A=new gv(A,B)).recoveryParam)return A.recoveryParam;for(var i,e=0;e<4;e++){try{i=this.recoverPubKey(F,A,e)}catch(F){continue}if(i.eq(t))return e}throw Error("Unable to find valid recovery factor")};var g0=gp(function(F,A){A.version="6.5.4",A.utils=gk,A.rand=function(){throw Error("unsupported")},A.curve=gN,A.curves=gj,A.ec=g2,A.eddsa=null}).ec;let g1=new rp("signing-key/5.7.0"),g4=null;function g5(){return g4||(g4=new g0("secp256k1")),g4}class g8{constructor(F){rb(this,"curve","secp256k1"),rb(this,"privateKey",rT(F)),32!==rL(this.privateKey)&&g1.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let A=g5().keyFromPrivate(rK(this.privateKey));rb(this,"publicKey","0x"+A.getPublic(!1,"hex")),rb(this,"compressedPublicKey","0x"+A.getPublic(!0,"hex")),rb(this,"_isSigningKey",!0)}_addPoint(F){let A=g5().keyFromPublic(rK(this.publicKey)),t=g5().keyFromPublic(rK(F));return"0x"+A.pub.add(t.pub).encodeCompressed("hex")}signDigest(F){let A=g5().keyFromPrivate(rK(this.privateKey)),t=rK(F);32!==t.length&&g1.throwArgumentError("bad digest length","digest",F);let B=A.sign(t,{canonical:!0});return rf({recoveryParam:B.recoveryParam,r:rz("0x"+B.r.toString(16),32),s:rz("0x"+B.s.toString(16),32)})}computeSharedSecret(F){let A=g5().keyFromPrivate(rK(this.privateKey)),t=g5().keyFromPublic(rK(g3(F)));return rz("0x"+A.derive(t.getPublic()).toString(16),32)}static isSigningKey(F){return!!(F&&F._isSigningKey)}}function g6(F,A){let t=rf(A),B={r:rK(t.r),s:rK(t.s)};return"0x"+g5().recoverPubKey(rK(F),B,t.recoveryParam).encode("hex",!1)}function g3(F,A){let t=rK(F);if(32===t.length){let F=new g8(t);return A?"0x"+g5().keyFromPrivate(t).getPublic(!0,"hex"):F.publicKey}return 33===t.length?A?rT(t):"0x"+g5().keyFromPublic(t).getPublic(!1,"hex"):65===t.length?A?"0x"+g5().keyFromPublic(t).getPublic(!0,"hex"):rT(t):g1.throwArgumentError("invalid public or private key","key","[REDACTED]")}let g9=new rp("transactions/5.7.0");function g7(F){return"0x"===F?null:nd(F)}function lF(F){return"0x"===F?n2:nF.from(F)}(Ap=AJ||(AJ={}))[Ap.legacy=0]="legacy",Ap[Ap.eip2930=1]="eip2930",Ap[Ap.eip1559=2]="eip1559";let lA=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],lt={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,type:!0,value:!0};function lB(F){return nd(rN(nm(rN(g3(F),1)),12))}function li(F,A){return lB(g6(rK(F),A))}function le(F,A){let t=rJ(nF.from(F).toHexString());return t.length>32&&g9.throwArgumentError("invalid length for "+A,"transaction:"+A,F),t}function lV(F,A){return{address:nd(F),storageKeys:(A||[]).map((A,t)=>(32!==rL(A)&&g9.throwArgumentError("invalid access list storageKey",`accessList[${F}:${t}]`,A),A.toLowerCase()))}}function lo(F){if(Array.isArray(F))return F.map((F,A)=>Array.isArray(F)?(F.length>2&&g9.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${A}]`,F),lV(F[0],F[1])):lV(F.address,F.storageKeys));let A=Object.keys(F).map(A=>{let t=F[A].reduce((F,A)=>(F[A]=!0,F),{});return lV(A,Object.keys(t).sort())});return A.sort((F,A)=>F.address.localeCompare(A.address)),A}function ls(F){return lo(F).map(F=>[F.address,F.storageKeys])}function lq(F,A){if(null!=F.gasPrice){let A=nF.from(F.gasPrice),t=nF.from(F.maxFeePerGas||0);A.eq(t)||g9.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:A,maxFeePerGas:t})}let t=[le(F.chainId||0,"chainId"),le(F.nonce||0,"nonce"),le(F.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),le(F.maxFeePerGas||0,"maxFeePerGas"),le(F.gasLimit||0,"gasLimit"),null!=F.to?nd(F.to):"0x",le(F.value||0,"value"),F.data||"0x",ls(F.accessList||[])];if(A){let F=rf(A);t.push(le(F.recoveryParam,"recoveryParam")),t.push(rJ(F.r)),t.push(rJ(F.s))}return rj(["0x02",nG(t)])}function lh(F,A){let t=[le(F.chainId||0,"chainId"),le(F.nonce||0,"nonce"),le(F.gasPrice||0,"gasPrice"),le(F.gasLimit||0,"gasLimit"),null!=F.to?nd(F.to):"0x",le(F.value||0,"value"),F.data||"0x",ls(F.accessList||[])];if(A){let F=rf(A);t.push(le(F.recoveryParam,"recoveryParam")),t.push(rJ(F.r)),t.push(rJ(F.s))}return rj(["0x01",nG(t)])}function la(F,A){if(null==F.type||0===F.type)return null!=F.accessList&&g9.throwArgumentError("untyped transactions do not support accessList; include type: 1","transaction",F),function(F,A){r_(F,lt);let t=[];lA.forEach(function(A){let B=F[A.name]||[],i={};A.numeric&&(i.hexPad="left"),B=rK(rT(B,i)),A.length&&B.length!==A.length&&B.length>0&&g9.throwArgumentError("invalid length for "+A.name,"transaction:"+A.name,B),A.maxLength&&(B=rJ(B)).length>A.maxLength&&g9.throwArgumentError("invalid length for "+A.name,"transaction:"+A.name,B),t.push(rT(B))});let B=0;if(null!=F.chainId?"number"!=typeof(B=F.chainId)&&g9.throwArgumentError("invalid transaction.chainId","transaction",F):A&&!rk(A)&&A.v>28&&(B=Math.floor((A.v-35)/2)),0!==B&&(t.push(rT(B)),t.push("0x"),t.push("0x")),!A)return nG(t);let i=rf(A),e=27+i.recoveryParam;return 0!==B?(t.pop(),t.pop(),t.pop(),e+=2*B+8,i.v>28&&i.v!==e&&g9.throwArgumentError("transaction.chainId/signature.v mismatch","signature",A)):i.v!==e&&g9.throwArgumentError("transaction.chainId/signature.v mismatch","signature",A),t.push(rT(e)),t.push(rJ(rK(i.r))),t.push(rJ(rK(i.s))),nG(t)}(F,A);switch(F.type){case 1:return lh(F,A);case 2:return lq(F,A)}return g9.throwError(`unsupported transaction type: ${F.type}`,rp.errors.UNSUPPORTED_OPERATION,{operation:"serializeTransaction",transactionType:F.type})}function lr(F,A,t){try{let t=lF(A[0]).toNumber();if(0!==t&&1!==t)throw Error("bad recid");F.v=t}catch(F){g9.throwArgumentError("invalid v for transaction type: 1","v",A[0])}F.r=rz(A[1],32),F.s=rz(A[2],32);try{let A=nm(t(F));F.from=li(A,{r:F.r,s:F.s,recoveryParam:F.v})}catch(F){}}function ln(F){let A=rK(F);if(A[0]>127)return function(F){let A=nU(F);9!==A.length&&6!==A.length&&g9.throwArgumentError("invalid raw transaction","rawTransaction",F);let t={nonce:lF(A[0]).toNumber(),gasPrice:lF(A[1]),gasLimit:lF(A[2]),to:g7(A[3]),value:lF(A[4]),data:A[5],chainId:0};if(6===A.length)return t;try{t.v=nF.from(A[6]).toNumber()}catch(F){return t}if(t.r=rz(A[7],32),t.s=rz(A[8],32),nF.from(t.r).isZero()&&nF.from(t.s).isZero())t.chainId=t.v,t.v=0;else{t.chainId=Math.floor((t.v-35)/2),t.chainId<0&&(t.chainId=0);let B=t.v-27,i=A.slice(0,6);0!==t.chainId&&(i.push(rT(t.chainId)),i.push("0x"),i.push("0x"),B-=2*t.chainId+8);let e=nm(nG(i));try{t.from=li(e,{r:rT(t.r),s:rT(t.s),recoveryParam:B})}catch(F){}t.hash=nm(F)}return t.type=null,t}(A);switch(A[0]){case 1:return function(F){let A=nU(F.slice(1));8!==A.length&&11!==A.length&&g9.throwArgumentError("invalid component count for transaction type: 1","payload",rT(F));let t={type:1,chainId:lF(A[0]).toNumber(),nonce:lF(A[1]).toNumber(),gasPrice:lF(A[2]),gasLimit:lF(A[3]),to:g7(A[4]),value:lF(A[5]),data:A[6],accessList:lo(A[7])};return 8===A.length||(t.hash=nm(F),lr(t,A.slice(8),lh)),t}(A);case 2:return function(F){let A=nU(F.slice(1));9!==A.length&&12!==A.length&&g9.throwArgumentError("invalid component count for transaction type: 2","payload",rT(F));let t=lF(A[2]),B=lF(A[3]),i={type:2,chainId:lF(A[0]).toNumber(),nonce:lF(A[1]).toNumber(),maxPriorityFeePerGas:t,maxFeePerGas:B,gasPrice:null,gasLimit:lF(A[4]),to:g7(A[5]),value:lF(A[6]),data:A[7],accessList:lo(A[8])};return 9===A.length||(i.hash=nm(F),lr(i,A.slice(9),lq)),i}(A)}return g9.throwError(`unsupported transaction type: ${A[0]}`,rp.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:A[0]})}let lM=new rp("wordlists/5.7.0");class lg{constructor(F){lM.checkAbstract(new.target,lg),rb(this,"locale",F)}split(F){return F.toLowerCase().split(/ +/g)}join(F){return F.join(" ")}static check(F){let A=[];for(let t=0;t<2048;t++){let B=F.getWord(t);if(t!==F.getWordIndex(B))return"0x";A.push(B)}return MZ(A.join("\n")+"\n")}static register(F,A){A||(A=F.locale)}}let ll=null;function lC(F){if(null==ll&&(ll="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo".replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==lg.check(F)))throw ll=null,Error("BIP39 Wordlist for en (English) FAILED")}let lI=new class extends lg{constructor(){super("en")}getWord(F){return lC(this),ll[F]}getWordIndex(F){return lC(this),ll.indexOf(F)}};lg.register(lI);let lw={en:lI},lQ=new rp("hdnode/5.7.0"),lE=nF.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lc=n9("Bitcoin seed");function lm(F){return(1<=256)throw Error("Depth too large!");return lD(rZ([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",rT(this.depth),this.parentFingerprint,rz(rT(this.index),4),this.chainCode,null!=this.privateKey?rZ(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new lS(lu,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(F){if(F>4294967295)throw Error("invalid index - "+String(F));let A=this.path;A&&(A+="/"+(2147483647&F));let t=new Uint8Array(37);if(2147483648&F){if(!this.privateKey)throw Error("cannot derive child of neutered node");t.set(rK(this.privateKey),1),A&&(A+="'")}else t.set(rK(this.publicKey));for(let A=24;A>=0;A-=8)t[33+(A>>3)]=F>>24-A&255;let B=rK(gY(AZ.sha512,this.chainCode,t)),i=B.slice(0,32),e=B.slice(32),V=null,o=null;this.privateKey?V=lY(nF.from(i).add(this.privateKey).mod(lE)):o=new g8(rT(i))._addPoint(this.publicKey);let s=A,q=this.mnemonic;return q&&(s=Object.freeze({phrase:q.phrase,path:A,locale:q.locale||"en"})),new lS(lu,V,o,this.fingerprint,lY(e),F,this.depth+1,s)}derivePath(F){let A=F.split("/");if(0===A.length||"m"===A[0]&&0!==this.depth)throw Error("invalid path - "+F);"m"===A[0]&&A.shift();let t=this;for(let F=0;F=2147483648)throw Error("invalid path index - "+B);t=t._derive(2147483648+F)}else if(B.match(/^[0-9]+$/)){let F=parseInt(B);if(F>=2147483648)throw Error("invalid path index - "+B);t=t._derive(F)}else throw Error("invalid path component - "+B)}return t}static _fromSeed(F,A){let t=rK(F);if(t.length<16||t.length>64)throw Error("invalid seed");let B=rK(gY(AZ.sha512,lc,t));return new lS(lu,lY(B.slice(0,32)),null,"0x00000000",lY(B.slice(32)),0,0,A)}static fromMnemonic(F,A,t){return t=lp(t),F=ly(lU(F,t),t),lS._fromSeed(lk(F,A),{phrase:F,path:"m",locale:t.locale})}static fromSeed(F){return lS._fromSeed(F,null)}static fromExtendedKey(F){let A=Mv.decode(F);(82!==A.length||lD(A.slice(0,78))!==F)&&lQ.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let t=A[4],B=rT(A.slice(5,9)),i=parseInt(rT(A.slice(9,13)).substring(2),16),e=rT(A.slice(13,45)),V=A.slice(45,78);switch(rT(A.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new lS(lu,null,rT(V),B,e,i,t,null);case"0x0488ade4":case"0x04358394 ":if(0!==V[0])break;return new lS(lu,rT(V.slice(1)),null,B,e,i,t,null)}return lQ.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function lk(F,A){A||(A="");let t=n9("mnemonic"+A,Ay.NFKD);return function(F,A,t,B,i){let e,V,o;F=rK(F),A=rK(A);let s=1,q=new Uint8Array(64),h=new Uint8Array(A.length+4);h.set(A);for(let t=1;t<=s;t++){h[A.length]=t>>24&255,h[A.length+1]=t>>16&255,h[A.length+2]=t>>8&255,h[A.length+3]=255&t;let B=rK(gY(i,F,h));e||(o=new Uint8Array(e=B.length),V=64-((s=Math.ceil(64/e))-1)*e),o.set(B);for(let A=1;A<2048;A++){B=rK(gY(i,F,B));for(let F=0;F>3]|=1<<7-i%8),i++}let e=32*t.length/3,V=lm(t.length/3);if((rK(gc(B.slice(0,e/8)))[0]&V)!=(B[B.length-1]&V))throw Error("invalid checksum");return rT(B.slice(0,e/8))}function ly(F,A){if(A=lp(A),(F=rK(F)).length%4!=0||F.length<16||F.length>32)throw Error("invalid entropy");let t=[0],B=11;for(let A=0;A8?(t[t.length-1]<<=8,t[t.length-1]|=F[A],B-=8):(t[t.length-1]<<=B,t[t.length-1]|=F[A]>>8-B,t.push(F[A]&(1<<8-B)-1),B+=3);let i=F.length/4,e=rK(gc(F))[0]&lm(i);return t[t.length-1]<<=i,t[t.length-1]|=e>>8-i,A.join(t.map(F=>A.getWord(F)))}function lK(F,A){try{return lU(F,A),!0}catch(F){}return!1}function lZ(F){return("number"!=typeof F||F<0||F>=2147483648||F%1)&&lQ.throwArgumentError("invalid account index","index",F),`m/44'/60'/${F}'/0/0`}function lJ(F){if(function(F){let A=null;try{A=JSON.parse(F)}catch(F){return!1}return A.encseed&&A.ethaddr}(F))try{return nd(JSON.parse(F).ethaddr)}catch(F){return null}if(function(F){let A=null;try{A=JSON.parse(F)}catch(F){return!1}return!!A.version&&parseInt(A.version)===A.version&&3===parseInt(A.version)}(F))try{return nd(JSON.parse(F).address)}catch(F){}return null}let lR=RegExp("^bytes([0-9]+)$"),ld=RegExp("^(u?int)([0-9]*)$"),lx=RegExp("^(.*)\\[([0-9]*)\\]$"),lT=new rp("solidity/5.7.0");function lL(F,A){F.length!=A.length&&lT.throwArgumentError("wrong number of values; expected ${ types.length }","values",A);let t=[];return F.forEach(function(F,B){t.push(function F(A,t,B){switch(A){case"address":if(B)return rR(t,32);return rK(t);case"string":return n9(t);case"bytes":return rK(t);case"bool":if(t=t?"0x01":"0x00",B)return rR(t,32);return rK(t)}let i=A.match(ld);if(i){let F=parseInt(i[2]||"256");return(i[2]&&String(F)!==i[2]||F%8!=0||0===F||F>256)&&lT.throwArgumentError("invalid number type","type",A),B&&(F=256),rR(t=nF.from(t).toTwos(F),F/8)}if(i=A.match(lR)){let F=parseInt(i[1]);return((String(F)!==i[1]||0===F||F>32)&&lT.throwArgumentError("invalid bytes type","type",A),rK(t).byteLength!==F&&lT.throwArgumentError(`invalid value for ${A}`,"value",t),B)?rK((t+"0000000000000000000000000000000000000000000000000000000000000000").substring(0,66)):t}if((i=A.match(lx))&&Array.isArray(t)){let B=i[1];parseInt(i[2]||String(t.length))!=t.length&&lT.throwArgumentError(`invalid array length for ${A}`,"value",t);let e=[];return t.forEach(function(A){e.push(F(B,A,!0))}),rZ(e)}return lT.throwArgumentError("invalid type","type",A)}(F,A[B]))}),rT(rZ(t))}function lN(F,A){return nm(lL(F,A))}function lj(F,A){return gc(lL(F,A))}let lW=new rp("random/5.7.0"),lO=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==AL)return AL;throw Error("unable to locate global object")}(),lz=lO.crypto||lO.msCrypto;function lf(F){(F<=0||F>1024||F%1||F!=F)&&lW.throwArgumentError("invalid length","length",F);let A=new Uint8Array(F);return lz.getRandomValues(A),rK(A)}function lv(F){F=F.slice();for(let A=F.length-1;A>0;A--){let t=Math.floor(Math.random()*(A+1)),B=F[A];F[A]=F[t],F[t]=B}return F}function lH(F){let A=n9(F);if(A.length>31)throw Error("bytes32 string must be less than 32 bytes");return rT(rZ([A,"0x0000000000000000000000000000000000000000000000000000000000000000"]).slice(0,32))}function lb(F){let A=rK(F);if(32!==A.length)throw Error("invalid bytes32 - not 32 bytes long");if(0!==A[31])throw Error("invalid bytes32 string - no null terminator");let t=31;for(;0===A[t-1];)t--;return Mt(A.slice(0,t))}function lP(F,A){A||(A=function(F){return[parseInt(F,16)]});let t=0,B={};return F.split(",").forEach(F=>{let i=F.split(":");B[t+=parseInt(i[0],16)]=A(i[1])}),B}function lX(F){let A=0;return F.split(",").map(F=>{let t=F.split("-");return 1===t.length?t[1]="0":""===t[1]&&(t[1]="1"),{l:A+parseInt(t[0],16),h:A=parseInt(t[1],16)}})}function l_(F,A){let t=0;for(let B=0;B=(t+=i.l)&&F<=t+i.h&&(F-t)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(F-t))continue;return i}}return null}lz&&lz.getRandomValues||(lW.warn("WARNING: Missing strong random number source"),lz={getRandomValues:function(F){return lW.throwError("no secure random source avaialble",rp.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});let l$=lX("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),l2="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(F=>parseInt(F,16)),l0=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],l1=lP("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),l4=lP("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),l5=lP("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(F){if(F.length%4!=0)throw Error("bad data");let A=[];for(let t=0;tl2.indexOf(F)>=0||F>=65024&&F<=65039?[]:function(F){let A=l_(F,l0);if(A)return[F+A.s];let t=l1[F];if(t)return t;let B=l4[F];return B?[F+B[0]]:l5[F]||null}(F)||[F]).reduce((F,A)=>(A.forEach(A=>{F.push(A)}),F),[])),Ay.NFKC)).forEach(F=>{if(l_(F,l8))throw Error("STRINGPREP_CONTAINS_PROHIBITED")}),A.forEach(F=>{if(l_(F,l$))throw Error("STRINGPREP_CONTAINS_UNASSIGNED")});let t=MA(A);if("-"===t.substring(0,1)||"--"===t.substring(2,4)||"-"===t.substring(t.length-1))throw Error("invalid hyphen");return t}let l3=new rp(r8),l9={},l7=nF.from(0),CF=nF.from(-1);function CA(F,A,t,B){let i={fault:A,operation:t};return void 0!==B&&(i.value=B),l3.throwError(F,rp.errors.NUMERIC_FAULT,i)}let Ct="0";for(;Ct.length<256;)Ct+=Ct;function CB(F){if("number"!=typeof F)try{F=nF.from(F).toNumber()}catch(F){}return"number"==typeof F&&F>=0&&F<=256&&!(F%1)?"1"+Ct.substring(0,F):l3.throwArgumentError("invalid decimal size","decimals",F)}function Ci(F,A){null==A&&(A=0);let t=CB(A),B=(F=nF.from(F)).lt(l7);B&&(F=F.mul(CF));let i=F.mod(t).toString();for(;i.length2&&l3.throwArgumentError("too many decimal points","value",F);let e=i[0],V=i[1];for(e||(e="0"),V||(V="0");"0"===V[V.length-1];)V=V.substring(0,V.length-1);for(V.length>t.length-1&&CA("fractional component exceeds decimals","underflow","parseFixed"),""===V&&(V="0");V.lengthnull==F[A]?B:(typeof F[A]!==t&&l3.throwArgumentError("invalid fixed format ("+A+" not "+t+")","format."+A,F[A]),F[A]);A=i("signed","boolean",A),t=i("width","number",t),B=i("decimals","number",B)}return t%8&&l3.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",t),B>80&&l3.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",B),new CV(l9,A,t,B)}}class Co{constructor(F,A,t,B){F!==l9&&l3.throwError("cannot use FixedNumber constructor; use FixedNumber.from",rp.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=B,this._hex=A,this._value=t,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(F){this.format.name!==F.format.name&&l3.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",F)}addUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.add(t),this.format.decimals,this.format)}subUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.sub(t),this.format.decimals,this.format)}mulUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.mul(t).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.mul(this.format._multiplier).div(t),this.format.decimals,this.format)}floor(){let F=this.toString().split(".");1===F.length&&F.push("0");let A=Co.from(F[0],this.format),t=!F[1].match(/^(0*)$/);return this.isNegative()&&t&&(A=A.subUnsafe(Cs.toFormat(A.format))),A}ceiling(){let F=this.toString().split(".");1===F.length&&F.push("0");let A=Co.from(F[0],this.format),t=!F[1].match(/^(0*)$/);return!this.isNegative()&&t&&(A=A.addUnsafe(Cs.toFormat(A.format))),A}round(F){null==F&&(F=0);let A=this.toString().split(".");if(1===A.length&&A.push("0"),(F<0||F>80||F%1)&&l3.throwArgumentError("invalid decimal count","decimals",F),A[1].length<=F)return this;let t=Co.from("1"+Ct.substring(0,F),this.format),B=Cq.toFormat(this.format);return this.mulUnsafe(t).addUnsafe(B).floor().divUnsafe(t)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(F){return null==F?this._hex:(F%8&&l3.throwArgumentError("invalid byte width","width",F),rz(nF.from(this._hex).fromTwos(this.format.width).toTwos(F).toHexString(),F/8))}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(F){return Co.fromString(this._value,F)}static fromValue(F,A,t){var B;return null!=t||null==A||null!=(B=A)&&(nF.isBigNumber(B)||"number"==typeof B&&B%1==0||"string"==typeof B&&B.match(/^-?[0-9]+$/)||rd(B)||"bigint"==typeof B||ry(B))||(t=A,A=null),null==A&&(A=0),null==t&&(t="fixed"),Co.fromString(Ci(F,A),CV.from(t))}static fromString(F,A){null==A&&(A="fixed");let t=CV.from(A),B=Ce(F,t.decimals);!t.signed&&B.lt(l7)&&CA("unsigned value cannot be negative","overflow","value",F);let i=null;return new Co(l9,t.signed?B.toTwos(t.width).toHexString():rz(B.toHexString(),t.width/8),Ci(B,t.decimals),t)}static fromBytes(F,A){null==A&&(A="fixed");let t=CV.from(A);if(rK(F).length>t.width/8)throw Error("overflow");let B=nF.from(F);return t.signed&&(B=B.fromTwos(t.width)),new Co(l9,B.toTwos((t.signed?0:1)+t.width).toHexString(),Ci(B,t.decimals),t)}static from(F,A){if("string"==typeof F)return Co.fromString(F,A);if(ry(F))return Co.fromBytes(F,A);try{return Co.fromValue(F,0,A)}catch(F){if(F.code!==rp.errors.INVALID_ARGUMENT)throw F}return l3.throwArgumentError("invalid FixedNumber value","value",F)}static isFixedNumber(F){return!!(F&&F._isFixedNumber)}}let Cs=Co.from(1),Cq=Co.from("0.5"),Ch=new rp("units/5.7.0"),Ca=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Cr(F){let A=String(F).split(".");(A.length>2||!A[0].match(/^-?[0-9]*$/)||A[1]&&!A[1].match(/^[0-9]*$/)||"."===F||"-."===F)&&Ch.throwArgumentError("invalid value","value",F);let t=A[0],B="";for("-"===t.substring(0,1)&&(B="-",t=t.substring(1));"0"===t.substring(0,1);)t=t.substring(1);""===t&&(t="0");let i="";for(2===A.length&&(i="."+(A[1]||"0"));i.length>2&&"0"===i[i.length-1];)i=i.substring(0,i.length-1);let e=[];for(;t.length;)if(t.length<=3){e.unshift(t);break}else{let F=t.length-3;e.unshift(t.substring(F)),t=t.substring(0,F)}return B+e.join(",")+i}function Cn(F,A){if("string"==typeof A){let F=Ca.indexOf(A);-1!==F&&(A=3*F)}return Ci(F,null!=A?A:18)}function CM(F,A){if("string"!=typeof F&&Ch.throwArgumentError("value must be a string","value",F),"string"==typeof A){let F=Ca.indexOf(A);-1!==F&&(A=3*F)}return Ce(F,null!=A?A:18)}function Cg(F){return Cn(F,18)}function Cl(F){return CM(F,18)}new rp("abstract-provider/5.7.0"),new rp("abstract-signer/5.7.0"),rp.errors.INSUFFICIENT_FUNDS,rp.errors.NONCE_EXPIRED,rp.errors.REPLACEMENT_UNDERPRICED;!function(F){function A(F){return parseInt(F)===F}function t(F){if(!A(F.length))return!1;for(var t=0;t255)return!1;return!0}function B(F,B){if(F.buffer&&ArrayBuffer.isView(F)&&"Uint8Array"===F.name)return B&&(F=F.slice?F.slice():Array.prototype.slice.call(F)),F;if(Array.isArray(F)){if(!t(F))throw Error("Array contains invalid value: "+F);return new Uint8Array(F)}if(A(F.length)&&t(F))return new Uint8Array(F);throw Error("unsupported array-like object")}function i(F){return new Uint8Array(F)}function e(F,A,t,B,i){(null!=B||null!=i)&&(F=F.slice?F.slice(B,i):Array.prototype.slice.call(F,B,i)),A.set(F,t)}V="0123456789abcdef";var V,o={16:10,24:12,32:14},s=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],q=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],h=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],a=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],r=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],n=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],M=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],g=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],l=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],C=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],I=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],w=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],Q=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],E=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],c=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function m(F){for(var A=[],t=0;t>2,this._Ke[e][A%4]=i[A],this._Kd[F-e][A%4]=i[A];for(var e,V,h=0,a=B;a>16&255]<<24^q[V>>8&255]<<16^q[255&V]<<8^q[V>>24&255]^s[h]<<24,h+=1,8!=B)for(var A=1;A>8&255]<<8^q[V>>16&255]<<16^q[V>>24&255]<<24;for(var A=B/2+1;A>2,n=a%4,this._Ke[r][n]=i[A],this._Kd[F-r][n]=i[A++],a++}for(var r=1;r>24&255]^Q[V>>16&255]^E[V>>8&255]^c[255&V]},Y.prototype.encrypt=function(F){if(16!=F.length)throw Error("invalid plaintext size (must be 16 bytes)");for(var A=this._Ke.length-1,t=[0,0,0,0],B=m(F),e=0;e<4;e++)B[e]^=this._Ke[0][e];for(var V=1;V>24&255]^r[B[(e+1)%4]>>16&255]^n[B[(e+2)%4]>>8&255]^M[255&B[(e+3)%4]]^this._Ke[V][e];B=t.slice()}for(var o,s=i(16),e=0;e<4;e++)o=this._Ke[A][e],s[4*e]=(q[B[e]>>24&255]^o>>24)&255,s[4*e+1]=(q[B[(e+1)%4]>>16&255]^o>>16)&255,s[4*e+2]=(q[B[(e+2)%4]>>8&255]^o>>8)&255,s[4*e+3]=(q[255&B[(e+3)%4]]^o)&255;return s},Y.prototype.decrypt=function(F){if(16!=F.length)throw Error("invalid ciphertext size (must be 16 bytes)");for(var A=this._Kd.length-1,t=[0,0,0,0],B=m(F),e=0;e<4;e++)B[e]^=this._Kd[0][e];for(var V=1;V>24&255]^l[B[(e+3)%4]>>16&255]^C[B[(e+2)%4]>>8&255]^I[255&B[(e+1)%4]]^this._Kd[V][e];B=t.slice()}for(var o,s=i(16),e=0;e<4;e++)o=this._Kd[A][e],s[4*e]=(h[B[e]>>24&255]^o>>24)&255,s[4*e+1]=(h[B[(e+3)%4]>>16&255]^o>>16)&255,s[4*e+2]=(h[B[(e+2)%4]>>8&255]^o>>8)&255,s[4*e+3]=(h[255&B[(e+1)%4]]^o)&255;return s};var D=function(F){if(!(this instanceof D))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new Y(F)};D.prototype.encrypt=function(F){if((F=B(F)).length%16!=0)throw Error("invalid plaintext size (must be multiple of 16 bytes)");for(var A=i(F.length),t=i(16),V=0;V=0;--A)this._counter[A]=F%256,F>>=8},S.prototype.setBytes=function(F){if(16!=(F=B(F,!0)).length)throw Error("invalid counter bytes size (must be 16 bytes)");this._counter=F},S.prototype.increment=function(){for(var F=15;F>=0;F--)if(255===this._counter[F])this._counter[F]=0;else{this._counter[F]++;break}};var k=function(F,A){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",A instanceof S||(A=new S(A)),this._counter=A,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new Y(F)};k.prototype.encrypt=function(F){for(var A=B(F,!0),t=0;t=64;){let n=t,M=B,g=i,l=e,C=V,I=o,w=s,Q=q,E,c,m,Y,D;for(c=0;c<16;c++)m=a+4*c,h[c]=(255&F[m])<<24|(255&F[m+1])<<16|(255&F[m+2])<<8|255&F[m+3];for(c=16;c<64;c++)Y=((E=h[c-2])>>>17|E<<15)^(E>>>19|E<<13)^E>>>10,D=((E=h[c-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3,h[c]=(Y+h[c-7]|0)+(D+h[c-16]|0)|0;for(c=0;c<64;c++)Y=(((C>>>6|C<<26)^(C>>>11|C<<21)^(C>>>25|C<<7))+(C&I^~C&w)|0)+(Q+(A[c]+h[c]|0)|0)|0,D=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&M^n&g^M&g)|0,Q=w,w=I,I=C,C=l+Y|0,l=g,g=M,M=n,n=Y+D|0;t=t+n|0,B=B+M|0,i=i+g|0,e=e+l|0,V=V+C|0,o=o+I|0,s=s+w|0,q=q+Q|0,a+=64,r-=64}}a(F);let r,n=F.length%64,M=F.length/536870912|0,g=F.length<<3,l=n<56?56:120,C=F.slice(F.length-n,F.length);for(C.push(128),r=n+1;r>>24&255),C.push(M>>>16&255),C.push(M>>>8&255),C.push(M>>>0&255),C.push(g>>>24&255),C.push(g>>>16&255),C.push(g>>>8&255),C.push(g>>>0&255),a(C),[t>>>24&255,t>>>16&255,t>>>8&255,t>>>0&255,B>>>24&255,B>>>16&255,B>>>8&255,B>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,e>>>24&255,e>>>16&255,e>>>8&255,e>>>0&255,V>>>24&255,V>>>16&255,V>>>8&255,V>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,q>>>24&255,q>>>16&255,q>>>8&255,q>>>0&255]}function t(F,t,B){let i;F=F.length<=64?F:A(F);let e=64+t.length+4,V=Array(e),o=Array(64),s=[];for(i=0;i<64;i++)V[i]=54;for(i=0;i=e-4;F--){if(V[F]++,V[F]<=255)return;V[F]=0}}for(;B>=32;)q(),s=s.concat(A(o.concat(A(V)))),B-=32;return B>0&&(q(),s=s.concat(A(o.concat(A(V))).slice(0,B))),s}function B(F,A,t,B,o){let s;for(V(F,(2*t-1)*16,o,0,16),s=0;s<2*t;s++)e(F,16*s,o,16),function(F,A){V(F,0,A,0,16);for(let F=8;F>0;F-=2)A[4]^=i(A[0]+A[12],7),A[8]^=i(A[4]+A[0],9),A[12]^=i(A[8]+A[4],13),A[0]^=i(A[12]+A[8],18),A[9]^=i(A[5]+A[1],7),A[13]^=i(A[9]+A[5],9),A[1]^=i(A[13]+A[9],13),A[5]^=i(A[1]+A[13],18),A[14]^=i(A[10]+A[6],7),A[2]^=i(A[14]+A[10],9),A[6]^=i(A[2]+A[14],13),A[10]^=i(A[6]+A[2],18),A[3]^=i(A[15]+A[11],7),A[7]^=i(A[3]+A[15],9),A[11]^=i(A[7]+A[3],13),A[15]^=i(A[11]+A[7],18),A[1]^=i(A[0]+A[3],7),A[2]^=i(A[1]+A[0],9),A[3]^=i(A[2]+A[1],13),A[0]^=i(A[3]+A[2],18),A[6]^=i(A[5]+A[4],7),A[7]^=i(A[6]+A[5],9),A[4]^=i(A[7]+A[6],13),A[5]^=i(A[4]+A[7],18),A[11]^=i(A[10]+A[9],7),A[8]^=i(A[11]+A[10],9),A[9]^=i(A[8]+A[11],13),A[10]^=i(A[9]+A[8],18),A[12]^=i(A[15]+A[14],7),A[13]^=i(A[12]+A[15],9),A[14]^=i(A[13]+A[12],13),A[15]^=i(A[14]+A[13],18);for(let t=0;t<16;++t)F[t]+=A[t]}(o,B),V(o,0,F,A+16*s,16);for(s=0;s>>32-A}function e(F,A,t,B){for(let i=0;i=256)return!1}return!0}function s(F,A){if("number"!=typeof F||F%1)throw Error("invalid "+A);return F}function q(F,A,i,q,h,a,r){let n;if(i=s(i,"N"),q=s(q,"r"),h=s(h,"p"),a=s(a,"dkLen"),0===i||(i&i-1)!=0)throw Error("N must be power of 2");if(i>2147483647/128/q)throw Error("N too large");if(q>2147483647/128/h)throw Error("r too large");if(!o(F))throw Error("password must be an array or buffer");if(F=Array.prototype.slice.call(F),!o(A))throw Error("salt must be an array or buffer");A=Array.prototype.slice.call(A);let M=t(F,A,128*h*q),g=new Uint32Array(32*h*q);for(let F=0;FG&&(A=G);for(let F=0;FG&&(A=G);for(let F=0;F>0&255),M.push(g[F]>>8&255),M.push(g[F]>>16&255),M.push(g[F]>>24&255);let o=t(F,M,a);return r&&r(null,1,o),o}r&&S(k)};if(!r)for(;;){let F=k();if(void 0!=F)return F}k()}let h={scrypt:function(F,A,t,B,i,e,V){return new Promise(function(o,s){let h=0;V&&V(0),q(F,A,t,B,i,e,function(F,A,t){if(F)s(F);else if(t)V&&1!==h&&V(1),o(new Uint8Array(t));else if(V&&A!==h)return h=A,V(A)})})},syncScrypt:function(F,A,t,B,i,e){return new Uint8Array(q(F,A,t,B,i,e))}};void 0!==CI?CI=h:"function"==typeof define&&define.amd?define(h):F&&(F.scrypt&&(F._scrypt=F.scrypt),F.scrypt=h)}(CI),new rp(CC),new rp("wallet/5.7.0");let CE=new rp("web/5.7.1");function Cc(F){return new Promise(A=>{setTimeout(A,F)})}function Cm(F,A){if(null==F)return null;if("string"==typeof F)return F;if(rk(F)){if(A&&("text"===A.split("/")[0]||"application/json"===A.split(";")[0].trim()))try{return Mt(F)}catch(F){}return rT(F)}return F}function CY(F,A,t){let B;let i="object"==typeof F&&null!=F.throttleLimit?F.throttleLimit:12;CE.assertArgument(i>0&&i%1==0,"invalid connection throttle limit","connection.throttleLimit",i);let e="object"==typeof F?F.throttleCallback:null,V="object"==typeof F&&"number"==typeof F.throttleSlotInterval?F.throttleSlotInterval:100;CE.assertArgument(V>0&&V%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",V);let o="object"==typeof F&&!!F.errorPassThrough,s={},q=null,h={method:"GET"},a=!1,r=12e4;if("string"==typeof F)q=F;else if("object"==typeof F){if((null==F||null==F.url)&&CE.throwArgumentError("missing URL","connection.url",F),q=F.url,"number"==typeof F.timeout&&F.timeout>0&&(r=F.timeout),F.headers)for(let A in F.headers)s[A.toLowerCase()]={key:A,value:String(F.headers[A])},["if-none-match","if-modified-since"].indexOf(A.toLowerCase())>=0&&(a=!0);if(h.allowGzip=!!F.allowGzip,null!=F.user&&null!=F.password){"https:"!==q.substring(0,6)&&!0!==F.allowInsecureAuthentication&&CE.throwError("basic authentication requires a secure https url",rp.errors.INVALID_ARGUMENT,{argument:"url",url:q,user:F.user,password:"[REDACTED]"});let A=F.user+":"+F.password;s.authorization={key:"Authorization",value:"Basic "+Mz(n9(A))}}null!=F.skipFetchSetup&&(h.skipFetchSetup=!!F.skipFetchSetup),null!=F.fetchOptions&&(h.fetchOptions=r$(F.fetchOptions))}let n=RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),M=q?q.match(n):null;if(M)try{var g;let F={statusCode:200,statusMessage:"OK",headers:{"content-type":M[1]||"text/plain"},body:M[2]?MO(M[3]):(g=M[3],n9(g.replace(/%([0-9a-f][0-9a-f])/gi,(F,A)=>String.fromCharCode(parseInt(A,16)))))},A=F.body;return t&&(A=t(F.body,F)),Promise.resolve(A)}catch(F){CE.throwError("processing response error",rp.errors.SERVER_ERROR,{body:Cm(M[1],M[2]),error:F,requestBody:null,requestMethod:"GET",url:q})}A&&(h.method="POST",h.body=A,null==s["content-type"]&&(s["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==s["content-length"]&&(s["content-length"]={key:"Content-Length",value:String(A.length)}));let l={};Object.keys(s).forEach(F=>{let A=s[F];l[A.key]=A.value}),h.headers=l;let C=(B=null,{promise:new Promise(function(F,A){r&&(B=setTimeout(()=>{null!=B&&(B=null,A(CE.makeError("timeout",rp.errors.TIMEOUT,{requestBody:Cm(h.body,l["content-type"]),requestMethod:h.method,timeout:r,url:q})))},r))}),cancel:function(){null!=B&&(clearTimeout(B),B=null)}}),I=function(){var F,A,B,s;return F=this,A=void 0,B=void 0,s=function*(){for(let F=0;F{e[A.toLowerCase()]=F}):B.headers.keys().forEach(F=>{e[F.toLowerCase()]=B.headers.get(F)}),{headers:e,statusCode:B.status,statusMessage:B.statusText,body:rK(new Uint8Array(i))}},new(i||(i=Promise))(function(F,A){function V(F){try{s(e.next(F))}catch(F){A(F)}}function o(F){try{s(e.throw(F))}catch(F){A(F)}}function s(A){var t;A.done?F(A.value):((t=A.value)instanceof i?t:new i(function(F){F(t)})).then(V,o)}s((e=e.apply(t,B||[])).next())})}(q,h),F=300)&&(C.cancel(),CE.throwError("bad response",rp.errors.SERVER_ERROR,{status:A.statusCode,headers:A.headers,body:Cm(B,A.headers?A.headers["content-type"]:null),requestBody:Cm(h.body,l["content-type"]),requestMethod:h.method,url:q})),t)try{let F=yield t(B,A);return C.cancel(),F}catch(t){if(t.throttleRetry&&F"content-type"===F.toLowerCase()).length||(t.headers=r$(t.headers),t.headers["content-type"]="application/json"):t.headers={"content-type":"application/json"},F=t}return CY(F,B,(F,A)=>{let B=null;if(null!=F)try{B=JSON.parse(Mt(F))}catch(A){CE.throwError("invalid JSON",rp.errors.SERVER_ERROR,{body:F,error:A})}return t&&(B=t(B,A)),B})}function Cp(F,A){return A||(A={}),null==(A=r$(A)).floor&&(A.floor=0),null==A.ceiling&&(A.ceiling=1e4),null==A.interval&&(A.interval=250),new Promise(function(t,B){let i=null,e=!1,V=()=>!e&&(e=!0,i&&clearTimeout(i),!0);A.timeout&&(i=setTimeout(()=>{V()&&B(Error("timeout"))},A.timeout));let o=A.retryLimit,s=0;!function i(){return F().then(function(F){if(void 0!==F)V()&&t(F);else if(A.oncePoll)A.oncePoll.once("poll",i);else if(A.onceBlock)A.onceBlock.once("block",i);else if(!e){if(++s>o){V()&&B(Error("retry limit reached"));return}let F=A.interval*parseInt(String(Math.random()*Math.pow(2,s)));FA.ceiling&&(F=A.ceiling),setTimeout(i,F)}return null},function(F){V()&&B(F)})}()})}var Cu={};Cu='';var CG={};CG='';var CS={};CS='';var Ck={};Ck='';var CU={};CU='';var Cy={};Cy='';var CK={};CK='';var CZ={};CZ='';var CJ={};CJ='';var CR={};CR='';var Cd={};Cd='';var Cx={};Cx='';var CT={};CT='';var CL={};CL='';var CN={};CN='';var Cj={};Cj='';var CW={};CW='';var CO={};CO='';var Cz={};Cz='';var Cf={};Cf='';var Cv={};Cv='';var CH={};CH='';var Cb={};Cb='';var CP={};CP='';var CX={};CX='';var C_={};C_='';var C$={};C$='';var C2={};C2='';var C0={};C0='';var C1={};C1='';var C4={};C4='';var C5={};C5='';var C8={};C8='';var C6={};C6='';var C3={};C3='';var C9={};C9='';var C7={};C7='';var IF={};IF='';var IA={};IA='';var It={};It='';var IB={};IB='';var Ii={};Ii='';var Ie={};Ie='';var IV={};IV='';var Io={};Io='';var Is={};Is='';var Iq={};Iq='';var Ih={};Ih='';var Ia={};Ia='';var Ir={};Ir='';var In={};In='';var IM={};IM='';var Ig={};Ig='';var Il={};Il='';var IC={};IC='';var II={};II='';var Iw={};Iw='';var IQ={};IQ='';var IE={};IE='';var Ic={};Ic='';var Im={};Im='';var IY={};IY='';var ID={};ID='';var Ip={};Ip='';var Iu={};Iu='';var IG={};IG='';var IS=[{bodyIndex:0,radius:51e3,px:5e5,py:290750,vx:-1e5,vy:-1e6,exitX:100,exitY:-600},{bodyIndex:5,radius:11e3,px:793406,py:133029,vx:1e6,vy:-1e7,exitX:300,exitY:-50},{bodyIndex:2,radius:23e3,px:825620,py:328711,vx:1e5,vy:-1e6,exitX:500,exitY:50},{bodyIndex:1,radius:27e3,px:159878,py:234946,vx:-1e5,vy:-1e6,exitX:-300,exitY:-400},{bodyIndex:3,radius:19e3,px:229878,py:464946,vx:-1e5,vy:-1e6,exitX:-400,exitY:-50},{bodyIndex:4,radius:15e3,px:679878,py:668946,vx:1e5,vy:-1e6,exitX:600,exitY:300}];let Ik=[30,10,20,30,40,50],IU=Ik.length-1,Iy={fg:{direction:1,speed:25},bg:{direction:-1,speed:35},core:{direction:1,speed:100}},IK={fg:{1:{speed:0},8:{speed:0},9:{direction:-1}}},IZ=[FH(Cu),FH(CG),FH(CS),FH(Ck),FH(CU),FH(Cy),FH(CK),FH(CZ),FH(CJ),FH(CR)],IJ=[FH(Cd),FH(Cx),FH(CT),FH(CL),FH(CN),FH(Cj),FH(CW),FH(CO),FH(Cz),FH(Cf)],IR=[FH(Cv),FH(CH),FH(Cb),FH(CP),FH(CX),FH(C_),FH(C$),FH(C2),FH(C0),FH(C1),FH(C4),FH(C5),FH(C8),FH(C6)],Id=[FH(C3),FH(C9),FH(C7),FH(IF),FH(IA),FH(It),FH(IB),FH(Ii),FH(Ie),FH(IV),FH(Io),FH(Is),FH(Iq),FH(Ih)],Ix=[FH(Ia),FH(Ir),FH(In),FH(IM),FH(Ig),FH(Il),FH(IC),FH(II),FH(Iw),FH(IQ),FH(IE),FH(Ic),FH(Im),FH(IY)],IT=[FH(ID)],IL={BADDIE_SVG:{bg:FH(Ip),core:FH(Iu),face:FH(IG)},BG_SVGS:IZ,CORE_SVGS:IT,FACE_BLINK_SVGS:Id,FACE_SHOT_SVGS:Ix,FACE_SVGS:IR,FG_SVGS:IJ},IN=(F,A,t)=>F.replaceAll(RegExp(`(?<=\\s|^)${A}="(?!none)([^"]+)"`,"g"),`${A}="${t}"`),Ij={async draw(){for(let F in this.shaking&&this.shaking>0?this.shakeScreen():this.shaking=null,this.buttons)this.buttons[F].visible=!1;if(!this.showIt)return;this.firstFrame||this.hasStarted||(this.hasStarted=!0,this.started());let F=this.introStage>=this.totalIntroStages;if((F||this.level>0)&&!this.paused&&this.p5Frames%this.P5_FPS_MULTIPLIER==0){this.firstFrame=!1,this.frames++;let F=this.step(this.bodies,this.missiles);this.bodies=F.bodies||[],this.missiles=F.missiles||[]}if(this.shootMissileNextFrame){console.log("trigger missile click from draw");let{x:F,y:A}=this.shootMissileNextFrame;this.missileClick(F,A),this.shootMissileNextFrame=null}this.p.noFill(),this.drawBg(),this.p5Frames++,this.drawExplosions(),F||this.level>0?(this.drawPause(),this.drawBodies()):this.paused?this.drawPause():this.drawIntro(),this.drawScore(),this.drawMuteButton(),this.drawPopup(),this.drawGun(),this.drawGunSmoke(),this.drawExplosionSmoke(),this.frames-this.startingFrame+this.FPSF+A.radius,0)&&this.drawMissiles();let A=!this.paused,t=(this.frames-this.startingFrame)%this.stopEvery==0&&this.p5Frames%this.P5_FPS_MULTIPLIER==0,B=!this.justPaused,i=this.frames-this.startingFrame+this.FPS>=this.timer,e=0==this.bodies[0].radius&&0!==this.level;(i||e)&&!this.handledGameOver&&this.handleGameOver({won:!1,ranOutOfTime:i,hitHeroBody:e}),this.won||"game"!=this.mode||0!=this.bodies.slice(0==this.level?0:1).reduce((F,A)=>F+A.radius,0)||this.handledGameOver||this.handleGameOver({won:!0}),!this.firstFrame&&A&&t&&B&&!i&&!this.handledGameOver?this.finish():this.justPaused=!1},drawTextBubble({text:F="",x:A=0,y:t=0,w:B=240,h:i=56,fz:e=48,fg:V,bg:o,stroke:s,align:q=[this.p.CENTER,this.p.TOP]}){if(!F)return{x:A,y:t,h:i,w:B,fz:e};let{p:h}=this;h.fill(o??"black"),h.stroke(s??rV.iris_60),h.rect(A,t,B,i,16,16,16,16),q[0]===h.LEFT&&(A-=B/2),h.textFont(rg.body),h.textAlign(...q),h.textSize(e),h.fill(V??rV.iris_30),h.noStroke(),h.text(F,A+B/2,t+(i-e)/2-1),h.pop()},drawPause(){if(!rg.dot||!this.paused||-1!==this.showProblemRankingsScreenAt)return;let F=this.p,A=0==this.level?.7:0,t=A*this.P5_FPS;if(this.willUnpause&&!this.beganUnpauseAt&&(this.beganUnpauseAt=t?this.p5Frames:0),this.beganUnpauseAt+t{this.popup||(this.sound?.playStart(),this.setPause(!1))},fg:rV.violet_50,bg:rV.pink,width:410,height:108,textSize:78,x:this.opensea?this.windowWidth/2-205:508,y:862,p:F}),!0!==this.opensea&&this.drawButton({text:"MINT",onClick:()=>{this.emit("mint")},fg:rV.violet_25,bg:"#241465",width:410,height:108,textSize:78,x:82,y:862,p:F}),F.pop())},drawBodyOutlines(){for(let F=0;F{for(let i=0;i<5e3;i++){let i=F.random(0,F.TWO_PI),e=F.random(-125,250),V=e*F.cos(i),o=e*F.sin(i),s=F.lerpColor(F.color(B),F.color(F.random(150),F.random(150),F.random(150)),.65);s.setAlpha(100),F.fill(s),F.ellipse(A+V,t+o,2,2)}},A=(F,A,t,B)=>(1-B)*(1-B)*F+2*(1-B)*B*A+B*B*t;if(!this.starBG){this.starBG=this.p.createGraphics(this.windowWidth,this.windowHeight),this.starBG.pixelDensity(this.pixelDensity);for(let F=0;F<200;F++){this.starBG.noStroke(),this.starBG.fill(rV.fg),this.starBG.textSize(15);let F=[",",".","*"];this.starBG.text(F[Math.floor(Math.random()*F.length)],Math.floor(Math.random()*this.windowWidth),Math.floor(Math.random()*this.windowHeight))}(t=>{let B=(F,A,t=0)=>{let B=rI.solidityKeccak256(["bytes32"],[this.seed]);return 0!==t&&(B=rI.solidityKeccak256(["bytes32","uint256"],[B,t])),this.randomRange(F,A,B)};t.colorMode(t.RGB);let i=t.color(...rq(ra(ro.bodies.default.berlin.bg,!0,B.bind(this),0),1,!0)),e=t.color(...rq(ra(ro.bodies.default.berlin.bg,!0,B.bind(this),100),1,!0)),V=0==B(0,1,0),o=0==B(0,1,1),s=V?-100:this.windowWidth+100,q=o?this.windowHeight+100:0,h=V?0:this.windowWidth,a=o?0:this.windowHeight,r=V?this.windowWidth:-100,n=o?-100:this.windowHeight+100;for(let B=0;B<=1;B+=.01){let V=A(s,h,r,B),o=A(q,a,n,B),M=t.map(o,50,250,0,1),g=t.lerpColor(i,e,M);t.noStroke(),F(t,V,o,g)}t.colorMode(t.RGB)})(this.starBG)}this.p.image(this.starBG,0,0,this.windowWidth,this.windowHeight)},drawPopup(){if(!this.popup)return;let{p:F,popup:A}=this;A.lastVisibleFrame!==this.p5Frames-1&&(A.visibleForFrames=0),A.visibleForFrames++,A.lastVisibleFrame=this.p5Frames;let t=Math.min(.8,A.visibleForFrames/(.2*this.P5_FPS));F.fill(`rgba(20, 4, 32, ${t})`),F.noStroke(),F.rect(0,0,this.windowWidth,this.windowHeight);let B=(this.windowWidth-840)/2,i=A.bg??rV.violet_25,e=A.fg??rV.violet_50,V=A.stroke??e,o=130+44*A.body.length+140,s=Math.max(0,50-50/(.2*this.P5_FPS)*A.visibleForFrames),q=(this.windowHeight-o)/2+s;if(F.fill(i),F.stroke(V),F.strokeWeight(3),F.rect(B,q,840,o,24,24,24,24),!rg.dot||(F.textFont(rg.dot),F.fill(A.fg??e),F.textSize(90),F.textAlign(F.CENTER,F.TOP),F.noStroke(),F.text(A.header,B+420,q+40),!rg.body))return;F.textFont(rg.body),F.textSize(44),F.textAlign(F.CENTER,F.TOP);for(let t=0;t1?B+24+(a+10)*F:B+420-a/2,...r,...t})}F.pop()},handleRedoButtonClick(F=!0){this.skipRedoPopupTip?this.restart(null,!1):this.popup={bg:rV.teal_75,fg:rV.teal_50,stroke:rV.teal_50,header:"Tip",body:[this.hasTouched?"Tap the TIMER to restart levels":"Press {R} to restart levels"],buttons:[...F?[{text:"CLOSE",onClick:()=>{this.popup=null}}]:[],{text:"REDO",bg:rV.teal_50,fg:rV.teal_75,stroke:rV.teal_50,onClick:()=>{this.popup=null,this.restart(null,!1)}}]}},getColorDir(F){return Math.floor(this.frames/(255*F))%2==0},getGrey(){return this.getColorDir(this.chunk)?255-Math.floor(this.frames/this.chunk)%255:Math.floor(this.frames/this.chunk)%255},drawMuteButton(){if(this.paused||this.gameOver||0===this.introStage&&!(this.levelCountdown<200))return;let{p:F}=this;F.push(),F.noStroke(),F.fill("white");let A=this.windowWidth-(this.hasTouched?108:80),t=this.windowHeight-(this.hasTouched?116:84);F.translate(A,t);let B=this.hasTouched?Math.floor(8):Math.floor(6);this.drawMuteIconRect(0,3,1,4,B),this.drawMuteIconRect(2,3,1,4,B),this.drawMuteIconRect(3,2,1,6,B),this.drawMuteIconRect(4,1,1,8,B),this.drawMuteIconRect(5,0,1,10,B),this.drawMuteIconRect(1,3,1,4,B),this.mute?this.drawMuteIconRect(7,4.5,2.5,1,B):(this.drawMuteIconRect(6.5,4,1,2,B),this.drawMuteIconRect(8,3,1,4,B));let i={x:this.hasTouched?-20:-6,y:this.hasTouched?-20:-6,w:200},e=this.buttons["mute-button"];e||(this.buttons["mute-button"]={x:A+i.x,y:t+i.y,width:i.w,height:i.w,onClick:()=>{this.mute=!this.mute,this.sound?.setMuted(this.mute)}},(e=this.buttons["mute-button"]).disabled=!1),e.visible=!0,F.pop()},drawScore(){if(this.paused)return;let{p:F}=this;F.push(),F.fill("white"),F.noStroke(),F.textAlign(F.LEFT,F.TOP),this.drawProblemRankingsScreen();let A=this.frames-this.startingFrame,t=(this.framesTook||A)/this.FPS,B=(this.level>5?60:Ik[this.level])-t;if(!this.gameOver||(this.scoreSize=this.initialScoreSize,F.pop(),this.won?this.drawWinScreen():this.drawLoseScreen(),this.celebrating)){if(this.won){let A=Math.floor(this.frames/10)%2==0;F.fill(A?rV.red:"white")}F.textFont(rg.body),F.textSize(this.scoreSize),A>2&&(!this.gameOver||this.gameOver&&this.won&&!this.skipAhead)&&(this.won?(F.textSize(2*this.scoreSize),F.text(t.toFixed(2)+"s",20,0)):(F.text(B.toFixed(2),20,0),F.textAlign(F.RIGHT,F.TOP),this.hasTouched&&(this.buttons["touch-timer-reset"]={x:0,y:0,width:200,height:110,disabled:!1,visible:!0,onClick:()=>{this.skipRedoPopupTip=!0,this.restart(null,!1)}}),F.text("Lvl "+this.level,this.windowWidth-20,0))),F.pop()}},drawMuteIconRect(F,A,t,B,i){this.p.rect(F*i,A*i,t*i,B*i,1)},drawWinScreen(){this.showProblemRankingsScreenAt>=0||(this.winScreenLastVisibleFrame!==this.p5Frames-1&&(this.winScreenVisibleForFrames=0),this.winScreenVisibleForFrames++,this.winScreenLastVisibleFrame=this.p5Frames,this.celebrating=this.winScreenVisibleForFrames/this.P5_FPS<2.5,this.celebrating&&!this.skipAhead?this.drawGameOverTicker({text:" YES YES YES YES YES YES YES YES",bottom:!0,fg:rV.iris_30}):0==this.level?(this.level++,this.restart(null,!1)):(this.sound?.playbackRate!=="normal"&&this.sound?.playCurrentSong(),this.drawStatsScreen()))},drawStatsScreen(){this.shownStatScreen||(this.shownStatScreen=!0);let{p:F}=this,A=this.level>1;this.statsScreenLastVisibleFrame!==this.p5Frames-1&&(this.statsScreenVisibleForFrames=0,this.P5_FPS=this.FPS*this.P5_FPS_MULTIPLIER,this.p.frameRate(this.P5_FPS)),this.statsScreenVisibleForFrames++,this.statsScreenLastVisibleFrame=this.p5Frames;let t=Math.min(1,this.statsScreenVisibleForFrames/(.4*this.P5_FPS));if(F.push(),F.noStroke(),F.fill("white"),!rg.dot)return;F.textFont(rg.dot),F.fill(rV.pink),F.textSize(64),F.textAlign(F.LEFT,F.TOP);let B=F.map(t,0,1,-100,19);rC(F,"Anybody",340,B,.8),rC(F,"Problem",662,B,2),F.fill("black"),F.stroke(rV.border),F.strokeWeight(1);let i=this.windowWidth-40;if(F.rect(20,104,i,144,24),F.rect(20,320,i,A?444:364,24),F.rect(20,796,i,64,24),F.textSize(36),F.noStroke(),!rg.body)return;F.textFont(rg.body),F.fill(rV.iris_50),F.text("player",341,128),F.text("problem",341,188),F.textSize(54),F.fill(rV.iris_30);let e=new Date(this.date).toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}).toUpperCase();F.text(this.playerName??"YOU",495,114),F.text(e,495,174);let V=this.levelSpeeds.map(F=>F?.framesTook/this.FPS).filter(F=>void 0!==F),o=this.todaysRecords?.levels?.map(F=>F.events[0].time/this.FPS)??[],s=o.length;F.textSize(48),F.fill(rV.iris_30),F.textAlign(F.RIGHT,F.TOP);let q=s?580:964;F.text("time",q,264),s&&(F.text("best",780,264),F.text("diff",964,264));let h=V.length>=IU;F.fill(`rgba(146, 118, 255, ${Math.floor(F.frameCount/18)%2?"0.2":"0"})`),F.rect(20,320+(V.length-1)*72,this.windowWidth-40,72,1===this.level?24:0,1===this.level?24:0,0,0),F.push(),F.textAlign(F.RIGHT,F.CENTER),F.textSize(56);for(let A=0;A{if(A>=V.length)return"";let t=V[A]-F;return(Number(t.toFixed(2))>0?"+":"-")+Math.abs(t).toFixed(2)}).filter(Boolean);for(let A=0;AF+A,0),t=[A.toFixed(2)];if(s){let F=o.slice(0,V.length).reduce((F,A)=>F+A,0),B=Number((A-F).toFixed(2));t[1]=F.toFixed(2),t[2]=`${B>0?"+":"-"}${Math.abs(B).toFixed(2)}`}let B=320+72*Math.min(5,IU),e=B+40;for(let[A,B]of(F.textAlign(F.LEFT,F.CENTER),F.fill(rV.iris_50),F.text(h?"solved in":"total time",44,e),F.textAlign(F.RIGHT,F.CENTER),(s?[580,780,964]:[q]).entries()))0==A?F.fill(rV.iris_30):1==A?F.fill(rV.iris_60):F.fill(/^-/.test(t[A])?rV.lime:rV.flame_50),F.text(t[A],B,e,150,80);F.strokeWeight(1),F.stroke(rV.iris_60),F.line(20,B,i+20,B),F.noStroke()}F.pop();let a=this.getDisplayHero(),r=F.sin(F.frameCount/this.P5_FPS)*(5+a.bodyIndex),n=F.cos(F.frameCount/this.P5_FPS+3*a.bodyIndex)*(6+a.bodyIndex);a.position={x:F.map(t,0,1,-140,170)+r,y:180+n},this.drawBody(a),this.winScreenBaddies||=this.getDisplayBaddies();let M=this.winScreenBaddies;for(let F=0;F=2,this.showShare=this.level>=5;let l=2+Number(this.showRestart)+Number(this.showShare);this.drawBottomButton({text:"REDO",onClick:()=>{this.popup||this.handleRedoButtonClick()},...ro.buttons.teal,columns:l,column:0}),this.showRestart&&this.drawBottomButton({text:"EXIT",onClick:()=>{this.popup||(this.popup={bg:rV.flame_75,fg:rV.flame_50,stroke:rV.flame_50,header:"Start Over?",body:["Any progress will be lost!"],buttons:[{text:"CLOSE",fg:rV.flame_50,bg:rV.flame_75,stroke:rV.flame_50,onClick:()=>{this.popup=null}},{text:"EXIT",fg:rV.flame_75,bg:rV.flame_50,stroke:rV.flame_50,onClick:()=>{this.popup=null,this.level=1,this.restart(void 0,!0)}}]})},...ro.buttons.flame,columns:l,column:1}),this.showShare&&this.drawBottomButton({text:"SHARE",onClick:()=>{null===this.popup&&this.shareCanvas()},...ro.buttons.pink,columns:l,column:2}),this.level<5?this.drawBottomButton({text:"NEXT",onClick:()=>{this.level++,this.level>5?this.showProblemRankingsScreenAt=this.p5Frames:this.restart(null,!1)},...ro.buttons.green,columns:l,column:l-1}):this.drawBottomButton({text:"SAVE",onClick:()=>{if(!this.popup){if(this.opensea){this.popup={header:"Nice Job!",body:["Next time play on ANYBODY.gg to save","your win to the leaderboard !!"],fg:rV.green_50,bg:rV.green_75,buttons:[{text:"CLOSE",onClick:()=>{this.popup=null}},{text:"NEW GAME",onClick:()=>{this.popup=null,this.level=1,this.restart(void 0,!0)},fg:rV.green_75,bg:rV.green_50}]};return}this.emit("save")}},...ro.buttons.green,columns:l,column:l-1}),F.pop(),this.showShare?1!==t||this.shareCanvasBlob||F.canvas.toBlob(F=>{this.shareCanvasBlob=new File([F],"MyWin.png",{type:"image/png"})},"image/png"):this.shareCanvasBlob=void 0},drawProblemRankingsScreen(){if(-1===this.showProblemRankingsScreenAt)return;let{p:F}=this,A=Math.min(1,(this.p5Frames-this.showProblemRankingsScreenAt)/(1.5*this.P5_FPS));if(F.push(),F.noStroke(),F.fill("white"),F.fill("black"),F.stroke(rV.border),F.strokeWeight(1),F.rect(22,28,this.windowWidth-44,103,24),F.rect(22,155,this.windowWidth-44,216,24),F.rect(22,395,this.windowWidth-44,72,24),!rg.dot)return;F.textFont(rg.dot);let t=F.map(A,0,1,0,1);if(F.fill(rr(rV.pink,t)),F.textSize(60),F.textAlign(F.LEFT,F.TOP),rC(F,"Anybody",46,44,.8),rC(F,"Problem",356,44,2),F.textSize(56),F.noStroke(),!rg.body)return;F.textFont(rg.body),F.fill(rV.iris_30),F.textAlign(F.RIGHT,F.TOP),F.text(this.date,this.windowWidth-42,48),F.textSize(44),F.textAlign(F.RIGHT,F.TOP);let B=this.windowWidth-42;for(let[A,t]of[{rank:1,name:"0xABCD-1234",time:188.889192912},{rank:2,name:"longassensnamethatgoesofftherowalllllllls",time:189.889192912},{rank:3,name:"0xABCD-1234",time:198.889192912},{rank:999998,name:"petersugihara.eth",time:260.889192912}].entries()){let i=72*A+36+(3===A?24:0);F.textAlign(F.LEFT,F.CENTER),F.fill(rV.iris_60);let e=1===t.rank?"1st":2===t.rank?"2nd":3===t.rank?"3rd":`${t.rank.toLocaleString()}`;F.text(e,42,155+i),F.fill(rV.iris_30);let V=t.name;for(;F.textWidth(V)>656;)V=`${V.replaceAll(/\.\.\.$/g,"").slice(0,-1)}...`;F.text(V,187,155+i),F.textAlign(F.RIGHT,F.CENTER),F.fill(rV.iris_60),F.text(t.time.toFixed(2),B,155+i),A<2&&(F.fill(rV.iris_60),F.rect(22,155+72*(A+1),this.windowWidth-44,1))}let i=this.getDisplayHero({radius:33}),e=F.sin(F.frameCount/this.P5_FPS)*(5+i.bodyIndex),V=F.cos(F.frameCount/this.P5_FPS+3*i.bodyIndex)*(6+i.bodyIndex);if(i.position={x:F.map(A**3,0,1,-140,180)+e,y:670+V},this.drawBody(i),this.drawMessageBox||=({lines:A,x:t,y:B,color:i,start:e,textWidth:V})=>{if(-1!==e&&this.p5Framess.length&&this.sound?.playStart();let q=A.sort((F,A)=>A.length-F.length)[0];F.rect(t,B,(V||F.textWidth(q))+24+20,36*A.length+40,20),F.fill(i),F.text(s,t+24,B+20)},"unsaved"===this.saveStatus){let F=this.showProblemRankingsScreenAt+1.5*this.P5_FPS,A=this.showProblemRankingsScreenAt+3*this.P5_FPS,t=this.showProblemRankingsScreenAt+5.5*this.P5_FPS;this.drawMessageBox({lines:["wOwOwoWwwww ! ! ! !","you solved the daily problem !"],x:344,y:504,color:rV.iris_30,start:F}),this.drawMessageBox({lines:["replay as many times as you'd like","before tomorrow's problem..."],x:370,y:704,color:rV.pink,start:t}),this.drawMessageBox({lines:["SAVE your score to the leaderboard","and receive today's celestial body !"],x:484,y:604,color:rV.green_50,start:A,textWidth:451})}if("validating"===this.saveStatus&&(this.validatingAt||=this.p5Frames,this.drawMessageBox({lines:["validating your score..."],x:344,y:504,color:rV.iris_30,start:this.validatingAt})),("validated"===this.saveStatus||"saved"===this.saveStatus||"saving"===this.saveStatus)&&(this.validatedAt||=this.p5Frames,this.drawMessageBox({lines:["score validated!"],x:344,y:504,color:rV.iris_30,start:-1})),"validated"===this.saveStatus&&this.validatedAt){let F=this.validatedAt+1*this.P5_FPS;this.drawMessageBox({lines:["you can now save your score"],x:484,y:566,color:rV.green_50,start:F})}else if("saving"===this.saveStatus)this.savingAt||=this.p5Frames,this.drawMessageBox({lines:["saving your score..."],x:484,y:566,color:rV.green_50,start:this.savingAt});else if("saved"===this.saveStatus){this.savedAt||=this.p5Frames,this.drawMessageBox({lines:["score SAVED!"],x:478,y:566,color:rV.green_50,start:this.savedAt});let F=this.savedAt+1*this.P5_FPS;this.drawMessageBox({lines:["this body is now in your wallet !"],x:414,y:653,color:rV.pink_40,start:F});let A=this.savedAt+2*this.P5_FPS;this.drawMessageBox({lines:["but, maybe you can do better ??"],x:545,y:757,color:rV.yellow_50,start:A})}"saved"!==this.saveStatus?(this.drawBottomButton({text:"BACK",onClick:()=>{this.restart(null,!1)},...ro.buttons.teal,columns:2,column:0}),this.drawBottomButton({text:"unsaved"===this.saveStatus?"SAVE":"validated"===this.saveStatus?"SAVE":`${this.saveStatus.toUpperCase()}...`,onClick:()=>{this.handleSave()},...ro.buttons.green,disabled:"unsaved"!==this.saveStatus&&"validated"!==this.saveStatus,columns:2,column:1,key:"problem-save"})):this.drawBottomButton({text:"NEW GAME",onClick:()=>{this.restart()},...ro.buttons.yellow,columns:1,column:0}),F.pop()},getDisplayHero({radius:F}={radius:33}){let A=this.bodies[0],t=JSON.parse(JSON.stringify(A,(F,A)=>"bigint"==typeof A?A.toString():A));return t.position=this.p.createVector(A.position.x,A.position.y),t.velocity=this.p.createVector(A.velocity.x,A.velocity.y),t.radius=F,t},getDisplayBaddies(){let F=[],A=this.generateLevelData(this.day,5).map(F=>this.bodyDataToBodies.call(this,F,this.day));if(!A[A.length-1])return[];for(let t=0;t1){let F=this.windowWidth/2-400+20;this.drawFatButton({text:"REDO",onClick:()=>{this.handleRedoButtonClick()},x:F,bg:rV.teal_75,fg:rV.teal_50}),this.drawFatButton({text:"EXIT",x:this.windowWidth/2+100-20,bg:rV.flame_75,fg:rV.flame_50,onClick:()=>{this.popup||(this.popup={bg:rV.flame_75,fg:rV.flame_50,stroke:rV.flame_50,header:"Leave game?",body:["Any progress will be lost!"],buttons:[{text:"CLOSE",fg:rV.flame_50,bg:rV.flame_75,stroke:rV.flame_50,onClick:()=>{this.popup=null}},{text:"EXIT",fg:rV.flame_75,bg:rV.flame_50,stroke:rV.flame_50,onClick:()=>{this.popup=null,this.level=1,this.restart(void 0,!0)}}]})}})}else this.drawFatButton({text:"REDO",onClick:()=>this.handleRedoButtonClick(!1),bg:rV.teal_75,fg:rV.teal_50});F.pop()},scaleX(F){let{canvas:A}=this.p;return F/A.offsetWidth*this.windowWidth},scaleY(F){let{canvas:A}=this.p;return F/A.offsetHeight*this.windowHeight},drawGun(){if(this.p.stroke("rgba(200,200,200,1)"),this.p.strokeCap(this.p.SQUARE),this.p.mouseX<=0&&this.p.mouseY<=0)return;let F=this.windowHeight;this.p.strokeWeight(rV.borderWt);let A=this.scaleX(this.p.mouseX)-0,t=this.scaleY(this.p.mouseY)-F;this.p.line(this.scaleX(this.p.mouseX)-25,this.scaleX(this.p.mouseY),this.scaleX(this.p.mouseX)+25,this.scaleX(this.p.mouseY)),this.p.line(this.scaleX(this.p.mouseX),this.scaleX(this.p.mouseY)-25,this.scaleX(this.p.mouseX),this.scaleX(this.p.mouseY)+25);let B=this.introStage!==this.totalIntroStages-1,i=this.introStage"string"==typeof F?((F=F.split(","))[0]=parseInt(F[0].split("(")[1]),F[1]=parseInt(F[1]),F[2]=parseInt(F[2].split(")")[0]),`hsl(${F[0]},0%,${F[2]}%)`):[F[0],0,F[2]],rgbaToGrayscale(F,A=3){let t=F.split(","),B=parseInt(t[0].split("(")[1]),i=parseInt(t[1]),e=parseInt(t[2]),V=parseFloat(t[3].split(")")[0]),o=Math.min(Math.floor((B+i+e)/A),255);return`rgba(${o},${o},${o},${V})`},drawExplosions(){if(this.paused||this.gameOver&&(!this.celebrating||this.skipAhead)&&this.won)return;let{explosions:F}=this;for(let A=0;A=60)){this.stillVisibleMissiles.splice(F,1),F--;continue}}else{let F=ra(ro.bodies.default.pastel_highlighter_marker.cr),t=this.p5Frames/this.P5_FPS_MULTIPLIER%360;A.phase={color:F,life:0,rotateBy:t}}this.stillVisibleMissiles[F]=A;let t=F==this.stillVisibleMissiles.length-1?"white":A.phase.color,B=10/1.5+10*(A.phase.life/25*A.phase.life/25);this.p.push(),this.p.translate(A.position.x,A.position.y),this.star(0,0,B,B/2,5,t,A.phase.rotateBy,A.phase.life),this.p.pop()}}},isMissileClose(F){let A=!1;for(let t=0;tthis.p.dist(F.position.x,F.position.y,B.position.x,B.position.y)){A=!0;break}}return A},drawImageAsset(F,A,t,{fill:B,strokeColor:i,strokeWidth:e,maxWidth:V}={}){let o=F+A+B+(V=V||t);this.imgAssets||={};let s=this.imgAssets[o];if(!s){let t=IL[F][A];this.imgAssets[o]="loading",t=B?IN(t,"fill",B):t,t=i?IN(t,"stroke",i):t,t=IN(t,"width",V*this.pixelDensity),t=IN(t,"height",V*this.pixelDensity),t="data:image/svg+xml,"+encodeURIComponent(t=e?IN(t,"stroke-width",e):t);try{this.p.loadImage(t,F=>{this.imgAssets[o]=F})}catch(F){console.error(F),this.imgAssets[o]=void 0}}s&&"loading"!==s&&this.p.image(s,-t/2,-t/2,t,t)},closeTo(F){let A=this.introStagethis.bodyDataToBodies.call(this,A,F))[0],e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width",t),e.setAttribute("height",B),e.setAttribute("day",F),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),e.setAttribute("viewBox",`0 0 ${t} ${B}`),e.setAttribute("version","1.1");let V=i.c.bgIndex,o=i.c.coreIndex,s=i.c.fgIndex,q=i.c.fIndex,h=F=>`data:image/svg+xml;base64,${btoa(F)}`,a=h(IN(IZ[V],"fill",i.c.bg)),r=h(IN(IT[o],"fill",i.c.core)),n=h(IN(IJ[s],"fill",i.c.fg)),M=h(IR[q]),g=()=>Math.random().toString(36).substr(2,9),l=`bg-${V}-${g()}`,C=`core-${o}-${g()}`,I=`fg-${s}-${g()}`,w=`f-${q}-${g()}`,Q=document.createElementNS("http://www.w3.org/2000/svg","image"),E=1*t,c=1*B;Q.setAttribute("id",l),Q.setAttribute("x",(t-E)/2),Q.setAttribute("y",(B-c)/2),Q.setAttribute("width",E),Q.setAttribute("height",c),Q.setAttribute("href",a),e.appendChild(Q);let m=document.createElementNS("http://www.w3.org/2000/svg","image"),Y=.375*t,D=.375*B;m.setAttribute("id",C),m.setAttribute("x",(t-Y)/2),m.setAttribute("y",(B-D)/2),m.setAttribute("width",Y),m.setAttribute("height",D),m.setAttribute("href",r),e.appendChild(m);let p=document.createElementNS("http://www.w3.org/2000/svg","image"),u=1*t,G=1*B;p.setAttribute("id",I),p.setAttribute("x",(t-u)/2),p.setAttribute("y",(B-G)/2),p.setAttribute("width",u),p.setAttribute("height",G),p.setAttribute("href",n),e.appendChild(p);let S=document.createElementNS("http://www.w3.org/2000/svg","image"),k=1*t,U=1*B;if(S.setAttribute("id",w),S.setAttribute("x",(t-k)/2),S.setAttribute("y",(B-U)/2),S.setAttribute("width",k),S.setAttribute("height",U),S.setAttribute("href",M),e.appendChild(S),A){let F={...Iy.fg,...IK?.fg?.[s]??{}},A=F.direction<0?"fullRotateR":"fullRotate",t=(F.speed/3).toFixed(2),B={...Iy.bg,...IK?.bg?.[V]??{}},i=B.direction<0?"fullRotateR":"fullRotate",o=(B.speed/3).toFixed(2),q=(({...Iy.core}).speed/3).toFixed(2),h=document.createElement("style");h.innerHTML=`
+ */function(){var F="input is invalid type",A="object"==typeof window,t=A?window:{};t.JS_SHA3_NO_WINDOW&&(A=!1);var B=!A&&"object"==typeof self;!t.JS_SHA3_NO_NODE_JS&&"object"==typeof na&&na.versions&&na.versions.node?t=AL:B&&(t=self);var i=!t.JS_SHA3_NO_COMMON_JS&&nh,e="function"==typeof define&&define.amd,V=!t.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,o="0123456789abcdef".split(""),s=[4,1024,262144,67108864],q=[0,8,16,24],h=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],r=[128,256],n=["hex","buffer","arrayBuffer","array","digest"],M={128:168,256:136};(t.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(F){return"[object Array]"===Object.prototype.toString.call(F)}),V&&(t.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(F){return"object"==typeof F&&F.buffer&&F.buffer.constructor===ArrayBuffer});for(var g=function(F,A,t){return function(B){return new k(F,A,F).update(B)[t]()}},l=function(F,A,t){return function(B,i){return new k(F,A,i).update(B)[t]()}},C=function(F,A,t){return function(A,B,i,e){return c["cshake"+F].update(A,B,i,e)[t]()}},I=function(F,A,t){return function(A,B,i,e){return c["kmac"+F].update(A,B,i,e)[t]()}},w=function(F,A,t,B){for(var i=0;i>5,this.byteCount=this.blockCount<<2,this.outputBlocks=t>>5,this.extraBytes=(31&t)>>3;for(var B=0;B<50;++B)this.s[B]=0}function U(F,A,t){k.call(this,F,A,t)}k.prototype.update=function(A){if(this.finalized)throw Error("finalize already called");var t,B=typeof A;if("string"!==B){if("object"===B){if(null===A)throw Error(F);if(V&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!V||!ArrayBuffer.isView(A)))throw Error(F)}else throw Error(F);t=!0}for(var i,e,o=this.blocks,s=this.byteCount,h=A.length,a=this.blockCount,r=0,n=this.s;r>2]|=A[r]<>2]|=e<>2]|=(192|e>>6)<=57344?o[i>>2]|=(224|e>>12)<>2]|=(240|e>>18)<>2]|=(128|e>>12&63)<>2]|=(128|e>>6&63)<>2]|=(128|63&e)<=s){for(this.start=i-s,this.block=o[a],i=0;i>=8,t=255&F;t>0;)i.unshift(t),F>>=8,t=255&F,++B;return A?i.push(B):i.unshift(B),this.update(i),i.length},k.prototype.encodeString=function(A){var t,B=typeof A;if("string"!==B){if("object"===B){if(null===A)throw Error(F);if(V&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!V||!ArrayBuffer.isView(A)))throw Error(F)}else throw Error(F);t=!0}var i=0,e=A.length;if(t)i=e;else for(var o=0;o=57344?i+=3:(s=65536+((1023&s)<<10|1023&A.charCodeAt(++o)),i+=4)}return i+=this.encode(8*i),this.update(A),i},k.prototype.bytepad=function(F,A){for(var t=this.encode(A),B=0;B>2]|=this.padding[3&A],this.lastByteIndex===this.byteCount)for(A=1,F[0]=F[t];A>4&15]+o[15&F]+o[F>>12&15]+o[F>>8&15]+o[F>>20&15]+o[F>>16&15]+o[F>>28&15]+o[F>>24&15];V%A==0&&(y(t),e=0)}return i&&(s+=o[(F=t[e])>>4&15]+o[15&F],i>1&&(s+=o[F>>12&15]+o[F>>8&15]),i>2&&(s+=o[F>>20&15]+o[F>>16&15])),s},k.prototype.arrayBuffer=function(){this.finalize();for(var F,A=this.blockCount,t=this.s,B=this.outputBlocks,i=this.extraBytes,e=0,V=0,o=this.outputBits>>3,s=new Uint32Array(F=new ArrayBuffer(i?B+1<<2:o));V>8&255,s[F+2]=A>>16&255,s[F+3]=A>>24&255;o%t==0&&y(B)}return e&&(F=o<<2,A=B[V],s[F]=255&A,e>1&&(s[F+1]=A>>8&255),e>2&&(s[F+2]=A>>16&255)),s},U.prototype=new k,U.prototype.finalize=function(){return this.encode(this.outputBits,!0),k.prototype.finalize.call(this)};var y=function(F){var A,t,B,i,e,V,o,s,q,a,r,n,M,g,l,C,I,w,Q,E,c,m,Y,D,p,u,G,S,k,U,y,K,Z,J,R,d,x,T,L,N,j,W,O,z,f,v,H,b,P,X,$,FF,FA,Ft,FB,Fi,Fe,FV,Fo,Fs,Fq,Fh,Fa;for(B=0;B<48;B+=2)i=F[0]^F[10]^F[20]^F[30]^F[40],e=F[1]^F[11]^F[21]^F[31]^F[41],V=F[2]^F[12]^F[22]^F[32]^F[42],o=F[3]^F[13]^F[23]^F[33]^F[43],s=F[4]^F[14]^F[24]^F[34]^F[44],q=F[5]^F[15]^F[25]^F[35]^F[45],a=F[6]^F[16]^F[26]^F[36]^F[46],r=F[7]^F[17]^F[27]^F[37]^F[47],n=F[8]^F[18]^F[28]^F[38]^F[48],M=F[9]^F[19]^F[29]^F[39]^F[49],A=n^(V<<1|o>>>31),t=M^(o<<1|V>>>31),F[0]^=A,F[1]^=t,F[10]^=A,F[11]^=t,F[20]^=A,F[21]^=t,F[30]^=A,F[31]^=t,F[40]^=A,F[41]^=t,A=i^(s<<1|q>>>31),t=e^(q<<1|s>>>31),F[2]^=A,F[3]^=t,F[12]^=A,F[13]^=t,F[22]^=A,F[23]^=t,F[32]^=A,F[33]^=t,F[42]^=A,F[43]^=t,A=V^(a<<1|r>>>31),t=o^(r<<1|a>>>31),F[4]^=A,F[5]^=t,F[14]^=A,F[15]^=t,F[24]^=A,F[25]^=t,F[34]^=A,F[35]^=t,F[44]^=A,F[45]^=t,A=s^(n<<1|M>>>31),t=q^(M<<1|n>>>31),F[6]^=A,F[7]^=t,F[16]^=A,F[17]^=t,F[26]^=A,F[27]^=t,F[36]^=A,F[37]^=t,F[46]^=A,F[47]^=t,A=a^(i<<1|e>>>31),t=r^(e<<1|i>>>31),F[8]^=A,F[9]^=t,F[18]^=A,F[19]^=t,F[28]^=A,F[29]^=t,F[38]^=A,F[39]^=t,F[48]^=A,F[49]^=t,g=F[0],l=F[1],v=F[11]<<4|F[10]>>>28,H=F[10]<<4|F[11]>>>28,S=F[20]<<3|F[21]>>>29,k=F[21]<<3|F[20]>>>29,Fs=F[31]<<9|F[30]>>>23,Fq=F[30]<<9|F[31]>>>23,W=F[40]<<18|F[41]>>>14,O=F[41]<<18|F[40]>>>14,J=F[2]<<1|F[3]>>>31,R=F[3]<<1|F[2]>>>31,C=F[13]<<12|F[12]>>>20,I=F[12]<<12|F[13]>>>20,b=F[22]<<10|F[23]>>>22,P=F[23]<<10|F[22]>>>22,U=F[33]<<13|F[32]>>>19,y=F[32]<<13|F[33]>>>19,Fh=F[42]<<2|F[43]>>>30,Fa=F[43]<<2|F[42]>>>30,Ft=F[5]<<30|F[4]>>>2,FB=F[4]<<30|F[5]>>>2,d=F[14]<<6|F[15]>>>26,x=F[15]<<6|F[14]>>>26,w=F[25]<<11|F[24]>>>21,Q=F[24]<<11|F[25]>>>21,X=F[34]<<15|F[35]>>>17,$=F[35]<<15|F[34]>>>17,K=F[45]<<29|F[44]>>>3,Z=F[44]<<29|F[45]>>>3,D=F[6]<<28|F[7]>>>4,p=F[7]<<28|F[6]>>>4,Fi=F[17]<<23|F[16]>>>9,Fe=F[16]<<23|F[17]>>>9,T=F[26]<<25|F[27]>>>7,L=F[27]<<25|F[26]>>>7,E=F[36]<<21|F[37]>>>11,c=F[37]<<21|F[36]>>>11,FF=F[47]<<24|F[46]>>>8,FA=F[46]<<24|F[47]>>>8,z=F[8]<<27|F[9]>>>5,f=F[9]<<27|F[8]>>>5,u=F[18]<<20|F[19]>>>12,G=F[19]<<20|F[18]>>>12,FV=F[29]<<7|F[28]>>>25,Fo=F[28]<<7|F[29]>>>25,N=F[38]<<8|F[39]>>>24,j=F[39]<<8|F[38]>>>24,m=F[48]<<14|F[49]>>>18,Y=F[49]<<14|F[48]>>>18,F[0]=g^~C&w,F[1]=l^~I&Q,F[10]=D^~u&S,F[11]=p^~G&k,F[20]=J^~d&T,F[21]=R^~x&L,F[30]=z^~v&b,F[31]=f^~H&P,F[40]=Ft^~Fi&FV,F[41]=FB^~Fe&Fo,F[2]=C^~w&E,F[3]=I^~Q&c,F[12]=u^~S&U,F[13]=G^~k&y,F[22]=d^~T&N,F[23]=x^~L&j,F[32]=v^~b&X,F[33]=H^~P&$,F[42]=Fi^~FV&Fs,F[43]=Fe^~Fo&Fq,F[4]=w^~E&m,F[5]=Q^~c&Y,F[14]=S^~U&K,F[15]=k^~y&Z,F[24]=T^~N&W,F[25]=L^~j&O,F[34]=b^~X&FF,F[35]=P^~$&FA,F[44]=FV^~Fs&Fh,F[45]=Fo^~Fq&Fa,F[6]=E^~m&g,F[7]=c^~Y&l,F[16]=U^~K&D,F[17]=y^~Z&p,F[26]=N^~W&J,F[27]=j^~O&R,F[36]=X^~FF&z,F[37]=$^~FA&f,F[46]=Fs^~Fh&Ft,F[47]=Fq^~Fa&FB,F[8]=m^~g&C,F[9]=Y^~l&I,F[18]=K^~D&u,F[19]=Z^~p&G,F[28]=W^~J&d,F[29]=O^~R&x,F[38]=FF^~z&v,F[39]=FA^~f&H,F[48]=Fh^~Ft&Fi,F[49]=Fa^~FB&Fe,F[0]^=h[B],F[1]^=h[B+1]};if(i)nh=c;else{for(Y=0;Y>=8;return A}function nu(F,A,t){let B=0;for(let i=0;iA+1+B&&nD.throwError("child data too short",rp.errors.BUFFER_OVERRUN,{})}return{consumed:1+B,result:i}}function nk(F,A){if(0===F.length&&nD.throwError("data too short",rp.errors.BUFFER_OVERRUN,{}),F[A]>=248){let t=F[A]-247;A+1+t>F.length&&nD.throwError("data short segment too short",rp.errors.BUFFER_OVERRUN,{});let B=nu(F,A+1,t);return A+1+t+B>F.length&&nD.throwError("data long segment too short",rp.errors.BUFFER_OVERRUN,{}),nS(F,A,A+1+t,t+B)}if(F[A]>=192){let t=F[A]-192;return A+1+t>F.length&&nD.throwError("data array too short",rp.errors.BUFFER_OVERRUN,{}),nS(F,A,A+1,t)}if(F[A]>=184){let t=F[A]-183;A+1+t>F.length&&nD.throwError("data array too short",rp.errors.BUFFER_OVERRUN,{});let B=nu(F,A+1,t);A+1+t+B>F.length&&nD.throwError("data array too short",rp.errors.BUFFER_OVERRUN,{});let i=rT(F.slice(A+1+t,A+1+t+B));return{consumed:1+t+B,result:i}}if(F[A]>=128){let t=F[A]-128;A+1+t>F.length&&nD.throwError("data too short",rp.errors.BUFFER_OVERRUN,{});let B=rT(F.slice(A+1,A+1+t));return{consumed:1+t,result:B}}return{consumed:1,result:rT(F[A])}}function nU(F){let A=rK(F),t=nk(A,0);return t.consumed!==A.length&&nD.throwArgumentError("invalid rlp data","data",F),t.result}let ny=new rp("address/5.7.0");function nK(F){rd(F,20)||ny.throwArgumentError("invalid address","address",F);let A=(F=F.toLowerCase()).substring(2).split(""),t=new Uint8Array(40);for(let F=0;F<40;F++)t[F]=A[F].charCodeAt(0);let B=rK(nm(t));for(let F=0;F<40;F+=2)B[F>>1]>>4>=8&&(A[F]=A[F].toUpperCase()),(15&B[F>>1])>=8&&(A[F+1]=A[F+1].toUpperCase());return"0x"+A.join("")}let nZ={};for(let F=0;F<10;F++)nZ[String(F)]=String(F);for(let F=0;F<26;F++)nZ[String.fromCharCode(65+F)]=String(10+F);let nJ=Math.floor(Math.log10?Math.log10(9007199254740991):Math.log(9007199254740991)/Math.LN10);function nR(F){let A=(F=(F=F.toUpperCase()).substring(4)+F.substring(0,2)+"00").split("").map(F=>nZ[F]).join("");for(;A.length>=nJ;){let F=A.substring(0,nJ);A=parseInt(F,10)%97+A.substring(F.length)}let t=String(98-parseInt(A,10)%97);for(;t.length<2;)t="0"+t;return t}function nd(F){let A=null;if("string"!=typeof F&&ny.throwArgumentError("invalid address","address",F),F.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==F.substring(0,2)&&(F="0x"+F),A=nK(F),F.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&A!==F&&ny.throwArgumentError("bad address checksum","address",F);else if(F.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(F.substring(2,4)!==nR(F)&&ny.throwArgumentError("bad icap checksum","address",F),A=new r6(F.substring(4),36).toString(16);A.length<40;)A="0"+A;A=nK("0x"+A)}else ny.throwArgumentError("invalid address","address",F);return A}function nx(F){try{return nd(F),!0}catch(F){}return!1}function nT(F){let A=new r6(nd(F).substring(2),16).toString(36).toUpperCase();for(;A.length<30;)A="0"+A;return"XE"+nR("XE00"+A)+A}function nL(F){let A=null;try{A=nd(F.from)}catch(A){ny.throwArgumentError("missing from address","transaction",F)}return nd(rN(nm(nG([A,rJ(rK(nF.from(F.nonce).toHexString()))])),12))}function nN(F,A,t){return 32!==rL(A)&&ny.throwArgumentError("salt must be 32 bytes","salt",A),32!==rL(t)&&ny.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",t),nd(rN(nm(rZ(["0xff",nd(F),A,t])),12))}class nj extends no{constructor(F){super("address","address",F,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(F,A){try{A=nd(A)}catch(F){this._throwError(F.message,A)}return F.writeValue(A)}decode(F){return nd(rz(F.readValue().toHexString(),20))}}class nW extends no{constructor(F){super(F.name,F.type,void 0,F.dynamic),this.coder=F}defaultValue(){return this.coder.defaultValue()}encode(F,A){return this.coder.encode(F,A)}decode(F){return this.coder.decode(F)}}let nO=new rp(r4);function nz(F,A,t){let B=null;if(Array.isArray(t))B=t;else if(t&&"object"==typeof t){let F={};B=A.map(A=>{let B=A.localName;return B||nO.throwError("cannot encode object for signature with missing names",rp.errors.INVALID_ARGUMENT,{argument:"values",coder:A,value:t}),F[B]&&nO.throwError("cannot encode object for signature with duplicate names",rp.errors.INVALID_ARGUMENT,{argument:"values",coder:A,value:t}),F[B]=!0,t[B]})}else nO.throwArgumentError("invalid tuple value","tuple",t);A.length!==B.length&&nO.throwArgumentError("types/value length mismatch","tuple",t);let i=new ns(F.wordSize),e=new ns(F.wordSize),V=[];return A.forEach((F,A)=>{let t=B[A];if(F.dynamic){let A=e.length;F.encode(e,t);let B=i.writeUpdatableValue();V.push(F=>{B(F+A)})}else F.encode(i,t)}),V.forEach(F=>{F(i.length)}),F.appendWriter(i)+F.appendWriter(e)}function nf(F,A){let t=[],B=F.subReader(0);A.forEach(A=>{let i=null;if(A.dynamic){let t=F.readValue(),e=B.subReader(t.toNumber());try{i=A.decode(e)}catch(F){if(F.code===rp.errors.BUFFER_OVERRUN)throw F;(i=F).baseType=A.name,i.name=A.localName,i.type=A.type}}else try{i=A.decode(F)}catch(F){if(F.code===rp.errors.BUFFER_OVERRUN)throw F;(i=F).baseType=A.name,i.name=A.localName,i.type=A.type}void 0!=i&&t.push(i)});let i=A.reduce((F,A)=>{let t=A.localName;return t&&(F[t]||(F[t]=0),F[t]++),F},{});A.forEach((F,A)=>{let B=F.localName;if(!B||1!==i[B]||("length"===B&&(B="_length"),null!=t[B]))return;let e=t[A];e instanceof Error?Object.defineProperty(t,B,{enumerable:!0,get:()=>{throw e}}):t[B]=e});for(let F=0;F{throw A}})}return Object.freeze(t)}class nv extends no{constructor(F,A,t){super("array",F.type+"["+(A>=0?A:"")+"]",t,-1===A||F.dynamic),this.coder=F,this.length=A}defaultValue(){let F=this.coder.defaultValue(),A=[];for(let t=0;tF._data.length&&nO.throwError("insufficient data length",rp.errors.BUFFER_OVERRUN,{length:F._data.length,count:A});let t=[];for(let F=0;F>6==2;B++)F++;return F}return F===AK.OVERRUN?t.length-A-1:0}(Am=Ay||(Ay={})).current="",Am.NFC="NFC",Am.NFD="NFD",Am.NFKC="NFKC",Am.NFKD="NFKD",(AY=AK||(AK={})).UNEXPECTED_CONTINUE="unexpected continuation byte",AY.BAD_PREFIX="bad codepoint prefix",AY.OVERRUN="string overrun",AY.MISSING_CONTINUE="missing continuation byte",AY.OUT_OF_RANGE="out of UTF-8 range",AY.UTF16_SURROGATE="UTF-16 surrogate",AY.OVERLONG="overlong representation";let n6=Object.freeze({error:function(F,A,t,B,i){return n5.throwArgumentError(`invalid codepoint at offset ${A}; ${F}`,"bytes",t)},ignore:n8,replace:function(F,A,t,B,i){return F===AK.OVERLONG?(B.push(i),0):(B.push(65533),n8(F,A,t,B,i))}});function n3(F,A){null==A&&(A=n6.error),F=rK(F);let t=[],B=0;for(;B>7==0){t.push(i);continue}let e=null,V=null;if((224&i)==192)e=1,V=127;else if((240&i)==224)e=2,V=2047;else if((248&i)==240)e=3,V=65535;else{(192&i)==128?B+=A(AK.UNEXPECTED_CONTINUE,B-1,F,t):B+=A(AK.BAD_PREFIX,B-1,F,t);continue}if(B-1+e>=F.length){B+=A(AK.OVERRUN,B-1,F,t);continue}let o=i&(1<<8-e-1)-1;for(let i=0;i1114111){B+=A(AK.OUT_OF_RANGE,B-1-e,F,t,o);continue}if(o>=55296&&o<=57343){B+=A(AK.UTF16_SURROGATE,B-1-e,F,t,o);continue}if(o<=V){B+=A(AK.OVERLONG,B-1-e,F,t,o);continue}t.push(o)}}return t}function n9(F,A=Ay.current){A!=Ay.current&&(n5.checkNormalize(),F=F.normalize(A));let t=[];for(let A=0;A>6|192),t.push(63&B|128);else if((64512&B)==55296){A++;let i=F.charCodeAt(A);if(A>=F.length||(64512&i)!=56320)throw Error("invalid utf-8 string");let e=65536+((1023&B)<<10)+(1023&i);t.push(e>>18|240),t.push(e>>12&63|128),t.push(e>>6&63|128),t.push(63&e|128)}else t.push(B>>12|224),t.push(B>>6&63|128),t.push(63&B|128)}return rK(t)}function n7(F){let A="0000"+F.toString(16);return"\\u"+A.substring(A.length-4)}function MF(F,A){return'"'+n3(F,A).map(F=>{if(F<256){switch(F){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(F>=32&&F<127)return String.fromCharCode(F)}return F<=65535?n7(F):n7(((F-=65536)>>10&1023)+55296)+n7((1023&F)+56320)}).join("")+'"'}function MA(F){return F.map(F=>F<=65535?String.fromCharCode(F):String.fromCharCode(((F-=65536)>>10&1023)+55296,(1023&F)+56320)).join("")}function Mt(F,A){return MA(n3(F,A))}function MB(F,A=Ay.current){return n3(n9(F,A))}class Mi extends nb{constructor(F){super("string",F)}defaultValue(){return""}encode(F,A){return super.encode(F,n9(A))}decode(F){return Mt(super.decode(F))}}class Me extends no{constructor(F,A){let t=!1,B=[];F.forEach(F=>{F.dynamic&&(t=!0),B.push(F.type)}),super("tuple","tuple("+B.join(",")+")",A,t),this.coders=F}defaultValue(){let F=[];this.coders.forEach(A=>{F.push(A.defaultValue())});let A=this.coders.reduce((F,A)=>{let t=A.localName;return t&&(F[t]||(F[t]=0),F[t]++),F},{});return this.coders.forEach((t,B)=>{let i=t.localName;i&&1===A[i]&&("length"===i&&(i="_length"),null==F[i]&&(F[i]=F[B]))}),Object.freeze(F)}encode(F,A){return nz(F,this.coders,A)}decode(F){return F.coerce(this.name,nf(F,this.coders))}}let MV=new rp(r4),Mo={},Ms={calldata:!0,memory:!0,storage:!0},Mq={calldata:!0,memory:!0};function Mh(F,A){if("bytes"===F||"string"===F){if(Ms[A])return!0}else if("address"===F){if("payable"===A)return!0}else if((F.indexOf("[")>=0||"tuple"===F)&&Mq[A])return!0;return(Ms[A]||"payable"===A)&&MV.throwArgumentError("invalid modifier","name",A),!1}function Ma(F,A){for(let t in A)rb(F,t,A[t])}let Mr=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),Mn=new RegExp(/^(.*)\[([0-9]*)\]$/);class MM{constructor(F,A){F!==Mo&&MV.throwError("use fromString",rp.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),Ma(this,A);let t=this.type.match(Mn);t?Ma(this,{arrayLength:parseInt(t[2]||"-1"),arrayChildren:MM.fromObject({type:t[1],components:this.components}),baseType:"array"}):Ma(this,{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json){let A={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(A.indexed=this.indexed),this.components&&(A.components=this.components.map(A=>JSON.parse(A.format(F)))),JSON.stringify(A)}let A="";return"array"===this.baseType?A+=this.arrayChildren.format(F)+"["+(this.arrayLength<0?"":String(this.arrayLength))+"]":"tuple"===this.baseType?(F!==Mr.sighash&&(A+=this.type),A+="("+this.components.map(A=>A.format(F)).join(F===Mr.full?", ":",")+")"):A+=this.type,F!==Mr.sighash&&(!0===this.indexed&&(A+=" indexed"),F===Mr.full&&this.name&&(A+=" "+this.name)),A}static from(F,A){return"string"==typeof F?MM.fromString(F,A):MM.fromObject(F)}static fromObject(F){return MM.isParamType(F)?F:new MM(Mo,{name:F.name||null,type:MD(F.type),indexed:null==F.indexed?null:!!F.indexed,components:F.components?F.components.map(MM.fromObject):null})}static fromString(F,A){var t;return t=function(F,A){let t=F;function B(A){MV.throwArgumentError(`unexpected character at position ${A}`,"param",F)}function i(F){let t={type:"",name:"",parent:F,state:{allowType:!0}};return A&&(t.indexed=!1),t}F=F.replace(/\s/g," ");let e={type:"",name:"",state:{allowType:!0}},V=e;for(let t=0;tMM.fromString(F,A))}class Ml{constructor(F,A){F!==Mo&&MV.throwError("use a static from method",rp.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),Ma(this,A),this._isFragment=!0,Object.freeze(this)}static from(F){return Ml.isFragment(F)?F:"string"==typeof F?Ml.fromString(F):Ml.fromObject(F)}static fromObject(F){if(Ml.isFragment(F))return F;switch(F.type){case"function":return Mc.fromObject(F);case"event":return MC.fromObject(F);case"constructor":return ME.fromObject(F);case"error":return MY.fromObject(F);case"fallback":case"receive":return null}return MV.throwArgumentError("invalid fragment object","value",F)}static fromString(F){return"event"===(F=(F=(F=F.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?MC.fromString(F.substring(5).trim()):"function"===F.split(" ")[0]?Mc.fromString(F.substring(8).trim()):"constructor"===F.split("(")[0].trim()?ME.fromString(F.trim()):"error"===F.split(" ")[0]?MY.fromString(F.substring(5).trim()):MV.throwArgumentError("unsupported fragment","value",F)}static isFragment(F){return!!(F&&F._isFragment)}}class MC extends Ml{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(A=>JSON.parse(A.format(F)))});let A="";return F!==Mr.sighash&&(A+="event "),A+=this.name+"("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ",F!==Mr.sighash&&this.anonymous&&(A+="anonymous "),A.trim()}static from(F){return"string"==typeof F?MC.fromString(F):MC.fromObject(F)}static fromObject(F){return MC.isEventFragment(F)?F:("event"!==F.type&&MV.throwArgumentError("invalid event object","value",F),new MC(Mo,{name:Mu(F.name),anonymous:F.anonymous,inputs:F.inputs?F.inputs.map(MM.fromObject):[],type:"event"}))}static fromString(F){let A=F.match(MG);A||MV.throwArgumentError("invalid event string","value",F);let t=!1;return A[3].split(" ").forEach(F=>{switch(F.trim()){case"anonymous":t=!0;break;case"":break;default:MV.warn("unknown modifier: "+F)}}),MC.fromObject({name:A[1].trim(),anonymous:t,inputs:Mg(A[2],!0),type:"event"})}static isEventFragment(F){return F&&F._isFragment&&"event"===F.type}}function MI(F,A){A.gas=null;let t=F.split("@");return 1!==t.length?(t.length>2&&MV.throwArgumentError("invalid human-readable ABI signature","value",F),t[1].match(/^[0-9]+$/)||MV.throwArgumentError("invalid human-readable ABI signature gas","value",F),A.gas=nF.from(t[1]),t[0]):F}function Mw(F,A){A.constant=!1,A.payable=!1,A.stateMutability="nonpayable",F.split(" ").forEach(F=>{switch(F.trim()){case"constant":A.constant=!0;break;case"payable":A.payable=!0,A.stateMutability="payable";break;case"nonpayable":A.payable=!1,A.stateMutability="nonpayable";break;case"pure":A.constant=!0,A.stateMutability="pure";break;case"view":A.constant=!0,A.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+F)}})}function MQ(F){let A={constant:!1,payable:!0,stateMutability:"payable"};return null!=F.stateMutability?(A.stateMutability=F.stateMutability,A.constant="view"===A.stateMutability||"pure"===A.stateMutability,null!=F.constant&&!!F.constant!==A.constant&&MV.throwArgumentError("cannot have constant function with mutability "+A.stateMutability,"value",F),A.payable="payable"===A.stateMutability,null!=F.payable&&!!F.payable!==A.payable&&MV.throwArgumentError("cannot have payable function with mutability "+A.stateMutability,"value",F)):null!=F.payable?(A.payable=!!F.payable,null!=F.constant||A.payable||"constructor"===F.type||MV.throwArgumentError("unable to determine stateMutability","value",F),A.constant=!!F.constant,A.constant?A.stateMutability="view":A.stateMutability=A.payable?"payable":"nonpayable",A.payable&&A.constant&&MV.throwArgumentError("cannot have constant payable function","value",F)):null!=F.constant?(A.constant=!!F.constant,A.payable=!A.constant,A.stateMutability=A.constant?"view":"payable"):"constructor"!==F.type&&MV.throwArgumentError("unable to determine stateMutability","value",F),A}class ME extends Ml{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(A=>JSON.parse(A.format(F)))});F===Mr.sighash&&MV.throwError("cannot format a constructor for sighash",rp.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let A="constructor("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(A+=this.stateMutability+" "),A.trim()}static from(F){return"string"==typeof F?ME.fromString(F):ME.fromObject(F)}static fromObject(F){if(ME.isConstructorFragment(F))return F;"constructor"!==F.type&&MV.throwArgumentError("invalid constructor object","value",F);let A=MQ(F);return A.constant&&MV.throwArgumentError("constructor cannot be constant","value",F),new ME(Mo,{name:null,type:F.type,inputs:F.inputs?F.inputs.map(MM.fromObject):[],payable:A.payable,stateMutability:A.stateMutability,gas:F.gas?nF.from(F.gas):null})}static fromString(F){let A={type:"constructor"},t=(F=MI(F,A)).match(MG);return t&&"constructor"===t[1].trim()||MV.throwArgumentError("invalid constructor string","value",F),A.inputs=Mg(t[2].trim(),!1),Mw(t[3].trim(),A),ME.fromObject(A)}static isConstructorFragment(F){return F&&F._isFragment&&"constructor"===F.type}}class Mc extends ME{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(A=>JSON.parse(A.format(F))),outputs:this.outputs.map(A=>JSON.parse(A.format(F)))});let A="";return F!==Mr.sighash&&(A+="function "),A+=this.name+"("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ",F!==Mr.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(A+=this.stateMutability+" "):this.constant&&(A+="view "),this.outputs&&this.outputs.length&&(A+="returns ("+this.outputs.map(A=>A.format(F)).join(", ")+") "),null!=this.gas&&(A+="@"+this.gas.toString()+" ")),A.trim()}static from(F){return"string"==typeof F?Mc.fromString(F):Mc.fromObject(F)}static fromObject(F){if(Mc.isFunctionFragment(F))return F;"function"!==F.type&&MV.throwArgumentError("invalid function object","value",F);let A=MQ(F);return new Mc(Mo,{type:F.type,name:Mu(F.name),constant:A.constant,inputs:F.inputs?F.inputs.map(MM.fromObject):[],outputs:F.outputs?F.outputs.map(MM.fromObject):[],payable:A.payable,stateMutability:A.stateMutability,gas:F.gas?nF.from(F.gas):null})}static fromString(F){let A={type:"function"},t=(F=MI(F,A)).split(" returns ");t.length>2&&MV.throwArgumentError("invalid function string","value",F);let B=t[0].match(MG);if(B||MV.throwArgumentError("invalid function signature","value",F),A.name=B[1].trim(),A.name&&Mu(A.name),A.inputs=Mg(B[2],!1),Mw(B[3].trim(),A),t.length>1){let B=t[1].match(MG);(""!=B[1].trim()||""!=B[3].trim())&&MV.throwArgumentError("unexpected tokens","value",F),A.outputs=Mg(B[2],!1)}else A.outputs=[];return Mc.fromObject(A)}static isFunctionFragment(F){return F&&F._isFragment&&"function"===F.type}}function Mm(F){let A=F.format();return("Error(string)"===A||"Panic(uint256)"===A)&&MV.throwArgumentError(`cannot specify user defined ${A} error`,"fragment",F),F}class MY extends Ml{format(F){if(F||(F=Mr.sighash),Mr[F]||MV.throwArgumentError("invalid format type","format",F),F===Mr.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(A=>JSON.parse(A.format(F)))});let A="";return F!==Mr.sighash&&(A+="error "),(A+=this.name+"("+this.inputs.map(A=>A.format(F)).join(F===Mr.full?", ":",")+") ").trim()}static from(F){return"string"==typeof F?MY.fromString(F):MY.fromObject(F)}static fromObject(F){return MY.isErrorFragment(F)?F:("error"!==F.type&&MV.throwArgumentError("invalid error object","value",F),Mm(new MY(Mo,{type:F.type,name:Mu(F.name),inputs:F.inputs?F.inputs.map(MM.fromObject):[]})))}static fromString(F){let A={type:"error"},t=F.match(MG);return t||MV.throwArgumentError("invalid error signature","value",F),A.name=t[1].trim(),A.name&&Mu(A.name),A.inputs=Mg(t[2],!1),Mm(MY.fromObject(A))}static isErrorFragment(F){return F&&F._isFragment&&"error"===F.type}}function MD(F){return F.match(/^uint($|[^1-9])/)?F="uint256"+F.substring(4):F.match(/^int($|[^1-9])/)&&(F="int256"+F.substring(3)),F}let Mp=RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Mu(F){return F&&F.match(Mp)||MV.throwArgumentError(`invalid identifier "${F}"`,"value",F),F}let MG=RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"),MS=new rp(r4),Mk=new RegExp(/^bytes([0-9]*)$/),MU=new RegExp(/^(u?int)([0-9]*)$/);class My{constructor(F){rb(this,"coerceFunc",F||null)}_getCoder(F){switch(F.baseType){case"address":return new nj(F.name);case"bool":return new nH(F.name);case"string":return new Mi(F.name);case"bytes":return new nP(F.name);case"array":return new nv(this._getCoder(F.arrayChildren),F.arrayLength,F.name);case"tuple":return new Me((F.components||[]).map(F=>this._getCoder(F)),F.name);case"":return new n_(F.name)}let A=F.type.match(MU);if(A){let t=parseInt(A[2]||"256");return(0===t||t>256||t%8!=0)&&MS.throwArgumentError("invalid "+A[1]+" bit length","param",F),new n4(t/8,"int"===A[1],F.name)}if(A=F.type.match(Mk)){let t=parseInt(A[1]);return(0===t||t>32)&&MS.throwArgumentError("invalid bytes length","param",F),new nX(t,F.name)}return MS.throwArgumentError("invalid type","type",F.type)}_getWordSize(){return 32}_getReader(F,A){return new nq(F,this._getWordSize(),this.coerceFunc,A)}_getWriter(){return new ns(this._getWordSize())}getDefaultValue(F){return new Me(F.map(F=>this._getCoder(MM.from(F))),"_").defaultValue()}encode(F,A){F.length!==A.length&&MS.throwError("types/values length mismatch",rp.errors.INVALID_ARGUMENT,{count:{types:F.length,values:A.length},value:{types:F,values:A}});let t=new Me(F.map(F=>this._getCoder(MM.from(F))),"_"),B=this._getWriter();return t.encode(B,A),B.data}decode(F,A,t){return new Me(F.map(F=>this._getCoder(MM.from(F))),"_").decode(this._getReader(rK(A),t))}}let MK=new My;function MZ(F){return nm(n9(F))}let MJ=new rp(r4);class MR extends r1{}class Md extends r1{}class Mx extends r1{}class MT extends r1{static isIndexed(F){return!!(F&&F._isIndexed)}}let ML={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function MN(F,A){let t=Error(`deferred error during ABI decoding triggered accessing ${F}`);return t.error=A,t}class Mj{constructor(F){rb(this,"fragments",("string"==typeof F?JSON.parse(F):F).map(F=>Ml.from(F)).filter(F=>null!=F)),rb(this,"_abiCoder",rP(new.target,"getAbiCoder")()),rb(this,"functions",{}),rb(this,"errors",{}),rb(this,"events",{}),rb(this,"structs",{}),this.fragments.forEach(F=>{let A=null;switch(F.type){case"constructor":if(this.deploy){MJ.warn("duplicate definition - constructor");return}rb(this,"deploy",F);return;case"function":A=this.functions;break;case"event":A=this.events;break;case"error":A=this.errors;break;default:return}let t=F.format();if(A[t]){MJ.warn("duplicate definition - "+t);return}A[t]=F}),this.deploy||rb(this,"deploy",ME.from({payable:!1,type:"constructor"})),rb(this,"_isInterface",!0)}format(F){F||(F=Mr.full),F===Mr.sighash&&MJ.throwArgumentError("interface does not support formatting sighash","format",F);let A=this.fragments.map(A=>A.format(F));return F===Mr.json?JSON.stringify(A.map(F=>JSON.parse(F))):A}static getAbiCoder(){return MK}static getAddress(F){return nd(F)}static getSighash(F){return rN(MZ(F.format()),0,4)}static getEventTopic(F){return MZ(F.format())}getFunction(F){if(rd(F)){for(let A in this.functions)if(F===this.getSighash(A))return this.functions[A];MJ.throwArgumentError("no matching function","sighash",F)}if(-1===F.indexOf("(")){let A=F.trim(),t=Object.keys(this.functions).filter(F=>F.split("(")[0]===A);return 0===t.length?MJ.throwArgumentError("no matching function","name",A):t.length>1&&MJ.throwArgumentError("multiple matching functions","name",A),this.functions[t[0]]}let A=this.functions[Mc.fromString(F).format()];return A||MJ.throwArgumentError("no matching function","signature",F),A}getEvent(F){if(rd(F)){let A=F.toLowerCase();for(let F in this.events)if(A===this.getEventTopic(F))return this.events[F];MJ.throwArgumentError("no matching event","topichash",A)}if(-1===F.indexOf("(")){let A=F.trim(),t=Object.keys(this.events).filter(F=>F.split("(")[0]===A);return 0===t.length?MJ.throwArgumentError("no matching event","name",A):t.length>1&&MJ.throwArgumentError("multiple matching events","name",A),this.events[t[0]]}let A=this.events[MC.fromString(F).format()];return A||MJ.throwArgumentError("no matching event","signature",F),A}getError(F){if(rd(F)){let A=rP(this.constructor,"getSighash");for(let t in this.errors)if(F===A(this.errors[t]))return this.errors[t];MJ.throwArgumentError("no matching error","sighash",F)}if(-1===F.indexOf("(")){let A=F.trim(),t=Object.keys(this.errors).filter(F=>F.split("(")[0]===A);return 0===t.length?MJ.throwArgumentError("no matching error","name",A):t.length>1&&MJ.throwArgumentError("multiple matching errors","name",A),this.errors[t[0]]}let A=this.errors[Mc.fromString(F).format()];return A||MJ.throwArgumentError("no matching error","signature",F),A}getSighash(F){if("string"==typeof F)try{F=this.getFunction(F)}catch(A){try{F=this.getError(F)}catch(F){throw A}}return rP(this.constructor,"getSighash")(F)}getEventTopic(F){return"string"==typeof F&&(F=this.getEvent(F)),rP(this.constructor,"getEventTopic")(F)}_decodeParams(F,A){return this._abiCoder.decode(F,A)}_encodeParams(F,A){return this._abiCoder.encode(F,A)}encodeDeploy(F){return this._encodeParams(this.deploy.inputs,F||[])}decodeErrorResult(F,A){"string"==typeof F&&(F=this.getError(F));let t=rK(A);return rT(t.slice(0,4))!==this.getSighash(F)&&MJ.throwArgumentError(`data signature does not match error ${F.name}.`,"data",rT(t)),this._decodeParams(F.inputs,t.slice(4))}encodeErrorResult(F,A){return"string"==typeof F&&(F=this.getError(F)),rT(rZ([this.getSighash(F),this._encodeParams(F.inputs,A||[])]))}decodeFunctionData(F,A){"string"==typeof F&&(F=this.getFunction(F));let t=rK(A);return rT(t.slice(0,4))!==this.getSighash(F)&&MJ.throwArgumentError(`data signature does not match function ${F.name}.`,"data",rT(t)),this._decodeParams(F.inputs,t.slice(4))}encodeFunctionData(F,A){return"string"==typeof F&&(F=this.getFunction(F)),rT(rZ([this.getSighash(F),this._encodeParams(F.inputs,A||[])]))}decodeFunctionResult(F,A){"string"==typeof F&&(F=this.getFunction(F));let t=rK(A),B=null,i="",e=null,V=null,o=null;switch(t.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(F.outputs,t)}catch(F){}break;case 4:{let F=rT(t.slice(0,4)),A=ML[F];if(A)e=this._abiCoder.decode(A.inputs,t.slice(4)),V=A.name,o=A.signature,A.reason&&(B=e[0]),"Error"===V?i=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(e[0])}`:"Panic"===V&&(i=`; VM Exception while processing transaction: reverted with panic code ${e[0]}`);else try{let A=this.getError(F);e=this._abiCoder.decode(A.inputs,t.slice(4)),V=A.name,o=A.format()}catch(F){}}}return MJ.throwError("call revert exception"+i,rp.errors.CALL_EXCEPTION,{method:F.format(),data:rT(A),errorArgs:e,errorName:V,errorSignature:o,reason:B})}encodeFunctionResult(F,A){return"string"==typeof F&&(F=this.getFunction(F)),rT(this._abiCoder.encode(F.outputs,A||[]))}encodeFilterTopics(F,A){"string"==typeof F&&(F=this.getEvent(F)),A.length>F.inputs.length&&MJ.throwError("too many arguments for "+F.format(),rp.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:A});let t=[];F.anonymous||t.push(this.getEventTopic(F));let B=(F,A)=>"string"===F.type?MZ(A):"bytes"===F.type?nm(rT(A)):("bool"===F.type&&"boolean"==typeof A&&(A=A?"0x01":"0x00"),F.type.match(/^u?int/)&&(A=nF.from(A).toHexString()),"address"===F.type&&this._abiCoder.encode(["address"],[A]),rz(rT(A),32));for(A.forEach((A,i)=>{let e=F.inputs[i];if(!e.indexed){null!=A&&MJ.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+e.name,A);return}null==A?t.push(null):"array"===e.baseType||"tuple"===e.baseType?MJ.throwArgumentError("filtering with tuples or arrays not supported","contract."+e.name,A):Array.isArray(A)?t.push(A.map(F=>B(e,F))):t.push(B(e,A))});t.length&&null===t[t.length-1];)t.pop();return t}encodeEventLog(F,A){"string"==typeof F&&(F=this.getEvent(F));let t=[],B=[],i=[];return F.anonymous||t.push(this.getEventTopic(F)),A.length!==F.inputs.length&&MJ.throwArgumentError("event arguments/values mismatch","values",A),F.inputs.forEach((F,e)=>{let V=A[e];if(F.indexed){if("string"===F.type)t.push(MZ(V));else if("bytes"===F.type)t.push(nm(V));else if("tuple"===F.baseType||"array"===F.baseType)throw Error("not implemented");else t.push(this._abiCoder.encode([F.type],[V]))}else B.push(F),i.push(V)}),{data:this._abiCoder.encode(B,i),topics:t}}decodeEventLog(F,A,t){if("string"==typeof F&&(F=this.getEvent(F)),null!=t&&!F.anonymous){let A=this.getEventTopic(F);rd(t[0],32)&&t[0].toLowerCase()===A||MJ.throwError("fragment/topic mismatch",rp.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:A,value:t[0]}),t=t.slice(1)}let B=[],i=[],e=[];F.inputs.forEach((F,A)=>{F.indexed?"string"===F.type||"bytes"===F.type||"tuple"===F.baseType||"array"===F.baseType?(B.push(MM.fromObject({type:"bytes32",name:F.name})),e.push(!0)):(B.push(F),e.push(!1)):(i.push(F),e.push(!1))});let V=null!=t?this._abiCoder.decode(B,rZ(t)):null,o=this._abiCoder.decode(i,A,!0),s=[],q=0,h=0;F.inputs.forEach((F,A)=>{if(F.indexed){if(null==V)s[A]=new MT({_isIndexed:!0,hash:null});else if(e[A])s[A]=new MT({_isIndexed:!0,hash:V[h++]});else try{s[A]=V[h++]}catch(F){s[A]=F}}else try{s[A]=o[q++]}catch(F){s[A]=F}if(F.name&&null==s[F.name]){let t=s[A];t instanceof Error?Object.defineProperty(s,F.name,{enumerable:!0,get:()=>{throw MN(`property ${JSON.stringify(F.name)}`,t)}}):s[F.name]=t}});for(let F=0;F{throw MN(`index ${F}`,A)}})}return Object.freeze(s)}parseTransaction(F){let A=this.getFunction(F.data.substring(0,10).toLowerCase());return A?new Md({args:this._abiCoder.decode(A.inputs,"0x"+F.data.substring(10)),functionFragment:A,name:A.name,signature:A.format(),sighash:this.getSighash(A),value:nF.from(F.value||"0")}):null}parseLog(F){let A=this.getEvent(F.topics[0]);return!A||A.anonymous?null:new MR({eventFragment:A,name:A.name,signature:A.format(),topic:this.getEventTopic(A),args:this.decodeEventLog(A,F.data,F.topics)})}parseError(F){let A=rT(F),t=this.getError(A.substring(0,10).toLowerCase());return t?new Mx({args:this._abiCoder.decode(t.inputs,"0x"+A.substring(10)),errorFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t)}):null}static isInterface(F){return!!(F&&F._isInterface)}}var MW={};function MO(F){F=atob(F);let A=[];for(let t=0;t0;)t.push(B%this.base),B=B/this.base|0}let B="";for(let F=0;0===A[F]&&F=0;--F)B+=this.alphabet[t[F]];return B}decode(F){if("string"!=typeof F)throw TypeError("Expected String");let A=[];if(0===F.length)return new Uint8Array(A);A.push(0);for(let t=0;t>=8;for(;i>0;)A.push(255&i),i>>=8}for(let t=0;F[t]===this._leader&&t256||A[2]&&A[2]!==String(B))&&Mb.throwArgumentError("invalid numeric width","type",F);let i=M2.mask(t?B-1:B),e=t?i.add(M$).mul(MX):M_;return function(A){let t=nF.from(A);return(t.lt(e)||t.gt(i))&&Mb.throwArgumentError(`value out-of-bounds for ${F}`,"value",A),rz(t.toTwos(256).toHexString(),32)}}}{let A=F.match(/^bytes(\d+)$/);if(A){let t=parseInt(A[1]);return(0===t||t>32||A[1]!==String(t))&&Mb.throwArgumentError("invalid bytes width","type",F),function(A){return rK(A).length!==t&&Mb.throwArgumentError(`invalid length for ${F}`,"value",A),function(F){let A=rK(F),t=A.length%32;return t?rj([A,MP.slice(t)]):rT(A)}(A)}}}switch(F){case"address":return function(F){return rz(nd(F),32)};case"bool":return function(F){return F?M0:M1};case"bytes":return function(F){return nm(F)};case"string":return function(F){return MZ(F)}}return null}function M9(F,A){return`${F}(${A.map(({name:F,type:A})=>A+" "+F).join(",")})`}class M7{constructor(F){rb(this,"types",Object.freeze(r0(F))),rb(this,"_encoderCache",{}),rb(this,"_types",{});let A={},t={},B={};for(let i in Object.keys(F).forEach(F=>{A[F]={},t[F]=[],B[F]={}}),F){let B={};F[i].forEach(e=>{B[e.name]&&Mb.throwArgumentError(`duplicate variable name ${JSON.stringify(e.name)} in ${JSON.stringify(i)}`,"types",F),B[e.name]=!0;let V=e.type.match(/^([^\x5b]*)(\x5b|$)/)[1];V===i&&Mb.throwArgumentError(`circular type reference to ${JSON.stringify(V)}`,"types",F),M3(V)||(t[V]||Mb.throwArgumentError(`unknown type ${JSON.stringify(V)}`,"types",F),t[V].push(i),A[i][V]=!0)})}let i=Object.keys(t).filter(F=>0===t[F].length);for(let e in 0===i.length?Mb.throwArgumentError("missing primary type","types",F):i.length>1&&Mb.throwArgumentError(`ambiguous primary types or unused types: ${i.map(F=>JSON.stringify(F)).join(", ")}`,"types",F),rb(this,"primaryType",i[0]),!function i(e,V){V[e]&&Mb.throwArgumentError(`circular type reference to ${JSON.stringify(e)}`,"types",F),V[e]=!0,Object.keys(A[e]).forEach(F=>{t[F]&&(i(F,V),Object.keys(V).forEach(A=>{B[A][F]=!0}))}),delete V[e]}(this.primaryType,{}),B){let A=Object.keys(B[e]);A.sort(),this._types[e]=M9(e,F[e])+A.map(A=>M9(A,F[A])).join("")}}getEncoder(F){let A=this._encoderCache[F];return A||(A=this._encoderCache[F]=this._getEncoder(F)),A}_getEncoder(F){{let A=M3(F);if(A)return A}let A=F.match(/^(.*)(\x5b(\d*)\x5d)$/);if(A){let F=A[1],t=this.getEncoder(F),B=parseInt(A[3]);return A=>{B>=0&&A.length!==B&&Mb.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",A);let i=A.map(t);return this._types[F]&&(i=i.map(nm)),nm(rj(i))}}let t=this.types[F];if(t){let A=MZ(this._types[F]);return F=>{let B=t.map(({name:A,type:t})=>{let B=this.getEncoder(t)(F[A]);return this._types[t]?nm(B):B});return B.unshift(A),rj(B)}}return Mb.throwArgumentError(`unknown type: ${F}`,"type",F)}encodeType(F){let A=this._types[F];return A||Mb.throwArgumentError(`unknown type: ${JSON.stringify(F)}`,"name",F),A}encodeData(F,A){return this.getEncoder(F)(A)}hashStruct(F,A){return nm(this.encodeData(F,A))}encode(F){return this.encodeData(this.primaryType,F)}hash(F){return this.hashStruct(this.primaryType,F)}_visit(F,A,t){if(M3(F))return t(F,A);let B=F.match(/^(.*)(\x5b(\d*)\x5d)$/);if(B){let F=B[1],i=parseInt(B[3]);return i>=0&&A.length!==i&&Mb.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",A),A.map(A=>this._visit(F,A,t))}let i=this.types[F];return i?i.reduce((F,{name:B,type:i})=>(F[B]=this._visit(i,A[B],t),F),{}):Mb.throwArgumentError(`unknown type: ${F}`,"type",F)}visit(F,A){return this._visit(this.primaryType,F,A)}static from(F){return new M7(F)}static getPrimaryType(F){return M7.from(F).primaryType}static hashStruct(F,A,t){return M7.from(A).hashStruct(F,t)}static hashDomain(F){let A=[];for(let t in F){let B=M4[t];B||Mb.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",F),A.push({name:t,type:B})}return A.sort((F,A)=>M5.indexOf(F.name)-M5.indexOf(A.name)),M7.hashStruct("EIP712Domain",{EIP712Domain:A},F)}static encode(F,A,t){return rj(["0x1901",M7.hashDomain(F),M7.from(A).hash(t)])}static hash(F,A,t){return nm(M7.encode(F,A,t))}static resolveNames(F,A,t,B){var i,e,V,o;return i=this,e=void 0,V=void 0,o=function*(){F=r$(F);let i={};F.verifyingContract&&!rd(F.verifyingContract,20)&&(i[F.verifyingContract]="0x");let e=M7.from(A);for(let F in e.visit(t,(F,A)=>("address"!==F||rd(A,20)||(i[A]="0x"),A)),i)i[F]=yield B(F);return F.verifyingContract&&i[F.verifyingContract]&&(F.verifyingContract=i[F.verifyingContract]),t=e.visit(t,(F,A)=>"address"===F&&i[A]?i[A]:A),{domain:F,value:t}},new(V||(V=Promise))(function(F,A){function t(F){try{s(o.next(F))}catch(F){A(F)}}function B(F){try{s(o.throw(F))}catch(F){A(F)}}function s(A){var i;A.done?F(A.value):((i=A.value)instanceof V?i:new V(function(F){F(i)})).then(t,B)}s((o=o.apply(i,e||[])).next())})}static getPayload(F,A,t){M7.hashDomain(F);let B={},i=[];M5.forEach(A=>{let t=F[A];null!=t&&(B[A]=M6[A](t),i.push({name:A,type:M4[A]}))});let e=M7.from(A),V=r$(A);return V.EIP712Domain?Mb.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",A):V.EIP712Domain=i,e.encode(t),{types:V,domain:B,primaryType:e.primaryType,message:e.visit(t,(F,A)=>{if(F.match(/^bytes(\d*)/))return rT(rK(A));if(F.match(/^u?int/))return nF.from(A).toString();switch(F){case"address":return A.toLowerCase();case"bool":return!!A;case"string":return"string"!=typeof A&&Mb.throwArgumentError("invalid string","value",A),A}return Mb.throwArgumentError("unsupported type","type",F)})}}}function gF(F,A){null==A&&(A=1);let t=[],B=t.forEach,i=function(F,A){B.call(F,function(F){A>0&&Array.isArray(F)?i(F,A-1):t.push(F)})};return i(F,A),t}function gA(F,A){let t=Array(F);for(let B=0,i=-1;BA[F]):t}function gB(F,A,t){let B=Array(F).fill(void 0).map(()=>[]);for(let i=0;i>1:B>>1}return t})(F,t).forEach((F,A)=>B[A].push(F));return B}let gi=(Ah=function(F){let A=0;function t(){return F[A++]<<8|F[A++]}let B=t(),i=1,e=[0,1];for(let F=1;F>--s&1}let a=0;for(let F=0;F<31;F++)a=a<<1|h();let r=[],n=0,M=2147483648;for(;;){let F=Math.floor(((a-n+1)*i-1)/M),A=0,t=B;for(;t-A>1;){let B=A+t>>>1;F{switch(A-g){case 3:return g+65792+(F[o++]<<16|F[o++]<<8|F[o++]);case 2:return g+256+(F[o++]<<8|F[o++]);case 1:return g+F[o++];default:return A-1}})}(MO("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA==")),Ff=0,()=>Ah[Ff++]),ge=new Set(gt(gi)),gV=new Set(gt(gi)),go=function(F){let A=[];for(;;){let t=F();if(0==t)break;A.push(function(F,A){let t=1+A(),B=A(),i=function(F){let A=[];for(;;){let t=F();if(0==t)break;A.push(t)}return A}(A);return gF(gB(i.length,1+F,A).map((F,A)=>{let e=F[0],V=F.slice(1);return Array(i[A]).fill(void 0).map((F,A)=>{let i=A*B;return[e+A*t,V.map(F=>F+i)]})}))}(t,F))}for(;;){let t=F()-1;if(t<0)break;A.push(gB(1+F(),1+t,F).map(F=>[F[0],F.slice(1)]))}return function(F){let A={};for(let t=0;tF-A),function F(){let A=[];for(;;){let t=gt(gi,Fz);if(0==t.length)break;A.push({set:new Set(t),node:F()})}A.sort((F,A)=>A.set.size-F.set.size);let t=gi();return{branches:A,valid:t%3,fe0f:!!(1&(t=t/3|0)),save:1==(t>>=1),check:2==t}}());function gq(F){return F.filter(F=>65039!=F)}function gh(F){for(let A of F.split(".")){let F=MB(A);try{for(let A=F.lastIndexOf(95)-1;A>=0;A--)if(95!==F[A])throw Error("underscore only allowed at start");if(F.length>=4&&F.every(F=>F<128)&&45===F[2]&&45===F[3])throw Error("invalid label extension")}catch(F){throw Error(`Invalid label "${A}": ${F.message}`)}}return F}let ga=new rp(MH),gr=new Uint8Array(32);function gn(F){if(0===F.length)throw Error("invalid ENS name; empty component");return F}function gM(F){let A=n9(gh(function(F,A){let t=MB(F).reverse(),B=[];for(;t.length;){let F=function(F,A){var t;let B,i;let e=gs,V=[],o=F.length;for(;o;){let A=F[--o];if(!(e=null===(t=e.branches.find(F=>F.set.has(A)))||void 0===t?void 0:t.node))break;if(e.save)i=A;else if(e.check&&A===i)break;V.push(A),e.fe0f&&(V.push(65039),o>0&&65039==F[o-1]&&o--),e.valid&&(B=V.slice(),2==e.valid&&B.splice(1,1),F.length=o)}return B}(t);if(F){B.push(...A(F));continue}let i=t.pop();if(ge.has(i)){B.push(i);continue}if(gV.has(i))continue;let e=go[i];if(e){B.push(...e);continue}throw Error(`Disallowed codepoint: 0x${i.toString(16).toUpperCase()}`)}return gh(String.fromCodePoint(...B).normalize("NFC"))}(F,gq))),t=[];if(0===F.length)return t;let B=0;for(let F=0;F=A.length)throw Error("invalid ENS name; empty component");return t.push(gn(A.slice(B))),t}function gg(F){try{return 0!==gM(F).length}catch(F){}return!1}function gl(F){"string"!=typeof F&&ga.throwArgumentError("invalid ENS name; not a string","name",F);let A=gr,t=gM(F);for(;t.length;)A=nm(rZ([A,nm(t.pop())]));return rT(A)}function gC(F){return rT(rZ(gM(F).map(F=>{if(F.length>63)throw Error("invalid DNS encoded entry; length exceeds 63 bytes");let A=new Uint8Array(F.length+1);return A.set(F,1),A[0]=A.length-1,A})))+"00"}function gI(F){return"string"==typeof F&&(F=n9(F)),nm(rZ([n9("\x19Ethereum Signed Message:\n"),n9(String(F.length)),F]))}gr.fill(0);var gw={};gw.utils=AW("hjPlJ"),gw.common=AW("853Y9"),gw.sha=AW("7ItNj"),gw.ripemd=AW("Eozyl"),gw.hmac=AW("bZxkF"),gw.sha1=gw.sha.sha1,gw.sha256=gw.sha.sha256,gw.sha224=gw.sha.sha224,gw.sha384=gw.sha.sha384,gw.sha512=gw.sha.sha512,gw.ripemd160=gw.ripemd.ripemd160,(AD=AZ||(AZ={})).sha256="sha256",AD.sha512="sha512";let gQ=new rp("sha2/5.7.0");function gE(F){return"0x"+FH(gw).ripemd160().update(rK(F)).digest("hex")}function gc(F){return"0x"+FH(gw).sha256().update(rK(F)).digest("hex")}function gm(F){return"0x"+FH(gw).sha512().update(rK(F)).digest("hex")}function gY(F,A,t){return AZ[F]||gQ.throwError("unsupported algorithm "+F,rp.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:F}),"0x"+FH(gw).hmac(FH(gw)[F],rK(A)).update(rK(t)).digest("hex")}var gD=AW("l59t0");function gp(F,A,t){return F(t={path:A,exports:{},require:function(F,A){return function(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(F,null==A?t.path:A)}},t.exports),t.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==AL||"undefined"!=typeof self&&self;var gu=gG;function gG(F,A){if(!F)throw Error(A||"Assertion failed")}gG.equal=function(F,A,t){if(F!=A)throw Error(t||"Assertion failed: "+F+" != "+A)};var gS=gp(function(F,A){function t(F){return 1===F.length?"0"+F:F}function B(F){for(var A="",B=0;B>8,V=255&i;e?t.push(e,V):t.push(V)}return t},A.zero2=t,A.toHex=B,A.encode=function(F,A){return"hex"===A?B(F):F}}),gk=gp(function(F,A){A.assert=gu,A.toArray=gS.toArray,A.zero2=gS.zero2,A.toHex=gS.toHex,A.encode=gS.encode,A.getNAF=function(F,A,t){var B=Array(Math.max(F.bitLength(),t)+1);B.fill(0);for(var i=1<(i>>1)-1?(i>>1)-s:s,e.isubn(o)):o=0,B[V]=o,e.iushrn(1)}return B},A.getJSF=function(F,A){var t=[[],[]];F=F.clone(),A=A.clone();for(var B=0,i=0;F.cmpn(-B)>0||A.cmpn(-i)>0;){var e,V,o,s=F.andln(3)+B&3,q=A.andln(3)+i&3;3===s&&(s=-1),3===q&&(q=-1),V=(1&s)==0?0:(3==(e=F.andln(7)+B&7)||5===e)&&2===q?-s:s,t[0].push(V),o=(1&q)==0?0:(3==(e=A.andln(7)+i&7)||5===e)&&2===s?-q:q,t[1].push(o),2*B===V+1&&(B=1-B),2*i===o+1&&(i=1-i),F.iushrn(1),A.iushrn(1)}return t},A.cachedProperty=function(F,A,t){var B="_"+A;F.prototype[A]=function(){return void 0!==this[B]?this[B]:this[B]=t.call(this)}},A.parseBytes=function(F){return"string"==typeof F?A.toArray(F,"hex"):F},A.intFromLE=function(F){return new(FH(gD))(F,"hex","le")}}),gU=gk.getNAF,gy=gk.getJSF,gK=gk.assert;function gZ(F,A){this.type=F,this.p=new(FH(gD))(A.p,16),this.red=A.prime?FH(gD).red(A.prime):FH(gD).mont(this.p),this.zero=new(FH(gD))(0).toRed(this.red),this.one=new(FH(gD))(1).toRed(this.red),this.two=new(FH(gD))(2).toRed(this.red),this.n=A.n&&new(FH(gD))(A.n,16),this.g=A.g&&this.pointFromJSON(A.g,A.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,],this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function gJ(F,A){this.curve=F,this.type=A,this.precomputed=null}gZ.prototype.point=function(){throw Error("Not implemented")},gZ.prototype.validate=function(){throw Error("Not implemented")},gZ.prototype._fixedNafMul=function(F,A){gK(F.precomputed);var t,B,i=F._getDoubles(),e=gU(A,1,this._bitLength),V=(1<=t;s--)B=(B<<1)+e[s];o.push(B)}for(var q=this.jpoint(null,null,null),h=this.jpoint(null,null,null),a=V;a>0;a--){for(t=0;t=0;o--){for(var s=0;o>=0&&0===e[o];o--)s++;if(o>=0&&s++,V=V.dblp(s),o<0)break;var q=e[o];gK(0!==q),V="affine"===F.type?q>0?V.mixedAdd(i[q-1>>1]):V.mixedAdd(i[-q-1>>1].neg()):q>0?V.add(i[q-1>>1]):V.add(i[-q-1>>1].neg())}return"affine"===F.type?V.toP():V},gZ.prototype._wnafMulAdd=function(F,A,t,B,i){var e,V,o,s=this._wnafT1,q=this._wnafT2,h=this._wnafT3,a=0;for(e=0;e=1;e-=2){var n=e-1,M=e;if(1!==s[n]||1!==s[M]){h[n]=gU(t[n],s[n],this._bitLength),h[M]=gU(t[M],s[M],this._bitLength),a=Math.max(h[n].length,a),a=Math.max(h[M].length,a);continue}var g=[A[n],null,null,A[M]];0===A[n].y.cmp(A[M].y)?(g[1]=A[n].add(A[M]),g[2]=A[n].toJ().mixedAdd(A[M].neg())):0===A[n].y.cmp(A[M].y.redNeg())?(g[1]=A[n].toJ().mixedAdd(A[M]),g[2]=A[n].add(A[M].neg())):(g[1]=A[n].toJ().mixedAdd(A[M]),g[2]=A[n].toJ().mixedAdd(A[M].neg()));var l=[-3,-1,-5,-7,0,7,5,1,3],C=gy(t[n],t[M]);for(V=0,a=Math.max(C[0].length,a),h[n]=Array(a),h[M]=Array(a);V=0;e--){for(var c=0;e>=0;){var m=!0;for(V=0;V=0&&c++,Q=Q.dblp(c),e<0)break;for(V=0;V0?o=q[V][Y-1>>1]:Y<0&&(o=q[V][-Y-1>>1].neg()),Q="affine"===o.type?Q.mixedAdd(o):Q.add(o))}}for(e=0;e=Math.ceil((F.bitLength()+1)/A.step)},gJ.prototype._getDoubles=function(F,A){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],B=this,i=0;ii[0].cmp(i[1])?i[0]:i[1]).toRed(this.red)}if(F.lambda)t=new(FH(gD))(F.lambda,16);else{var e=this._getEndoRoots(this.n);0===this.g.mul(e[0]).x.cmp(this.g.x.redMul(A))?t=e[0]:(t=e[1],gd(0===this.g.mul(t).x.cmp(this.g.x.redMul(A))))}return B=F.basis?F.basis.map(function(F){return{a:new(FH(gD))(F.a,16),b:new(FH(gD))(F.b,16)}}):this._getEndoBasis(t),{beta:A,lambda:t,basis:B}}},gx.prototype._getEndoRoots=function(F){var A=F===this.p?this.red:FH(gD).mont(F),t=new(FH(gD))(2).toRed(A).redInvm(),B=t.redNeg(),i=new(FH(gD))(3).toRed(A).redNeg().redSqrt().redMul(t);return[B.redAdd(i).fromRed(),B.redSub(i).fromRed()]},gx.prototype._getEndoBasis=function(F){for(var A,t,B,i,e,V,o,s,q,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),a=F,r=this.n.clone(),n=new(FH(gD))(1),M=new(FH(gD))(0),g=new(FH(gD))(0),l=new(FH(gD))(1),C=0;0!==a.cmpn(0);){var I=r.div(a);s=r.sub(I.mul(a)),q=g.sub(I.mul(n));var w=l.sub(I.mul(M));if(!B&&0>s.cmp(h))A=o.neg(),t=n,B=s.neg(),i=q;else if(B&&2==++C)break;o=s,r=a,a=s,g=n,n=q,l=M,M=w}e=s.neg(),V=q;var Q=B.sqr().add(i.sqr());return e.sqr().add(V.sqr()).cmp(Q)>=0&&(e=A,V=t),B.negative&&(B=B.neg(),i=i.neg()),e.negative&&(e=e.neg(),V=V.neg()),[{a:B,b:i},{a:e,b:V}]},gx.prototype._endoSplit=function(F){var A=this.endo.basis,t=A[0],B=A[1],i=B.b.mul(F).divRound(this.n),e=t.b.neg().mul(F).divRound(this.n),V=i.mul(t.a),o=e.mul(B.a),s=i.mul(t.b),q=e.mul(B.b);return{k1:F.sub(V).sub(o),k2:s.add(q).neg()}},gx.prototype.pointFromX=function(F,A){(F=new(FH(gD))(F,16)).red||(F=F.toRed(this.red));var t=F.redSqr().redMul(F).redIAdd(F.redMul(this.a)).redIAdd(this.b),B=t.redSqrt();if(0!==B.redSqr().redSub(t).cmp(this.zero))throw Error("invalid point");var i=B.fromRed().isOdd();return(A&&!i||!A&&i)&&(B=B.redNeg()),this.point(F,B)},gx.prototype.validate=function(F){if(F.inf)return!0;var A=F.x,t=F.y,B=this.a.redMul(A),i=A.redSqr().redMul(A).redIAdd(B).redIAdd(this.b);return 0===t.redSqr().redISub(i).cmpn(0)},gx.prototype._endoWnafMulAdd=function(F,A,t){for(var B=this._endoWnafT1,i=this._endoWnafT2,e=0;e":""},gT.prototype.isInfinity=function(){return this.inf},gT.prototype.add=function(F){if(this.inf)return F;if(F.inf)return this;if(this.eq(F))return this.dbl();if(this.neg().eq(F)||0===this.x.cmp(F.x))return this.curve.point(null,null);var A=this.y.redSub(F.y);0!==A.cmpn(0)&&(A=A.redMul(this.x.redSub(F.x).redInvm()));var t=A.redSqr().redISub(this.x).redISub(F.x),B=A.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,B)},gT.prototype.dbl=function(){if(this.inf)return this;var F=this.y.redAdd(this.y);if(0===F.cmpn(0))return this.curve.point(null,null);var A=this.curve.a,t=this.x.redSqr(),B=F.redInvm(),i=t.redAdd(t).redIAdd(t).redIAdd(A).redMul(B),e=i.redSqr().redISub(this.x.redAdd(this.x)),V=i.redMul(this.x.redSub(e)).redISub(this.y);return this.curve.point(e,V)},gT.prototype.getX=function(){return this.x.fromRed()},gT.prototype.getY=function(){return this.y.fromRed()},gT.prototype.mul=function(F){return(F=new(FH(gD))(F,16),this.isInfinity())?this:this._hasDoubles(F)?this.curve._fixedNafMul(this,F):this.curve.endo?this.curve._endoWnafMulAdd([this],[F]):this.curve._wnafMul(this,F)},gT.prototype.mulAdd=function(F,A,t){var B=[this,A],i=[F,t];return this.curve.endo?this.curve._endoWnafMulAdd(B,i):this.curve._wnafMulAdd(1,B,i,2)},gT.prototype.jmulAdd=function(F,A,t){var B=[this,A],i=[F,t];return this.curve.endo?this.curve._endoWnafMulAdd(B,i,!0):this.curve._wnafMulAdd(1,B,i,2,!0)},gT.prototype.eq=function(F){return this===F||this.inf===F.inf&&(this.inf||0===this.x.cmp(F.x)&&0===this.y.cmp(F.y))},gT.prototype.neg=function(F){if(this.inf)return this;var A=this.curve.point(this.x,this.y.redNeg());if(F&&this.precomputed){var t=this.precomputed,B=function(F){return F.neg()};A.precomputed={naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(B)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(B)}}}return A},gT.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},gR(gL,gZ.BasePoint),gx.prototype.jpoint=function(F,A,t){return new gL(this,F,A,t)},gL.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var F=this.z.redInvm(),A=F.redSqr(),t=this.x.redMul(A),B=this.y.redMul(A).redMul(F);return this.curve.point(t,B)},gL.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},gL.prototype.add=function(F){if(this.isInfinity())return F;if(F.isInfinity())return this;var A=F.z.redSqr(),t=this.z.redSqr(),B=this.x.redMul(A),i=F.x.redMul(t),e=this.y.redMul(A.redMul(F.z)),V=F.y.redMul(t.redMul(this.z)),o=B.redSub(i),s=e.redSub(V);if(0===o.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var q=o.redSqr(),h=q.redMul(o),a=B.redMul(q),r=s.redSqr().redIAdd(h).redISub(a).redISub(a),n=s.redMul(a.redISub(r)).redISub(e.redMul(h)),M=this.z.redMul(F.z).redMul(o);return this.curve.jpoint(r,n,M)},gL.prototype.mixedAdd=function(F){if(this.isInfinity())return F.toJ();if(F.isInfinity())return this;var A=this.z.redSqr(),t=this.x,B=F.x.redMul(A),i=this.y,e=F.y.redMul(A).redMul(this.z),V=t.redSub(B),o=i.redSub(e);if(0===V.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var s=V.redSqr(),q=s.redMul(V),h=t.redMul(s),a=o.redSqr().redIAdd(q).redISub(h).redISub(h),r=o.redMul(h.redISub(a)).redISub(i.redMul(q)),n=this.z.redMul(V);return this.curve.jpoint(a,r,n)},gL.prototype.dblp=function(F){if(0===F||this.isInfinity())return this;if(!F)return this.dbl();if(this.curve.zeroA||this.curve.threeA){var A,t=this;for(A=0;A=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},gL.prototype.inspect=function(){return this.isInfinity()?"":""},gL.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var gN=gp(function(F,A){A.base=gZ,A.short=gx,A.mont=null,A.edwards=null}),gj=gp(function(F,A){var t,B=gk.assert;function i(F){"short"===F.type?this.curve=new gN.short(F):"edwards"===F.type?this.curve=new gN.edwards(F):this.curve=new gN.mont(F),this.g=this.curve.g,this.n=this.curve.n,this.hash=F.hash,B(this.g.validate(),"Invalid curve"),B(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function e(F,t){Object.defineProperty(A,F,{configurable:!0,enumerable:!0,get:function(){var B=new i(t);return Object.defineProperty(A,F,{configurable:!0,enumerable:!0,value:B}),B}})}A.PresetCurve=i,e("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:FH(gw).sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),e("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:FH(gw).sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),e("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:FH(gw).sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),e("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:FH(gw).sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),e("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:FH(gw).sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),e("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:FH(gw).sha256,gRed:!1,g:["9"]}),e("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:FH(gw).sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{t=null.crash()}catch(F){t=void 0}e("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:FH(gw).sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",t]})});function gW(F){if(!(this instanceof gW))return new gW(F);this.hash=F.hash,this.predResist=!!F.predResist,this.outLen=this.hash.outSize,this.minEntropy=F.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var A=gS.toArray(F.entropy,F.entropyEnc||"hex"),t=gS.toArray(F.nonce,F.nonceEnc||"hex"),B=gS.toArray(F.pers,F.persEnc||"hex");gu(A.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(A,t,B)}gW.prototype._init=function(F,A,t){var B=F.concat(A).concat(t);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(F.concat(t||[])),this._reseed=1},gW.prototype.generate=function(F,A,t,B){if(this._reseed>this.reseedInterval)throw Error("Reseed is required");"string"!=typeof A&&(B=t,t=A,A=null),t&&(t=gS.toArray(t,B||"hex"),this._update(t));for(var i=[];i.length"};var gf=gk.assert;function gv(F,A){if(F instanceof gv)return F;this._importDER(F,A)||(gf(F.r&&F.s,"Signature without r or s"),this.r=new(FH(gD))(F.r,16),this.s=new(FH(gD))(F.s,16),void 0===F.recoveryParam?this.recoveryParam=null:this.recoveryParam=F.recoveryParam)}function gH(){this.place=0}function gb(F,A){var t=F[A.place++];if(!(128&t))return t;var B=15&t;if(0===B||B>4)return!1;for(var i=0,e=0,V=A.place;e>>=0;return!(i<=127)&&(A.place=V,i)}function gP(F){for(var A=0,t=F.length-1;!F[A]&&!(128&F[A+1])&&A>>3);for(F.push(128|t);--t;)F.push(A>>>(t<<3)&255);F.push(A)}gv.prototype._importDER=function(F,A){F=gk.toArray(F,A);var t=new gH;if(48!==F[t.place++])return!1;var B=gb(F,t);if(!1===B||B+t.place!==F.length||2!==F[t.place++])return!1;var i=gb(F,t);if(!1===i)return!1;var e=F.slice(t.place,i+t.place);if(t.place+=i,2!==F[t.place++])return!1;var V=gb(F,t);if(!1===V||F.length!==V+t.place)return!1;var o=F.slice(t.place,V+t.place);if(0===e[0]){if(!(128&e[1]))return!1;e=e.slice(1)}if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}return this.r=new(FH(gD))(e),this.s=new(FH(gD))(o),this.recoveryParam=null,!0},gv.prototype.toDER=function(F){var A=this.r.toArray(),t=this.s.toArray();for(128&A[0]&&(A=[0].concat(A)),128&t[0]&&(t=[0].concat(t)),A=gP(A),t=gP(t);!t[0]&&!(128&t[1]);)t=t.slice(1);var B=[2];gX(B,A.length),(B=B.concat(A)).push(2),gX(B,t.length);var i=B.concat(t),e=[48];return gX(e,i.length),e=e.concat(i),gk.encode(e,F)};var g_=function(){throw Error("unsupported")},g$=gk.assert;function g2(F){if(!(this instanceof g2))return new g2(F);"string"==typeof F&&(g$(Object.prototype.hasOwnProperty.call(gj,F),"Unknown curve "+F),F=gj[F]),F instanceof gj.PresetCurve&&(F={curve:F}),this.curve=F.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=F.curve.g,this.g.precompute(F.curve.n.bitLength()+1),this.hash=F.hash||F.curve.hash}g2.prototype.keyPair=function(F){return new gz(this,F)},g2.prototype.keyFromPrivate=function(F,A){return gz.fromPrivate(this,F,A)},g2.prototype.keyFromPublic=function(F,A){return gz.fromPublic(this,F,A)},g2.prototype.genKeyPair=function(F){F||(F={});for(var A=new gW({hash:this.hash,pers:F.pers,persEnc:F.persEnc||"utf8",entropy:F.entropy||g_(this.hash.hmacStrength),entropyEnc:F.entropy&&F.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),B=this.n.sub(new(FH(gD))(2));;){var i=new(FH(gD))(A.generate(t));if(!(i.cmp(B)>0))return i.iaddn(1),this.keyFromPrivate(i)}},g2.prototype._truncateToN=function(F,A){var t=8*F.byteLength()-this.n.bitLength();return(t>0&&(F=F.ushrn(t)),!A&&F.cmp(this.n)>=0)?F.sub(this.n):F},g2.prototype.sign=function(F,A,t,B){"object"==typeof t&&(B=t,t=null),B||(B={}),A=this.keyFromPrivate(A,t),F=this._truncateToN(new(FH(gD))(F,16));for(var i=this.n.byteLength(),e=A.getPrivate().toArray("be",i),V=F.toArray("be",i),o=new gW({hash:this.hash,entropy:e,nonce:V,pers:B.pers,persEnc:B.persEnc||"utf8"}),s=this.n.sub(new(FH(gD))(1)),q=0;;q++){var h=B.k?B.k(q):new(FH(gD))(o.generate(this.n.byteLength()));if(!(0>=(h=this._truncateToN(h,!0)).cmpn(1)||h.cmp(s)>=0)){var a=this.g.mul(h);if(!a.isInfinity()){var r=a.getX(),n=r.umod(this.n);if(0!==n.cmpn(0)){var M=h.invm(this.n).mul(n.mul(A.getPrivate()).iadd(F));if(0!==(M=M.umod(this.n)).cmpn(0)){var g=(a.getY().isOdd()?1:0)|(0!==r.cmp(n)?2:0);return B.canonical&&M.cmp(this.nh)>0&&(M=this.n.sub(M),g^=1),new gv({r:n,s:M,recoveryParam:g})}}}}}},g2.prototype.verify=function(F,A,t,B){F=this._truncateToN(new(FH(gD))(F,16)),t=this.keyFromPublic(t,B);var i,e=(A=new gv(A,"hex")).r,V=A.s;if(0>e.cmpn(1)||e.cmp(this.n)>=0||0>V.cmpn(1)||V.cmp(this.n)>=0)return!1;var o=V.invm(this.n),s=o.mul(F).umod(this.n),q=o.mul(e).umod(this.n);return this.curve._maxwellTrick?!(i=this.g.jmulAdd(s,t.getPublic(),q)).isInfinity()&&i.eqXToP(e):!(i=this.g.mulAdd(s,t.getPublic(),q)).isInfinity()&&0===i.getX().umod(this.n).cmp(e)},g2.prototype.recoverPubKey=function(F,A,t,B){g$((3&t)===t,"The recovery param is more than two bits"),A=new gv(A,B);var i=this.n,e=new(FH(gD))(F),V=A.r,o=A.s,s=1&t,q=t>>1;if(V.cmp(this.curve.p.umod(this.curve.n))>=0&&q)throw Error("Unable to find sencond key candinate");V=q?this.curve.pointFromX(V.add(this.curve.n),s):this.curve.pointFromX(V,s);var h=A.r.invm(i),a=i.sub(e).mul(h).umod(i),r=o.mul(h).umod(i);return this.g.mulAdd(a,V,r)},g2.prototype.getKeyRecoveryParam=function(F,A,t,B){if(null!==(A=new gv(A,B)).recoveryParam)return A.recoveryParam;for(var i,e=0;e<4;e++){try{i=this.recoverPubKey(F,A,e)}catch(F){continue}if(i.eq(t))return e}throw Error("Unable to find valid recovery factor")};var g0=gp(function(F,A){A.version="6.5.4",A.utils=gk,A.rand=function(){throw Error("unsupported")},A.curve=gN,A.curves=gj,A.ec=g2,A.eddsa=null}).ec;let g1=new rp("signing-key/5.7.0"),g4=null;function g5(){return g4||(g4=new g0("secp256k1")),g4}class g8{constructor(F){rb(this,"curve","secp256k1"),rb(this,"privateKey",rT(F)),32!==rL(this.privateKey)&&g1.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let A=g5().keyFromPrivate(rK(this.privateKey));rb(this,"publicKey","0x"+A.getPublic(!1,"hex")),rb(this,"compressedPublicKey","0x"+A.getPublic(!0,"hex")),rb(this,"_isSigningKey",!0)}_addPoint(F){let A=g5().keyFromPublic(rK(this.publicKey)),t=g5().keyFromPublic(rK(F));return"0x"+A.pub.add(t.pub).encodeCompressed("hex")}signDigest(F){let A=g5().keyFromPrivate(rK(this.privateKey)),t=rK(F);32!==t.length&&g1.throwArgumentError("bad digest length","digest",F);let B=A.sign(t,{canonical:!0});return rf({recoveryParam:B.recoveryParam,r:rz("0x"+B.r.toString(16),32),s:rz("0x"+B.s.toString(16),32)})}computeSharedSecret(F){let A=g5().keyFromPrivate(rK(this.privateKey)),t=g5().keyFromPublic(rK(g3(F)));return rz("0x"+A.derive(t.getPublic()).toString(16),32)}static isSigningKey(F){return!!(F&&F._isSigningKey)}}function g6(F,A){let t=rf(A),B={r:rK(t.r),s:rK(t.s)};return"0x"+g5().recoverPubKey(rK(F),B,t.recoveryParam).encode("hex",!1)}function g3(F,A){let t=rK(F);if(32===t.length){let F=new g8(t);return A?"0x"+g5().keyFromPrivate(t).getPublic(!0,"hex"):F.publicKey}return 33===t.length?A?rT(t):"0x"+g5().keyFromPublic(t).getPublic(!1,"hex"):65===t.length?A?"0x"+g5().keyFromPublic(t).getPublic(!0,"hex"):rT(t):g1.throwArgumentError("invalid public or private key","key","[REDACTED]")}let g9=new rp("transactions/5.7.0");function g7(F){return"0x"===F?null:nd(F)}function lF(F){return"0x"===F?n2:nF.from(F)}(Ap=AJ||(AJ={}))[Ap.legacy=0]="legacy",Ap[Ap.eip2930=1]="eip2930",Ap[Ap.eip1559=2]="eip1559";let lA=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],lt={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,type:!0,value:!0};function lB(F){return nd(rN(nm(rN(g3(F),1)),12))}function li(F,A){return lB(g6(rK(F),A))}function le(F,A){let t=rJ(nF.from(F).toHexString());return t.length>32&&g9.throwArgumentError("invalid length for "+A,"transaction:"+A,F),t}function lV(F,A){return{address:nd(F),storageKeys:(A||[]).map((A,t)=>(32!==rL(A)&&g9.throwArgumentError("invalid access list storageKey",`accessList[${F}:${t}]`,A),A.toLowerCase()))}}function lo(F){if(Array.isArray(F))return F.map((F,A)=>Array.isArray(F)?(F.length>2&&g9.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${A}]`,F),lV(F[0],F[1])):lV(F.address,F.storageKeys));let A=Object.keys(F).map(A=>{let t=F[A].reduce((F,A)=>(F[A]=!0,F),{});return lV(A,Object.keys(t).sort())});return A.sort((F,A)=>F.address.localeCompare(A.address)),A}function ls(F){return lo(F).map(F=>[F.address,F.storageKeys])}function lq(F,A){if(null!=F.gasPrice){let A=nF.from(F.gasPrice),t=nF.from(F.maxFeePerGas||0);A.eq(t)||g9.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:A,maxFeePerGas:t})}let t=[le(F.chainId||0,"chainId"),le(F.nonce||0,"nonce"),le(F.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),le(F.maxFeePerGas||0,"maxFeePerGas"),le(F.gasLimit||0,"gasLimit"),null!=F.to?nd(F.to):"0x",le(F.value||0,"value"),F.data||"0x",ls(F.accessList||[])];if(A){let F=rf(A);t.push(le(F.recoveryParam,"recoveryParam")),t.push(rJ(F.r)),t.push(rJ(F.s))}return rj(["0x02",nG(t)])}function lh(F,A){let t=[le(F.chainId||0,"chainId"),le(F.nonce||0,"nonce"),le(F.gasPrice||0,"gasPrice"),le(F.gasLimit||0,"gasLimit"),null!=F.to?nd(F.to):"0x",le(F.value||0,"value"),F.data||"0x",ls(F.accessList||[])];if(A){let F=rf(A);t.push(le(F.recoveryParam,"recoveryParam")),t.push(rJ(F.r)),t.push(rJ(F.s))}return rj(["0x01",nG(t)])}function la(F,A){if(null==F.type||0===F.type)return null!=F.accessList&&g9.throwArgumentError("untyped transactions do not support accessList; include type: 1","transaction",F),function(F,A){r_(F,lt);let t=[];lA.forEach(function(A){let B=F[A.name]||[],i={};A.numeric&&(i.hexPad="left"),B=rK(rT(B,i)),A.length&&B.length!==A.length&&B.length>0&&g9.throwArgumentError("invalid length for "+A.name,"transaction:"+A.name,B),A.maxLength&&(B=rJ(B)).length>A.maxLength&&g9.throwArgumentError("invalid length for "+A.name,"transaction:"+A.name,B),t.push(rT(B))});let B=0;if(null!=F.chainId?"number"!=typeof(B=F.chainId)&&g9.throwArgumentError("invalid transaction.chainId","transaction",F):A&&!rk(A)&&A.v>28&&(B=Math.floor((A.v-35)/2)),0!==B&&(t.push(rT(B)),t.push("0x"),t.push("0x")),!A)return nG(t);let i=rf(A),e=27+i.recoveryParam;return 0!==B?(t.pop(),t.pop(),t.pop(),e+=2*B+8,i.v>28&&i.v!==e&&g9.throwArgumentError("transaction.chainId/signature.v mismatch","signature",A)):i.v!==e&&g9.throwArgumentError("transaction.chainId/signature.v mismatch","signature",A),t.push(rT(e)),t.push(rJ(rK(i.r))),t.push(rJ(rK(i.s))),nG(t)}(F,A);switch(F.type){case 1:return lh(F,A);case 2:return lq(F,A)}return g9.throwError(`unsupported transaction type: ${F.type}`,rp.errors.UNSUPPORTED_OPERATION,{operation:"serializeTransaction",transactionType:F.type})}function lr(F,A,t){try{let t=lF(A[0]).toNumber();if(0!==t&&1!==t)throw Error("bad recid");F.v=t}catch(F){g9.throwArgumentError("invalid v for transaction type: 1","v",A[0])}F.r=rz(A[1],32),F.s=rz(A[2],32);try{let A=nm(t(F));F.from=li(A,{r:F.r,s:F.s,recoveryParam:F.v})}catch(F){}}function ln(F){let A=rK(F);if(A[0]>127)return function(F){let A=nU(F);9!==A.length&&6!==A.length&&g9.throwArgumentError("invalid raw transaction","rawTransaction",F);let t={nonce:lF(A[0]).toNumber(),gasPrice:lF(A[1]),gasLimit:lF(A[2]),to:g7(A[3]),value:lF(A[4]),data:A[5],chainId:0};if(6===A.length)return t;try{t.v=nF.from(A[6]).toNumber()}catch(F){return t}if(t.r=rz(A[7],32),t.s=rz(A[8],32),nF.from(t.r).isZero()&&nF.from(t.s).isZero())t.chainId=t.v,t.v=0;else{t.chainId=Math.floor((t.v-35)/2),t.chainId<0&&(t.chainId=0);let B=t.v-27,i=A.slice(0,6);0!==t.chainId&&(i.push(rT(t.chainId)),i.push("0x"),i.push("0x"),B-=2*t.chainId+8);let e=nm(nG(i));try{t.from=li(e,{r:rT(t.r),s:rT(t.s),recoveryParam:B})}catch(F){}t.hash=nm(F)}return t.type=null,t}(A);switch(A[0]){case 1:return function(F){let A=nU(F.slice(1));8!==A.length&&11!==A.length&&g9.throwArgumentError("invalid component count for transaction type: 1","payload",rT(F));let t={type:1,chainId:lF(A[0]).toNumber(),nonce:lF(A[1]).toNumber(),gasPrice:lF(A[2]),gasLimit:lF(A[3]),to:g7(A[4]),value:lF(A[5]),data:A[6],accessList:lo(A[7])};return 8===A.length||(t.hash=nm(F),lr(t,A.slice(8),lh)),t}(A);case 2:return function(F){let A=nU(F.slice(1));9!==A.length&&12!==A.length&&g9.throwArgumentError("invalid component count for transaction type: 2","payload",rT(F));let t=lF(A[2]),B=lF(A[3]),i={type:2,chainId:lF(A[0]).toNumber(),nonce:lF(A[1]).toNumber(),maxPriorityFeePerGas:t,maxFeePerGas:B,gasPrice:null,gasLimit:lF(A[4]),to:g7(A[5]),value:lF(A[6]),data:A[7],accessList:lo(A[8])};return 9===A.length||(i.hash=nm(F),lr(i,A.slice(9),lq)),i}(A)}return g9.throwError(`unsupported transaction type: ${A[0]}`,rp.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:A[0]})}let lM=new rp("wordlists/5.7.0");class lg{constructor(F){lM.checkAbstract(new.target,lg),rb(this,"locale",F)}split(F){return F.toLowerCase().split(/ +/g)}join(F){return F.join(" ")}static check(F){let A=[];for(let t=0;t<2048;t++){let B=F.getWord(t);if(t!==F.getWordIndex(B))return"0x";A.push(B)}return MZ(A.join("\n")+"\n")}static register(F,A){A||(A=F.locale)}}let ll=null;function lC(F){if(null==ll&&(ll="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo".replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==lg.check(F)))throw ll=null,Error("BIP39 Wordlist for en (English) FAILED")}let lI=new class extends lg{constructor(){super("en")}getWord(F){return lC(this),ll[F]}getWordIndex(F){return lC(this),ll.indexOf(F)}};lg.register(lI);let lw={en:lI},lQ=new rp("hdnode/5.7.0"),lE=nF.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lc=n9("Bitcoin seed");function lm(F){return(1<=256)throw Error("Depth too large!");return lD(rZ([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",rT(this.depth),this.parentFingerprint,rz(rT(this.index),4),this.chainCode,null!=this.privateKey?rZ(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new lS(lu,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(F){if(F>4294967295)throw Error("invalid index - "+String(F));let A=this.path;A&&(A+="/"+(2147483647&F));let t=new Uint8Array(37);if(2147483648&F){if(!this.privateKey)throw Error("cannot derive child of neutered node");t.set(rK(this.privateKey),1),A&&(A+="'")}else t.set(rK(this.publicKey));for(let A=24;A>=0;A-=8)t[33+(A>>3)]=F>>24-A&255;let B=rK(gY(AZ.sha512,this.chainCode,t)),i=B.slice(0,32),e=B.slice(32),V=null,o=null;this.privateKey?V=lY(nF.from(i).add(this.privateKey).mod(lE)):o=new g8(rT(i))._addPoint(this.publicKey);let s=A,q=this.mnemonic;return q&&(s=Object.freeze({phrase:q.phrase,path:A,locale:q.locale||"en"})),new lS(lu,V,o,this.fingerprint,lY(e),F,this.depth+1,s)}derivePath(F){let A=F.split("/");if(0===A.length||"m"===A[0]&&0!==this.depth)throw Error("invalid path - "+F);"m"===A[0]&&A.shift();let t=this;for(let F=0;F=2147483648)throw Error("invalid path index - "+B);t=t._derive(2147483648+F)}else if(B.match(/^[0-9]+$/)){let F=parseInt(B);if(F>=2147483648)throw Error("invalid path index - "+B);t=t._derive(F)}else throw Error("invalid path component - "+B)}return t}static _fromSeed(F,A){let t=rK(F);if(t.length<16||t.length>64)throw Error("invalid seed");let B=rK(gY(AZ.sha512,lc,t));return new lS(lu,lY(B.slice(0,32)),null,"0x00000000",lY(B.slice(32)),0,0,A)}static fromMnemonic(F,A,t){return t=lp(t),F=ly(lU(F,t),t),lS._fromSeed(lk(F,A),{phrase:F,path:"m",locale:t.locale})}static fromSeed(F){return lS._fromSeed(F,null)}static fromExtendedKey(F){let A=Mv.decode(F);(82!==A.length||lD(A.slice(0,78))!==F)&&lQ.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let t=A[4],B=rT(A.slice(5,9)),i=parseInt(rT(A.slice(9,13)).substring(2),16),e=rT(A.slice(13,45)),V=A.slice(45,78);switch(rT(A.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new lS(lu,null,rT(V),B,e,i,t,null);case"0x0488ade4":case"0x04358394 ":if(0!==V[0])break;return new lS(lu,rT(V.slice(1)),null,B,e,i,t,null)}return lQ.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function lk(F,A){A||(A="");let t=n9("mnemonic"+A,Ay.NFKD);return function(F,A,t,B,i){let e,V,o;F=rK(F),A=rK(A);let s=1,q=new Uint8Array(64),h=new Uint8Array(A.length+4);h.set(A);for(let t=1;t<=s;t++){h[A.length]=t>>24&255,h[A.length+1]=t>>16&255,h[A.length+2]=t>>8&255,h[A.length+3]=255&t;let B=rK(gY(i,F,h));e||(o=new Uint8Array(e=B.length),V=64-((s=Math.ceil(64/e))-1)*e),o.set(B);for(let A=1;A<2048;A++){B=rK(gY(i,F,B));for(let F=0;F>3]|=1<<7-i%8),i++}let e=32*t.length/3,V=lm(t.length/3);if((rK(gc(B.slice(0,e/8)))[0]&V)!=(B[B.length-1]&V))throw Error("invalid checksum");return rT(B.slice(0,e/8))}function ly(F,A){if(A=lp(A),(F=rK(F)).length%4!=0||F.length<16||F.length>32)throw Error("invalid entropy");let t=[0],B=11;for(let A=0;A8?(t[t.length-1]<<=8,t[t.length-1]|=F[A],B-=8):(t[t.length-1]<<=B,t[t.length-1]|=F[A]>>8-B,t.push(F[A]&(1<<8-B)-1),B+=3);let i=F.length/4,e=rK(gc(F))[0]&lm(i);return t[t.length-1]<<=i,t[t.length-1]|=e>>8-i,A.join(t.map(F=>A.getWord(F)))}function lK(F,A){try{return lU(F,A),!0}catch(F){}return!1}function lZ(F){return("number"!=typeof F||F<0||F>=2147483648||F%1)&&lQ.throwArgumentError("invalid account index","index",F),`m/44'/60'/${F}'/0/0`}function lJ(F){if(function(F){let A=null;try{A=JSON.parse(F)}catch(F){return!1}return A.encseed&&A.ethaddr}(F))try{return nd(JSON.parse(F).ethaddr)}catch(F){return null}if(function(F){let A=null;try{A=JSON.parse(F)}catch(F){return!1}return!!A.version&&parseInt(A.version)===A.version&&3===parseInt(A.version)}(F))try{return nd(JSON.parse(F).address)}catch(F){}return null}let lR=RegExp("^bytes([0-9]+)$"),ld=RegExp("^(u?int)([0-9]*)$"),lx=RegExp("^(.*)\\[([0-9]*)\\]$"),lT=new rp("solidity/5.7.0");function lL(F,A){F.length!=A.length&&lT.throwArgumentError("wrong number of values; expected ${ types.length }","values",A);let t=[];return F.forEach(function(F,B){t.push(function F(A,t,B){switch(A){case"address":if(B)return rR(t,32);return rK(t);case"string":return n9(t);case"bytes":return rK(t);case"bool":if(t=t?"0x01":"0x00",B)return rR(t,32);return rK(t)}let i=A.match(ld);if(i){let F=parseInt(i[2]||"256");return(i[2]&&String(F)!==i[2]||F%8!=0||0===F||F>256)&&lT.throwArgumentError("invalid number type","type",A),B&&(F=256),rR(t=nF.from(t).toTwos(F),F/8)}if(i=A.match(lR)){let F=parseInt(i[1]);return((String(F)!==i[1]||0===F||F>32)&&lT.throwArgumentError("invalid bytes type","type",A),rK(t).byteLength!==F&&lT.throwArgumentError(`invalid value for ${A}`,"value",t),B)?rK((t+"0000000000000000000000000000000000000000000000000000000000000000").substring(0,66)):t}if((i=A.match(lx))&&Array.isArray(t)){let B=i[1];parseInt(i[2]||String(t.length))!=t.length&&lT.throwArgumentError(`invalid array length for ${A}`,"value",t);let e=[];return t.forEach(function(A){e.push(F(B,A,!0))}),rZ(e)}return lT.throwArgumentError("invalid type","type",A)}(F,A[B]))}),rT(rZ(t))}function lN(F,A){return nm(lL(F,A))}function lj(F,A){return gc(lL(F,A))}let lW=new rp("random/5.7.0"),lO=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==AL)return AL;throw Error("unable to locate global object")}(),lz=lO.crypto||lO.msCrypto;function lf(F){(F<=0||F>1024||F%1||F!=F)&&lW.throwArgumentError("invalid length","length",F);let A=new Uint8Array(F);return lz.getRandomValues(A),rK(A)}function lv(F){F=F.slice();for(let A=F.length-1;A>0;A--){let t=Math.floor(Math.random()*(A+1)),B=F[A];F[A]=F[t],F[t]=B}return F}function lH(F){let A=n9(F);if(A.length>31)throw Error("bytes32 string must be less than 32 bytes");return rT(rZ([A,"0x0000000000000000000000000000000000000000000000000000000000000000"]).slice(0,32))}function lb(F){let A=rK(F);if(32!==A.length)throw Error("invalid bytes32 - not 32 bytes long");if(0!==A[31])throw Error("invalid bytes32 string - no null terminator");let t=31;for(;0===A[t-1];)t--;return Mt(A.slice(0,t))}function lP(F,A){A||(A=function(F){return[parseInt(F,16)]});let t=0,B={};return F.split(",").forEach(F=>{let i=F.split(":");B[t+=parseInt(i[0],16)]=A(i[1])}),B}function lX(F){let A=0;return F.split(",").map(F=>{let t=F.split("-");return 1===t.length?t[1]="0":""===t[1]&&(t[1]="1"),{l:A+parseInt(t[0],16),h:A=parseInt(t[1],16)}})}function l_(F,A){let t=0;for(let B=0;B=(t+=i.l)&&F<=t+i.h&&(F-t)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(F-t))continue;return i}}return null}lz&&lz.getRandomValues||(lW.warn("WARNING: Missing strong random number source"),lz={getRandomValues:function(F){return lW.throwError("no secure random source avaialble",rp.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});let l$=lX("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),l2="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(F=>parseInt(F,16)),l0=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],l1=lP("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),l4=lP("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),l5=lP("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(F){if(F.length%4!=0)throw Error("bad data");let A=[];for(let t=0;tl2.indexOf(F)>=0||F>=65024&&F<=65039?[]:function(F){let A=l_(F,l0);if(A)return[F+A.s];let t=l1[F];if(t)return t;let B=l4[F];return B?[F+B[0]]:l5[F]||null}(F)||[F]).reduce((F,A)=>(A.forEach(A=>{F.push(A)}),F),[])),Ay.NFKC)).forEach(F=>{if(l_(F,l8))throw Error("STRINGPREP_CONTAINS_PROHIBITED")}),A.forEach(F=>{if(l_(F,l$))throw Error("STRINGPREP_CONTAINS_UNASSIGNED")});let t=MA(A);if("-"===t.substring(0,1)||"--"===t.substring(2,4)||"-"===t.substring(t.length-1))throw Error("invalid hyphen");return t}let l3=new rp(r8),l9={},l7=nF.from(0),CF=nF.from(-1);function CA(F,A,t,B){let i={fault:A,operation:t};return void 0!==B&&(i.value=B),l3.throwError(F,rp.errors.NUMERIC_FAULT,i)}let Ct="0";for(;Ct.length<256;)Ct+=Ct;function CB(F){if("number"!=typeof F)try{F=nF.from(F).toNumber()}catch(F){}return"number"==typeof F&&F>=0&&F<=256&&!(F%1)?"1"+Ct.substring(0,F):l3.throwArgumentError("invalid decimal size","decimals",F)}function Ci(F,A){null==A&&(A=0);let t=CB(A),B=(F=nF.from(F)).lt(l7);B&&(F=F.mul(CF));let i=F.mod(t).toString();for(;i.length2&&l3.throwArgumentError("too many decimal points","value",F);let e=i[0],V=i[1];for(e||(e="0"),V||(V="0");"0"===V[V.length-1];)V=V.substring(0,V.length-1);for(V.length>t.length-1&&CA("fractional component exceeds decimals","underflow","parseFixed"),""===V&&(V="0");V.lengthnull==F[A]?B:(typeof F[A]!==t&&l3.throwArgumentError("invalid fixed format ("+A+" not "+t+")","format."+A,F[A]),F[A]);A=i("signed","boolean",A),t=i("width","number",t),B=i("decimals","number",B)}return t%8&&l3.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",t),B>80&&l3.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",B),new CV(l9,A,t,B)}}class Co{constructor(F,A,t,B){F!==l9&&l3.throwError("cannot use FixedNumber constructor; use FixedNumber.from",rp.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=B,this._hex=A,this._value=t,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(F){this.format.name!==F.format.name&&l3.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",F)}addUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.add(t),this.format.decimals,this.format)}subUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.sub(t),this.format.decimals,this.format)}mulUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.mul(t).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(F){this._checkFormat(F);let A=Ce(this._value,this.format.decimals),t=Ce(F._value,F.format.decimals);return Co.fromValue(A.mul(this.format._multiplier).div(t),this.format.decimals,this.format)}floor(){let F=this.toString().split(".");1===F.length&&F.push("0");let A=Co.from(F[0],this.format),t=!F[1].match(/^(0*)$/);return this.isNegative()&&t&&(A=A.subUnsafe(Cs.toFormat(A.format))),A}ceiling(){let F=this.toString().split(".");1===F.length&&F.push("0");let A=Co.from(F[0],this.format),t=!F[1].match(/^(0*)$/);return!this.isNegative()&&t&&(A=A.addUnsafe(Cs.toFormat(A.format))),A}round(F){null==F&&(F=0);let A=this.toString().split(".");if(1===A.length&&A.push("0"),(F<0||F>80||F%1)&&l3.throwArgumentError("invalid decimal count","decimals",F),A[1].length<=F)return this;let t=Co.from("1"+Ct.substring(0,F),this.format),B=Cq.toFormat(this.format);return this.mulUnsafe(t).addUnsafe(B).floor().divUnsafe(t)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(F){return null==F?this._hex:(F%8&&l3.throwArgumentError("invalid byte width","width",F),rz(nF.from(this._hex).fromTwos(this.format.width).toTwos(F).toHexString(),F/8))}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(F){return Co.fromString(this._value,F)}static fromValue(F,A,t){var B;return null!=t||null==A||null!=(B=A)&&(nF.isBigNumber(B)||"number"==typeof B&&B%1==0||"string"==typeof B&&B.match(/^-?[0-9]+$/)||rd(B)||"bigint"==typeof B||ry(B))||(t=A,A=null),null==A&&(A=0),null==t&&(t="fixed"),Co.fromString(Ci(F,A),CV.from(t))}static fromString(F,A){null==A&&(A="fixed");let t=CV.from(A),B=Ce(F,t.decimals);!t.signed&&B.lt(l7)&&CA("unsigned value cannot be negative","overflow","value",F);let i=null;return new Co(l9,t.signed?B.toTwos(t.width).toHexString():rz(B.toHexString(),t.width/8),Ci(B,t.decimals),t)}static fromBytes(F,A){null==A&&(A="fixed");let t=CV.from(A);if(rK(F).length>t.width/8)throw Error("overflow");let B=nF.from(F);return t.signed&&(B=B.fromTwos(t.width)),new Co(l9,B.toTwos((t.signed?0:1)+t.width).toHexString(),Ci(B,t.decimals),t)}static from(F,A){if("string"==typeof F)return Co.fromString(F,A);if(ry(F))return Co.fromBytes(F,A);try{return Co.fromValue(F,0,A)}catch(F){if(F.code!==rp.errors.INVALID_ARGUMENT)throw F}return l3.throwArgumentError("invalid FixedNumber value","value",F)}static isFixedNumber(F){return!!(F&&F._isFixedNumber)}}let Cs=Co.from(1),Cq=Co.from("0.5"),Ch=new rp("units/5.7.0"),Ca=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Cr(F){let A=String(F).split(".");(A.length>2||!A[0].match(/^-?[0-9]*$/)||A[1]&&!A[1].match(/^[0-9]*$/)||"."===F||"-."===F)&&Ch.throwArgumentError("invalid value","value",F);let t=A[0],B="";for("-"===t.substring(0,1)&&(B="-",t=t.substring(1));"0"===t.substring(0,1);)t=t.substring(1);""===t&&(t="0");let i="";for(2===A.length&&(i="."+(A[1]||"0"));i.length>2&&"0"===i[i.length-1];)i=i.substring(0,i.length-1);let e=[];for(;t.length;)if(t.length<=3){e.unshift(t);break}else{let F=t.length-3;e.unshift(t.substring(F)),t=t.substring(0,F)}return B+e.join(",")+i}function Cn(F,A){if("string"==typeof A){let F=Ca.indexOf(A);-1!==F&&(A=3*F)}return Ci(F,null!=A?A:18)}function CM(F,A){if("string"!=typeof F&&Ch.throwArgumentError("value must be a string","value",F),"string"==typeof A){let F=Ca.indexOf(A);-1!==F&&(A=3*F)}return Ce(F,null!=A?A:18)}function Cg(F){return Cn(F,18)}function Cl(F){return CM(F,18)}new rp("abstract-provider/5.7.0"),new rp("abstract-signer/5.7.0"),rp.errors.INSUFFICIENT_FUNDS,rp.errors.NONCE_EXPIRED,rp.errors.REPLACEMENT_UNDERPRICED;!function(F){function A(F){return parseInt(F)===F}function t(F){if(!A(F.length))return!1;for(var t=0;t255)return!1;return!0}function B(F,B){if(F.buffer&&ArrayBuffer.isView(F)&&"Uint8Array"===F.name)return B&&(F=F.slice?F.slice():Array.prototype.slice.call(F)),F;if(Array.isArray(F)){if(!t(F))throw Error("Array contains invalid value: "+F);return new Uint8Array(F)}if(A(F.length)&&t(F))return new Uint8Array(F);throw Error("unsupported array-like object")}function i(F){return new Uint8Array(F)}function e(F,A,t,B,i){(null!=B||null!=i)&&(F=F.slice?F.slice(B,i):Array.prototype.slice.call(F,B,i)),A.set(F,t)}V="0123456789abcdef";var V,o={16:10,24:12,32:14},s=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],q=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],h=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],a=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],r=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],n=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],M=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],g=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],l=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],C=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],I=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],w=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],Q=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],E=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],c=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function m(F){for(var A=[],t=0;t>2,this._Ke[e][A%4]=i[A],this._Kd[F-e][A%4]=i[A];for(var e,V,h=0,a=B;a>16&255]<<24^q[V>>8&255]<<16^q[255&V]<<8^q[V>>24&255]^s[h]<<24,h+=1,8!=B)for(var A=1;A>8&255]<<8^q[V>>16&255]<<16^q[V>>24&255]<<24;for(var A=B/2+1;A>2,n=a%4,this._Ke[r][n]=i[A],this._Kd[F-r][n]=i[A++],a++}for(var r=1;r>24&255]^Q[V>>16&255]^E[V>>8&255]^c[255&V]},Y.prototype.encrypt=function(F){if(16!=F.length)throw Error("invalid plaintext size (must be 16 bytes)");for(var A=this._Ke.length-1,t=[0,0,0,0],B=m(F),e=0;e<4;e++)B[e]^=this._Ke[0][e];for(var V=1;V>24&255]^r[B[(e+1)%4]>>16&255]^n[B[(e+2)%4]>>8&255]^M[255&B[(e+3)%4]]^this._Ke[V][e];B=t.slice()}for(var o,s=i(16),e=0;e<4;e++)o=this._Ke[A][e],s[4*e]=(q[B[e]>>24&255]^o>>24)&255,s[4*e+1]=(q[B[(e+1)%4]>>16&255]^o>>16)&255,s[4*e+2]=(q[B[(e+2)%4]>>8&255]^o>>8)&255,s[4*e+3]=(q[255&B[(e+3)%4]]^o)&255;return s},Y.prototype.decrypt=function(F){if(16!=F.length)throw Error("invalid ciphertext size (must be 16 bytes)");for(var A=this._Kd.length-1,t=[0,0,0,0],B=m(F),e=0;e<4;e++)B[e]^=this._Kd[0][e];for(var V=1;V>24&255]^l[B[(e+3)%4]>>16&255]^C[B[(e+2)%4]>>8&255]^I[255&B[(e+1)%4]]^this._Kd[V][e];B=t.slice()}for(var o,s=i(16),e=0;e<4;e++)o=this._Kd[A][e],s[4*e]=(h[B[e]>>24&255]^o>>24)&255,s[4*e+1]=(h[B[(e+3)%4]>>16&255]^o>>16)&255,s[4*e+2]=(h[B[(e+2)%4]>>8&255]^o>>8)&255,s[4*e+3]=(h[255&B[(e+1)%4]]^o)&255;return s};var D=function(F){if(!(this instanceof D))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new Y(F)};D.prototype.encrypt=function(F){if((F=B(F)).length%16!=0)throw Error("invalid plaintext size (must be multiple of 16 bytes)");for(var A=i(F.length),t=i(16),V=0;V=0;--A)this._counter[A]=F%256,F>>=8},S.prototype.setBytes=function(F){if(16!=(F=B(F,!0)).length)throw Error("invalid counter bytes size (must be 16 bytes)");this._counter=F},S.prototype.increment=function(){for(var F=15;F>=0;F--)if(255===this._counter[F])this._counter[F]=0;else{this._counter[F]++;break}};var k=function(F,A){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",A instanceof S||(A=new S(A)),this._counter=A,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new Y(F)};k.prototype.encrypt=function(F){for(var A=B(F,!0),t=0;t=64;){let n=t,M=B,g=i,l=e,C=V,I=o,w=s,Q=q,E,c,m,Y,D;for(c=0;c<16;c++)m=a+4*c,h[c]=(255&F[m])<<24|(255&F[m+1])<<16|(255&F[m+2])<<8|255&F[m+3];for(c=16;c<64;c++)Y=((E=h[c-2])>>>17|E<<15)^(E>>>19|E<<13)^E>>>10,D=((E=h[c-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3,h[c]=(Y+h[c-7]|0)+(D+h[c-16]|0)|0;for(c=0;c<64;c++)Y=(((C>>>6|C<<26)^(C>>>11|C<<21)^(C>>>25|C<<7))+(C&I^~C&w)|0)+(Q+(A[c]+h[c]|0)|0)|0,D=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&M^n&g^M&g)|0,Q=w,w=I,I=C,C=l+Y|0,l=g,g=M,M=n,n=Y+D|0;t=t+n|0,B=B+M|0,i=i+g|0,e=e+l|0,V=V+C|0,o=o+I|0,s=s+w|0,q=q+Q|0,a+=64,r-=64}}a(F);let r,n=F.length%64,M=F.length/536870912|0,g=F.length<<3,l=n<56?56:120,C=F.slice(F.length-n,F.length);for(C.push(128),r=n+1;r>>24&255),C.push(M>>>16&255),C.push(M>>>8&255),C.push(M>>>0&255),C.push(g>>>24&255),C.push(g>>>16&255),C.push(g>>>8&255),C.push(g>>>0&255),a(C),[t>>>24&255,t>>>16&255,t>>>8&255,t>>>0&255,B>>>24&255,B>>>16&255,B>>>8&255,B>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,e>>>24&255,e>>>16&255,e>>>8&255,e>>>0&255,V>>>24&255,V>>>16&255,V>>>8&255,V>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,q>>>24&255,q>>>16&255,q>>>8&255,q>>>0&255]}function t(F,t,B){let i;F=F.length<=64?F:A(F);let e=64+t.length+4,V=Array(e),o=Array(64),s=[];for(i=0;i<64;i++)V[i]=54;for(i=0;i=e-4;F--){if(V[F]++,V[F]<=255)return;V[F]=0}}for(;B>=32;)q(),s=s.concat(A(o.concat(A(V)))),B-=32;return B>0&&(q(),s=s.concat(A(o.concat(A(V))).slice(0,B))),s}function B(F,A,t,B,o){let s;for(V(F,(2*t-1)*16,o,0,16),s=0;s<2*t;s++)e(F,16*s,o,16),function(F,A){V(F,0,A,0,16);for(let F=8;F>0;F-=2)A[4]^=i(A[0]+A[12],7),A[8]^=i(A[4]+A[0],9),A[12]^=i(A[8]+A[4],13),A[0]^=i(A[12]+A[8],18),A[9]^=i(A[5]+A[1],7),A[13]^=i(A[9]+A[5],9),A[1]^=i(A[13]+A[9],13),A[5]^=i(A[1]+A[13],18),A[14]^=i(A[10]+A[6],7),A[2]^=i(A[14]+A[10],9),A[6]^=i(A[2]+A[14],13),A[10]^=i(A[6]+A[2],18),A[3]^=i(A[15]+A[11],7),A[7]^=i(A[3]+A[15],9),A[11]^=i(A[7]+A[3],13),A[15]^=i(A[11]+A[7],18),A[1]^=i(A[0]+A[3],7),A[2]^=i(A[1]+A[0],9),A[3]^=i(A[2]+A[1],13),A[0]^=i(A[3]+A[2],18),A[6]^=i(A[5]+A[4],7),A[7]^=i(A[6]+A[5],9),A[4]^=i(A[7]+A[6],13),A[5]^=i(A[4]+A[7],18),A[11]^=i(A[10]+A[9],7),A[8]^=i(A[11]+A[10],9),A[9]^=i(A[8]+A[11],13),A[10]^=i(A[9]+A[8],18),A[12]^=i(A[15]+A[14],7),A[13]^=i(A[12]+A[15],9),A[14]^=i(A[13]+A[12],13),A[15]^=i(A[14]+A[13],18);for(let t=0;t<16;++t)F[t]+=A[t]}(o,B),V(o,0,F,A+16*s,16);for(s=0;s>>32-A}function e(F,A,t,B){for(let i=0;i=256)return!1}return!0}function s(F,A){if("number"!=typeof F||F%1)throw Error("invalid "+A);return F}function q(F,A,i,q,h,a,r){let n;if(i=s(i,"N"),q=s(q,"r"),h=s(h,"p"),a=s(a,"dkLen"),0===i||(i&i-1)!=0)throw Error("N must be power of 2");if(i>2147483647/128/q)throw Error("N too large");if(q>2147483647/128/h)throw Error("r too large");if(!o(F))throw Error("password must be an array or buffer");if(F=Array.prototype.slice.call(F),!o(A))throw Error("salt must be an array or buffer");A=Array.prototype.slice.call(A);let M=t(F,A,128*h*q),g=new Uint32Array(32*h*q);for(let F=0;FG&&(A=G);for(let F=0;FG&&(A=G);for(let F=0;F>0&255),M.push(g[F]>>8&255),M.push(g[F]>>16&255),M.push(g[F]>>24&255);let o=t(F,M,a);return r&&r(null,1,o),o}r&&S(k)};if(!r)for(;;){let F=k();if(void 0!=F)return F}k()}let h={scrypt:function(F,A,t,B,i,e,V){return new Promise(function(o,s){let h=0;V&&V(0),q(F,A,t,B,i,e,function(F,A,t){if(F)s(F);else if(t)V&&1!==h&&V(1),o(new Uint8Array(t));else if(V&&A!==h)return h=A,V(A)})})},syncScrypt:function(F,A,t,B,i,e){return new Uint8Array(q(F,A,t,B,i,e))}};void 0!==CI?CI=h:"function"==typeof define&&define.amd?define(h):F&&(F.scrypt&&(F._scrypt=F.scrypt),F.scrypt=h)}(CI),new rp(CC),new rp("wallet/5.7.0");let CE=new rp("web/5.7.1");function Cc(F){return new Promise(A=>{setTimeout(A,F)})}function Cm(F,A){if(null==F)return null;if("string"==typeof F)return F;if(rk(F)){if(A&&("text"===A.split("/")[0]||"application/json"===A.split(";")[0].trim()))try{return Mt(F)}catch(F){}return rT(F)}return F}function CY(F,A,t){let B;let i="object"==typeof F&&null!=F.throttleLimit?F.throttleLimit:12;CE.assertArgument(i>0&&i%1==0,"invalid connection throttle limit","connection.throttleLimit",i);let e="object"==typeof F?F.throttleCallback:null,V="object"==typeof F&&"number"==typeof F.throttleSlotInterval?F.throttleSlotInterval:100;CE.assertArgument(V>0&&V%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",V);let o="object"==typeof F&&!!F.errorPassThrough,s={},q=null,h={method:"GET"},a=!1,r=12e4;if("string"==typeof F)q=F;else if("object"==typeof F){if((null==F||null==F.url)&&CE.throwArgumentError("missing URL","connection.url",F),q=F.url,"number"==typeof F.timeout&&F.timeout>0&&(r=F.timeout),F.headers)for(let A in F.headers)s[A.toLowerCase()]={key:A,value:String(F.headers[A])},["if-none-match","if-modified-since"].indexOf(A.toLowerCase())>=0&&(a=!0);if(h.allowGzip=!!F.allowGzip,null!=F.user&&null!=F.password){"https:"!==q.substring(0,6)&&!0!==F.allowInsecureAuthentication&&CE.throwError("basic authentication requires a secure https url",rp.errors.INVALID_ARGUMENT,{argument:"url",url:q,user:F.user,password:"[REDACTED]"});let A=F.user+":"+F.password;s.authorization={key:"Authorization",value:"Basic "+Mz(n9(A))}}null!=F.skipFetchSetup&&(h.skipFetchSetup=!!F.skipFetchSetup),null!=F.fetchOptions&&(h.fetchOptions=r$(F.fetchOptions))}let n=RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),M=q?q.match(n):null;if(M)try{var g;let F={statusCode:200,statusMessage:"OK",headers:{"content-type":M[1]||"text/plain"},body:M[2]?MO(M[3]):(g=M[3],n9(g.replace(/%([0-9a-f][0-9a-f])/gi,(F,A)=>String.fromCharCode(parseInt(A,16)))))},A=F.body;return t&&(A=t(F.body,F)),Promise.resolve(A)}catch(F){CE.throwError("processing response error",rp.errors.SERVER_ERROR,{body:Cm(M[1],M[2]),error:F,requestBody:null,requestMethod:"GET",url:q})}A&&(h.method="POST",h.body=A,null==s["content-type"]&&(s["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==s["content-length"]&&(s["content-length"]={key:"Content-Length",value:String(A.length)}));let l={};Object.keys(s).forEach(F=>{let A=s[F];l[A.key]=A.value}),h.headers=l;let C=(B=null,{promise:new Promise(function(F,A){r&&(B=setTimeout(()=>{null!=B&&(B=null,A(CE.makeError("timeout",rp.errors.TIMEOUT,{requestBody:Cm(h.body,l["content-type"]),requestMethod:h.method,timeout:r,url:q})))},r))}),cancel:function(){null!=B&&(clearTimeout(B),B=null)}}),I=function(){var F,A,B,s;return F=this,A=void 0,B=void 0,s=function*(){for(let F=0;F{e[A.toLowerCase()]=F}):B.headers.keys().forEach(F=>{e[F.toLowerCase()]=B.headers.get(F)}),{headers:e,statusCode:B.status,statusMessage:B.statusText,body:rK(new Uint8Array(i))}},new(i||(i=Promise))(function(F,A){function V(F){try{s(e.next(F))}catch(F){A(F)}}function o(F){try{s(e.throw(F))}catch(F){A(F)}}function s(A){var t;A.done?F(A.value):((t=A.value)instanceof i?t:new i(function(F){F(t)})).then(V,o)}s((e=e.apply(t,B||[])).next())})}(q,h),F=300)&&(C.cancel(),CE.throwError("bad response",rp.errors.SERVER_ERROR,{status:A.statusCode,headers:A.headers,body:Cm(B,A.headers?A.headers["content-type"]:null),requestBody:Cm(h.body,l["content-type"]),requestMethod:h.method,url:q})),t)try{let F=yield t(B,A);return C.cancel(),F}catch(t){if(t.throttleRetry&&F"content-type"===F.toLowerCase()).length||(t.headers=r$(t.headers),t.headers["content-type"]="application/json"):t.headers={"content-type":"application/json"},F=t}return CY(F,B,(F,A)=>{let B=null;if(null!=F)try{B=JSON.parse(Mt(F))}catch(A){CE.throwError("invalid JSON",rp.errors.SERVER_ERROR,{body:F,error:A})}return t&&(B=t(B,A)),B})}function Cp(F,A){return A||(A={}),null==(A=r$(A)).floor&&(A.floor=0),null==A.ceiling&&(A.ceiling=1e4),null==A.interval&&(A.interval=250),new Promise(function(t,B){let i=null,e=!1,V=()=>!e&&(e=!0,i&&clearTimeout(i),!0);A.timeout&&(i=setTimeout(()=>{V()&&B(Error("timeout"))},A.timeout));let o=A.retryLimit,s=0;!function i(){return F().then(function(F){if(void 0!==F)V()&&t(F);else if(A.oncePoll)A.oncePoll.once("poll",i);else if(A.onceBlock)A.onceBlock.once("block",i);else if(!e){if(++s>o){V()&&B(Error("retry limit reached"));return}let F=A.interval*parseInt(String(Math.random()*Math.pow(2,s)));FA.ceiling&&(F=A.ceiling),setTimeout(i,F)}return null},function(F){V()&&B(F)})}()})}var Cu={};Cu='';var CG={};CG='';var CS={};CS='';var Ck={};Ck='';var CU={};CU='';var Cy={};Cy='';var CK={};CK='';var CZ={};CZ='';var CJ={};CJ='';var CR={};CR='';var Cd={};Cd='';var Cx={};Cx='';var CT={};CT='';var CL={};CL='';var CN={};CN='';var Cj={};Cj='';var CW={};CW='';var CO={};CO='';var Cz={};Cz='';var Cf={};Cf='';var Cv={};Cv='';var CH={};CH='';var Cb={};Cb='';var CP={};CP='';var CX={};CX='';var C_={};C_='';var C$={};C$='';var C2={};C2='';var C0={};C0='';var C1={};C1='';var C4={};C4='';var C5={};C5='';var C8={};C8='';var C6={};C6='';var C3={};C3='';var C9={};C9='';var C7={};C7='';var IF={};IF='';var IA={};IA='';var It={};It='';var IB={};IB='';var Ii={};Ii='';var Ie={};Ie='';var IV={};IV='';var Io={};Io='';var Is={};Is='';var Iq={};Iq='';var Ih={};Ih='';var Ia={};Ia='';var Ir={};Ir='';var In={};In='';var IM={};IM='';var Ig={};Ig='';var Il={};Il='';var IC={};IC='';var II={};II='';var Iw={};Iw='';var IQ={};IQ='';var IE={};IE='';var Ic={};Ic='';var Im={};Im='';var IY={};IY='';var ID={};ID='';var Ip={};Ip='';var Iu={};Iu='';var IG={};IG='';var IS=[{bodyIndex:0,radius:51e3,px:5e5,py:290750,vx:-1e5,vy:-1e6,exitX:100,exitY:-600},{bodyIndex:5,radius:11e3,px:793406,py:133029,vx:1e6,vy:-1e7,exitX:300,exitY:-50},{bodyIndex:2,radius:23e3,px:825620,py:328711,vx:1e5,vy:-1e6,exitX:500,exitY:50},{bodyIndex:1,radius:27e3,px:159878,py:234946,vx:-1e5,vy:-1e6,exitX:-300,exitY:-400},{bodyIndex:3,radius:19e3,px:229878,py:464946,vx:-1e5,vy:-1e6,exitX:-400,exitY:-50},{bodyIndex:4,radius:15e3,px:679878,py:668946,vx:1e5,vy:-1e6,exitX:600,exitY:300}];let Ik=[30,10,20,30,40,50],IU=Ik.length-1,Iy={fg:{direction:1,speed:25},bg:{direction:-1,speed:35},core:{direction:1,speed:100}},IK={fg:{1:{speed:0},8:{speed:0},9:{direction:-1}}},IZ=[FH(Cu),FH(CG),FH(CS),FH(Ck),FH(CU),FH(Cy),FH(CK),FH(CZ),FH(CJ),FH(CR)],IJ=[FH(Cd),FH(Cx),FH(CT),FH(CL),FH(CN),FH(Cj),FH(CW),FH(CO),FH(Cz),FH(Cf)],IR=[FH(Cv),FH(CH),FH(Cb),FH(CP),FH(CX),FH(C_),FH(C$),FH(C2),FH(C0),FH(C1),FH(C4),FH(C5),FH(C8),FH(C6)],Id=[FH(C3),FH(C9),FH(C7),FH(IF),FH(IA),FH(It),FH(IB),FH(Ii),FH(Ie),FH(IV),FH(Io),FH(Is),FH(Iq),FH(Ih)],Ix=[FH(Ia),FH(Ir),FH(In),FH(IM),FH(Ig),FH(Il),FH(IC),FH(II),FH(Iw),FH(IQ),FH(IE),FH(Ic),FH(Im),FH(IY)],IT=[FH(ID)],IL={BADDIE_SVG:{bg:FH(Ip),core:FH(Iu),face:FH(IG)},BG_SVGS:IZ,CORE_SVGS:IT,FACE_BLINK_SVGS:Id,FACE_SHOT_SVGS:Ix,FACE_SVGS:IR,FG_SVGS:IJ},IN=(F,A,t)=>F.replaceAll(RegExp(`(?<=\\s|^)${A}="(?!none)([^"]+)"`,"g"),`${A}="${t}"`),Ij={async draw(){if(this.missileEvent){let{x:F,y:A}=this.missileEvent;this.missileEvent=!1,this.processMissileClick(F,A)}for(let F in this.shaking&&this.shaking>0?this.shakeScreen():this.shaking=null,this.buttons)this.buttons[F].visible=!1;if(!this.showIt)return;this.firstFrame||this.hasStarted||(this.hasStarted=!0,this.started());let F=this.introStage>=this.totalIntroStages;if((F||this.level>0)&&!this.paused&&this.p5Frames%this.P5_FPS_MULTIPLIER==0){this.firstFrame=!1,this.frames++;let F=this.step(this.bodies,this.missiles);this.bodies=F.bodies||[],this.missiles=F.missiles||[]}if(this.shootMissileNextFrame){let{x:F,y:A}=this.shootMissileNextFrame;console.log("trigger missile click from draw",{x:F,y:A}),this.shootMissileNextFrame=null,this.missileClick(F,A)}this.p.noFill(),this.drawBg(),this.p5Frames++,this.drawExplosions(),F||this.level>0?(this.drawPause(),this.drawBodies()):this.paused?this.drawPause():this.drawIntro(),this.drawScore(),this.drawMuteButton(),this.drawPopup(),this.drawGun(),this.drawGunSmoke(),this.drawExplosionSmoke(),this.frames-this.startingFrame+this.FPSF+A.radius,0)&&this.drawMissiles();let A=!this.paused,t=(this.frames-this.startingFrame)%this.stopEvery==0&&this.p5Frames%this.P5_FPS_MULTIPLIER==0,B=!this.justPaused,i=this.frames-this.startingFrame+this.FPS>=this.timer,e=0==this.bodies[0].radius&&0!==this.level;(i||e)&&!this.handledGameOver&&this.handleGameOver({won:!1,ranOutOfTime:i,hitHeroBody:e}),this.won||"game"!=this.mode||0!=this.bodies.slice(0==this.level?0:1).reduce((F,A)=>F+A.radius,0)||this.handledGameOver||this.handleGameOver({won:!0}),!this.firstFrame&&A&&t&&B&&!i&&!this.handledGameOver?this.finish():this.justPaused=!1},drawTextBubble({text:F="",x:A=0,y:t=0,w:B=240,h:i=56,fz:e=48,fg:V,bg:o,stroke:s,align:q=[this.p.CENTER,this.p.TOP]}){if(!F)return{x:A,y:t,h:i,w:B,fz:e};let{p:h}=this;h.fill(o??"black"),h.stroke(s??rV.iris_60),h.rect(A,t,B,i,16,16,16,16),q[0]===h.LEFT&&(A-=B/2),h.textFont(rg.body),h.textAlign(...q),h.textSize(e),h.fill(V??rV.iris_30),h.noStroke(),h.text(F,A+B/2,t+(i-e)/2-1),h.pop()},drawPause(){if(!rg.dot||!this.paused||-1!==this.showProblemRankingsScreenAt)return;let F=this.p,A=0==this.level?.7:0,t=A*this.P5_FPS;if(this.willUnpause&&!this.beganUnpauseAt&&(this.beganUnpauseAt=t?this.p5Frames:0),this.beganUnpauseAt+t{this.popup||(this.sound?.playStart(),this.setPause(!1))},fg:rV.violet_50,bg:rV.pink,width:410,height:108,textSize:78,x:this.opensea?this.windowWidth/2-205:508,y:862,p:F}),!0!==this.opensea&&this.drawButton({text:"MINT",onClick:()=>{this.emit("mint")},fg:rV.violet_25,bg:"#241465",width:410,height:108,textSize:78,x:82,y:862,p:F}),F.pop())},drawBodyOutlines(){for(let F=0;F{for(let i=0;i<5e3;i++){let i=F.random(0,F.TWO_PI),e=F.random(-125,250),V=e*F.cos(i),o=e*F.sin(i),s=F.lerpColor(F.color(B),F.color(F.random(150),F.random(150),F.random(150)),.65);s.setAlpha(100),F.fill(s),F.ellipse(A+V,t+o,2,2)}},A=(F,A,t,B)=>(1-B)*(1-B)*F+2*(1-B)*B*A+B*B*t;if(!this.starBG){this.starBG=this.p.createGraphics(this.windowWidth,this.windowHeight),this.starBG.pixelDensity(this.pixelDensity);for(let F=0;F<200;F++){this.starBG.noStroke(),this.starBG.fill(rV.fg),this.starBG.textSize(15);let F=[",",".","*"];this.starBG.text(F[Math.floor(Math.random()*F.length)],Math.floor(Math.random()*this.windowWidth),Math.floor(Math.random()*this.windowHeight))}(t=>{let B=(F,A,t=0)=>{let B=rI.solidityKeccak256(["bytes32"],[this.seed]);return 0!==t&&(B=rI.solidityKeccak256(["bytes32","uint256"],[B,t])),this.randomRange(F,A,B)};t.colorMode(t.RGB);let i=t.color(...rq(ra(ro.bodies.default.berlin.bg,!0,B.bind(this),0),1,!0)),e=t.color(...rq(ra(ro.bodies.default.berlin.bg,!0,B.bind(this),100),1,!0)),V=0==B(0,1,0),o=0==B(0,1,1),s=V?-100:this.windowWidth+100,q=o?this.windowHeight+100:0,h=V?0:this.windowWidth,a=o?0:this.windowHeight,r=V?this.windowWidth:-100,n=o?-100:this.windowHeight+100;for(let B=0;B<=1;B+=.01){let V=A(s,h,r,B),o=A(q,a,n,B),M=t.map(o,50,250,0,1),g=t.lerpColor(i,e,M);t.noStroke(),F(t,V,o,g)}t.colorMode(t.RGB)})(this.starBG)}this.p.image(this.starBG,0,0,this.windowWidth,this.windowHeight)},drawPopup(){if(!this.popup)return;let{p:F,popup:A}=this;A.lastVisibleFrame!==this.p5Frames-1&&(A.visibleForFrames=0),A.visibleForFrames++,A.lastVisibleFrame=this.p5Frames;let t=Math.min(.8,A.visibleForFrames/(.2*this.P5_FPS));F.fill(`rgba(20, 4, 32, ${t})`),F.noStroke(),F.rect(0,0,this.windowWidth,this.windowHeight);let B=(this.windowWidth-840)/2,i=A.bg??rV.violet_25,e=A.fg??rV.violet_50,V=A.stroke??e,o=130+44*A.body.length+140,s=Math.max(0,50-50/(.2*this.P5_FPS)*A.visibleForFrames),q=(this.windowHeight-o)/2+s;if(F.fill(i),F.stroke(V),F.strokeWeight(3),F.rect(B,q,840,o,24,24,24,24),!rg.dot||(F.textFont(rg.dot),F.fill(A.fg??e),F.textSize(90),F.textAlign(F.CENTER,F.TOP),F.noStroke(),F.text(A.header,B+420,q+40),!rg.body))return;F.textFont(rg.body),F.textSize(44),F.textAlign(F.CENTER,F.TOP);for(let t=0;t1?B+24+(a+10)*F:B+420-a/2,...r,...t})}F.pop()},handleRedoButtonClick(F=!0){this.skipRedoPopupTip?this.restart(null,!1):this.popup={bg:rV.teal_75,fg:rV.teal_50,stroke:rV.teal_50,header:"Tip",body:[this.hasTouched?"Tap the TIMER to restart levels":"Press {R} to restart levels"],buttons:[...F?[{text:"CLOSE",onClick:()=>{this.popup=null}}]:[],{text:"REDO",bg:rV.teal_50,fg:rV.teal_75,stroke:rV.teal_50,onClick:()=>{this.popup=null,this.restart(null,!1)}}]}},getColorDir(F){return Math.floor(this.frames/(255*F))%2==0},getGrey(){return this.getColorDir(this.chunk)?255-Math.floor(this.frames/this.chunk)%255:Math.floor(this.frames/this.chunk)%255},drawMuteButton(){if(this.paused||this.gameOver||0===this.introStage&&!(this.levelCountdown<200))return;let{p:F}=this;F.push(),F.noStroke(),F.fill("white");let A=this.windowWidth-(this.hasTouched?108:80),t=this.windowHeight-(this.hasTouched?116:84);F.translate(A,t);let B=this.hasTouched?Math.floor(8):Math.floor(6);this.drawMuteIconRect(0,3,1,4,B),this.drawMuteIconRect(2,3,1,4,B),this.drawMuteIconRect(3,2,1,6,B),this.drawMuteIconRect(4,1,1,8,B),this.drawMuteIconRect(5,0,1,10,B),this.drawMuteIconRect(1,3,1,4,B),this.mute?this.drawMuteIconRect(7,4.5,2.5,1,B):(this.drawMuteIconRect(6.5,4,1,2,B),this.drawMuteIconRect(8,3,1,4,B));let i={x:this.hasTouched?-20:-6,y:this.hasTouched?-20:-6,w:200},e=this.buttons["mute-button"];e||(this.buttons["mute-button"]={x:A+i.x,y:t+i.y,width:i.w,height:i.w,onClick:()=>{this.mute=!this.mute,this.sound?.setMuted(this.mute)}},(e=this.buttons["mute-button"]).disabled=!1),e.visible=!0,F.pop()},drawScore(){if(this.paused)return;let{p:F}=this;F.push(),F.fill("white"),F.noStroke(),F.textAlign(F.LEFT,F.TOP),this.drawProblemRankingsScreen();let A=this.frames-this.startingFrame,t=(this.framesTook||A)/this.FPS,B=(this.level>5?60:Ik[this.level])-t;if(!this.gameOver||(this.scoreSize=this.initialScoreSize,F.pop(),this.won?this.drawWinScreen():this.drawLoseScreen(),this.celebrating)){if(this.won){let A=Math.floor(this.frames/10)%2==0;F.fill(A?rV.red:"white")}F.textFont(rg.body),F.textSize(this.scoreSize),A>2&&(!this.gameOver||this.gameOver&&this.won&&!this.skipAhead)&&(this.won?(F.textSize(2*this.scoreSize),F.text(t.toFixed(2)+"s",20,0)):(F.text(B.toFixed(2),20,0),F.textAlign(F.RIGHT,F.TOP),this.hasTouched&&(this.buttons["touch-timer-reset"]={x:0,y:0,width:200,height:110,disabled:!1,visible:!0,onClick:()=>{this.skipRedoPopupTip=!0,this.restart(null,!1)}}),F.text("Lvl "+this.level,this.windowWidth-20,0))),F.pop()}},drawMuteIconRect(F,A,t,B,i){this.p.rect(F*i,A*i,t*i,B*i,1)},drawWinScreen(){this.showProblemRankingsScreenAt>=0||(this.winScreenLastVisibleFrame!==this.p5Frames-1&&(this.winScreenVisibleForFrames=0),this.winScreenVisibleForFrames++,this.winScreenLastVisibleFrame=this.p5Frames,this.celebrating=this.winScreenVisibleForFrames/this.P5_FPS<2.5,this.celebrating&&!this.skipAhead?this.drawGameOverTicker({text:" YES YES YES YES YES YES YES YES",bottom:!0,fg:rV.iris_30}):0==this.level?(this.level++,this.restart(null,!1)):(this.sound?.playbackRate!=="normal"&&this.sound?.playCurrentSong(),this.drawStatsScreen()))},drawStatsScreen(){this.shownStatScreen||(this.shownStatScreen=!0);let{p:F}=this,A=this.level>1;this.statsScreenLastVisibleFrame!==this.p5Frames-1&&(this.statsScreenVisibleForFrames=0,this.P5_FPS=this.FPS*this.P5_FPS_MULTIPLIER,this.p.frameRate(this.P5_FPS)),this.statsScreenVisibleForFrames++,this.statsScreenLastVisibleFrame=this.p5Frames;let t=Math.min(1,this.statsScreenVisibleForFrames/(.4*this.P5_FPS));if(F.push(),F.noStroke(),F.fill("white"),!rg.dot)return;F.textFont(rg.dot),F.fill(rV.pink),F.textSize(64),F.textAlign(F.LEFT,F.TOP);let B=F.map(t,0,1,-100,19);rC(F,"Anybody",340,B,.8),rC(F,"Problem",662,B,2),F.fill("black"),F.stroke(rV.border),F.strokeWeight(1);let i=this.windowWidth-40;if(F.rect(20,104,i,144,24),F.rect(20,320,i,A?444:364,24),F.rect(20,796,i,64,24),F.textSize(36),F.noStroke(),!rg.body)return;F.textFont(rg.body),F.fill(rV.iris_50),F.text("player",341,128),F.text("problem",341,188),F.textSize(54),F.fill(rV.iris_30);let e=new Date(this.date).toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}).toUpperCase();F.text(this.playerName??"YOU",495,114),F.text(e,495,174);let V=this.levelSpeeds.map(F=>F?.framesTook/this.FPS).filter(F=>void 0!==F),o=this.todaysRecords?.levels?.map(F=>F.events[0].time/this.FPS)??[],s=o.length;F.textSize(48),F.fill(rV.iris_30),F.textAlign(F.RIGHT,F.TOP);let q=s?580:964;F.text("time",q,264),s&&(F.text("best",780,264),F.text("diff",964,264));let h=V.length>=IU;F.fill(`rgba(146, 118, 255, ${Math.floor(F.frameCount/18)%2?"0.2":"0"})`),F.rect(20,320+(V.length-1)*72,this.windowWidth-40,72,1===this.level?24:0,1===this.level?24:0,0,0),F.push(),F.textAlign(F.RIGHT,F.CENTER),F.textSize(56);for(let A=0;A{if(A>=V.length)return"";let t=V[A]-F;return(Number(t.toFixed(2))>0?"+":"-")+Math.abs(t).toFixed(2)}).filter(Boolean);for(let A=0;AF+A,0),t=[A.toFixed(2)];if(s){let F=o.slice(0,V.length).reduce((F,A)=>F+A,0),B=Number((A-F).toFixed(2));t[1]=F.toFixed(2),t[2]=`${B>0?"+":"-"}${Math.abs(B).toFixed(2)}`}let B=320+72*Math.min(5,IU),e=B+40;for(let[A,B]of(F.textAlign(F.LEFT,F.CENTER),F.fill(rV.iris_50),F.text(h?"solved in":"total time",44,e),F.textAlign(F.RIGHT,F.CENTER),(s?[580,780,964]:[q]).entries()))0==A?F.fill(rV.iris_30):1==A?F.fill(rV.iris_60):F.fill(/^-/.test(t[A])?rV.lime:rV.flame_50),F.text(t[A],B,e,150,80);F.strokeWeight(1),F.stroke(rV.iris_60),F.line(20,B,i+20,B),F.noStroke()}F.pop();let a=this.getDisplayHero(),r=F.sin(F.frameCount/this.P5_FPS)*(5+a.bodyIndex),n=F.cos(F.frameCount/this.P5_FPS+3*a.bodyIndex)*(6+a.bodyIndex);a.position={x:F.map(t,0,1,-140,170)+r,y:180+n},this.drawBody(a),this.winScreenBaddies||=this.getDisplayBaddies();let M=this.winScreenBaddies;for(let F=0;F=2,this.showShare=this.level>=5;let l=2+Number(this.showRestart)+Number(this.showShare);this.drawBottomButton({text:"REDO",onClick:()=>{this.popup||this.handleRedoButtonClick()},...ro.buttons.teal,columns:l,column:0}),this.showRestart&&this.drawBottomButton({text:"EXIT",onClick:()=>{this.popup||(this.popup={bg:rV.flame_75,fg:rV.flame_50,stroke:rV.flame_50,header:"Start Over?",body:["Any progress will be lost!"],buttons:[{text:"CLOSE",fg:rV.flame_50,bg:rV.flame_75,stroke:rV.flame_50,onClick:()=>{this.popup=null}},{text:"EXIT",fg:rV.flame_75,bg:rV.flame_50,stroke:rV.flame_50,onClick:()=>{this.popup=null,this.level=1,this.restart(void 0,!0)}}]})},...ro.buttons.flame,columns:l,column:1}),this.showShare&&this.drawBottomButton({text:"SHARE",onClick:()=>{null===this.popup&&this.shareCanvas()},...ro.buttons.pink,columns:l,column:2}),this.level<5?this.drawBottomButton({text:"NEXT",onClick:()=>{this.level++,this.level>5?this.showProblemRankingsScreenAt=this.p5Frames:this.restart(null,!1)},...ro.buttons.green,columns:l,column:l-1}):this.drawBottomButton({text:"SAVE",onClick:()=>{if(!this.popup){if(this.opensea){this.popup={header:"Nice Job!",body:["Next time play on ANYBODY.gg to save","your win to the leaderboard !!"],fg:rV.green_50,bg:rV.green_75,buttons:[{text:"CLOSE",onClick:()=>{this.popup=null}},{text:"NEW GAME",onClick:()=>{this.popup=null,this.level=1,this.restart(void 0,!0)},fg:rV.green_75,bg:rV.green_50}]};return}this.emit("save")}},...ro.buttons.green,columns:l,column:l-1}),F.pop(),this.showShare?1!==t||this.shareCanvasBlob||F.canvas.toBlob(F=>{this.shareCanvasBlob=new File([F],"MyWin.png",{type:"image/png"})},"image/png"):this.shareCanvasBlob=void 0},drawProblemRankingsScreen(){if(-1===this.showProblemRankingsScreenAt)return;let{p:F}=this,A=Math.min(1,(this.p5Frames-this.showProblemRankingsScreenAt)/(1.5*this.P5_FPS));if(F.push(),F.noStroke(),F.fill("white"),F.fill("black"),F.stroke(rV.border),F.strokeWeight(1),F.rect(22,28,this.windowWidth-44,103,24),F.rect(22,155,this.windowWidth-44,216,24),F.rect(22,395,this.windowWidth-44,72,24),!rg.dot)return;F.textFont(rg.dot);let t=F.map(A,0,1,0,1);if(F.fill(rr(rV.pink,t)),F.textSize(60),F.textAlign(F.LEFT,F.TOP),rC(F,"Anybody",46,44,.8),rC(F,"Problem",356,44,2),F.textSize(56),F.noStroke(),!rg.body)return;F.textFont(rg.body),F.fill(rV.iris_30),F.textAlign(F.RIGHT,F.TOP),F.text(this.date,this.windowWidth-42,48),F.textSize(44),F.textAlign(F.RIGHT,F.TOP);let B=this.windowWidth-42;for(let[A,t]of[{rank:1,name:"0xABCD-1234",time:188.889192912},{rank:2,name:"longassensnamethatgoesofftherowalllllllls",time:189.889192912},{rank:3,name:"0xABCD-1234",time:198.889192912},{rank:999998,name:"petersugihara.eth",time:260.889192912}].entries()){let i=72*A+36+(3===A?24:0);F.textAlign(F.LEFT,F.CENTER),F.fill(rV.iris_60);let e=1===t.rank?"1st":2===t.rank?"2nd":3===t.rank?"3rd":`${t.rank.toLocaleString()}`;F.text(e,42,155+i),F.fill(rV.iris_30);let V=t.name;for(;F.textWidth(V)>656;)V=`${V.replaceAll(/\.\.\.$/g,"").slice(0,-1)}...`;F.text(V,187,155+i),F.textAlign(F.RIGHT,F.CENTER),F.fill(rV.iris_60),F.text(t.time.toFixed(2),B,155+i),A<2&&(F.fill(rV.iris_60),F.rect(22,155+72*(A+1),this.windowWidth-44,1))}let i=this.getDisplayHero({radius:33}),e=F.sin(F.frameCount/this.P5_FPS)*(5+i.bodyIndex),V=F.cos(F.frameCount/this.P5_FPS+3*i.bodyIndex)*(6+i.bodyIndex);if(i.position={x:F.map(A**3,0,1,-140,180)+e,y:670+V},this.drawBody(i),this.drawMessageBox||=({lines:A,x:t,y:B,color:i,start:e,textWidth:V})=>{if(-1!==e&&this.p5Framess.length&&this.sound?.playStart();let q=A.sort((F,A)=>A.length-F.length)[0];F.rect(t,B,(V||F.textWidth(q))+24+20,36*A.length+40,20),F.fill(i),F.text(s,t+24,B+20)},"unsaved"===this.saveStatus){let F=this.showProblemRankingsScreenAt+1.5*this.P5_FPS,A=this.showProblemRankingsScreenAt+3*this.P5_FPS,t=this.showProblemRankingsScreenAt+5.5*this.P5_FPS;this.drawMessageBox({lines:["wOwOwoWwwww ! ! ! !","you solved the daily problem !"],x:344,y:504,color:rV.iris_30,start:F}),this.drawMessageBox({lines:["replay as many times as you'd like","before tomorrow's problem..."],x:370,y:704,color:rV.pink,start:t}),this.drawMessageBox({lines:["SAVE your score to the leaderboard","and receive today's celestial body !"],x:484,y:604,color:rV.green_50,start:A,textWidth:451})}if("validating"===this.saveStatus&&(this.validatingAt||=this.p5Frames,this.drawMessageBox({lines:["validating your score..."],x:344,y:504,color:rV.iris_30,start:this.validatingAt})),("validated"===this.saveStatus||"saved"===this.saveStatus||"saving"===this.saveStatus)&&(this.validatedAt||=this.p5Frames,this.drawMessageBox({lines:["score validated!"],x:344,y:504,color:rV.iris_30,start:-1})),"validated"===this.saveStatus&&this.validatedAt){let F=this.validatedAt+1*this.P5_FPS;this.drawMessageBox({lines:["you can now save your score"],x:484,y:566,color:rV.green_50,start:F})}else if("saving"===this.saveStatus)this.savingAt||=this.p5Frames,this.drawMessageBox({lines:["saving your score..."],x:484,y:566,color:rV.green_50,start:this.savingAt});else if("saved"===this.saveStatus){this.savedAt||=this.p5Frames,this.drawMessageBox({lines:["score SAVED!"],x:478,y:566,color:rV.green_50,start:this.savedAt});let F=this.savedAt+1*this.P5_FPS;this.drawMessageBox({lines:["this body is now in your wallet !"],x:414,y:653,color:rV.pink_40,start:F});let A=this.savedAt+2*this.P5_FPS;this.drawMessageBox({lines:["but, maybe you can do better ??"],x:545,y:757,color:rV.yellow_50,start:A})}"saved"!==this.saveStatus?(this.drawBottomButton({text:"BACK",onClick:()=>{this.restart(null,!1)},...ro.buttons.teal,columns:2,column:0}),this.drawBottomButton({text:"unsaved"===this.saveStatus?"SAVE":"validated"===this.saveStatus?"SAVE":`${this.saveStatus.toUpperCase()}...`,onClick:()=>{this.handleSave()},...ro.buttons.green,disabled:"unsaved"!==this.saveStatus&&"validated"!==this.saveStatus,columns:2,column:1,key:"problem-save"})):this.drawBottomButton({text:"NEW GAME",onClick:()=>{this.restart()},...ro.buttons.yellow,columns:1,column:0}),F.pop()},getDisplayHero({radius:F}={radius:33}){let A=this.bodies[0],t=JSON.parse(JSON.stringify(A,(F,A)=>"bigint"==typeof A?A.toString():A));return t.position=this.p.createVector(A.position.x,A.position.y),t.velocity=this.p.createVector(A.velocity.x,A.velocity.y),t.radius=F,t},getDisplayBaddies(){let F=[],A=this.generateLevelData(this.day,5).map(F=>this.bodyDataToBodies.call(this,F,this.day));if(!A[A.length-1])return[];for(let t=0;t1){let F=this.windowWidth/2-400+20;this.drawFatButton({text:"REDO",onClick:()=>{this.handleRedoButtonClick()},x:F,bg:rV.teal_75,fg:rV.teal_50}),this.drawFatButton({text:"EXIT",x:this.windowWidth/2+100-20,bg:rV.flame_75,fg:rV.flame_50,onClick:()=>{this.popup||(this.popup={bg:rV.flame_75,fg:rV.flame_50,stroke:rV.flame_50,header:"Leave game?",body:["Any progress will be lost!"],buttons:[{text:"CLOSE",fg:rV.flame_50,bg:rV.flame_75,stroke:rV.flame_50,onClick:()=>{this.popup=null}},{text:"EXIT",fg:rV.flame_75,bg:rV.flame_50,stroke:rV.flame_50,onClick:()=>{this.popup=null,this.level=1,this.restart(void 0,!0)}}]})}})}else this.drawFatButton({text:"REDO",onClick:()=>this.handleRedoButtonClick(!1),bg:rV.teal_75,fg:rV.teal_50});F.pop()},scaleX(F){let{canvas:A}=this.p;return F/A.offsetWidth*this.windowWidth},scaleY(F){let{canvas:A}=this.p;return F/A.offsetHeight*this.windowHeight},drawGun(){if(this.p.stroke("rgba(200,200,200,1)"),this.p.strokeCap(this.p.SQUARE),this.p.mouseX<=0&&this.p.mouseY<=0)return;let F=this.windowHeight;this.p.strokeWeight(rV.borderWt);let A=this.scaleX(this.p.mouseX)-0,t=this.scaleY(this.p.mouseY)-F;this.p.line(this.scaleX(this.p.mouseX)-25,this.scaleX(this.p.mouseY),this.scaleX(this.p.mouseX)+25,this.scaleX(this.p.mouseY)),this.p.line(this.scaleX(this.p.mouseX),this.scaleX(this.p.mouseY)-25,this.scaleX(this.p.mouseX),this.scaleX(this.p.mouseY)+25);let B=this.introStage!==this.totalIntroStages-1,i=this.introStage"string"==typeof F?((F=F.split(","))[0]=parseInt(F[0].split("(")[1]),F[1]=parseInt(F[1]),F[2]=parseInt(F[2].split(")")[0]),`hsl(${F[0]},0%,${F[2]}%)`):[F[0],0,F[2]],rgbaToGrayscale(F,A=3){let t=F.split(","),B=parseInt(t[0].split("(")[1]),i=parseInt(t[1]),e=parseInt(t[2]),V=parseFloat(t[3].split(")")[0]),o=Math.min(Math.floor((B+i+e)/A),255);return`rgba(${o},${o},${o},${V})`},drawExplosions(){if(this.paused||this.gameOver&&(!this.celebrating||this.skipAhead)&&this.won)return;let{explosions:F}=this;for(let A=0;A=60)){this.stillVisibleMissiles.splice(F,1),F--;continue}}else{let F=ra(ro.bodies.default.pastel_highlighter_marker.cr),t=this.p5Frames/this.P5_FPS_MULTIPLIER%360;A.phase={color:F,life:0,rotateBy:t}}this.stillVisibleMissiles[F]=A;let t=F==this.stillVisibleMissiles.length-1?"white":A.phase.color,B=10/1.5+10*(A.phase.life/25*A.phase.life/25);this.p.push(),this.p.translate(A.position.x,A.position.y),this.star(0,0,B,B/2,5,t,A.phase.rotateBy,A.phase.life),this.p.pop()}}},isMissileClose(F){let A=!1;for(let t=0;tthis.p.dist(F.position.x,F.position.y,B.position.x,B.position.y)){A=!0;break}}return A},drawImageAsset(F,A,t,{fill:B,strokeColor:i,strokeWidth:e,maxWidth:V}={}){let o=F+A+B+(V=V||t);this.imgAssets||={};let s=this.imgAssets[o];if(!s){let t=IL[F][A];this.imgAssets[o]="loading",t=B?IN(t,"fill",B):t,t=i?IN(t,"stroke",i):t,t=IN(t,"width",V*this.pixelDensity),t=IN(t,"height",V*this.pixelDensity),t="data:image/svg+xml,"+encodeURIComponent(t=e?IN(t,"stroke-width",e):t);try{this.p.loadImage(t,F=>{this.imgAssets[o]=F})}catch(F){console.error(F),this.imgAssets[o]=void 0}}s&&"loading"!==s&&this.p.image(s,-t/2,-t/2,t,t)},closeTo(F){let A=this.introStagethis.bodyDataToBodies.call(this,A,F))[0],e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width",t),e.setAttribute("height",B),e.setAttribute("day",F),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),e.setAttribute("viewBox",`0 0 ${t} ${B}`),e.setAttribute("version","1.1");let V=i.c.bgIndex,o=i.c.coreIndex,s=i.c.fgIndex,q=i.c.fIndex,h=F=>`data:image/svg+xml;base64,${btoa(F)}`,a=h(IN(IZ[V],"fill",i.c.bg)),r=h(IN(IT[o],"fill",i.c.core)),n=h(IN(IJ[s],"fill",i.c.fg)),M=h(IR[q]),g=()=>Math.random().toString(36).substr(2,9),l=`bg-${V}-${g()}`,C=`core-${o}-${g()}`,I=`fg-${s}-${g()}`,w=`f-${q}-${g()}`,Q=document.createElementNS("http://www.w3.org/2000/svg","image"),E=1*t,c=1*B;Q.setAttribute("id",l),Q.setAttribute("x",(t-E)/2),Q.setAttribute("y",(B-c)/2),Q.setAttribute("width",E),Q.setAttribute("height",c),Q.setAttribute("href",a),e.appendChild(Q);let m=document.createElementNS("http://www.w3.org/2000/svg","image"),Y=.375*t,D=.375*B;m.setAttribute("id",C),m.setAttribute("x",(t-Y)/2),m.setAttribute("y",(B-D)/2),m.setAttribute("width",Y),m.setAttribute("height",D),m.setAttribute("href",r),e.appendChild(m);let p=document.createElementNS("http://www.w3.org/2000/svg","image"),u=1*t,G=1*B;p.setAttribute("id",I),p.setAttribute("x",(t-u)/2),p.setAttribute("y",(B-G)/2),p.setAttribute("width",u),p.setAttribute("height",G),p.setAttribute("href",n),e.appendChild(p);let S=document.createElementNS("http://www.w3.org/2000/svg","image"),k=1*t,U=1*B;if(S.setAttribute("id",w),S.setAttribute("x",(t-k)/2),S.setAttribute("y",(B-U)/2),S.setAttribute("width",k),S.setAttribute("height",U),S.setAttribute("href",M),e.appendChild(S),A){let F={...Iy.fg,...IK?.fg?.[s]??{}},A=F.direction<0?"fullRotateR":"fullRotate",t=(F.speed/3).toFixed(2),B={...Iy.bg,...IK?.bg?.[V]??{}},i=B.direction<0?"fullRotateR":"fullRotate",o=(B.speed/3).toFixed(2),q=(({...Iy.core}).speed/3).toFixed(2),h=document.createElement("style");h.innerHTML=`
@keyframes fullRotate {
from {
transform: rotate(0deg);
@@ -250,4 +250,4 @@
#canvas, canvas {
cursor: none;
}
- `,document.head.appendChild(F)}clearValues(){this.level<=1&&(this.levelSpeeds=[]),this.skip0&&0==this.level&&(this.level=1),this.totalIntroStages=3,this.lastMissileCantBeUndone=!1,this.speedFactor=2,this.speedLimit=10,this.missileSpeed=15,this.shownStatScreen=!1,this.G=100,this.vectorLimit=this.speedLimit*this.speedFactor,this.missileVectorLimit=this.missileSpeed*this.speedFactor,this.missileVectorLimitSum=42426,this.FPS=25,this.P5_FPS_MULTIPLIER=3,this.P5_FPS=this.FPS*this.P5_FPS_MULTIPLIER,this.p?.frameRate(this.P5_FPS),this.timer=(this.level>5?60:IP[this.level])*this.FPS,this.deadOpacity="0.9",this.initialScoreSize=120,this.scoreSize=this.initialScoreSize,this.opac=(this.globalStyle,1),this.tailLength=1,this.tailMod="psycho"==this.globalStyle?2:1,this.explosions=[],this.missiles=[],this.stillVisibleMissiles=[],this.missileInits=[],this.bodies=[],this.witheringBodies=[],this.bodyInits=[],this.bodyFinal=[],this.missileCount=0,this.frames=0,this.p5Frames=0,this.showIt=!0,this.justStopped=!1,this.gameOver=!1,this.firstFrame=!0,this.loaded=!1,this.showPlayAgain=!1,this.handledGameOver=!1,this.statsText="",this.hasStarted=!1,this.buttons={},this.won=!1,this.finalBatchSent=!1,this.solved=!1,this.shaking=0,this.explosionSmoke=[],this.gunSmoke=[],this.date=new Date(1e3*this.day).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),this.framesTook=!1,this.showProblemRankingsScreenAt=-1,this.saveStatus="unsaved",this.shareCanvasBlob=void 0,delete this.validatedAt,delete this.validatingAt,delete this.savingAt,delete this.savedAt}init(){if(this.skipAhead=!1,this.winScreenBaddies=void 0,this.seed=rI.solidityKeccak256(["uint256"],[this.day]),this.generateBodies(),this.frames=this.alreadyRun,this.startingFrame=this.alreadyRun,this.stopEvery=this.test?20:this.proverTickIndex(this.level+1),this.lastLevel=this.level,this.setPause(this.paused,!0),this.storeInits(),!this.opensea&&!this.util)try{this.mute=JSON.parse(sessionStorage.getItem("muted"))||!1}catch(F){this.mute=!1,sessionStorage.removeItem("muted")}this.sound?.setMuted(this.mute)}async start(){this.addCSS(),this.addListeners(),this.runSteps(this.preRun),this.freeze&&this.setPause(!0,!0)}destroy(){this.resizeObserver.disconnect(this.p.canvas),this.setPause(!0),this.p.noLoop(),this.removeListener(),this.sound?.stop(),this.sound=null,this.p.remove()}storeInits(){this.bodyInits=this.processInits(this.bodies)}processInits(F){return this.convertBodiesToBigInts(F).map(F=>((F=this.convertScaledBigIntBodyToArray(F))[2]=BigInt(F[2]).toString(),F[3]=BigInt(F[3]).toString(),F))}runSteps(F=this.preRun){let A=0,t=!0;for(this.showIt=!1;t;)if(++A>F)t=!1,this.showIt=!0;else{let F=this.step(this.bodies,this.missiles);this.frames++,this.bodies=F.bodies,this.missiles=F.missiles||[]}}addListeners(){this.p.mouseMoved=this.handleMouseMove,this.p.touchStarted=F=>{this.hasTouched=!0,this.handleGameClick(F)},this.p.mouseClicked=this.handleGameClick,this.p.keyPressed=this.handleKeyPressed}removeListener(){this.p.remove()}getXY(F){let A,t;return F.touches?(A=F.touches[0].pageX-this.canvasRect.left,t=F.touches[0].pageY-this.canvasRect.top):(A=F.offsetX||F.layerX,t=F.offsetY||F.layerY),{x:A=A*this.windowWidth/this.canvasRect.width,y:t=t*this.windowHeight/this.canvasRect.height}}handleMouseMove=F=>{let{x:A,y:t}=this.getXY(F);for(let F in this.mouseX=A,this.mouseY=t,this.buttons){let B=this.buttons[F];B.hover=I_(B,A,t)}};handleGameClick=F=>{this.gameOver&&this.won&&(this.skipAhead=!0);let{x:A,y:t}=this.getXY(F);for(let F in this.buttons){let B=this.buttons[F];if(B.visible&&I_(B,A,t)&&!B.disabled){B.onClick();return}}if(this.introStage{this.setPause()};handleKeyPressed=F=>{if(this.gameOver&&this.won&&(this.skipAhead=!0),!(F.shiftKey||F.altKey||F.ctrlKey||F.metaKey))switch(F.code){case"Space":(this.mouseX||this.mouseY)&&(F.preventDefault(),this.missileClick(this.mouseX,this.mouseY)),this.shownStatScreen&&this.level<5&&(this.level++,this.restart(null,!1));break;case"KeyR":if(this.level<1)return;this.skipRedoPopupTip=!0,this.restart(null,!1);break;case"KeyP":this.gameOver||this.setPause();break;case"KeyM":this.mute=!this.mute,this.sound?.setMuted(this.mute)}};handleGameOver=({won:F})=>{if(this.handledGameOver)return;if(this.handledGameOver=!0,this.gameoverTickerX=0,0!==this.level&&this.sound?.playGameOver({won:F}),this.gameOver=!0,this.won=F,0!==this.level&&!this.won){let F=this.bodies.slice(1).filter(F=>0n!==F.radius).length,A=this.generateLevelData(this.day,6-F).slice(1);this.bodies.push(...A.map(F=>this.bodyDataToBodies.call(this,F)).map(F=>(F.position.x=0,F.position.y=0,F.py=0n,F.px=0n,F)))}this.P5_FPS*=2,this.p.frameRate(this.P5_FPS);var A=0;let t=this.calculateStats();A=t.timeTook,this.framesTook=t.framesTook,this.emit("done",{level:this.level,won:F,ticks:this.frames-this.startingFrame,timeTook:A,framesTook:this.framesTook}),F&&this.finish()};restart=(F,A=!0)=>{F&&this.setOptions(F),this.clearValues(),this.level!==this.lastLevel&&1!==this.level&&0!==this.level&&(this.sound?.stop(),this.sound?.playStart(),this.sound?.advanceToNextLevelSong(),this.sound?.resume()),this.sound?.playbackRate!=="normal"&&this.sound?.playCurrentSong(),this.init(),this.draw(),A&&this.setPause(!0),this.addCSS()};doubleTextInverted(F){return F.slice(0,-1)+F.split("").reverse().join("")}setPause(F=!this.paused,A=!1){"boolean"!=typeof F&&(F=!this.paused),F?(this.pauseBodies=IS.map(F=>this.bodyDataToBodies.call(this,F)),this.paused=F,this.willUnpause=!1,delete this.beganUnpauseAt):(this.justPaused=!0,this.willUnpause=!0),this.emit("paused",F),F?A||this.sound?.pause():A||this.sound?.resume(),!F&&this.introStage<0&&(this.introStage=0)}step(F=this.bodies,A=this.missiles){0==A.length&&this.lastMissileCantBeUndone&&(console.log("LASTMISSILECANTBEUNDONE = FALSE"),this.lastMissileCantBeUndone=!1),F=this.forceAccumulator(F);var t=this.detectCollision(F,this.missiles);if(F=t.bodies,(A=t.missiles||[]).length>0){let F=JSON.parse(JSON.stringify(A[0]));this.stillVisibleMissiles.push(F)}if(A.length>0&&0==A[0].radius)A.splice(0,1);else if(A.length>1&&0!==A[0].radius){let F=A.splice(0,1);A.splice(0,1,F[0])}return{bodies:F,missiles:A}}started(){this.emit("started",{day:this.day,level:this.level,bodyInits:JSON.parse(JSON.stringify(this.bodyInits))})}processMissileInits(F){return F.map(F=>({step:F.step,x:this.convertFloatToScaledBigInt(F.position.x).toString(),y:this.convertFloatToScaledBigInt(F.position.y).toString(),vx:this.convertFloatToScaledBigInt(F.velocity.x).toString(),vy:this.convertFloatToScaledBigInt(F.velocity.y).toString(),radius:"10"}))}finish(){if(this.finalBatchSent)return;this.calculateBodyFinal();let F=[];if("game"==this.mode){let A=0;for(let t=this.alreadyRun;t(F.step=this.frames,F)),this.emit("chunk",h),this.bodyFinal=[],"game"==this.mode&&0==this.bodies.slice(0==this.level?0:1).reduce((F,A)=>F+A.radius,0)&&(this.finalBatchSent=!0),this.missiles.length>0&&(console.log("LASTMISSILECANTBEUNDONE = TRUE"),this.lastMissileCantBeUndone=!0),0!==V&&(this.levelSpeeds.lengthA))return parseInt(t%(A-F+i)+F);{let B=t%(359n-(F-A+i));return Bthis.bodyDataToBodies.call(this,F)),this.startingBodies=this.bodies.length}bodyDataToBodies(F,A=this.day){let t=F.bodyIndex,B=F.px/parseInt(this.scalingFactor),i=F.py/parseInt(this.scalingFactor),e=(F.vx-this.vectorLimit*parseInt(this.scalingFactor))/parseInt(this.scalingFactor),V=(F.vy-this.vectorLimit*parseInt(this.scalingFactor))/parseInt(this.scalingFactor),o=F.radius/parseInt(this.scalingFactor);return{seed:F.seed,bodyIndex:t,position:this.createVector(B,i),velocity:this.createVector(e,V),radius:o,c:this.getBodyColor(A,t)}}getBodyColor(F,A=0){let t=Object.keys(rs),B=t.length,i=1723766400==F?19:0,e=rI.solidityKeccak256(["uint256","uint256"],[F,i]),V=this.randomRange(0,13,e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let o=this.randomRange(0,9,e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let s=this.randomRange(0,9,e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let q=this.randomRange(0,0,e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let h=rs[t[this.randomRange(0,B-1,e,F)]];e=rI.solidityKeccak256(["bytes32"],[e]);let a=h.bg[0]?h.bg[0].split("-"):[0,359],r=this.randomRange(a[0],a[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let n=h.bg[1].split("-"),M=this.randomRange(n[0],n[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let g=h.bg[2].split("-"),l=this.randomRange(g[0],g[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let C=h.bg[0]?h.cr[0].split("-"):[0,359],I=this.randomRange(C[0],C[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let w=h.cr[1].split("-"),Q=this.randomRange(w[0],w[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let E=h.cr[2].split("-"),c=this.randomRange(E[0],E[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let m=h.bg[0]?h.fg[0].split("-"):[0,359],Y=this.randomRange(m[0],m[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let D=h.fg[1].split("-"),p=this.randomRange(D[0],D[1],e,F);e=rI.solidityKeccak256(["bytes32"],[e]);let u=h.fg[2].split("-"),G=this.randomRange(u[0],u[1],e,F);return{fIndex:V,bgIndex:o,fgIndex:s,coreIndex:q,bg:`hsl(${r},${M}%,${l}%`,core:`hsl(${I},${Q}%,${c}%`,fg:`hsl(${Y},${p}%,${G}%`,baddie:[[342,100,48],[342,100,48],[260,94,62],[151,100,63],[11,100,62],[58,100,54]][A]}}setPixelDensity(F){this.p.pixelDensity(F)}prepareP5(){this.p.frameRate(this.P5_FPS),this.p.createCanvas(this.windowWidth,this.windowWidth),this.setPixelDensity(this.pixelDensity),this.p.background("white"),this.canvasRect=this.p.canvas.getBoundingClientRect(),this.resizeObserver=new ResizeObserver(()=>{this.canvasRect=this.p.canvas.getBoundingClientRect()}),this.resizeObserver.observe(this.p.canvas)}missileClick(F,A){if(this.gameOver||this.paused||this.missilesDisabled||0==this.bodies.reduce((F,A)=>F+A.radius,0)||this.frames-this.startingFrame>=this.timer)return;if(this.frames%this.stopEvery==0){console.log("MISSILE CANT BE FIRED ON EDGE ATM"),this.shootMissileNextFrame={x:F,y:A};return}this.shootMissileNextFrame=null,this.missiles.length>0&&(this.lastMissileCantBeUndone&&(this.emit("remove-last-missile"),this.lastMissileCantBeUndone=!1,console.log("LASTMISSILECANTBEUNDONE = FALSE")),this.missileInits.pop(),this.missileCount--),this.missileCount++;let t={step:this.frames,position:this.p.createVector(0,this.windowWidth),velocity:this.p.createVector(F,A-this.windowWidth),radius:10};t.velocity.limit(this.missileSpeed*this.speedFactor),t.velocity.x<=0&&(t.velocity.x=1),t.velocity.y>=0&&(t.velocity.y=-1);let B=t.velocity.x-t.velocity.y,i=this.missileVectorLimitSum/1e3;if(B>i&&(t.velocity.limit(this.missileSpeed*this.speedFactor*.999),console.log({x:t.velocity.x,y:t.velocity.y,max:this.missileVectorLimitSum/1e3}),(B=t.velocity.x-t.velocity.y)>i)){console.error("still too fast");return}this.missiles.push(t),this.missiles=this.missiles.slice(-1);let e=F**2+(A-this.windowWidth)**2;this.sound?.playMissile(e),this.missileInits.push(...this.processMissileInits([t])),this.makeMissileStart()}calculateStats=()=>{let F=this.bodies.length,{startingFrame:A,frames:t}=this,B=t-A-1,i=B/this.FPS;return{missilesShot:this.missileInits.reduce((F,A)=>0==A[0]?F:F+1,0),bodiesIncluded:F,timeTook:i,framesTook:B}};handleSave=()=>{"unsaved"==this.saveStatus?(this.saveStatus="validating",setTimeout(()=>{this.saveStatus="validated"},2e3)):"validated"==this.saveStatus&&(this.saveStatus="saving",setTimeout(()=>{this.saveStatus="saved"},2e3))}}"undefined"!=typeof window&&(window.Anybody=I2),BigInt.prototype.toJSON=function(){return this.toString()},AR=function(F){var A,t,B=function(F){var A=F.length;if(A%4>0)throw Error("Invalid string. Length must be a multiple of 4");var t=F.indexOf("=");-1===t&&(t=A);var B=t===A?0:4-t%4;return[t,B]}(F),i=B[0],e=B[1],V=new I4((i+e)*3/4-e),o=0,s=e>0?i-4:i;for(t=0;t>16&255,V[o++]=A>>8&255,V[o++]=255&A;return 2===e&&(A=I1[F.charCodeAt(t)]<<2|I1[F.charCodeAt(t+1)]>>4,V[o++]=255&A),1===e&&(A=I1[F.charCodeAt(t)]<<10|I1[F.charCodeAt(t+1)]<<4|I1[F.charCodeAt(t+2)]>>2,V[o++]=A>>8&255,V[o++]=255&A),V},Ad=function(F){for(var A,t=F.length,B=t%3,i=[],e=0,V=t-B;e>18&63]+I0[B>>12&63]+I0[B>>6&63]+I0[63&B]);return i.join("")}(F,e,e+16383>V?V:e+16383));return 1===B?i.push(I0[(A=F[t-1])>>2]+I0[A<<4&63]+"=="):2===B&&i.push(I0[(A=(F[t-2]<<8)+F[t-1])>>10]+I0[A>>4&63]+I0[A<<2&63]+"="),i.join("")};for(var I0=[],I1=[],I4="undefined"!=typeof Uint8Array?Uint8Array:Array,I5="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",I8=0,I6=I5.length;I8>1,h=-7,a=t?i-1:0,r=t?-1:1,n=F[A+a];for(a+=r,e=n&(1<<-h)-1,n>>=-h,h+=o;h>0;e=256*e+F[A+a],a+=r,h-=8);for(V=e&(1<<-h)-1,e>>=-h,h+=B;h>0;V=256*V+F[A+a],a+=r,h-=8);if(0===e)e=1-q;else{if(e===s)return V?NaN:1/0*(n?-1:1);V+=Math.pow(2,B),e-=q}return(n?-1:1)*V*Math.pow(2,e-B)},AT=function(F,A,t,B,i,e){var V,o,s,q=8*e-i-1,h=(1<>1,r=23===i?5960464477539062e-23:0,n=B?0:e-1,M=B?1:-1,g=A<0||0===A&&1/A<0?1:0;for(isNaN(A=Math.abs(A))||A===1/0?(o=isNaN(A)?1:0,V=h):(V=Math.floor(Math.log(A)/Math.LN2),A*(s=Math.pow(2,-V))<1&&(V--,s*=2),V+a>=1?A+=r/s:A+=r*Math.pow(2,1-a),A*s>=2&&(V++,s/=2),V+a>=h?(o=0,V=h):V+a>=1?(o=(A*s-1)*Math.pow(2,i),V+=a):(o=A*Math.pow(2,a-1)*Math.pow(2,i),V=0));i>=8;F[t+n]=255&o,n+=M,o/=256,i-=8);for(V=V<0;F[t+n]=255&V,n+=M,V/=256,q-=8);F[t+n-M]|=128*g};var I3="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function I9(F){if(F>2147483647)throw RangeError('The value "'+F+'" is invalid for option "size"');var A=new Uint8Array(F);return Object.setPrototypeOf(A,I7.prototype),A}function I7(F,A,t){if("number"==typeof F){if("string"==typeof A)throw TypeError('The "string" argument must be of type string. Received type number');return wt(F)}return wF(F,A,t)}function wF(F,A,t){if("string"==typeof F)return function(F,A){if(("string"!=typeof A||""===A)&&(A="utf8"),!I7.isEncoding(A))throw TypeError("Unknown encoding: "+A);var t=0|wV(F,A),B=I9(t),i=B.write(F,A);return i!==t&&(B=B.slice(0,i)),B}(F,A);if(ArrayBuffer.isView(F))return function(F){if(wE(F,Uint8Array)){var A=new Uint8Array(F);return wi(A.buffer,A.byteOffset,A.byteLength)}return wB(F)}(F);if(null==F)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof F);if(wE(F,ArrayBuffer)||F&&wE(F.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(wE(F,SharedArrayBuffer)||F&&wE(F.buffer,SharedArrayBuffer)))return wi(F,A,t);if("number"==typeof F)throw TypeError('The "value" argument must not be of type number. Received type number');var B=F.valueOf&&F.valueOf();if(null!=B&&B!==F)return I7.from(B,A,t);var i=function(F){if(I7.isBuffer(F)){var A,t=0|we(F.length),B=I9(t);return 0===B.length||F.copy(B,0,0,t),B}return void 0!==F.length?"number"!=typeof F.length||(A=F.length)!=A?I9(0):wB(F):"Buffer"===F.type&&Array.isArray(F.data)?wB(F.data):void 0}(F);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof F[Symbol.toPrimitive])return I7.from(F[Symbol.toPrimitive]("string"),A,t);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof F)}function wA(F){if("number"!=typeof F)throw TypeError('"size" argument must be of type number');if(F<0)throw RangeError('The value "'+F+'" is invalid for option "size"')}function wt(F){return wA(F),I9(F<0?0:0|we(F))}function wB(F){for(var A=F.length<0?0:0|we(F.length),t=I9(A),B=0;B=2147483647)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|F}function wV(F,A){if(I7.isBuffer(F))return F.length;if(ArrayBuffer.isView(F)||wE(F,ArrayBuffer))return F.byteLength;if("string"!=typeof F)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof F);var t=F.length,B=arguments.length>2&&!0===arguments[2];if(!B&&0===t)return 0;for(var i=!1;;)switch(A){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return wI(F).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*t;case"hex":return t>>>1;case"base64":return ww(F).length;default:if(i)return B?-1:wI(F).length;A=(""+A).toLowerCase(),i=!0}}function wo(F,A,t){var B,i,e=!1;if((void 0===A||A<0)&&(A=0),A>this.length||((void 0===t||t>this.length)&&(t=this.length),t<=0||(t>>>=0)<=(A>>>=0)))return"";for(F||(F="utf8");;)switch(F){case"hex":return function(F,A,t){var B=F.length;(!A||A<0)&&(A=0),(!t||t<0||t>B)&&(t=B);for(var i="",e=A;e2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),(e=t=+t)!=e&&(t=i?0:F.length-1),t<0&&(t=F.length+t),t>=F.length){if(i)return -1;t=F.length-1}else if(t<0){if(!i)return -1;t=0}if("string"==typeof A&&(A=I7.from(A,B)),I7.isBuffer(A))return 0===A.length?-1:wh(F,A,t,B,i);if("number"==typeof A)return(A&=255,"function"==typeof Uint8Array.prototype.indexOf)?i?Uint8Array.prototype.indexOf.call(F,A,t):Uint8Array.prototype.lastIndexOf.call(F,A,t):wh(F,[A],t,B,i);throw TypeError("val must be string, number or Buffer")}function wh(F,A,t,B,i){var e,V=1,o=F.length,s=A.length;if(void 0!==B&&("ucs2"===(B=String(B).toLowerCase())||"ucs-2"===B||"utf16le"===B||"utf-16le"===B)){if(F.length<2||A.length<2)return -1;V=2,o/=2,s/=2,t/=2}function q(F,A){return 1===V?F[A]:F.readUInt16BE(A*V)}if(i){var h=-1;for(e=t;eo&&(t=o-s),e=t;e>=0;e--){for(var a=!0,r=0;r239?4:q>223?3:q>191?2:1;if(i+a<=t)switch(a){case 1:q<128&&(h=q);break;case 2:(192&(e=F[i+1]))==128&&(s=(31&q)<<6|63&e)>127&&(h=s);break;case 3:e=F[i+1],V=F[i+2],(192&e)==128&&(192&V)==128&&(s=(15&q)<<12|(63&e)<<6|63&V)>2047&&(s<55296||s>57343)&&(h=s);break;case 4:e=F[i+1],V=F[i+2],o=F[i+3],(192&e)==128&&(192&V)==128&&(192&o)==128&&(s=(15&q)<<18|(63&e)<<12|(63&V)<<6|63&o)>65535&&s<1114112&&(h=s)}null===h?(h=65533,a=1):h>65535&&(h-=65536,B.push(h>>>10&1023|55296),h=56320|1023&h),B.push(h),i+=a}return function(F){var A=F.length;if(A<=4096)return String.fromCharCode.apply(String,F);for(var t="",B=0;Bt)throw RangeError("Trying to access beyond buffer length")}function wn(F,A,t,B,i,e){if(!I7.isBuffer(F))throw TypeError('"buffer" argument must be a Buffer instance');if(A>i||AF.length)throw RangeError("Index out of range")}function wM(F,A,t,B,i,e){if(t+B>F.length||t<0)throw RangeError("Index out of range")}function wg(F,A,t,B,i){return A=+A,t>>>=0,i||wM(F,A,t,4,34028234663852886e22,-34028234663852886e22),AT(F,A,t,B,23,4),t+4}function wl(F,A,t,B,i){return A=+A,t>>>=0,i||wM(F,A,t,8,17976931348623157e292,-17976931348623157e292),AT(F,A,t,B,52,8),t+8}I7.TYPED_ARRAY_SUPPORT=function(){try{var F=new Uint8Array(1),A={foo:function(){return 42}};return Object.setPrototypeOf(A,Uint8Array.prototype),Object.setPrototypeOf(F,A),42===F.foo()}catch(F){return!1}}(),I7.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(I7.prototype,"parent",{enumerable:!0,get:function(){if(I7.isBuffer(this))return this.buffer}}),Object.defineProperty(I7.prototype,"offset",{enumerable:!0,get:function(){if(I7.isBuffer(this))return this.byteOffset}}),I7.poolSize=8192,I7.from=function(F,A,t){return wF(F,A,t)},Object.setPrototypeOf(I7.prototype,Uint8Array.prototype),Object.setPrototypeOf(I7,Uint8Array),I7.alloc=function(F,A,t){return(wA(F),F<=0)?I9(F):void 0!==A?"string"==typeof t?I9(F).fill(A,t):I9(F).fill(A):I9(F)},I7.allocUnsafe=function(F){return wt(F)},I7.allocUnsafeSlow=function(F){return wt(F)},I7.isBuffer=function(F){return null!=F&&!0===F._isBuffer&&F!==I7.prototype},I7.compare=function(F,A){if(wE(F,Uint8Array)&&(F=I7.from(F,F.offset,F.byteLength)),wE(A,Uint8Array)&&(A=I7.from(A,A.offset,A.byteLength)),!I7.isBuffer(F)||!I7.isBuffer(A))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(F===A)return 0;for(var t=F.length,B=A.length,i=0,e=Math.min(t,B);iB.length?I7.from(e).copy(B,i):Uint8Array.prototype.set.call(B,e,i);else if(I7.isBuffer(e))e.copy(B,i);else throw TypeError('"list" argument must be an Array of Buffers');i+=e.length}return B},I7.byteLength=wV,I7.prototype._isBuffer=!0,I7.prototype.swap16=function(){var F=this.length;if(F%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var A=0;A50&&(F+=" ... "),""},I3&&(I7.prototype[I3]=I7.prototype.inspect),I7.prototype.compare=function(F,A,t,B,i){if(wE(F,Uint8Array)&&(F=I7.from(F,F.offset,F.byteLength)),!I7.isBuffer(F))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof F);if(void 0===A&&(A=0),void 0===t&&(t=F?F.length:0),void 0===B&&(B=0),void 0===i&&(i=this.length),A<0||t>F.length||B<0||i>this.length)throw RangeError("out of range index");if(B>=i&&A>=t)return 0;if(B>=i)return -1;if(A>=t)return 1;if(A>>>=0,t>>>=0,B>>>=0,i>>>=0,this===F)return 0;for(var e=i-B,V=t-A,o=Math.min(e,V),s=this.slice(B,i),q=F.slice(A,t),h=0;h>>=0,isFinite(t)?(t>>>=0,void 0===B&&(B="utf8")):(B=t,t=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,e,V,o,s,q,h,a,r=this.length-A;if((void 0===t||t>r)&&(t=r),F.length>0&&(t<0||A<0)||A>this.length)throw RangeError("Attempt to write outside buffer bounds");B||(B="utf8");for(var n=!1;;)switch(B){case"hex":return function(F,A,t,B){t=Number(t)||0;var i=F.length-t;B?(B=Number(B))>i&&(B=i):B=i;var e=A.length;B>e/2&&(B=e/2);for(var V=0;V>8,i.push(t%256),i.push(B);return i}(F,this.length-h),this,h,a);default:if(n)throw TypeError("Unknown encoding: "+B);B=(""+B).toLowerCase(),n=!0}},I7.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},I7.prototype.slice=function(F,A){var t=this.length;F=~~F,A=void 0===A?t:~~A,F<0?(F+=t)<0&&(F=0):F>t&&(F=t),A<0?(A+=t)<0&&(A=0):A>t&&(A=t),A>>=0,A>>>=0,t||wr(F,A,this.length);for(var B=this[F],i=1,e=0;++e>>=0,A>>>=0,t||wr(F,A,this.length);for(var B=this[F+--A],i=1;A>0&&(i*=256);)B+=this[F+--A]*i;return B},I7.prototype.readUint8=I7.prototype.readUInt8=function(F,A){return F>>>=0,A||wr(F,1,this.length),this[F]},I7.prototype.readUint16LE=I7.prototype.readUInt16LE=function(F,A){return F>>>=0,A||wr(F,2,this.length),this[F]|this[F+1]<<8},I7.prototype.readUint16BE=I7.prototype.readUInt16BE=function(F,A){return F>>>=0,A||wr(F,2,this.length),this[F]<<8|this[F+1]},I7.prototype.readUint32LE=I7.prototype.readUInt32LE=function(F,A){return F>>>=0,A||wr(F,4,this.length),(this[F]|this[F+1]<<8|this[F+2]<<16)+16777216*this[F+3]},I7.prototype.readUint32BE=I7.prototype.readUInt32BE=function(F,A){return F>>>=0,A||wr(F,4,this.length),16777216*this[F]+(this[F+1]<<16|this[F+2]<<8|this[F+3])},I7.prototype.readIntLE=function(F,A,t){F>>>=0,A>>>=0,t||wr(F,A,this.length);for(var B=this[F],i=1,e=0;++e=(i*=128)&&(B-=Math.pow(2,8*A)),B},I7.prototype.readIntBE=function(F,A,t){F>>>=0,A>>>=0,t||wr(F,A,this.length);for(var B=A,i=1,e=this[F+--B];B>0&&(i*=256);)e+=this[F+--B]*i;return e>=(i*=128)&&(e-=Math.pow(2,8*A)),e},I7.prototype.readInt8=function(F,A){return(F>>>=0,A||wr(F,1,this.length),128&this[F])?-((255-this[F]+1)*1):this[F]},I7.prototype.readInt16LE=function(F,A){F>>>=0,A||wr(F,2,this.length);var t=this[F]|this[F+1]<<8;return 32768&t?4294901760|t:t},I7.prototype.readInt16BE=function(F,A){F>>>=0,A||wr(F,2,this.length);var t=this[F+1]|this[F]<<8;return 32768&t?4294901760|t:t},I7.prototype.readInt32LE=function(F,A){return F>>>=0,A||wr(F,4,this.length),this[F]|this[F+1]<<8|this[F+2]<<16|this[F+3]<<24},I7.prototype.readInt32BE=function(F,A){return F>>>=0,A||wr(F,4,this.length),this[F]<<24|this[F+1]<<16|this[F+2]<<8|this[F+3]},I7.prototype.readFloatLE=function(F,A){return F>>>=0,A||wr(F,4,this.length),Ax(this,F,!0,23,4)},I7.prototype.readFloatBE=function(F,A){return F>>>=0,A||wr(F,4,this.length),Ax(this,F,!1,23,4)},I7.prototype.readDoubleLE=function(F,A){return F>>>=0,A||wr(F,8,this.length),Ax(this,F,!0,52,8)},I7.prototype.readDoubleBE=function(F,A){return F>>>=0,A||wr(F,8,this.length),Ax(this,F,!1,52,8)},I7.prototype.writeUintLE=I7.prototype.writeUIntLE=function(F,A,t,B){if(F=+F,A>>>=0,t>>>=0,!B){var i=Math.pow(2,8*t)-1;wn(this,F,A,t,i,0)}var e=1,V=0;for(this[A]=255&F;++V>>=0,t>>>=0,!B){var i=Math.pow(2,8*t)-1;wn(this,F,A,t,i,0)}var e=t-1,V=1;for(this[A+e]=255&F;--e>=0&&(V*=256);)this[A+e]=F/V&255;return A+t},I7.prototype.writeUint8=I7.prototype.writeUInt8=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,1,255,0),this[A]=255&F,A+1},I7.prototype.writeUint16LE=I7.prototype.writeUInt16LE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,2,65535,0),this[A]=255&F,this[A+1]=F>>>8,A+2},I7.prototype.writeUint16BE=I7.prototype.writeUInt16BE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,2,65535,0),this[A]=F>>>8,this[A+1]=255&F,A+2},I7.prototype.writeUint32LE=I7.prototype.writeUInt32LE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,4,4294967295,0),this[A+3]=F>>>24,this[A+2]=F>>>16,this[A+1]=F>>>8,this[A]=255&F,A+4},I7.prototype.writeUint32BE=I7.prototype.writeUInt32BE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,4,4294967295,0),this[A]=F>>>24,this[A+1]=F>>>16,this[A+2]=F>>>8,this[A+3]=255&F,A+4},I7.prototype.writeIntLE=function(F,A,t,B){if(F=+F,A>>>=0,!B){var i=Math.pow(2,8*t-1);wn(this,F,A,t,i-1,-i)}var e=0,V=1,o=0;for(this[A]=255&F;++e>0)-o&255;return A+t},I7.prototype.writeIntBE=function(F,A,t,B){if(F=+F,A>>>=0,!B){var i=Math.pow(2,8*t-1);wn(this,F,A,t,i-1,-i)}var e=t-1,V=1,o=0;for(this[A+e]=255&F;--e>=0&&(V*=256);)F<0&&0===o&&0!==this[A+e+1]&&(o=1),this[A+e]=(F/V>>0)-o&255;return A+t},I7.prototype.writeInt8=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,1,127,-128),F<0&&(F=255+F+1),this[A]=255&F,A+1},I7.prototype.writeInt16LE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,2,32767,-32768),this[A]=255&F,this[A+1]=F>>>8,A+2},I7.prototype.writeInt16BE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,2,32767,-32768),this[A]=F>>>8,this[A+1]=255&F,A+2},I7.prototype.writeInt32LE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,4,2147483647,-2147483648),this[A]=255&F,this[A+1]=F>>>8,this[A+2]=F>>>16,this[A+3]=F>>>24,A+4},I7.prototype.writeInt32BE=function(F,A,t){return F=+F,A>>>=0,t||wn(this,F,A,4,2147483647,-2147483648),F<0&&(F=4294967295+F+1),this[A]=F>>>24,this[A+1]=F>>>16,this[A+2]=F>>>8,this[A+3]=255&F,A+4},I7.prototype.writeFloatLE=function(F,A,t){return wg(this,F,A,!0,t)},I7.prototype.writeFloatBE=function(F,A,t){return wg(this,F,A,!1,t)},I7.prototype.writeDoubleLE=function(F,A,t){return wl(this,F,A,!0,t)},I7.prototype.writeDoubleBE=function(F,A,t){return wl(this,F,A,!1,t)},I7.prototype.copy=function(F,A,t,B){if(!I7.isBuffer(F))throw TypeError("argument should be a Buffer");if(t||(t=0),B||0===B||(B=this.length),A>=F.length&&(A=F.length),A||(A=0),B>0&&B=this.length)throw RangeError("Index out of range");if(B<0)throw RangeError("sourceEnd out of bounds");B>this.length&&(B=this.length),F.length-A>>=0,t=void 0===t?this.length:t>>>0,F||(F=0),"number"==typeof F)for(i=A;i55295&&t<57344){if(!i){if(t>56319||V+1===B){(A-=3)>-1&&e.push(239,191,189);continue}i=t;continue}if(t<56320){(A-=3)>-1&&e.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(A-=3)>-1&&e.push(239,191,189);if(i=null,t<128){if((A-=1)<0)break;e.push(t)}else if(t<2048){if((A-=2)<0)break;e.push(t>>6|192,63&t|128)}else if(t<65536){if((A-=3)<0)break;e.push(t>>12|224,t>>6&63|128,63&t|128)}else if(t<1114112){if((A-=4)<0)break;e.push(t>>18|240,t>>12&63|128,t>>6&63|128,63&t|128)}else throw Error("Invalid code point")}return e}function ww(F){return AR(function(F){if((F=(F=F.split("=")[0]).trim().replace(wC,"")).length<2)return"";for(;F.length%4!=0;)F+="=";return F}(F))}function wQ(F,A,t,B){for(var i=0;i=A.length)&&!(i>=F.length);++i)A[i+t]=F[i];return i}function wE(F,A){return F instanceof A||null!=F&&null!=F.constructor&&null!=F.constructor.name&&F.constructor.name===A.name}var wc=function(){for(var F="0123456789abcdef",A=Array(256),t=0;t<16;++t)for(var B=16*t,i=0;i<16;++i)A[B+i]=F[t]+F[i];return A}();let wm=new function(F,A){return new function F(t){let B="global"==t?window:this;B.canvas=document.createElement("canvas");let i=B.canvas.getContext("2d");B.width=100,B.height=100,B.canvas.width=B.width,B.canvas.height=B.height,"offscreen"!=t&&(A?A.appendChild(B.canvas):document.body?document.body.appendChild(B.canvas):window.addEventListener("load",function(){document.body.appendChild(B.canvas)})),I(),B.MAGIC=161533525,B.RGB=0,B.HSV=1,B.HSB=1,B.CHORD=0,B.PIE=1,B.OPEN=2,B.RADIUS=1,B.CORNER=2,B.CORNERS=3,B.ROUND="round",B.SQUARE="butt",B.PROJECT="square",B.MITER="miter",B.BEVEL="bevel",B.CLOSE=1,B.BLEND="source-over",B.REMOVE="destination-out",B.ADD="lighter",B.DARKEST="darken",B.LIGHTEST="lighten",B.DIFFERENCE="difference",B.SUBTRACT="subtract",B.EXCLUSION="exclusion",B.MULTIPLY="multiply",B.SCREEN="screen",B.REPLACE="copy",B.OVERLAY="overlay",B.HARD_LIGHT="hard-light",B.SOFT_LIGHT="soft-light",B.DODGE="color-dodge",B.BURN="color-burn",B.NORMAL="normal",B.ITALIC="italic",B.BOLD="bold",B.BOLDITALIC="italic bold",B.CENTER="center",B.LEFT="left",B.RIGHT="right",B.TOP="top",B.BOTTOM="bottom",B.BASELINE="alphabetic",B.LANDSCAPE="landscape",B.PORTRAIT="portrait",B.ALT=18,B.BACKSPACE=8,B.CONTROL=17,B.DELETE=46,B.DOWN_ARROW=40,B.ENTER=13,B.ESCAPE=27,B.LEFT_ARROW=37,B.OPTION=18,B.RETURN=13,B.RIGHT_ARROW=39,B.SHIFT=16,B.TAB=9,B.UP_ARROW=38,B.HALF_PI=Math.PI/2,B.PI=Math.PI,B.QUARTER_PI=Math.PI/4,B.TAU=2*Math.PI,B.TWO_PI=2*Math.PI,B.THRESHOLD=1,B.GRAY=2,B.OPAQUE=3,B.INVERT=4,B.POSTERIZE=5,B.DILATE=6,B.ERODE=7,B.BLUR=8,B.ARROW="default",B.CROSS="crosshair",B.HAND="pointer",B.MOVE="move",B.TEXT="text",B.VIDEO={video:!0,audio:!1},B.AUDIO={video:!1,audio:!0},B.SHR3=1,B.LCG=2,B.HARDWARE_FILTERS=!0,B.hint=function(F,A){B[F]=A},B.frameCount=0,B.mouseX=0,B.mouseY=0,B.pmouseX=0,B.pmouseY=0,B.mouseButton=null,B.keyIsPressed=!1,B.mouseIsPressed=!1,B.key=null,B.keyCode=null,B.pixels=null,B.accelerationX=0,B.accelerationY=0,B.accelerationZ=0,B.rotationX=0,B.rotationY=0,B.rotationZ=0,B.relRotationX=0,B.relRotationY=0,B.relRotationZ=0,B.pAccelerationX=0,B.pAccelerationY=0,B.pAccelerationZ=0,B.pRotationX=0,B.pRotationY=0,B.pRotationZ=0,B.pRelRotationX=0,B.pRelRotationY=0,B.pRelRotationZ=0,B.touches=[],B._styleCache=[{colorMode:B.RGB,noStroke:!1,noFill:!1,ellipseMode:B.CENTER,rectMode:B.CORNER,curveDetail:20,curveAlpha:0,textFont:"sans-serif",textSize:12,textLeading:12,textStyle:"normal"}],B._style=B._styleCache[B._styleCache.length-1],B._noLoop=!1,B._pixelDensity=1,B._frameRate=null,B._tint=null;let e=null,V=!0,o=[],s=null,q=0,h={},a=0,r=0,n=0,M=null,g=null,l=null;for(let A of(Object.defineProperty(B,"deviceOrientation",{get:function(){return 90==Math.abs(window.orientation)?B.LANDSCAPE:B.PORTRAIT}}),Object.defineProperty(B,"windowWidth",{get:function(){return window.innerWidth}}),Object.defineProperty(B,"windowHeight",{get:function(){return window.innerHeight}}),Object.defineProperty(B,"drawingContext",{get:function(){return i}}),B.createCanvas=function(F,A){return B.width=F,B.height=A,B.canvas.width=F,B.canvas.height=A,I(),B.canvas},B.resizeCanvas=function(F,A){B.width=F,B.height=A,B.canvas.width=F,B.canvas.height=A},B.createGraphics=B.createImage=function(A,t){let B=new F("offscreen");return B.createCanvas(A,t),B.noLoop(),B},B.pixelDensity=function(F){return void 0==F||(B._pixelDensity=F,B.canvas.width=Math.ceil(B.width*F),B.canvas.height=Math.ceil(B.height*F),B.canvas.style.width=B.width+"px",B.canvas.style.height=B.height+"px",i.scale(B._pixelDensity,B._pixelDensity),I()),B._pixelDensity},B.map=function(F,A,t,B,i,e){let V=B+(F-A)*1/(t-A)*(i-B);return e?BF){let t=F/A;i.x*=t,i.y*=t,i.z*=t,e=F,V=F*F}return i},i.setMag=function(F){s();let A=F/e;return i.x*=A,i.y*=A,i.z*=A,e=F,V=F*F,i},i.heading=function(){return Math.atan2(i.y,i.x)},i.rotate=function(F){let A=Math.cos(F),t=Math.sin(F),B=i.x*A-i.y*t,e=i.x*t+i.y*A;return i.x=B,i.y=e,i},i.angleBetween=function(){let F=o.apply(null,arguments);return Math.acos(Math.min(1,Math.max(-1,i.dot(F)/(i.mag()*F.mag()))))*Math.sign(i.cross(F).z||1)},i.lerp=function(F,A){return i.x=i.x*(1-A)+F.x*A,i.y=i.y*(1-A)+F.y*A,i.z=i.z*(1-A)+F.z*A,q(),i},i.reflect=function(F){return F.normalize(),i.sub(F.mult(2*i.dot(F)))},i.array=function(){return[i.x,i.y,i.z]},i.equals=function(F,A){return void 0==A&&void 0==(A=Number.EPSILON)&&(A=0),Math.abs(F.x-i.x)360&&(V=0),V/=60,o=~~V,s=V-o,q=t*(1-A),h=t*(1-A*s),a=t*(1-A*(1-s)),o){case 0:B=t,i=a,e=q;break;case 1:B=h,i=t,e=q;break;case 2:B=q,i=t,e=a;break;case 3:B=q,i=h,e=t;break;case 4:B=a,i=q,e=t;break;default:B=t,i=q,e=h}return[255*B,255*i,255*e]}function I(){i.fillStyle="white",i.strokeStyle="black",i.lineCap="round",i.lineJoin="miter"}function w(F){if(0<=F&&F<2*Math.PI)return F;for(;F<0;)F+=2*Math.PI;for(;F>=Math.PI;)F-=2*Math.PI;return F}function Q(F,A,t,e,V,o,s,q){if(B._style.noFill&&B._style.noStroke)return;let h=w(V),a=w(o);i.beginPath();for(let V=0;VA?F>t?F:t:A>t?A:t)/255))?[0,V=0,o]:0==(V=100*(e-B)/e)?[0,V,o]:[e==F?0+60*(A-t)/(e-B):e==A?120+60*(t-F)/(e-B):240+60*(F-A)/(e-B),V,o]),i._hsvInferred=!0}},i.toString=function(){return`rgba(${Math.round(i._r)},${Math.round(i._g)},${Math.round(i._b)},${~~(1e3*i._a)/1e3})`}},B.colorMode=function(F){B._style.colorMode=F},B.color=function(){if(1==arguments.length&&786698==arguments[0].MAGIC)return arguments[0];if(B._style.colorMode==B.RGB){if(1==arguments.length)return new B.Color(arguments[0],arguments[0],arguments[0],1);if(2==arguments.length)return new B.Color(arguments[0],arguments[0],arguments[0],arguments[1]/255);if(3==arguments.length)return new B.Color(arguments[0],arguments[1],arguments[2],1);if(4==arguments.length)return new B.Color(arguments[0],arguments[1],arguments[2],arguments[3]/255)}else{if(1==arguments.length)return new B.Color(...C(0,0,arguments[0]/100),1);if(2==arguments.length)return new B.Color(...C(0,0,arguments[0]/100),arguments[1]/255);if(3==arguments.length)return new B.Color(...C(arguments[0],arguments[1]/100,arguments[2]/100),1);if(4==arguments.length)return new B.Color(...C(arguments[0],arguments[1]/100,arguments[2]/100),arguments[3])}return null},B.red=function(F){return F._r},B.green=function(F){return F._g},B.blue=function(F){return F._b},B.alpha=function(F){return 255*F._a},B.hue=function(F){return F._inferHSV(),F._h},B.saturation=function(F){return F._inferHSV(),F._s},B.brightness=function(F){return F._inferHSV(),F._v},B.lightness=function(F){return(.2126*F._r+.7152*F._g+.0722*F._b)*100/255},B.lerpColor=function(F,A,t){var i,e,V;return B._style.colorMode==B.RGB?new B.Color(B.constrain(B.lerp(F._r,A._r,t),0,255),B.constrain(B.lerp(F._g,A._g,t),0,255),B.constrain(B.lerp(F._b,A._b,t),0,255),B.constrain(B.lerp(F._a,A._a,t),0,1)):(F._inferHSV(),A._inferHSV(),new B.Color(B.constrain((i=F._h,(V=[[Math.abs((e=A._h)-i),B.map(t,0,1,i,e)],[Math.abs(e+360-i),B.map(t,0,1,i,e+360)],[Math.abs(e-360-i),B.map(t,0,1,i,e-360)]]).sort((F,A)=>F[0]-A[0]),(V[0][1]+720)%360),0,360),B.constrain(B.lerp(F._s,A._s,t),0,100),B.constrain(B.lerp(F._v,A._v,t),0,100),B.constrain(B.lerp(F._a,A._a,t),0,1)))},B.strokeWeight=function(F){B._style_noStroke=!1,i.lineWidth=F},B.stroke=function(){if(B._style.noStroke=!1,"string"==typeof arguments[0]){i.strokeStyle=arguments[0];return}let F=B.color.apply(null,arguments);if(F._a<=0){B._style.noStroke=!0;return}i.strokeStyle=F},B.noStroke=function(){B._style.noStroke=!0},B.fill=function(){if(B._style.noFill=!1,"string"==typeof arguments[0]){i.fillStyle=arguments[0];return}let F=B.color.apply(null,arguments);if(F._a<=0){B._style.noFill=!0;return}i.fillStyle=F},B.noFill=function(){B._style.noFill=!0},B.blendMode=function(F){i.globalCompositeOperation=F},B.strokeCap=function(F){i.lineCap=F},B.strokeJoin=function(F){i.lineJoin=F},B.ellipseMode=function(F){B._style.ellipseMode=F},B.rectMode=function(F){B._style.rectMode=F},B.curveDetail=function(F){B._style.curveDetail=F},B.curveAlpha=function(F){B._style.curveAlpha=F},B.curveTightness=function(F){console.warn("curveTightness() sets the 'alpha' parameter of Catmull-Rom curve, and is NOT identical to p5.js counterpart. As this might change in the future, please call curveAlpha() directly."),B._style.curveAlpha=F},B.clear=function(){i.clearRect(0,0,B.width,B.height)},B.background=function(){if(arguments[0]&&arguments[0].MAGIC==B.MAGIC)return B.image(arguments[0],0,0,B.width,B.height);i.save(),i.resetTransform(),i.scale(B._pixelDensity,B._pixelDensity),"string"==typeof arguments[0]?i.fillStyle=arguments[0]:i.fillStyle=B.color(...Array.from(arguments)),i.fillRect(0,0,B.width,B.height),i.restore()},B.line=function(F,A,t,e){B._style.noStroke||(i.beginPath(),i.moveTo(F,A),i.lineTo(t,e),i.stroke())},B.arc=function(F,A,t,i,e,V,o,s){if(e==V)return B.ellipse(F,A,t,i);void 0==s&&(s=25),void 0==o&&(o=B.PIE),B._style.ellipseMode==B.CENTER?Q(F,A,t,i,e,V,o,s):B._style.ellipseMode==B.RADIUS?Q(F,A,2*t,2*i,e,V,o,s):B._style.ellipseMode==B.CORNER?Q(F+t/2,A+i/2,t,i,e,V,o,s):B._style.ellipseMode==B.CORNERS&&Q((F+t)/2,(A+i)/2,t-F,i-A,e,V,o,s)},B.ellipse=function(F,A,t,i){void 0==i&&(i=t),B._style.ellipseMode==B.CENTER?E(F,A,t,i):B._style.ellipseMode==B.RADIUS?E(F,A,2*t,2*i):B._style.ellipseMode==B.CORNER?E(F+t/2,A+i/2,t,i):B._style.ellipseMode==B.CORNERS&&E((F+t)/2,(A+i)/2,t-F,i-A)},B.circle=function(F,A,t){return B.ellipse(F,A,t,t)},B.point=function(F,A){F.x&&(A=F.y,F=F.x),i.beginPath(),i.ellipse(F,A,.4,.4,0,0,2*Math.PI),i.stroke()},B.rect=function(F,A,t,i,e,V,o,s){B._style.rectMode==B.CENTER?c(F-t/2,A-i/2,t,i,e,V,o,s):B._style.rectMode==B.RADIUS?c(F-t,A-i,2*t,2*i,e,V,o,s):B._style.rectMode==B.CORNER?c(F,A,t,i,e,V,o,s):B._style.rectMode==B.CORNERS&&c(F,A,t-F,i-A,e,V,o,s)},B.square=function(F,A,t,i,e,V,o){return B.rect(F,A,t,t,i,e,V,o)},B.beginShape=function(){m(),i.beginPath(),V=!0},B.beginContour=function(){i.closePath(),m(),V=!0},B.endContour=function(){m(),V=!0},B.vertex=function(F,A){m(),V?i.moveTo(F,A):i.lineTo(F,A),V=!1},B.bezierVertex=function(F,A,t,B,e,V){m(),i.bezierCurveTo(F,A,t,B,e,V)},B.quadraticVertex=function(F,A,t,B){m(),i.quadraticCurveTo(F,A,t,B)},B.bezier=function(F,A,t,i,e,V,o,s){B.beginShape(),B.vertex(F,A),B.bezierVertex(t,i,e,V,o,s),B.endShape()},B.triangle=function(F,A,t,i,e,V){B.beginShape(),B.vertex(F,A),B.vertex(t,i),B.vertex(e,V),B.endShape(B.CLOSE)},B.quad=function(F,A,t,i,e,V,o,s){B.beginShape(),B.vertex(F,A),B.vertex(t,i),B.vertex(e,V),B.vertex(o,s),B.endShape(B.CLOSE)},B.endShape=function(F){m(),F&&i.closePath(),B._style.noFill||i.fill(),B._style.noStroke||i.stroke(),B._style.noFill&&B._style.noStroke&&(i.save(),i.fillStyle="none",i.fill(),i.restore())},B.curveVertex=function(F,A){if(o.push([F,A]),o.length<4)return;let t=function(F,A,t,B,i,e,V,o,s,q){function h(F,A,t,B,i,e){return Math.pow(Math.pow(B-A,2)+Math.pow(i-t,2),.5*e)+F}let a=[],r=h(0,F,A,t,B,q),n=h(r,t,B,i,e,q),M=h(n,i,e,V,o,q);for(let q=0;q0?(g[F]=1,g[F+1]=0):(g[F]=0,g[F+1]=1));let l=F*g[0]+t*g[1],C=A*g[0]+B*g[1],I=t*g[2]+i*g[3],w=B*g[2]+e*g[3],Q=i*g[4]+V*g[5],E=e*g[4]+o*g[5],c=l*g[6]+I*g[7],m=C*g[6]+w*g[7],Y=I*g[8]+Q*g[9],D=w*g[8]+E*g[9],p=c*g[2]+Y*g[3],u=m*g[2]+D*g[3];a.push([p,u])}return a}(...o[o.length-4],...o[o.length-3],...o[o.length-2],...o[o.length-1],B._style.curveDetail,B._style.curveAlpha);for(let F=0;F=A?255:0}},Y[B.GRAY]=function(F){for(let A=0;A>8)*255/t,F[B+1]=(F[B+1]*A>>8)*255/t,F[B+2]=(F[B+2]*A>>8)*255/t},Y[B.DILATE]=function(F){p(),l.set(F);let[A,t]=[i.canvas.width,i.canvas.height];for(let B=0;B=1&&(q++,r--),n>=1&&(h++,n--),M>=1&&(a++,M--)}return g},B.noiseDetail=function(F,A){F>0&&(S=F),A>0&&(k=A)};let y=function(){let F,A;return{setSeed(t){A=F=(null==t?4294967296*Math.random():t)>>>0},getSeed:()=>F,rand:()=>(A=(1664525*A+1013904223)%4294967296)/4294967296}},K=function(){let F,A;return{setSeed(t){F=A=(null==t?4294967295*Math.random():t)>>>0},getSeed:()=>A,rand:()=>(F^=F<<17,F^=F>>13,((F^=F<<5)>>>0)/4294967295)}},Z=K();Z.setSeed(),B.noiseSeed=function(F){let A=void 0==F?4294967295*Math.random():F;G||(G=new Float32Array(4096));for(var t=0;t<4096;t++)A^=A<<17,A^=A>>13,A^=A<<5,G[t]=(A>>>0)/4294967295},B.randomSeed=function(F){Z.setSeed(F)},B.random=function(F,A){return void 0==F?Z.rand():"number"!=typeof F?F[~~(F.length*Z.rand())]:void 0!=A?Z.rand()*(A-F)+F:Z.rand()*F},B.randomGenerator=function(F){F==B.LCG?Z=y():F==B.SHR3&&(Z=K()),Z.setSeed()};var J=new function(){var F,A,t,B=Array(128),i=Array(256),e=Array(128),V=Array(128),o=Array(256),s=Array(256),q=function(){return 4294967296*Z.rand()-2147483648},h=function(){return .5+(q()<<0)*2328306e-16},a=function(){for(var A,i,o,s;;){if(A=t*e[F],0==F){do o=h(),s=h(),A=-(.2904764*Math.log(o)),i=-Math.log(s);while(i+i0?3.44262+A:-3.44262-A}if(V[F]+h()*(V[F-1]-V[F])>>0),A=1;A--)t=Math.sqrt(-2*Math.log(.00991256303526217/t+Math.exp(-.5*t*t))),B[A+1]=Math.floor(t/q*2147483648),q=t,V[A]=Math.exp(-.5*t*t),e[A]=t/2147483648;for(A=254,F=.003949659822581572/Math.exp(-h),i[0]=Math.floor(h/F*4294967296),i[1]=0,o[0]=F/4294967296,o[255]=h/4294967296,s[0]=1,s[255]=Math.exp(-h);A>=1;A--)h=-Math.log(.003949659822581572/h+Math.exp(-h)),i[A+1]=Math.floor(h/a*4294967296),a=h,s[A]=Math.exp(-h),o[A]=h/4294967296}};for(let F of(J.hasInit=!1,B.randomGaussian=function(F,A){return J.hasInit||(J.zigset(),J.hasInit=!0),J.RNOR()*A+F},B.randomExponential=function(){return J.hasInit||(J.zigset(),J.hasInit=!0),J.REXP()},B.print=console.log,B.cursor=function(F,A,t){let i="";F.includes(".")&&(F=`url("${F}")`,i=", auto"),void 0!=A&&(F+=" "+A+" "+t),B.canvas.style.cursor=F+i},B.noCursor=function(){B.canvas.style.cursor="none"},B.createCapture=function(F){var A=document.createElement("video");return A.playsinline="playsinline",A.autoplay="autoplay",navigator.mediaDevices.getUserMedia(F).then(function(F){A.srcObject=F}),A.style.position="absolute",A.style.opacity=1e-5,A.style.zIndex=-1e3,document.body.appendChild(A),A},["setup","draw","preload","mouseMoved","mousePressed","mouseReleased","mouseDragged","mouseClicked","keyPressed","keyReleased","keyTyped","touchStarted","touchEnded","touchMoved"])){let A="_"+F+"Fn";B[A]=function(){},B[A].isPlaceHolder=!0,B[F]?B[A]=B[F]:Object.defineProperty(B,F,{set:function(F){B[A]=F}})}function R(){B._noLoop||(e=null==B._frameRate?requestAnimationFrame(R):setTimeout(R,1e3/B._frameRate)),m(),V=!0,B.push(),B._drawFn(),B.pop(),++B.frameCount,B.frameCount%60==0&&(r=window.performance.now()-a,n=B.frameCount)}B.noLoop=function(){B._noLoop=!0,clearTimeout(e),e=null},B.loop=function(){B._noLoop=!1,null==e&&R()},B.redraw=function(){R()},B.frameRate=function(F){B._frameRate=F},setTimeout(function(){B._preloadFn(),a=window.performance.now(),function F(){if(q>0)return setTimeout(F,10);B._setupFn(),R()}()},1),B.canvas.onmousemove=function(F){B.pmouseX=B.mouseX,B.pmouseY=B.mouseY,B.mouseX=F.offsetX,B.mouseY=F.offsetY,B.mouseIsPressed?B._mouseDraggedFn(F):B._mouseMovedFn(F)},B.canvas.onmousedown=function(F){B.pmouseX=B.mouseX,B.pmouseY=B.mouseY,B.mouseX=F.offsetX,B.mouseY=F.offsetY,B.mouseIsPressed=!0,B.mouseButton=[B.LEFT,B.CENTER,B.RIGHT][F.button],B._mousePressedFn(F)},B.canvas.onmouseup=function(F){B.pmouseX=B.mouseX,B.pmouseY=B.mouseY,B.mouseX=F.offsetX,B.mouseY=F.offsetY,B.mouseIsPressed=!1,B._mouseReleasedFn(F)},B.canvas.onclick=function(F){B.pmouseX=B.mouseX,B.pmouseY=B.mouseY,B.mouseX=F.offsetX,B.mouseY=F.offsetY,B.mouseIsPressed=!0,B._mouseClickedFn(F),B.mouseIsPressed=!1};let d=function(F){B.keyIsPressed=!0,B.key=F.key,B.keyCode=F.keyCode,h[B.keyCode]=!0,B._keyPressedFn(F),1==F.key.length&&B._keyTypedFn(F)};window.addEventListener("keydown",d);let x=function(F){B.keyIsPressed=!1,B.key=F.key,B.keyCode=F.keyCode,h[B.keyCode]=!1,B._keyReleasedFn(F)};function T(F){let A=B.canvas.getBoundingClientRect(),t=B.canvas.scrollWidth/B.width||1,i=B.canvas.scrollHeight/B.height||1;return{x:(F.clientX-A.left)/t,y:(F.clientY-A.top)/i,id:F.identifier}}function L(){return B._touchStartedFn.isPlaceHolder&&B._touchMovedFn.isPlaceHolder&&B._touchEndedFn.isPlaceHolder}window.addEventListener("keyup",x),B.keyIsDown=function(F){return!!h[F]},B.canvas.ontouchstart=function(F){B.touches=[...F.touches].map(T),L()&&(B.pmouseX=B.mouseX,B.pmouseY=B.mouseY,B.mouseX=B.touches[0].x,B.mouseY=B.touches[0].y,B.mouseIsPressed=!0,B.mouseButton=B.LEFT,B._mousePressedFn(F)||F.preventDefault()),B._touchStartedFn(F)||F.preventDefault()},B.canvas.ontouchmove=function(F){B.touches=[...F.touches].map(T),L()&&(B.pmouseX=B.mouseX,B.pmouseY=B.mouseY,B.mouseX=B.touches[0].x,B.mouseY=B.touches[0].y,B.mouseIsPressed=!0,B.mouseButton=B.LEFT,B._mouseDraggedFn(F)||F.preventDefault()),B._touchMovedFn(F)||F.preventDefault()},B.canvas.ontouchend=B.canvas.ontouchcancel=function(F){B.touches=[...F.touches].map(T),L()&&(B.pmouseX=B.mouseX,B.pmouseY=B.mouseY,B.mouseX=B.touches[0].x,B.mouseY=B.touches[0].y,B.mouseIsPressed=!1,B._mouseReleasedFn(F)||F.preventDefault()),B._touchEndedFn(F)||F.preventDefault()},B.hasSensorPermission=!window.DeviceOrientationEvent&&!window.DeviceMotionEvent||!(DeviceOrientationEvent.requestPermission||DeviceMotionEvent.requestPermission),B.requestSensorPermissions=function(){DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then(F=>{"granted"==F&&DeviceMotionEvent.requestPermission&&DeviceMotionEvent.requestPermission().then(F=>{"granted"==F&&(B.hasSensorPermission=!0)}).catch(alert)}).catch(alert)},B.remove=function(){B.canvas.onmousemove=null,B.canvas.onmousedown=null,B.canvas.onmouseup=null,B.canvas.onclick=null,window.removeEventListener("keydown",d),window.removeEventListener("keyup",x),B.canvas.ontouchstart=null,B.canvas.ontouchmove=null,B.canvas.ontouchend=null,B.canvas.remove()};let N=F=>[1,0,0,0,0,Math.cos(F),-Math.sin(F),0,0,Math.sin(F),Math.cos(F),0,0,0,0,1],j=F=>[Math.cos(F),0,Math.sin(F),0,0,1,0,0,-Math.sin(F),0,Math.cos(F),0,0,0,0,1],W=(F,A)=>[F[0]*A[0]+F[1]*A[4]+F[2]*A[8]+F[3]*A[12],F[0]*A[1]+F[1]*A[5]+F[2]*A[9]+F[3]*A[13],F[0]*A[2]+F[1]*A[6]+F[2]*A[10]+F[3]*A[14],F[0]*A[3]+F[1]*A[7]+F[2]*A[11]+F[3]*A[15],F[4]*A[0]+F[5]*A[4]+F[6]*A[8]+F[7]*A[12],F[4]*A[1]+F[5]*A[5]+F[6]*A[9]+F[7]*A[13],F[4]*A[2]+F[5]*A[6]+F[6]*A[10]+F[7]*A[14],F[4]*A[3]+F[5]*A[7]+F[6]*A[11]+F[7]*A[15],F[8]*A[0]+F[9]*A[4]+F[10]*A[8]+F[11]*A[12],F[8]*A[1]+F[9]*A[5]+F[10]*A[9]+F[11]*A[13],F[8]*A[2]+F[9]*A[6]+F[10]*A[10]+F[11]*A[14],F[8]*A[3]+F[9]*A[7]+F[10]*A[11]+F[11]*A[15],F[12]*A[0]+F[13]*A[4]+F[14]*A[8]+F[15]*A[12],F[12]*A[1]+F[13]*A[5]+F[14]*A[9]+F[15]*A[13],F[12]*A[2]+F[13]*A[6]+F[14]*A[10]+F[15]*A[14],F[12]*A[3]+F[13]*A[7]+F[14]*A[11]+F[15]*A[15]],O=(F,A)=>[(F[0]*A[0]+F[1]*A[1]+F[2]*A[2]+F[3])/(F[12]*A[0]+F[13]*A[1]+F[14]*A[2]+F[15]),(F[4]*A[0]+F[5]*A[1]+F[6]*A[2]+F[7])/(F[12]*A[0]+F[13]*A[1]+F[14]*A[2]+F[15]),(F[8]*A[0]+F[9]*A[1]+F[10]*A[2]+F[11])/(F[12]*A[0]+F[13]*A[1]+F[14]*A[2]+F[15])];window.ondeviceorientation=function(F){B.pRotationX=B.rotationX,B.pRotationY=B.rotationY,B.pRotationZ=B.rotationZ,B.pRelRotationX=B.relRotationX,B.pRelRotationY=B.relRotationY,B.pRelRotationZ=B.relRotationZ,B.rotationX=F.beta*(Math.PI/180),B.rotationY=F.gamma*(Math.PI/180),B.rotationZ=F.alpha*(Math.PI/180),B.relRotationX=[-B.rotationY,-B.rotationX,B.rotationY][~~(window.orientation/90)+1],B.relRotationY=[-B.rotationX,B.rotationY,B.rotationX][~~(window.orientation/90)+1],B.relRotationZ=B.rotationZ},window.ondevicemotion=function(F){if(B.pAccelerationX=B.accelerationX,B.pAccelerationY=B.accelerationY,B.pAccelerationZ=B.accelerationZ,!F.acceleration){let A=O(W(j(B.rotationY),N(B.rotationX)),[0,0,-9.80665]);B.accelerationX=F.accelerationIncludingGravity.x+A[0],B.accelerationY=F.accelerationIncludingGravity.y+A[1],B.accelerationZ=F.accelerationIncludingGravity.z-A[2]}},B.year=function(){return new Date().getFullYear()},B.day=function(){return new Date().getDay()},B.hour=function(){return new Date().getHours()},B.minute=function(){return new Date().getMinutes()},B.second=function(){return new Date().getSeconds()},B.millis=function(){return window.performance.now()-a},B.avgRate=function(){return B.frameCount/(B.millis()/1e3)},B.currRate=function(){return(B.frameCount-n)/(B.millis()-r)*1e3}}(F)},wY=window.location.hash.slice(1),wD=wY.split("-")[0];try{let A=wY.split("-")[1],t=I7.from(A,"base64").toString("utf-8");F=JSON.parse(t)}catch(F){console.log("parsing hash failed",{hash:wY,error:F})}window.anybody,wm.setup=()=>{let A={level:0,opensea:!0,todaysRecords:F};wD&&""!==wD&&(A.day=parseInt(wD)),window.anybody=new I2(wm,A),wD||(console.log("no day!"),window.location.hash=window.anybody.day.toString())},wm.draw=()=>{window.anybody.draw()}}();