This project exposes a locally-installed Z3 instance as a web service.
Run:
$ npm install
You will also need to ensure that Z3 is installed locally, and you also need a local copy of OpenSSL. Windows users can get OpenSSL by installing the Git for Windows package, which includes an openssl.exe
binary. Both z3
and openssl
need to be in the user's path.
z3-web
uses SSL by default, so in order to run it, you will need SSL certificates. It looks in the certs
directory of the repository for two files, a private key called certs/z3web.key
and a public key called certs/z3web.cert
. You may generate these yourself, but for development purposes, a self-signed certificate suffices.
You need to add this via mmc
. TODO.
- In the repository root, run
scripts/certgen.sh
. - Double-click the
certs/z3web.cert
file to open the Keychain Access program. You will be prompted to enter your password. - Double-click on the certificate just added. It will have a randomly-generated name like
3cb69473-50de-4bac-a7a9-3e0c272131b4
. If you're having trouble finding it, look for a certificate with an expiration date roughly one month from now. - Expand the
Trust
item and selectAlways Trust
from theWhen using this certificate
dropdown.
These should not be considered canonical Z3 installation instructions, but here's what works for me.
- Download the 64 bit release ZIP file and unzip it to
C:\Program Files
. - Find the path of the
bin
folder in your Z3 installation path. For me, it isC:\Program Files\z3-4.8.10-x64-win\bin
. - Open Explorer, right-click on
This PC
and selectProperties
and find theAdvanced system settings
link, which will bring up aSystem Properties
dialog. - Click the
Environment Variables
button, selectPath
in theUser variables
pane, and clickEdit...
. - Click the
New
button and then paste yourbin
path into the text box. - Click
OK
to exit the edit window. - Click
OK
to exit the rest of the windows.
Z3 is available via Homebrew. If you have Homebrew installed, just run:
$ brew install z3
On Debian, Z3 is available via apt
. Run:
$ sudo apt install z3
Run:
$ npm run start
The web service will listen on http://localhost:3456
by default.
This service expects to receive queries via HTTP GET request. Your Z3 query should be encoded as a URL-encoded SMTLIBv2 string passed as the program
parameter. For example,
The program
(check-sat)
can be sent to this service as:
http://localhost:3456/?program=%28check-sat%29%0A
If you want to modify this package, there is a debug mode that is very helpful. You should instead run:
$ npm run dev:debug
which will start up the web service with the nodemon
monitor. There are two benefits to this:
nodemon
will detect when your.ts
code changes, recompile and restart the web service, and- it will run this code "breakpointable", and if you've configured VSCode to "auto-attach" to node processes launched from the VSCode terminal (this is the default behavior), then you can set breakpoints in VSCode and inspect the running state of the web service.
The service does no filtering of queries of any kind, and it calls Z3 synchronously, so be warned: it's probably not secure and it's easy to stage a denial-of-service attack. If you need something for public deployment, this isn't it. I developed this wrapper to make research code possible.