Skip to content

Commit

Permalink
Fixed minor spelling errors and added dockerfile for MacOS compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
psinelnikov committed Oct 13, 2024
1 parent d7d82b4 commit ad7c567
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 6 deletions.
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM rustlang/rust:nightly AS builder
RUN apt-get update && apt-get install -y \
autoconf \
automake \
libtool \
curl \
make \
gcc \
g++ \
unzip \
pkg-config \
openssl \
libssl-dev \
wget \
vim \
&& rm -rf /var/lib/apt/lists/*

# install musl cross compiler
RUN wget http://musl.cc/mips-linux-muslsf-cross.tgz
RUN mkdir -p "/root/.mipsrust"
RUN tar -xzf "mips-linux-muslsf-cross.tgz" -C "/root/.mipsrust"

ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER="/root/.mipsrust/mips-linux-muslsf-cross/bin/mips-linux-muslsf-gcc"
ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUSTFLAGS='--cfg target_os="zkvm" -C target-feature=+crt-static -C link-arg=-g'

# install golang
ENV GOLANG_VERSION=1.23.2
ENV GOLANG_DOWNLOAD_URL=https://go.dev/dl/
ENV GOLANG_DOWNLOAD_SHA256_AMD64=542d3c1705f1c6a1c5a80d5dc62e2e45171af291e755d591c5e6531ef63b454e
ENV GOLANG_DOWNLOAD_SHA256_ARM64=f626cdd92fc21a88b31c1251f419c17782933a42903db87a174ce74eeecc66a9

RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
GOARCH=amd64; \
GO_SHA256=$GOLANG_DOWNLOAD_SHA256_AMD64; \
elif [ "$ARCH" = "aarch64" ]; then \
GOARCH=arm64; \
GO_SHA256=$GOLANG_DOWNLOAD_SHA256_ARM64; \
else \
echo "Unsupported architecture"; exit 1; \
fi && \
wget ${GOLANG_DOWNLOAD_URL}go${GOLANG_VERSION}.linux-${GOARCH}.tar.gz && \
echo "${GO_SHA256} go${GOLANG_VERSION}.linux-${GOARCH}.tar.gz" | sha256sum -c - && \
tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-${GOARCH}.tar.gz && \
rm go${GOLANG_VERSION}.linux-${GOARCH}.tar.gz

ENV PATH=/usr/local/go/bin:$PATH

# docker build -t zkm/zkmips:compile .
# docker run -it --rm -v ./:/zkm zkm/zkmips:compile
# compile rust mips
# cd /zkm/prover/examples/sha2-rust && cargo build -r --target=mips-unknown-linux-musl
# cd /zkm/prover/examples/revme && cargo build -r --target=mips-unknown-linux-musl
# compile go mips
# cd /zkm/prover/examples/add-go && GOOS=linux GOARCH=mips GOMIPS=softfloat go build .
# cd /zkm/prover/examples/sha2-go && GOOS=linux GOARCH=mips GOMIPS=softfloat go build .

12 changes: 6 additions & 6 deletions host-program/src/bin/zkm-prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let input: ProverInput = match args[1].as_str() {
"sha2-rust" => {
set_sha2_rust_intput(seg_size2, execute_only2).expect("set sha2-rust input error")
set_sha2_rust_input(seg_size2, execute_only2).expect("set sha2-rust input error")
}
"sha2-go" => set_sha2_go_intput(seg_size2, execute_only2).expect("set sha2-go input error"),
"mem-alloc-vec" => set_mem_alloc_vec_intput(seg_size2, execute_only2)
"sha2-go" => set_sha2_go_input(seg_size2, execute_only2).expect("set sha2-go input error"),
"mem-alloc-vec" => set_mem_alloc_vec_input(seg_size2, execute_only2)
.expect("set mem-alloc-vec input error"),
"revme" => set_revme_input(seg_size2, execute_only2).expect("set revme input error"),
_ => {
Expand Down Expand Up @@ -139,7 +139,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}

fn set_sha2_rust_intput(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<ProverInput> {
fn set_sha2_rust_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<ProverInput> {
let elf_path = env::var("ELF_PATH").expect("ELF PATH is missed");
let num_bytes: usize = 1024; //Notice! : if this value is small, it will not generate the snark proof.
let pri_input = vec![5u8; num_bytes];
Expand Down Expand Up @@ -214,7 +214,7 @@ impl Data {
}
}

fn set_sha2_go_intput(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<ProverInput> {
fn set_sha2_go_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<ProverInput> {
let elf_path = env::var("ELF_PATH").expect("ELF PATH is missed");
let args = env::var("ARGS").unwrap_or("data-to-hash".to_string());
// assume the arg[0] is the hash(input)(which is a public input), and the arg[1] is the input.
Expand All @@ -237,7 +237,7 @@ fn set_sha2_go_intput(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<P
Ok(input)
}

fn set_mem_alloc_vec_intput(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<ProverInput> {
fn set_mem_alloc_vec_input(seg_size_u: u32, execute_only_b: bool) -> anyhow::Result<ProverInput> {
let elf_path = env::var("ELF_PATH").expect("ELF PATH is missed");
let input = ProverInput {
elf: read(elf_path).unwrap(),
Expand Down

0 comments on commit ad7c567

Please sign in to comment.