DelphinusLab / zkWasm

Apache License 2.0
478 stars 95 forks source link

How to use other library in rust code #146

Open notawayne opened 1 year ago

notawayne commented 1 year ago

I am trying to compile rust code and convert it to wasm file with wasm-pack.Everything is ok when running simple calculations in rust code.

But when I try to use an ecdsa library k256 in my code, an error will be reported thread 'main' panicked at 'failed to load wasm: Validation("Unknown opcode 192")', /home/Project/zkWasm/src/cli/app_builder.rs:75:67 note: run withRUST_BACKTRACE=1environment variable to display a backtrace

When I try to do the following hash operation in the rust code, an error will be reported when doing single-prove ` let string = "Hello, World!";

let mut hasher = DefaultHasher::new();

string.hash(&mut hasher);

let result = hasher.finish().try_into().unwrap();

wasm_output(result)

`

thread 'main' panicked at 'proof generation should not fail: ConstraintSystemFailure', /home/.cargo/git/checkouts/halo2aggregator-s-4591bb34d62c1163/2db5888/src/circuits/utils.rs:191:14 note: run withRUST_BACKTRACE=1environment variable to display a backtrace

How can I use other library in rust code?

Act0r1 commented 1 year ago

Can show start it with RUST_BACKTRACE=1 and show the output?

notawayne commented 1 year ago

The code of using k256 may changed,I don't get the same result

I start the code of hash with RUST_BACKTRACE=1 and the output is here Nothing is wrong with setup

panicked when single-prove

thread 'main' panicked at 'proof generation should not fail: ConstraintSystemFailure', /home/.cargo/git/checkouts/halo2aggregator-s-4591bb34d62c1163/2db5888/src/circuits/utils.rs:191:14
stack backtrace:

   0: rust_begin_unwind
             at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:593:5

   1: core::panicking::panic_fmt
             at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/panicking.rs:67:14

   2: core::result::unwrap_failed
             at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/result.rs:1651:5

   3: halo2aggregator_s::circuits::utils::load_or_create_proof

   4: delphinus_zkwasm::cli::exec::exec_create_proof

   5: cli::main

note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
xgaozoyoe commented 8 months ago

what is the dry-run output?