-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README.md and link to website with docs
- Loading branch information
1 parent
1cc583b
commit 56825ce
Showing
1 changed file
with
4 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
# Garble Language | ||
# The Garble Programming Language | ||
|
||
Garble is a simple programming language for [Secure Multi-Party Computation](https://en.wikipedia.org/wiki/Secure_multi-party_computation) with [Garbled Circuits](https://en.wikipedia.org/wiki/Garbled_circuit). The circuits generated by Garble specify a _function_, with each input coming from a different party and the output computed collaboratively by all parties in a way that no party learns another party's input. Garble is statically typed, low-level, purely functional and uses a syntax heavily inspired by Rust. | ||
|
||
All programs written in Garble are deliberately Turing-incomplete (only supporting bounded recursion), guaranteeing that they can be compiled to circuits using only `AND`, `XOR` and `NOT` gates (without any kind of stateful latches or registers). Here's an example of solving the [Millionaire's Problem](https://en.wikipedia.org/wiki/Yao%27s_Millionaires%27_problem) in Garble: | ||
Garble is a simple programming language for [**Multi-Party Computation**](https://en.wikipedia.org/wiki/Secure_multi-party_computation) with [**Garbled Circuits**](https://en.wikipedia.org/wiki/Garbled_circuit). Garble programs are **compiled to boolean circuits** and always terminate. Garble is **statically typed, low-level, purely functional** and uses a **Rust-like syntax**. Garble is much simpler than Rust though, making it easy to learn and simple to [integrate](https://sine-fdn.github.io/garble-lang/integration.html) into MPC engines. | ||
|
||
```rust | ||
// A function for solving Yao's Millionaires' problem: | ||
// A program for solving Yao's Millionaires' problem in Garble: | ||
|
||
enum Richest { | ||
IsA, | ||
|
@@ -24,36 +22,4 @@ pub fn main(a: u64, b: u64) -> Richest { | |
} | ||
``` | ||
|
||
For more examples, see the [Language Tour](language_tour.md). | ||
|
||
## How to Use Garble | ||
|
||
The circuits generated by Garble are meant to be executed using a cryptographically secure MPC engine, which is not provided by this crate. Garble is agnostic about the details of the MPC engine and assumes only that the engine executes Garbled Circuits with support for `AND`, `XOR` and `NOT` gates. For local development and testing, Garble supports a direct and unencrypted evaluation of a generated circuit, with all inputs supplied by the local user. | ||
|
||
To execute the Millionaire's problem example, first install the `garble` utility, checkout the repository to get the example programs, then run the function inside the repository directory: | ||
|
||
```sh | ||
$ cargo install garble_lang --features="bin" | ||
$ git clone [email protected]:sine-fdn/garble-lang.git | ||
$ cd garble-lang | ||
$ garble run garble_examples/millionaires.garble.rs --function=main 10000000 10000 | ||
Richest::IsA | ||
$ garble run garble_examples/millionaires.garble.rs --function=main 100 5000000 | ||
Richest::IsB | ||
$ garble run garble_examples/millionaires.garble.rs --function=main 1000 1000 | ||
Richest::Tie | ||
``` | ||
|
||
You can also type-check a program without running it by using `garble check` followed by the file name. | ||
|
||
You might need to wrap input or metadata in single quotes if they contain whitespace. | ||
|
||
## Architecture of this Repository | ||
|
||
The Garble compiler is relatively straightforward and turns a program `&str` into a `circuit::Circuit` (or aborts with a scan/parse/type error). The different steps and their modules are as follows (with steps 1-4 happening during compile time, step 5 during run time): | ||
|
||
1. [`scan.rs`](src/scan.rs) splits a program `&str` into a `token::Token` sequence. | ||
2. [`parse.rs`](src/parse.rs) parses a `token::Token` sequence into an untyped `ast::Program`. | ||
3. [`check.rs`](src/check.rs) type-checks an untyped `ast::Program`, returning a typed `ast::Program`. | ||
4. [`compile.rs`](src/compile.rs) converts a well-typed `ast::Program` into a `circuit::Circuit`. | ||
5. [`eval.rs`](src/eval.rs) executes a `circuit::Circuit` with locally supplied inputs. | ||
To learn more about Garble, check out the [website](https://sine-fdn.github.io/garble-lang) |