alucard icon indicating copy to clipboard operation
alucard copied to clipboard

A common lisp DSL for writing zero knowledge circuits

  • Alu ** Description ALucard (Alu) is a high level DSL for writing [[https://en.wikipedia.org/wiki/Zero-knowledge_proof][Zero Knowledge]] circuits. Alu compiles to a constraint agnostic system known as [[https://github.com/ZK-Garage/vamp-ir][vamp-ir]] which allows easy integration and deployment into existing Zero Knowledge stacks or private applications into new systems.

Since Alu is a DSL, it's syntax is heavily inspired from it's host language [[https://common-lisp.net/][Common lisp]], extending the language with circuit compilation capabilities. This means that Alucard can use language infrastructure like [[https://fiveam.common-lisp.dev/][FiveAM]] and [[https://www.cliki.net/SWANK][SWANK]] to allow a battle tested interactive developer experience. ** Quick Start [[https://hackmd.io/KTN_7tyGTe2RvJ5-aC4rBw][A friendly introduction can be found here]] ** Documentation The most complete documentation is the [[https://hackmd.io/emeUBiYoSqmJ95Ls2wsrMQ][Alucard Reference Manual]].

  • [[https://hackmd.io/emeUBiYoSqmJ95Ls2wsrMQ][Reference Manual]]
  • [[file:doc/spec.md][Specification]]
  • [[file:doc/using-alucard.md][Syntax Guide]]

For those curious about test coverage, the test coverage of the compiler can be found [[https://anoma.github.io/juvix-circuits/][here]]. ** Editor Integration Since Alucard Relies on Common lisp, we support all major editors. For the best experience Emacs is recommend though the other editors work well! *** Emacs With Emacs you have a few choices for easy editor integration, either:

  • [[https://github.com/joaotavora/sly][Sly]]
  • [[https://github.com/slime/slime][Slime]]

Then you just have to set the default lisp program to alucard. #+begin_src lisp (setq inferior-lisp-program "alu.image") #+end_src

If you don't wish for the default implementation to be alucard, then =alu.image= can be passed in manually when calling =M-x sly= (In helm this is =C-u= before running the command) *** VSCode [[https://lispcookbook.github.io/cl-cookbook/vscode-alive.html][Alive]]

With [[https://lispcookbook.github.io/cl-cookbook/vscode-alive.html][Alive]] Alucard integration is quite simple, just grab the extension off the marketplace and then edit the settings.json with

However the following dependencies will also be needed

  • [[https://github.com/nobody-famous/alive-lsp][alive-lsp]]
    • This can be installed with
    • =ros install "nobody-famous/alive-lsp"=

#+begin_src javascript { "alive.lsp.startCommand": [ "alu.image", "-a" ] } #+end_src

when now connecting to a =.lisp= file, alucard will automatically be booted up. Note that to get =alucard= in the right package, in the bottom left prompt in the =REPL= tab, you should click on the =cl-user= and type in =aluser= to set the system in the right package. *** Vim [[https://github.com/vlime/vlime][vlime]] [TODO] *** Terminal Alucard can be launched from the terminal and attach to your editor as well. This can be done by launching the program with =-s= for swank or =-y= for sly. Once done you should be given a REPL on the terminal along with the message #+begin_src lisp ;; Swank started at port: 4005. #+end_src This means that you can hookup your editor of choice to localhost:4005 via =sly-connect= or =alive attach to REPL=. ** For Developers *** Test Coverage

  • Test coverage can be found [[https://anoma.github.io/juvix-circuits/][here]]. *** Setting up the Developer Environment Alucard works on many different implementations of CL, namely
    • SBCL
    • CCL
    • ECL

To quickly get started with Alucard development, one can run the following commands from their lisp REPL

  • =(load "alu.asd")=
  • =(ql:quickload :alu/test)=
    • If one is using =CLPM= then you should run =(activate-project)= instead.
  • =(asdf:test-system :alu)=

If there was an error in the above commands, look at the section below for some common solutions.

If the commands work, then you can start hacking on Alucard!

Currently binary extraction does not work with SBCL, but it is perfectly fit to load the environment like any normal CL library!

**** Errors with SBCL SBCL by default does not ship a new enough version of ASDF, and you may encounter an error like #+begin_src lisp

  • (ql:quickload :alu)

debugger invoked on a ASDF/FIND-COMPONENT:MISSING-DEPENDENCY-OF-VERSION in thread #<THREAD "main thread" RUNNING {1004E58073}>: Component "asdf" does not match version 3.3.5, required by #<SYSTEM "alu">

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name): 0: [ABORT ] Give up on "alu" 1: [REGISTER-LOCAL-PROJECTS] Register local projects and try again. 2: Exit debugger, returning to top level.

(QUICKLISP-CLIENT::AUTOLOAD-SYSTEM-AND-DEPENDENCIES "alu" :PROMPT NIL) source: (ERROR C) #+end_src If this occurs you may need to update your asdf to a newer version.

  1. Clone the repo: =git clone https://gitlab.common-lisp.net/asdf/asdf.git=
  2. =cd asdf=
  3. =git checkout 3.3.5.8= ([[https://gitlab.common-lisp.net/asdf/asdf/-/tags][any tag in =3.3.5.*= works]])
  4. =make=
  5. In the lisp REPL: =(load "/path/to/asdf/build/asdf.lisp")=
  6. put =(load "/path/to/asdf/build/asdf.lisp")= in your =~/.sbclrc=
  7. rerun the command that triggered the error