Repository navigation
Rewynth: recovering reusable inverse programs from compiled ARM64 transforms with Z3 #11140
Nazeeh Abdul-Hadi (nazeeh111)
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Update: exact 64-bit transforms and a released SplitMix64 inverse
Rewynth 0.2.0 adds explicit 64-bit register semantics, exact textual HTTP inputs and BigInt browser arithmetic. The shipped pure SplitMix64 output-step adapter is recovered from its actual compiled ARM64 bytes. Its reusable backward program maps full output
0x161922c645ce50e8back to prior state0x123456789abcdef0; the original compiled adapter and the downloaded installed workbench reproduce that pair. This requires the full output and known adapter position. The original stateful PRNG interface, truncated observations and cryptographic recovery are outside the supported scope.The 64-bit inverse retains the same proof boundary: exact chain binding and two-sided checks for each primitive, while whole nonlinear composition checks remain UNKNOWN. No global UNSAT or formally verified CPU claim is made. The released standalone uint64 C was downloaded, compiled with UBSan and checked independently. The 59-test hosted suite and installed 32/64-bit CLI gates passed on Linux Python 3.11/3.14 and ARM64 macOS Python 3.12; five native fixture checks are explicitly skipped on Linux.
The pinned source, generated inverse/evidence and exact-precision workspace are included in the release. Codex built, tested and prepared this update as well. The original 0.1 result and its narrower implementation boundary are retained below as dated evidence.
Rewynth is a local workbench that turns selected compiled ARM64 integer functions into editable source, counterexamples and reusable inverse programs. I am sharing a project published under my account; Codex built and tested it and prepared this post. It uses Capstone and Z3, with no model API or paid runtime.
The useful distinction is recovering a program that runs backward, rather than asking a solver for a new input for each desired output.
The release includes a permitted compiled xxHash32 avalanche fixture. Select
_kernel_avalanchewith one 32-bit argument, recover its source, and derive its inverse. For a desired output of0xdeadbeef, the backward program returns0x471f246e. The original identified compiled function returns0xdeadbeeffor that input on ARM64 hardware. The workbench can trace that input through every modeled register write. Exported inverse C computes future inputs without Z3. This reverses the avalanche transform, not the complete variable-length hash algorithm.What Z3 checks
The forward comparison asks whether any input in the declared domain makes the lifted instruction model and editable source produce different output bits. A satisfiable result includes the contradicting input, both results and a register trace. A deliberately unsigned replacement for the compiled signed clamp produced input
0xf298b119, original output0, and edited output255.For reusable inversion, Rewynth extracts a reversible chain from the actual lifted expression: odd multiplication modulo 2^32, constant add/subtract/XOR, rotations, full-width bit reversal and self-XOR shifts. Acceptance requires an exact binding to the forward expression and two-sided UNSAT checks for every primitive. Lossy operations, unsupported chains and restricted domains do not get an all-input inverse result.
The proof boundary matters: these are results under the implemented 32-bit instruction model, not a formally verified CPU lifter. The whole nonlinear inverse composition checks timed out and remain UNKNOWN in the exported evidence. Acceptance uses the separately checked compositional chain; UNKNOWN is never relabeled UNSAT. Three inverse programs, including xxHash avalanche and Murmur fmix32, passed 12,060 concrete native roundtrip assertions. These tests do not prove arbitrary CPU behavior.
Try the released artifact
Release 0.1.0 has a wheel, source archive, standalone inverse C and actual proof evidence. All four public downloads were compared byte-for-byte with the local artifacts and GitHub's SHA-256 digests. The downloaded wheel's installed CLI reproduced recovery, inverse derivation and the example evaluation. Installation and workbench walkthrough.
Hosted CI passed on Linux Python 3.11/3.14 and ARM64 macOS Python 3.12, including the 39-test suite and installed CLI checks. Three native fixture tests are explicitly skipped on Linux. Validation separates hardware observations from model checks.
The reader accepts bounded thin little-endian ARM64 Mach-O/ELF with named code symbols. Arguments must be explicitly declared, one to four 32-bit registers, returning
w0. Memory, calls, loops, 64-bit operands, floating point and SIMD are rejected. Imports are read as bytes and never executed. Only identified public or owned fixtures and generated C are executed in controlled tests.The fixture was built with Apple Clang 21.0.0 using
clang -O2 -dynamiclib kernels.c -o kernels.dylib; artifact SHA-256 isd6b206f48f758bc43e3498a7de54054f3fcb77b2fafc85618faf96d1f8f1f53e. Pinned sources and licenses retain stb MIT and xxHash BSD-2-Clause attribution.Feedback on the encoding or compositional evidence would be particularly useful. A small already-public or invented supported transform with an expected result and concrete witness is enough; please do not share private binaries. The project credits prior synthesis/decompilation work and claims no first invention of these techniques.
All reactions