A BrainFuck zkVM implementation using Halo2.

Overview

zkvm_brainfuck

A BrainFuck zkVM implementation using Halo2. Zkvm_brainfuck is a zero-knowledge BrainFuck VM, designed as a custom, STARK-inspired version of PSE's Halo2. It's only for learning purposes only, out of a desire to gain a deeper, detailed understanding of Halo2 and VM arithmetization.

For what's about Brainfuck language and it's constraints, please read the BrainSTARK introduction and Arithmetization of Brainfuck VM first.

Difference with BrainSTARK

Primitives

  1. In BrainSTARK, the author uses Permuation Running Product to do permutation check, which requires some challeges values chosen by the Fiat-Shamir public oracle, thus might incur potential security risk. Here we use Halo2's in-house lookup_any API to do the Permuation check.

  2. In BrainSTARK, the author uses Running Evaluation to verify that one table contains rows that are an (order-preserving) sublist of another table. Here, by combining lookup and a order-perservating gate, we can constrait the same thing on output table and input table.

Protocol

Because we can directly do the above two constraints in halo2, there is no need to introduce a Instrcution table as a bridge fullfill the Permuation Running Product and Running Evaluation.

For clarity, the two gates involved with memory inverse inv required by Processor table in Arithmetization of Brainfuck VM is replace by IsZeroChip.

A range table is used to constrain the memory value and cycle offset, here the chosen range is [0,255].

VM

Credits to cryptape to VM implementation. We made some minor changes to the Matrix structure in bf_vm/src/matrix.rs for easier lookup integration.

test 2 simple program in bf_vm/tests

cd bf_vm && cargo test

ZK_VM

In bf_zk/tests dir, we provide two basic test cases, of which one is without inputs while the other is with inputs.

cd bf_zk
cargo test test_vmcircuit -- --show-output
You might also like...
Build terminal user interfaces and dashboards using Rust
Build terminal user interfaces and dashboards using Rust

tui-rs tui-rs is a Rust library to build rich terminal user interfaces and dashboards. It is heavily inspired by the Javascript library blessed-contri

Pure-Rust rewrite of the Linux fontconfig library (no system dependencies) - using ttf-parser and allsorts

rust-fontconfig Pure-Rust rewrite of the Linux fontconfig library (no system dependencies) - using allsorts as a font parser in order to parse .woff,

A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies
A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies

cargo-temp A CLI tool that allow you to create a new rust project in a temporary directory with already installed dependencies. Install Requires Rust

Mini Rust CLI to deploy sites to Netlify using their API

This is a Rust CLI that uses the Netlify API to deploy sites.

Build terminal dashboards using ascii/ansi art and javascript
Build terminal dashboards using ascii/ansi art and javascript

blessed-contrib Build dashboards (or any other application) using ascii/ansi art and javascript. Friendly to terminals, ssh and developers.

`decaf377-rdsa` is a randomizable signature scheme using the `decaf377` group.

decaf377-rdsa is a variant of RedDSA, instantiated using the decaf377 group. Signatures are parameterized by domain (for instance, Binding and SpendAu

A few demos showing how to estimate projects using Monte Carlo simulations.

Agile Monte Carlo Simulations Demos This is the repository which accompanies the blog post "How to replace estimations and guesses with a Monte Carlo

A CLI tool for getting screenshots of URLs using headless chrome

rustywitness 🦀 🌐 📸 Web screenshot utility A CLI tool for getting screenshots of URLs using headless chrome Built with ❤︎ by swanandx and contributo

Shellcode Runner/Injector in Rust using NTDLL functions directly with the ntapi Library
Shellcode Runner/Injector in Rust using NTDLL functions directly with the ntapi Library

RustSCRunner Shellcode Runner/Injector in Rust using NTDLL functions directly with the ntapi Library. Surprisingly this is my first ever Rust project

Owner
PO
Stay hungry, and stay foolish! Try to make a difference in Web3 and contribute to the higher good.
PO
Verifiable and confidential computation based on ZKP and FHE, powered by risc0 zkVM.

zkFHE Verifiable and confidential computation based on ZKP and FHE, powered by risc0 zkVM. A PoC to demonstrate an approach for private computation on

Emiliano Bonassi 29 Apr 25, 2023
Interpreted, optimized, JITed and compiled implementations of the Brainfuck lang.

Interpreted, Optimized, JITed and Compiled Brainfuck implementations This repo contains a series of brainfuck implementations based on Eli Bendersky b

Rodrigo Batista de Moraes 5 Jan 6, 2023
An Interpreter for Brainfuck programming language implemented in the Rust programming language with zero dependencies.

Brainfuck Hello, Visitor! Hey there, welcome to my project showcase website! It's great to have you here. I hope you're ready to check out some awesom

Syed Vilayat Ali Rizvi 7 Mar 31, 2023
An interpreter and compiler for the Brainfuck language.

Brainrust ?? An interpreter and compiler for the Brainfuck language. Prerequisites You need a LLVM 16.0.* installation on your system. On Windows, you

Michael Gerhold 4 Nov 4, 2023
Using BDK from nodejs using WASM webpack 🦀

BDK + nodejs = ❤️ This repository shows how to use the bdk library in nodejs. It's just a proof-of-concept, not a complete example, and as such, it's

Daniela Brozzoni 10 Feb 21, 2023
🐎 A fast implementation of the Aho-Corasick algorithm using the compact double-array data structure. (Python wrapper for daachorse)

python-daachorse daachorse is a fast implementation of the Aho-Corasick algorithm using the compact double-array data structure. This is a Python wrap

Koichi Akabe 11 Nov 30, 2022
An implementation of Piet's text interface using cosmic-text

piet-cosmic-text Implements piet's Text interface using the cosmic-text crate. License piet-cosmic-text is free software: you can redistribute it and/

John Nunley 7 Mar 12, 2023
Implementation of Nova using arkworks for learning purposes

nova-study Implementation of Nova using arkworks-rs just for learning purposes. Warning: Implementation from scratch to learn the internals of Nova. D

null 16 Apr 23, 2023
Code implementation of DDIA, primarily using Rust and Go languages.

Let's implement DDIA in rust and golang (with some Java and Cpp). This repository contains code implementations for 'Designing Data-Intensive Applicat

Arthur.Zhang 4 Apr 21, 2023
A SIMD implementation of Keccak256 for aarch64, forked from Remco Bloeman's Goldilocks K12 implementation.

keccak256-aarch64 Warning This crate was forked from real cryptographers (Goldilocks by Remco Bloeman), by not a real cryptographer. Do not use this k

null 6 Oct 24, 2023