Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Darude mods #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ strum_macros = "0.24"
pollster = "0.2.4"
rayon = { version = "1.5.3", optional = true }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.5.0"

# taken from https://github.com/recmo/uint
# Compilation profile for any non-workspace member.
Expand Down
Binary file added proof.local.bin
Binary file not shown.
1 change: 1 addition & 0 deletions proof.local.hex

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions scripts/frombinary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# read the file in array-sum.proof and write it in hex to the file array-sum.proof.hex
# this is the file that is used by the verifier

import sys
import binascii


data = open(sys.argv[1], 'r').read()
# decode data from hex into binary string
data = binascii.unhexlify(data)
open(sys.argv[2], 'wb').write(data)
5 changes: 5 additions & 0 deletions scripts/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set -ex

python2 binary.py memory.bin memory.bin.hex
python2 binary.py trace.bin trace.bin.hex

7 changes: 7 additions & 0 deletions scripts/tobinary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# read the file in array-sum.proof and write it in hex to the file array-sum.proof.hex
# this is the file that is used by the verifier

import sys

data = open(sys.argv[1], 'rb').read()
open(sys.argv[2], 'wb').write(data.encode('hex'))
3 changes: 3 additions & 0 deletions scripts/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cargo +nightly run -r -F asm -- \
verify --program array-sum.json \
--proof proof.local.bin
4 changes: 2 additions & 2 deletions src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct RegisterState {
pub pc: usize,
}

pub struct RegisterStates(Vec<RegisterState>);
pub struct RegisterStates(pub Vec<RegisterState>);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types already implement deref. Is there a need to make this public?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I should've said WIP. Short-term fix to get this working:

https://github.com/ponderingdemocritus/darude/blob/main/wasm/src/lib.rs#L172-L183

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK how to use deref to solve it, so just publicised it for now (we don't have to merge it in).


impl RegisterStates {
/// Parses trace data in the format outputted by a `cairo-run`.
Expand All @@ -67,7 +67,7 @@ impl Deref for RegisterStates {
}

#[derive(Debug)]
pub struct Memory(Vec<Option<Word>>);
pub struct Memory(pub Vec<Option<Word>>);

impl Memory {
/// Parses the partial memory data outputted by a `cairo-run`.
Expand Down
5 changes: 0 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use ark_serialize::CanonicalDeserialize;
use ark_serialize::CanonicalSerialize;
// use more performant global allocator
#[cfg(not(target_env = "msvc"))]
use jemallocator::Jemalloc;
use ministark::Proof;
use ministark::ProofOptions;
use ministark::Prover;
Expand All @@ -20,10 +19,6 @@ use std::path::PathBuf;
use std::time::Instant;
use structopt::StructOpt;

#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;

Comment on lines -23 to -26
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

#[derive(StructOpt, Debug)]
#[structopt(name = "sandstorm", about = "cairo prover")]
enum SandstormOptions {
Expand Down