Separate dynamic circuit integers and streamline integer kernels - #211
Draft
wangxiao1254 wants to merge 4 commits into
Draft
wangxiao1254 wants to merge 4 commits into
wangxiao1254 wants to merge 4 commits into
Conversation
Seed equality and multiplication from their first useful row, compute comparison borrows without a discarded difference vector, and reuse division scratch for quotient bits. Preserve aliasing and division-by-zero semantics while removing dead gates, heap allocations, and a per-bit quotient branch.
Run the Batcher network directly over pointer-backed circuit values instead of copying through temporary vectors. Cover ascending and descending pointer forms, keyed sorting, exact aliasing, and empty ranges.
Require positive compile-time widths for UInt_T and Int_T, and move runtime widths into DynamicUInt_T and DynamicInt_T with private vector storage and validated codecs. Add fixed-to-dynamic and dynamic-to-fixed conversions, preserve zero-gate reinterpretation between signed and unsigned forms, and remove the invalid mod_exp API. Migrate concepts, sessions, documentation, and fixed/dynamic parity tests.
Check signed secret-shift operands before building the barrel shifter and reject foreign-context values at the operator boundary. Exercise fixed and dynamic values at widths 1, 2, 7, 8, 31, 32, 63, 64, and 65. Compare values, gate counts, output wires, and structural digests; cover unbound assignment targets, move state, conversions, and runtime codec boundaries.
wangxiao1254
force-pushed
the
audit/circuits-foundations
branch
from
August 22, 2026 13:47
f5d8044 to
f6d68ce
Compare
wangxiao1254
force-pushed
the
audit/ir-foundations
branch
from
August 22, 2026 13:47
e8ad0af to
2fb1c26
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Separate fixed-width and dynamic circuit integers, reduce integer circuit costs, and remove pointer-sort staging copies.
Changes
Integer representations
N > 0for fixedUInt_T<Ctx,N>andInt_T<Ctx,N>;DynamicUInt_T<Ctx>andDynamicInt_T<Ctx>types with private positive-width vector storage;to_dynamic()/to_fixed<M>()conversions and signed/unsigned reinterpretation;UInt_T::mod_exp;BitVec_T<Ctx,0>use while excluding zero-width frontend/session bundles.Circuit kernels
Sorting and ownership checks
Source migration
Replace both old runtime-width spellings:
UInt_T::mod_exphas no replacement in this PR. A future modular exponentiation API should use a full-width modular multiplication rather than an N-bit wrapping product.Tests
Fixed/dynamic parity is checked at widths 1, 2, 7, 8, 31, 32, 63, 64, and 65, including values, gate counts, output wires, and structural digests. Additional tests cover exhaustive small-width arithmetic, exact gate counts, codecs, unbound/moved states, conversions, pointer sorting, empty ranges, and foreign-context secret shifts.
Stack
This is PR 6 of 6 and targets
audit/ir-foundations.