A compiler for a language representing plonk circuits

Related tags

Miscellaneous plang
Overview

Plang

A language representing PLONK circuits.

Compiler

This repository contains a compiler for a language representing PLONK circuits. It allows circuits represented in the language to be compiled into their prover key and verifier data.

Usage

To compile one of the included circuits into its keys using the provided public parameters, run the following command:

cargo run --release compile -p plang/test.pp plang/test.plang

Circuits are declared using a language defined in the pest grammar file. The contents for of a test circuit:

# Equations of the form:
# 
# q_m⋅a⋅b + q_l⋅a + q_r⋅b + q_o⋅o = PI
#
# Can be processed and compiled into prover and verifier keys.
a + b = c
a * b = d

Disclaimer

This is a prototype and as such not ready for production use. Use with caution.

Licensing

This code is licensed under Mozilla Public License Version 2.0 (MPL-2.0). Please see LICENSE for further info.

About

Designed by the dusk team.

Contributing

  • If you want to contribute to this repository/project please, check CONTRIBUTING.md
  • If you want to report a bug or request a new feature addition, please open an issue on this repository.
Comments
  • Add changelog

    Add changelog

    Describe what you want implemented

    A change log in the root of the repository.

    Describe "Why" this is needed

    Its important to keep track of changes.

    area:cryptography team:Core 
    opened by ureeves 0
  • Doesn't compile on absent new line

    Doesn't compile on absent new line

    Describe the bug

    When compiling a circuit that is missing a final new line an error is produced:

    Error: Pest(Error { variant: ParsingError { positives: [sign], negatives: [] }, location: Pos(18), line_col: Pos((2, 9)), path: None, line: "c + d = e", continued_line: None })

    To Reproduce

    Fill a file with a small circuit - perhaps the simple equation a+b=c and "forget" to add a new line at the end of the file. The run:

    plangc compile test.plang
    

    Expected Behavior It shouldn't be a problem when there is a new line at the end of the circuit description.

    area:cryptography fix:bug team:Core 
    opened by ureeves 0
  • Panic when variable used both as PI and Witness

    Panic when variable used both as PI and Witness

    Describe the bug

    a + b = c
    c + d = e
    

    This circuit has c being both a public input and a witness. This will produce a problem when compiling the circuit.

    thread 'main' panicked at 'public is not as public in map', plang/src/circuit.rs:318:26
    

    To Reproduce Place the above circuit in a file called test.plang and run

    plangc compile test.plang
    

    Expected behaviour

    I'm unsure as to how this situation should be handled. This issue can be used to discuss.

    area:cryptography fix:bug team:Core 
    opened by ureeves 0
  • Enforce at most one tri term in the grammar

    Enforce at most one tri term in the grammar

    Describe what you want implemented

    This construction in circuit.rs:

    if tris.len() > 1
        return Err(PlangError::TooManyTriTerms);
    }
    

    Is meant to ensure - post pest parsing - that there is only one term of the form q_m·a·b in each expression. We should try to enforce this in the pest grammar instead.

    Describe "Why" this is needed

    This change is likely to significantly simplify the parsing code by leveraging pest instead of writing our own code.

    area:cryptography team:Core 
    opened by ureeves 0
  • Parsing negative coefficients

    Parsing negative coefficients

    Describe what you want implemented

    Currently we parse any coefficient as a positive BlsScalar and keep additional information about it being negative or not separately. We should consider parsing coefficients immediately as positive or negative.

    Describe "Why" this is needed

    This could remove a significant portion of code in the parser.

    area:cryptography team:Core 
    opened by ureeves 0
Owner
Dusk Network
Dusk Network is a privacy-oriented blockchain protocol, that anyone can use to create zero-knowledge dApps.
Dusk Network
A compiler for the esoteric language ℂ.

The ℂ Programming Language It's a language where the only types are "complex number" and "matrix of complex numbers". In particular, this means you ca

Eleanor McMurtry 24 Jul 15, 2022
JIT compiler and runtime for a toy language, using Cranelift

Hello! This is a simple demo that JIT-compiles a toy language, using Cranelift. It uses the new JIT interface in development here. JIT takes care of m

Bytecode Alliance 468 Jan 7, 2023
Compiler from a lisp-like language to mlog

slimlog slimlog compiles a lisp-like language to mlog Architecture slimlog is divided into three distinct parts Parser Parses the source file Compiler

The Potato Chronicler 6 May 7, 2022
Compiler & Interpreter for the (rather new and very experimental) Y programming language.

Y Lang Why would anyone build a new (and rather experimental) language with no real world use case. Design Y (pronounced as why) is based on the idea

Louis Meyer 8 Mar 5, 2023
The official zeta compiler

Torq What makes Torq the goto language for creating CLI's? Smaller Executables Inbuilt argument and flag parser Your code will work anywhere in any OS

ZetaLang 2 Nov 24, 2021
dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle!

dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle (such as rewriting/refactroing your DM code).

SS220 20 Dec 13, 2022
The nightly_crimes!{} macro commits horrible crimes to allow you to enable nightly features on the stable compiler.

The nightly_crimes!{} macro commits horrible crimes to allow you to enable nightly features on the stable compiler.

Mara Bos 151 Dec 16, 2022
An example of Brainf*** JIT-compiler with only the standard library.

jit-compiler An example of Brainf*** JIT-compiler with only the standard library. Prerequisite Rust(1.56.0-nightly or later, but it must work kind of

Akihito KIRISAKI 18 Jan 22, 2022
Solidity-Compiler Version Manager

Solidity Compiler Version Manager

Rohit Narurkar 114 Jan 2, 2023
A fusion of OTP lib/dialyzer + lib/compiler for regular Erlang with type inference

Typed ERLC The Problem I have a dream, that one day there will be an Erlang compiler, which will generate high quality type-correct code from deduced

Dmytro Lytovchenko 35 Sep 5, 2022
Use explicit container types with Scrypto! Leverage the Rust compiler's type checking to increase security and productivity when developing Radix blueprints.

Scrypto Static Types Use explicit container types with Scrypto! Leverage the Rust compiler's type checking to increase security and productivity when

null 7 Aug 5, 2022
An optimising Brainf*ck to x86-64 assembly compiler written in Rust

brainfrsk 2 An optimising Brainf*ck to x86-64 assembly compiler. This compiler can produce optimised binaries for macOS (Sytem V calling convention) b

Adam Soutar 1 Feb 20, 2022
A transpiler/compiler for CrabRave, a version of BrainFuck with sea-life emojis.

CrabRave Programming Language CrabRave is a fun and unique programming language based on Brainfuck, which utilizes crab and sea-life emojis as its syn

null 23 May 3, 2023
tr-lang is a language that aims to bring programming language syntax closer to Turkish.

tr-lang Made with ❤️ in ???? tr-lang is a language that aims to bring programming language syntax closer to Turkish. tr-lang is a stack based language

Kerem Göksu 10 Apr 2, 2022
A language server implementation for the WGSL shading language

wgsl-analyzer wgsl-analyzer is a language server plugin for the WGSL Shading language. It comes with a VS Code plugin located in ./editors/code, but d

null 155 Jan 2, 2023
The SATySFi Language Server

[WIP] SATySFi Language Server This repository is work-in-progress yet. Features Kind Function Done codeAction Add the definition of an undefined comma

monaqa 50 Dec 24, 2022
scraps of a potential language

seaslug small, beautiful, knowable, DOESN'T EXIST YET LOL non-turing complete, verified terminating code placed into well-defined interfaces similar t

Tyler Neely 34 Nov 1, 2022
A language server for lua written in rust

lua-analyzer lua-analyzer is a lsp server for lua. This is mostly for me to learn the lsp protocol and language analysis so suggestions are helpful. T

null 61 Dec 11, 2022
A scripting language that allows complex key remapping on Linux.

Map2 A scripting language that allows complex key remapping on Linux, written in Rust. All of the functionality related to interacting with graphical

Matt 99 Dec 6, 2022