Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable arbitrary constraint degree #593

Merged
merged 12 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 22 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 34 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[workspace]
members = [
"cli",
"core",
"derive",
"eval",
"helper",
"primitives",
"prover",
"recursion/circuit",
"recursion/compiler",
"recursion/core",
"recursion/gnark-ffi",
"recursion/program",
"sdk",
"zkvm/*",
"cli",
"core",
"derive",
"eval",
"helper",
"primitives",
"prover",
"recursion/circuit",
"recursion/compiler",
"recursion/core",
"recursion/gnark-ffi",
"recursion/program",
"sdk",
"zkvm/*",
]
exclude = ["examples/target"]
resolver = "2"
Expand All @@ -30,28 +30,28 @@ debug = true
debug-assertions = true

[workspace.dependencies]
p3-air = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-field = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-commit = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-air = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-field = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-commit = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3.git", features = [
"nightly-features",
], branch = "sp1" }
p3-util = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-challenger = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-dft = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-fri = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-keccak = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-keccak-air = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-blake3 = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-mds = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-maybe-rayon = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
p3-bn254-fr = { git = "https://github.com/Plonky3/Plonky3.git", branch = "sp1" }
], branch = "unistark-pair-support" }
p3-util = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-challenger = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-dft = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-fri = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-keccak = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-keccak-air = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-blake3 = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-mds = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-poseidon2 = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-uni-stark = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-maybe-rayon = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }
p3-bn254-fr = { git = "https://github.com/Plonky3/Plonky3.git", branch = "unistark-pair-support" }

# For local development.

Expand Down
1 change: 1 addition & 0 deletions core/src/air/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,4 +651,5 @@ impl<'a, SC: StarkGenericConfig> EmptyMessageBuilder for VerifierConstraintFolde
impl<F: Field> EmptyMessageBuilder for SymbolicAirBuilder<F> {}

#[cfg(debug_assertions)]
#[cfg(not(doctest))]
impl<'a, F: Field> EmptyMessageBuilder for p3_uni_stark::DebugConstraintBuilder<'a, F> {}
6 changes: 0 additions & 6 deletions core/src/alu/add_sub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ where
builder.assert_bool(local.is_add);
builder.assert_bool(local.is_sub);
builder.assert_bool(is_real);

// Degree 3 constraint to avoid "OodEvaluationMismatch".
builder.assert_zero(
local.operand_1[0] * local.operand_1[0] * local.operand_1[0]
- local.operand_1[0] * local.operand_1[0] * local.operand_1[0],
);
}
}

Expand Down
5 changes: 0 additions & 5 deletions core/src/alu/bitwise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ where
builder.assert_bool(local.is_or);
builder.assert_bool(local.is_and);
builder.assert_bool(is_real);

// Degree 3 constraint to avoid "OodEvaluationMismatch".
builder.assert_zero(
local.a[0] * local.b[0] * local.c[0] - local.a[0] * local.b[0] * local.c[0],
);
}
}

Expand Down
5 changes: 0 additions & 5 deletions core/src/alu/divrem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,6 @@ where
local.is_real,
);
}

// A dummy constraint to keep the degree 3.
builder.assert_zero(
local.a[0] * local.b[0] * local.c[0] - local.a[0] * local.b[0] * local.c[0],
)
}
}

Expand Down
5 changes: 0 additions & 5 deletions core/src/alu/lt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ where

let is_real = local.is_slt + local.is_sltu;

// Dummy degree 3 constraint to avoid "OodEvaluationMismatch".
builder.assert_zero(
local.a[0] * local.b[0] * local.c[0] - local.a[0] * local.b[0] * local.c[0],
);

// We can compute the signed set-less-than as follows:
// SLT (signed) = b_s * (1 - c_s) + (b_s == c_s) * SLTU(b_<s, c_<s)
// Source: Jolt 5.3: Set Less Than (https://people.cs.georgetown.edu/jthaler/Jolt-paper.pdf)
Expand Down
5 changes: 0 additions & 5 deletions core/src/alu/mul/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,6 @@ where
local.shard,
local.is_real,
);

// A dummy constraint to keep the degree at least 3.
builder.assert_zero(
local.a[0] * local.b[0] * local.c[0] - local.a[0] * local.b[0] * local.c[0],
);
}
}

Expand Down
5 changes: 0 additions & 5 deletions core/src/alu/sll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,6 @@ where
local.shard,
local.is_real,
);

// A dummy constraint to keep the degree at least 3.
builder.assert_zero(
local.a[0] * local.b[0] * local.c[0] - local.a[0] * local.b[0] * local.c[0],
);
}
}

Expand Down
3 changes: 0 additions & 3 deletions core/src/bytes/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,5 @@ impl<AB: SP1AirBuilder + PairBuilder> Air<AB> for ByteChip<AB::F> {
),
}
}

// Dummy constraint for normalizing to degree 3.
builder.assert_zero(local.b * local.b * local.b - local.b * local.b * local.b);
}
}
6 changes: 0 additions & 6 deletions core/src/memory/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ where
let local = main.row_slice(0);
let local: &MemoryInitCols<AB::Var> = (*local).borrow();

// Dummy constraint of degree 3.
builder.assert_eq(
local.is_real * local.is_real * local.is_real,
local.is_real * local.is_real * local.is_real,
);

if self.kind == MemoryChipType::Initialize {
let mut values = vec![AB::Expr::zero(), AB::Expr::zero(), local.addr.into()];
values.extend(local.value.map(Into::into));
Expand Down
3 changes: 0 additions & 3 deletions core/src/operations/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,5 @@ impl<F: Field> AddOperation<F> {
builder.slice_range_check_u8(&b.0, shard, is_real.clone());
builder.slice_range_check_u8(&cols.value.0, shard, is_real);
}

// Degree 3 constraint to avoid "OodEvaluationMismatch".
builder.assert_zero(a[0] * b[0] * cols.value[0] - a[0] * b[0] * cols.value[0]);
}
}
Loading
Loading