Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into matthias/name-space-2
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasgoergens committed Nov 4, 2024
2 parents ea80904 + 6d21d43 commit df70ce8
Show file tree
Hide file tree
Showing 64 changed files with 2,248 additions and 1,054 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ CUR_TARGET = { script = ['''
'''] }
RAYON_NUM_THREADS = "${CORE}"

[tasks.build]
# Override the default `--all-features`, that's broken, because some of our features are mutually exclusive.
args = ["build"]

[tasks.tests]
args = [
"test",
Expand Down
85 changes: 38 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
# Ceno: Non-uniform, Segment and Parallel Zero-knowledge Virtual Machine

Please see [the paper](https://eprint.iacr.org/2024/387) for an introduction to Ceno.

# MVP
step 1
- non-uniform prover end to end
- no recursion
- no PCS
- with IOP
- with lookup
- with Frontend + VM

step 2
- introduce PCS

step 3
- recursion and achieve uniformality

# Building blocks
- hash function
<!--- - [ ] merkle tree hash: 2-1 or 3-1 with padding
- [ ] transcript: 3-1
- [ ] (optional) breakdown: 16-1
- [ ] plonky2 12-4 --->
- [ ] decision: start with 8-4 first

- IOP
- lookup
- [ ] logup: spec @wenqing
- [ ] implement as an IOP module along with high degree gate
- high degree gates
- [ ] paper/spec @tianyi
- one on one tianyi/zhenfei

- PCS

- gates/subcircuits
- spec
- example by tianyi


option 1
- repeat sumcheck twice/three times
option 2
- use F_q^2/3 extension field, do not repeat
- rule of thumb: n rounds, soundness ~ (64-n) bits
# Ceno: Non-uniform, Segment and Parallel Risc-V Zero-knowledge Virtual Machine

Please see [the slightly outdated paper](https://eprint.iacr.org/2024/387) for an introduction to Ceno.

🚧 This project is currently under construction and not suitable for use in production. 🚧

If you are unfamiliar with the RISC-V instruction set, please have a look at the [RISC-V instruction set reference](https://github.com/jameslzhu/riscv-card/blob/master/riscv-card.pdf).

## Local build requirements

Ceno is built in Rust, so [installing the Rust toolchain](https://www.rust-lang.org/tools/install) is a pre-requisite, if you want to develop on your local machine. We also use [cargo-make](https://sagiegurari.github.io/cargo-make/) to build Ceno. You can install cargo-make with the following command:

```sh
cargo install cargo-make
```

You will also need to install the Risc-V target for Rust. You can do this with the following command:

```sh
rustup target add riscv32im-unknown-none-elf
```

## Building Ceno and running tests

To run the tests, you can use the following command:

```sh
cargo make tests
```

Clippy and check work as usual:

```sh
cargo check
cargo clippy
```

Alas, `cargo build` doesn't work. That's a known problem and we're working on it. Please use `cargo make build` instead for now.
2 changes: 1 addition & 1 deletion ceno_emul/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod vm_state;
pub use vm_state::VMState;

mod rv32im;
pub use rv32im::{DecodedInstruction, EmuContext, InsnCategory, InsnCodes, InsnKind};
pub use rv32im::{DecodedInstruction, EmuContext, InsnCodes, InsnKind};

mod elf;
pub use elf::Program;
Expand Down
36 changes: 29 additions & 7 deletions ceno_emul/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ impl Platform {
(self.rom_start()..=self.rom_end()).contains(&addr)
}

// TODO figure out proper region for program_data
pub const fn program_data_start(&self) -> Addr {
0x3000_0000
}

pub const fn program_data_end(&self) -> Addr {
0x3000_1000 - 1
}

// TODO figure out a proper region for public io
pub const fn public_io_start(&self) -> Addr {
0x3000_1000
}

pub const fn public_io_end(&self) -> Addr {
0x3000_2000 - 1
}

pub const fn ram_start(&self) -> Addr {
if cfg!(feature = "forbid_overflow") {
// -1<<11 == 0x800 is the smallest negative 'immediate'
Expand All @@ -61,6 +79,14 @@ impl Platform {
(self.ram_start()..=self.ram_end()).contains(&addr)
}

pub fn is_pub_io(&self, addr: Addr) -> bool {
(self.public_io_start()..=self.public_io_end()).contains(&addr)
}

pub fn is_program_data(&self, addr: Addr) -> bool {
(self.program_data_start()..=self.program_data_end()).contains(&addr)
}

/// Virtual address of a register.
pub const fn register_vma(&self, index: RegIdx) -> Addr {
// Register VMAs are aligned, cannot be confused with indices, and readable in hex.
Expand All @@ -72,11 +98,6 @@ impl Platform {
(vma >> 8) as RegIdx
}

/// Virtual address of the program counter.
pub const fn pc_vma(&self) -> Addr {
self.register_vma(32)
}

// Startup.

pub const fn pc_base(&self) -> Addr {
Expand All @@ -86,7 +107,7 @@ impl Platform {
// Permissions.

pub fn can_read(&self, addr: Addr) -> bool {
self.is_rom(addr) || self.is_ram(addr)
self.is_rom(addr) || self.is_ram(addr) || self.is_pub_io(addr) || self.is_program_data(addr)
}

pub fn can_write(&self, addr: Addr) -> bool {
Expand Down Expand Up @@ -128,6 +149,7 @@ impl Platform {
#[cfg(test)]
mod tests {
use super::*;
use crate::VMState;

#[test]
fn test_no_overlap() {
Expand All @@ -139,7 +161,7 @@ mod tests {
assert!(!p.is_ram(p.rom_start()));
assert!(!p.is_ram(p.rom_end()));
// Registers do not overlap with ROM or RAM.
for reg in [p.pc_vma(), p.register_vma(0), p.register_vma(31)] {
for reg in [p.register_vma(0), p.register_vma(VMState::REG_COUNT - 1)] {
assert!(!p.is_rom(reg));
assert!(!p.is_ram(reg));
}
Expand Down
Loading

0 comments on commit df70ce8

Please sign in to comment.