Skip to content

Commit

Permalink
Merge pull request #19 from lambdaclass/account_inclusion_verifier
Browse files Browse the repository at this point in the history
Proof of Account verifier
  • Loading branch information
gabrielbosio authored Aug 26, 2024
2 parents 5163c73 + 06bc10c commit ce5f842
Show file tree
Hide file tree
Showing 24 changed files with 2,767 additions and 131 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
run: make build_merkle_tree_linux
- name: Build Mina bindings
run: make build_mina_linux
- name: Build Mina Account bindings
run: make build_mina_account_linux
- name: Build operator
run: go build operator/cmd/main.go
- name: Build aggregator
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,27 @@ test_mina_go_bindings_linux: build_mina_linux
@echo "Testing Mina Go bindings..."
go test ./operator/mina/... -v

__MINA_ACCOUNT_FFI__: ##
build_mina_account_macos:
@cd operator/mina_account/lib && cargo build --release
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.dylib operator/mina_account/lib/libmina_account_verifier.dylib

build_mina_account_linux:
@cd operator/mina_account/lib && cargo build --release
@cp operator/mina_account/lib/target/release/libmina_account_verifier_ffi.so operator/mina_account/lib/libmina_account_verifier.so

test_mina_account_rust_ffi:
@echo "Testing Mina Account Rust FFI source code..."
@cd operator/mina_account/lib && cargo t --release

test_mina_account_go_bindings_macos: build_mina_account_macos
@echo "Testing Mina Account Go bindings..."
go test ./operator/mina_account/... -v

test_mina_account_go_bindings_linux: build_mina_linux
@echo "Testing Mina Account Go bindings..."
go test ./operator/mina_account/... -v

__BUILD_ALL_FFI__:

build_all_ffi: ## Build all FFIs
Expand All @@ -657,6 +678,8 @@ build_all_ffi_macos: ## Build all FFIs for macOS
@$(MAKE) build_merkle_tree_macos
@$(MAKE) build_halo2_ipa_macos
@$(MAKE) build_halo2_kzg_macos
@$(MAKE) build_mina_macos
@$(MAKE) build_mina_account_macos
@echo "All macOS FFIs built successfully."

build_all_ffi_linux: ## Build all FFIs for Linux
Expand All @@ -666,6 +689,8 @@ build_all_ffi_linux: ## Build all FFIs for Linux
@$(MAKE) build_merkle_tree_linux
@$(MAKE) build_halo2_ipa_linux
@$(MAKE) build_halo2_kzg_linux
@$(MAKE) build_mina_linux
@$(MAKE) build_mina_account_linux
@echo "All Linux FFIs built successfully."


Expand Down
4 changes: 3 additions & 1 deletion aggregator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"os"

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

Expand Down
3 changes: 2 additions & 1 deletion batcher/aligned-batcher/src/mina/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ pub fn check_state(pub_inputs: &[u8], offset: &mut usize) -> Result<(), String>
pub fn check_pub_inputs(pub_inputs: &[u8]) -> Result<(), String> {
let mut offset = 0;

check_hash(pub_inputs, &mut offset)?; // candidate hash
check_hash(pub_inputs, &mut offset)?; // candidate ledger hash
check_hash(pub_inputs, &mut offset)?; // candidate state hash
check_hash(pub_inputs, &mut offset)?; // tip hash

check_state(pub_inputs, &mut offset)?; // candidate state
Expand Down
9 changes: 9 additions & 0 deletions batcher/aligned-batcher/src/zk_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,14 @@ fn verify_internal(verification_data: &VerificationData) -> bool {
// verifier. These checks are fast and if they aren't successful then the Pickles proof
// isn't valid.
}
ProvingSystemId::MinaAccount => {
verification_data
.pub_input
.as_ref()
.expect("Public input is required");
true
// TODO(xqft): add basic integrity checks (e.g. length of merkle proof being multiple of 32
// bytes, etc)
}
}
}
1 change: 1 addition & 0 deletions batcher/aligned-sdk/src/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub enum ProvingSystemId {
Halo2IPA,
Risc0,
Mina,
MinaAccount,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down
9 changes: 9 additions & 0 deletions batcher/aligned/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ pub enum ProvingSystemArg {
Risc0,
#[clap(name = "Mina")]
Mina,
#[clap(name = "MinaAccount")]
MinaAccount,
}

const ANVIL_PRIVATE_KEY: &str = "2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"; // Anvil address 9
Expand All @@ -243,6 +245,7 @@ impl From<ProvingSystemArg> for ProvingSystemId {
ProvingSystemArg::Halo2IPA => ProvingSystemId::Halo2IPA,
ProvingSystemArg::Risc0 => ProvingSystemId::Risc0,
ProvingSystemArg::Mina => ProvingSystemId::Mina,
ProvingSystemArg::MinaAccount => ProvingSystemId::MinaAccount,
}
}
}
Expand Down Expand Up @@ -577,6 +580,12 @@ fn verification_data_from_args(args: SubmitArgs) -> Result<VerificationData, Sub
args.pub_input_file_name,
)?)
}
ProvingSystemId::MinaAccount => {
pub_input = Some(read_file_option(
"--public_input",
args.pub_input_file_name,
)?)
}
}

let proof_generator_addr = Address::from_str(&args.proof_generator_addr).map_err(|e| {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
������F6:|��+���!�y��(�޻[�!nV�6�z[2�5��)l�˄nP���-:]��r4�b'I������uǬ9#.h��x3b@��lv�矖@�
2 changes: 1 addition & 1 deletion batcher/aligned/test_files/mina/protocol_state.proof

Large diffs are not rendered by default.

Binary file modified batcher/aligned/test_files/mina/protocol_state.pub
Binary file not shown.
7 changes: 6 additions & 1 deletion common/proving_systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ const (
Halo2IPA
Risc0
Mina
MinaAccount
)

func (t *ProvingSystemId) String() string {
return [...]string{"GnarkPlonkBls12_381", "GnarkPlonkBn254", "Groth16Bn254", "SP1", "Halo2IPA", "Mina"}[*t]
return [...]string{"GnarkPlonkBls12_381", "GnarkPlonkBn254", "Groth16Bn254", "SP1", "Halo2IPA", "Mina", "MinaAccount"}[*t]
}

func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) {
Expand All @@ -40,6 +41,8 @@ func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) {
return Risc0, nil
case "Mina":
return Mina, nil
case "MinaAccount":
return MinaAccount, nil
}

return 0, fmt.Errorf("unknown proving system: %s", provingSystem)
Expand All @@ -63,6 +66,8 @@ func ProvingSystemIdToString(provingSystem ProvingSystemId) (string, error) {
return "Risc0", nil
case Mina:
return "Mina", nil
case MinaAccount:
return "MinaAccount", nil
}

return "", fmt.Errorf("unknown proving system: %d", provingSystem)
Expand Down
13 changes: 4 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/yetanotherco/aligned_layer
module github.com/lambdaclass/aligned_layer

go 1.22.2

Expand All @@ -13,10 +13,10 @@ require (
require (
github.com/consensys/gnark v0.10.0
github.com/consensys/gnark-crypto v0.12.2-0.20240215234832-d72fcb379d3e
github.com/yetanotherco/aligned_layer v0.0.0-00010101000000-000000000000
)

require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/aws/aws-sdk-go-v2 v1.26.1 // indirect
Expand Down Expand Up @@ -55,41 +55,36 @@ require (
github.com/holiman/uint256 v1.2.4 // indirect
github.com/ingonyama-zk/icicle v0.0.0-20230928131117-97f0079e5c71 // indirect
github.com/ingonyama-zk/iciclegnark v0.1.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/lmittmann/tint v1.0.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/rs/zerolog v1.32.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.6+incompatible // indirect
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/Layr-Labs/eigensdk-go => github.com/yetanotherco/eigensdk-go v0.1.10-0.20240805154752-29f4d3457921

replace github.com/yetanotherco/aligned_layer => .
Loading

0 comments on commit ce5f842

Please sign in to comment.