forked from nexus-xyz/nexus-zkvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate Jolt as secondary prover (nexus-xyz#159)
* implement jolt wrapper * integrate jolt into tools * clippy * cleanup * consts * bump upstream * switch to nexus fork * default to nova * update docs
- Loading branch information
Showing
34 changed files
with
977 additions
and
58 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ members = [ | |
"nova", | ||
"spartan", | ||
"api", | ||
"jolt", | ||
] | ||
default-members = [ | ||
"riscv", | ||
|
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
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
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,3 +1,3 @@ | ||
[vm] | ||
k = 16 # number of NexusVM instructions proved per Nova folding step. | ||
nova_impl = "seq" # IVC implementation to be used, should be one of "seq" (sequential), "par" (parallel). | ||
k = 16 # number of NexusVM instructions proved per Nova folding step. | ||
prover = "nova-seq" # IVC implementation to be used, should be one of "nova-seq" (sequential), "nova-par" (parallel). |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "nexus-jolt" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
nexus-riscv = { path = "../riscv" } | ||
nexus-vm = { path = "../vm" } | ||
|
||
tracing = { version = "0.1", default-features = false } | ||
thiserror = "1.0" | ||
rayon = "1.8" | ||
strum = "0.25.0" | ||
|
||
ark-bn254 = "0.4" | ||
|
||
# latest commit on slumber-arkworks-compat | ||
jolt-core = { git = "https://github.com/nexus-xyz/jolt", rev = "dfb9f27" } | ||
jolt-common = { git = "https://github.com/nexus-xyz/jolt", rev = "dfb9f27", package = "common" } |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//! Conversion between NexusVM and Jolt types. | ||
use nexus_riscv::rv32::{Inst, RV32}; | ||
|
||
use jolt_common::rv_trace as jolt_rv; | ||
|
||
pub fn inst(inst: Inst) -> jolt_rv::ELFInstruction { | ||
jolt_rv::ELFInstruction { | ||
address: inst.pc as u64, | ||
opcode: rv32_opcode(inst.inst), | ||
rs1: inst.inst.rs1().map(Into::into), | ||
rs2: inst.inst.rs2().map(Into::into), | ||
rd: inst.inst.rd().map(Into::into), | ||
imm: inst.inst.imm(), | ||
// unsupported | ||
virtual_sequence_index: None, | ||
} | ||
} | ||
|
||
pub fn rv32_opcode(inst: RV32) -> jolt_rv::RV32IM { | ||
use jolt_rv::RV32IM as JoltRV32IM; | ||
use nexus_riscv::rv32::{AOP::*, BOP::*, LOP::*, RV32::*, SOP::*}; | ||
|
||
match inst { | ||
LUI { .. } => JoltRV32IM::LUI, | ||
AUIPC { .. } => JoltRV32IM::AUIPC, | ||
JAL { .. } => JoltRV32IM::JAL, | ||
JALR { .. } => JoltRV32IM::JALR, | ||
|
||
BR { bop: BEQ, .. } => JoltRV32IM::BEQ, | ||
BR { bop: BNE, .. } => JoltRV32IM::BNE, | ||
BR { bop: BLT, .. } => JoltRV32IM::BLT, | ||
BR { bop: BGE, .. } => JoltRV32IM::BGE, | ||
BR { bop: BLTU, .. } => JoltRV32IM::BLTU, | ||
BR { bop: BGEU, .. } => JoltRV32IM::BGEU, | ||
|
||
LOAD { lop: LB, .. } => JoltRV32IM::LB, | ||
LOAD { lop: LH, .. } => JoltRV32IM::LH, | ||
LOAD { lop: LW, .. } => JoltRV32IM::LW, | ||
LOAD { lop: LBU, .. } => JoltRV32IM::LBU, | ||
LOAD { lop: LHU, .. } => JoltRV32IM::LHU, | ||
|
||
STORE { sop: SB, .. } => JoltRV32IM::SB, | ||
STORE { sop: SH, .. } => JoltRV32IM::SH, | ||
STORE { sop: SW, .. } => JoltRV32IM::SW, | ||
|
||
ALUI { aop: ADD, .. } => JoltRV32IM::ADDI, | ||
ALUI { aop: SUB, .. } => JoltRV32IM::ADDI, // note: does not exist | ||
ALUI { aop: SLL, .. } => JoltRV32IM::SLLI, | ||
ALUI { aop: SLT, .. } => JoltRV32IM::SLTI, | ||
ALUI { aop: SLTU, .. } => JoltRV32IM::SLTIU, | ||
ALUI { aop: XOR, .. } => JoltRV32IM::XORI, | ||
ALUI { aop: SRL, .. } => JoltRV32IM::SRLI, | ||
ALUI { aop: SRA, .. } => JoltRV32IM::SRAI, | ||
ALUI { aop: OR, .. } => JoltRV32IM::ORI, | ||
ALUI { aop: AND, .. } => JoltRV32IM::ANDI, | ||
|
||
ALU { aop: ADD, .. } => JoltRV32IM::ADD, | ||
ALU { aop: SUB, .. } => JoltRV32IM::SUB, | ||
ALU { aop: SLL, .. } => JoltRV32IM::SLL, | ||
ALU { aop: SLT, .. } => JoltRV32IM::SLT, | ||
ALU { aop: SLTU, .. } => JoltRV32IM::SLTU, | ||
ALU { aop: XOR, .. } => JoltRV32IM::XOR, | ||
ALU { aop: SRL, .. } => JoltRV32IM::SRL, | ||
ALU { aop: SRA, .. } => JoltRV32IM::SRA, | ||
ALU { aop: OR, .. } => JoltRV32IM::OR, | ||
ALU { aop: AND, .. } => JoltRV32IM::AND, | ||
|
||
FENCE => JoltRV32IM::FENCE, | ||
ECALL => JoltRV32IM::ECALL, | ||
EBREAK => JoltRV32IM::EBREAK, | ||
UNIMP => JoltRV32IM::UNIMPL, | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use nexus_riscv::{rv32::RV32, VMError}; | ||
|
||
use jolt_core::utils::errors::ProofVerifyError; | ||
|
||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
VM(#[from] VMError), | ||
|
||
#[error("Instruction isn't supported: {0}")] | ||
Unsupported(RV32), | ||
|
||
#[error(transparent)] | ||
ProofVerify(#[from] ProofVerifyError), | ||
|
||
#[error("memory access")] | ||
Memory(#[from] nexus_vm::error::NexusVMError), | ||
} |
Oops, something went wrong.