Skip to content

Commit

Permalink
Merge pull request #356 from trifle-labs/anybody-problem-v1
Browse files Browse the repository at this point in the history
Anybody problem v1
  • Loading branch information
okwme authored Sep 24, 2024
2 parents 3c810e4 + 72a2c5e commit 5b24318
Show file tree
Hide file tree
Showing 119 changed files with 13,068 additions and 2,024 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ circuits/*.r1cs
circuits/*.vkey.json
circuits/*.wasm
circuits/*.zkey
contracts/*Verifier.sol
# contracts/*Verifier.sol
# contractData/12345-*
# contractData/ABI-12345*

Expand All @@ -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
Expand Down
434 changes: 229 additions & 205 deletions README.md

Large diffs are not rendered by default.

32 changes: 27 additions & 5 deletions circuits/calculateMissile.circom
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion circuits/sindri.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading

0 comments on commit 5b24318

Please sign in to comment.