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

Proof of Account verifier #19

Merged
merged 32 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
19d2783
Copy mina operator
xqft Aug 16, 2024
6a0ca58
Mockup account verifier
xqft Aug 19, 2024
7e63c68
Update gitignore
xqft Aug 19, 2024
17c9f0c
Added new proving system to batcher
xqft Aug 19, 2024
4160da8
Fix Makefile
xqft Aug 19, 2024
a598c68
Deserialize merkle proof, added verify_merkle_proof()
xqft Aug 19, 2024
66fc5d3
Remove proof slicing
xqft Aug 19, 2024
a90a4ca
Update go modules
xqft Aug 20, 2024
958cf2e
Change yetanotherco modules to lambdaclass
xqft Aug 20, 2024
b5526cb
Revert "Change yetanotherco modules to lambdaclass"
xqft Aug 20, 2024
59ee79a
Fix go modules
xqft Aug 20, 2024
d2af2d6
Change go module name
xqft Aug 20, 2024
5d0618c
Change libmerkle_tree path
xqft Aug 20, 2024
2b353e2
Update lib merkle tree path
xqft Aug 20, 2024
b0c70c2
Update go mod replace
xqft Aug 20, 2024
a9ab0f2
Fix case
xqft Aug 20, 2024
43da621
Revert "Update lib merkle tree path"
xqft Aug 20, 2024
9597aca
Revert "Change libmerkle_tree path"
xqft Aug 20, 2024
a9577df
Add mina_account operator import, fix test module name
xqft Aug 20, 2024
3b36365
Temporal fix for internal package import
xqft Aug 21, 2024
b447638
Fix merkle proof deserialization
xqft Aug 21, 2024
ce8a206
Added clarifying comment
xqft Aug 21, 2024
38755a2
Added candidate ledger hash to state proof pub inputs
xqft Aug 21, 2024
3f7dbd1
Fix proof prechecks
xqft Aug 21, 2024
a9fa34e
Add support for account_id_hash
xqft Aug 22, 2024
141356b
Added verify merkle test
xqft Aug 22, 2024
1e6a457
Fix go binding test
xqft Aug 22, 2024
b0b6ce7
Remove unused test module
xqft Aug 22, 2024
2ca07ab
Fix CI
xqft Aug 23, 2024
c3c7b84
Update Makefile
xqft Aug 26, 2024
4bd6140
Update operator/mina_account/lib/src/lib.rs
xqft Aug 26, 2024
06bc10c
Update .env.dev
xqft Aug 26, 2024
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
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
Loading