Skip to content

Commit ce5f842

Browse files
authored
Merge pull request #19 from lambdaclass/account_inclusion_verifier
Proof of Account verifier
2 parents 5163c73 + 06bc10c commit ce5f842

File tree

24 files changed

+2767
-131
lines changed

24 files changed

+2767
-131
lines changed

.github/workflows/build-go.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
run: make build_merkle_tree_linux
3131
- name: Build Mina bindings
3232
run: make build_mina_linux
33+
- name: Build Mina Account bindings
34+
run: make build_mina_account_linux
3335
- name: Build operator
3436
run: go build operator/cmd/main.go
3537
- name: Build aggregator

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,27 @@ test_mina_go_bindings_linux: build_mina_linux
644644
@echo "Testing Mina Go bindings..."
645645
go test ./operator/mina/... -v
646646

647+
__MINA_ACCOUNT_FFI__: ##
648+
build_mina_account_macos:
649+
@cd operator/mina_account/lib && cargo build --release
650+
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.dylib operator/mina_account/lib/libmina_account_verifier.dylib
651+
652+
build_mina_account_linux:
653+
@cd operator/mina_account/lib && cargo build --release
654+
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.so operator/mina_account/lib/libmina_account_verifier.so
655+
656+
test_mina_account_rust_ffi:
657+
@echo "Testing Mina Account Rust FFI source code..."
658+
@cd operator/mina_account/lib && cargo t --release
659+
660+
test_mina_account_go_bindings_macos: build_mina_account_macos
661+
@echo "Testing Mina Account Go bindings..."
662+
go test ./operator/mina_account/... -v
663+
664+
test_mina_account_go_bindings_linux: build_mina_linux
665+
@echo "Testing Mina Account Go bindings..."
666+
go test ./operator/mina_account/... -v
667+
647668
__BUILD_ALL_FFI__:
648669

649670
build_all_ffi: ## Build all FFIs
@@ -657,6 +678,8 @@ build_all_ffi_macos: ## Build all FFIs for macOS
657678
@$(MAKE) build_merkle_tree_macos
658679
@$(MAKE) build_halo2_ipa_macos
659680
@$(MAKE) build_halo2_kzg_macos
681+
@$(MAKE) build_mina_macos
682+
@$(MAKE) build_mina_account_macos
660683
@echo "All macOS FFIs built successfully."
661684

662685
build_all_ffi_linux: ## Build all FFIs for Linux
@@ -666,6 +689,8 @@ build_all_ffi_linux: ## Build all FFIs for Linux
666689
@$(MAKE) build_merkle_tree_linux
667690
@$(MAKE) build_halo2_ipa_linux
668691
@$(MAKE) build_halo2_kzg_linux
692+
@$(MAKE) build_mina_linux
693+
@$(MAKE) build_mina_account_linux
669694
@echo "All Linux FFIs built successfully."
670695

671696

aggregator/cmd/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
"os"
88

99
"github.com/urfave/cli/v2"
10-
"github.com/yetanotherco/aligned_layer/aggregator/internal/pkg"
10+
// TODO(xqft): used lambdaclass below as a temporary solution, can't
11+
// import the internal package when in presence of a replace directive.
12+
"github.com/lambdaclass/aligned_layer/aggregator/internal/pkg"
1113
"github.com/yetanotherco/aligned_layer/core/config"
1214
)
1315

batcher/aligned-batcher/src/mina/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ pub fn check_state(pub_inputs: &[u8], offset: &mut usize) -> Result<(), String>
6060
pub fn check_pub_inputs(pub_inputs: &[u8]) -> Result<(), String> {
6161
let mut offset = 0;
6262

63-
check_hash(pub_inputs, &mut offset)?; // candidate hash
63+
check_hash(pub_inputs, &mut offset)?; // candidate ledger hash
64+
check_hash(pub_inputs, &mut offset)?; // candidate state hash
6465
check_hash(pub_inputs, &mut offset)?; // tip hash
6566

6667
check_state(pub_inputs, &mut offset)?; // candidate state

batcher/aligned-batcher/src/zk_utils/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,14 @@ fn verify_internal(verification_data: &VerificationData) -> bool {
9898
// verifier. These checks are fast and if they aren't successful then the Pickles proof
9999
// isn't valid.
100100
}
101+
ProvingSystemId::MinaAccount => {
102+
verification_data
103+
.pub_input
104+
.as_ref()
105+
.expect("Public input is required");
106+
true
107+
// TODO(xqft): add basic integrity checks (e.g. length of merkle proof being multiple of 32
108+
// bytes, etc)
109+
}
101110
}
102111
}

batcher/aligned-sdk/src/core/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub enum ProvingSystemId {
2020
Halo2IPA,
2121
Risc0,
2222
Mina,
23+
MinaAccount,
2324
}
2425

2526
#[derive(Debug, Serialize, Deserialize, Clone)]

batcher/aligned/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ pub enum ProvingSystemArg {
228228
Risc0,
229229
#[clap(name = "Mina")]
230230
Mina,
231+
#[clap(name = "MinaAccount")]
232+
MinaAccount,
231233
}
232234

233235
const ANVIL_PRIVATE_KEY: &str = "2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"; // Anvil address 9
@@ -243,6 +245,7 @@ impl From<ProvingSystemArg> for ProvingSystemId {
243245
ProvingSystemArg::Halo2IPA => ProvingSystemId::Halo2IPA,
244246
ProvingSystemArg::Risc0 => ProvingSystemId::Risc0,
245247
ProvingSystemArg::Mina => ProvingSystemId::Mina,
248+
ProvingSystemArg::MinaAccount => ProvingSystemId::MinaAccount,
246249
}
247250
}
248251
}
@@ -577,6 +580,12 @@ fn verification_data_from_args(args: SubmitArgs) -> Result<VerificationData, Sub
577580
args.pub_input_file_name,
578581
)?)
579582
}
583+
ProvingSystemId::MinaAccount => {
584+
pub_input = Some(read_file_option(
585+
"--public_input",
586+
args.pub_input_file_name,
587+
)?)
588+
}
580589
}
581590

582591
let proof_generator_addr = Address::from_str(&args.proof_generator_addr).map_err(|e| {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
������F6:|��+���!�y��(�޻[�!nV�6�z[2�5��)l�˄nP���-:]��r4�b'I������uǬ9#.h��x3b@��lv�矖@�

batcher/aligned/test_files/mina/protocol_state.proof

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)