Skip to content

Commit fb8bbde

Browse files
committed
Add the atomic-swap proof generation
1 parent e393cc7 commit fb8bbde

25 files changed

+2218
-334
lines changed

Cargo.lock

Lines changed: 1200 additions & 221 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@ version = "0.1.0"
44
edition = "2021"
55
license = "GPL-3.0"
66

7+
[workspace]
8+
members = [
9+
"crates/rapidsnark",
10+
"crates/rapidsnark-sys",
11+
"crates/witness_calculator"
12+
]
13+
714
[dependencies]
8-
eyre = { version = "0.6.11", default-features = false }
9-
poseidon-rs = { version = "0.0.10", default-features = false }
10-
clap = { version = "4.4.18", default-features = false, features = ["std"] }
11-
ethers = { version = "2.0.11", default-features = false }
12-
config = { version = "0.13.4", default-features = false, features = ["toml"] }
13-
serde = { version = "1.0.130", default-features = false }
15+
rand = { version = "0.8.4", default-features = false }
16+
eyre = { version = "0.6.11", default-features = false }
17+
poseidon-rs = { version = "0.0.10", default-features = false }
18+
clap = { version = "4.4.18", default-features = false, features = ["std"] }
19+
ethers = { version = "=2.0.7", default-features = false }
20+
config = { version = "0.13.4", default-features = false, features = ["toml"] }
21+
serde = { version = "1.0.130", default-features = false }
22+
num = { version = "0.4.0" }
23+
rapidsnark = { path = "crates/rapidsnark" }
24+
witness-calculator = { path = "crates/witness_calculator" }
1425

1526
[dependencies.bdk]
1627
git = "https://github.com/velykodnyi/bdk"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ url = "http://127.0.0.1:18443"
88
auth = { username = "admin1", password = "123" }
99
network = "regtest"
1010

11+
[circom]
12+
witnes_calculator_path = "./atomic_swap.dev/atomic_swap.wasm"
13+
proving_key_path = "./atomic_swap.dev/circuit_final.zkey"
14+
verification_key_path = "./atomic_swap.dev/verification_key.json"
15+
1116
[alice]
1217
bitcoin_private_key = "dbf0d0e35b10578d001e3560946a40a5da79d24004b91685dd4eae947d435741"
1318
ethereum_private_key = "7319e149ff5ae8c0993261ef7d93c40c45dade4eb34c3ca20ba49260e9043a55"

crates/rapidsnark-sys/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
name = "rapidsnark-sys"
3+
version = "0.1.0"
4+
edition = "2021"

crates/rapidsnark-sys/build.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::env;
2+
3+
fn main() {
4+
// Determine the directory where build.rs and Cargo.toml reside
5+
let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
6+
7+
// Construct the path to static libraries
8+
let path = format!("{}/vendor", dir);
9+
10+
// Specify the paths to the static libraries
11+
println!("cargo:rustc-link-search=native={}", path);
12+
13+
// Tell cargo to link with these static libraries
14+
println!("cargo:rustc-link-lib=static=rapidsnark-darwin-arm64");
15+
println!("cargo:rustc-link-lib=static=gmp-darwin-arm64");
16+
17+
// Link with the C++ standard library
18+
println!("cargo:rustc-link-lib=c++");
19+
}

crates/rapidsnark-sys/prover.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef PROVER_HPP
2+
#define PROVER_HPP
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
//Error codes returned by the functions.
9+
#define PRPOVER_OK 0x0
10+
#define PPROVER_ERROR 0x1
11+
#define PPROVER_ERROR_SHORT_BUFFER 0x2
12+
13+
14+
/**
15+
* @return error code:
16+
* PRPOVER_OK - in case of success.
17+
* PPROVER_ERROR - in case of an error.
18+
*/
19+
20+
int
21+
groth16_prover(const void *zkey_buffer, unsigned long zkey_size,
22+
const void *wtns_buffer, unsigned long wtns_size,
23+
char *proof_buffer, unsigned long *proof_size,
24+
char *public_buffer, unsigned long *public_size,
25+
char *error_msg, unsigned long error_msg_maxsize);
26+
27+
#ifdef __cplusplus
28+
}
29+
#endif
30+
31+
32+
#endif // PROVER_HPP

crates/rapidsnark-sys/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* automatically generated by rust-bindgen 0.65.1 */
2+
3+
pub const PRPOVER_OK: u32 = 0;
4+
pub const PPROVER_ERROR: u32 = 1;
5+
pub const PPROVER_ERROR_SHORT_BUFFER: u32 = 2;
6+
extern "C" {
7+
#[doc = " @return error code:\n PRPOVER_OK - in case of success.\n PPROVER_ERROR - in case of an error."]
8+
pub fn groth16_prover(
9+
zkey_buffer: *const ::std::os::raw::c_void,
10+
zkey_size: ::std::os::raw::c_ulong,
11+
wtns_buffer: *const ::std::os::raw::c_void,
12+
wtns_size: ::std::os::raw::c_ulong,
13+
proof_buffer: *mut ::std::os::raw::c_char,
14+
proof_size: *mut ::std::os::raw::c_ulong,
15+
public_buffer: *mut ::std::os::raw::c_char,
16+
public_size: *mut ::std::os::raw::c_ulong,
17+
error_msg: *mut ::std::os::raw::c_char,
18+
error_msg_maxsize: ::std::os::raw::c_ulong,
19+
) -> ::std::os::raw::c_int;
20+
}
916 KB
Binary file not shown.
871 KB
Binary file not shown.
1.36 MB
Binary file not shown.

0 commit comments

Comments
 (0)