From a90a4ca4fb7d948d2fb4d019e75d91a1ef5c0614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Est=C3=A9fano=20Bargas?= Date: Tue, 20 Aug 2024 16:27:50 -0300 Subject: [PATCH] Update go modules --- ...73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.proof | Bin 0 -> 1155 bytes ...hs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.pub | 1 + common/proving_systems.go | 9 ++++++++- operator/mina_account/mina_account.go | 14 +++++++------- operator/mina_account/mina_account_test.go | 16 ++++++++-------- operator/pkg/operator.go | 11 +++++++++++ 6 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.proof create mode 100644 batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.pub diff --git a/batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.proof b/batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.proof new file mode 100644 index 0000000000000000000000000000000000000000..7d80710ebd59f2d5dec17ef4c5a6aae5d1de6ef0 GIT binary patch literal 1155 zcmV-}1bq7e00+)B!=Bu7O#x3xhB^4B0KPlpZ|K(reiwQoRanyw0I=T{6>=il08x27 z(&LXkL5AisGdnsuZYGrS++tq+00EcJZd_+Rx-K!OvRCmYKM*5_%!~=4Bs_^mXgMWu z6)yn%5Y!+kY5KC1unXVZbKKXZ zVOw1L0&#d12?px6mdKJA0kK5N_iIAP136X%rLdK zmwh>w4m8e!05TT=%n&cyq6F3Ar=7{lCT|dq(X$~2$=C$Lxt=~Bp6QC|JMPX=`Zi71%syvQV%dn&b^C&V5BTR}|X3E8_=z{5A^ zanrZyx#qMKhK~ctGwiEMJukK1UL84cBad1{HP} z0H4v|SIvR8*XUCb)M>+YTu2x%2i`%c8$ifX&T`C8831vQ?#)Go2J#vzu=?IcPH&Ql)PPHHORu_KFyd zn2h+)QzcrNd`zmhFz>4^iQ zdu^Nr06E3eI_RZpbkHfm*YYF}*ATfKV>f@V)4I$xnv?fv8UVN7;DOQ88F^L`NsU7K VHg5R*Z$>u@j^uB7Gpd}G6%oJ#3RD09 literal 0 HcmV?d00001 diff --git a/batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.pub b/batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.pub new file mode 100644 index 000000000..3cd639772 --- /dev/null +++ b/batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.pub @@ -0,0 +1 @@ +1AF̰.~)s-K.s/nV6z[25)l˄nP-:]r4b' \ No newline at end of file diff --git a/common/proving_systems.go b/common/proving_systems.go index c69c7e305..f4af65d43 100644 --- a/common/proving_systems.go +++ b/common/proving_systems.go @@ -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) { @@ -41,6 +42,9 @@ func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) { case "Mina": return Mina, nil } + case "MinaAccount": + return MinaAccount, nil + } return 0, fmt.Errorf("unknown proving system: %s", provingSystem) } @@ -64,6 +68,9 @@ func ProvingSystemIdToString(provingSystem ProvingSystemId) (string, error) { case Mina: return "Mina", nil } + case MinaAccount: + return "MinaAccount", nil + } return "", fmt.Errorf("unknown proving system: %d", provingSystem) } diff --git a/operator/mina_account/mina_account.go b/operator/mina_account/mina_account.go index fe00fb24e..372707a2c 100644 --- a/operator/mina_account/mina_account.go +++ b/operator/mina_account/mina_account.go @@ -1,10 +1,10 @@ -package mina +package mina_account /* -#cgo darwin LDFLAGS: -L./lib -lmina_state_verifier -#cgo linux LDFLAGS: -L./lib -lmina_state_verifier -ldl -lrt -lm +#cgo darwin LDFLAGS: -L./lib -lmina_account_verifier +#cgo linux LDFLAGS: -L./lib -lmina_account_verifier -ldl -lrt -lm -#include "lib/mina_verifier.h" +#include "lib/mina_account_verifier.h" */ import "C" import ( @@ -20,13 +20,13 @@ const MAX_PUB_INPUT_SIZE = 6 * 1024 func timer() func() { start := time.Now() return func() { - fmt.Printf("Mina block verification took %v\n", time.Since(start)) + fmt.Printf("Mina account verification took %v\n", time.Since(start)) } } -func VerifyProtocolStateProof(proofBuffer [MAX_PROOF_SIZE]byte, proofLen uint, pubInputBuffer [MAX_PUB_INPUT_SIZE]byte, pubInputLen uint) bool { +func VerifyAccountInclusion(proofBuffer [MAX_PROOF_SIZE]byte, proofLen uint, pubInputBuffer [MAX_PUB_INPUT_SIZE]byte, pubInputLen uint) bool { defer timer()() proofPtr := (*C.uchar)(unsafe.Pointer(&proofBuffer[0])) pubInputPtr := (*C.uchar)(unsafe.Pointer(&pubInputBuffer[0])) - return (bool)(C.verify_protocol_state_proof_ffi(proofPtr, (C.uint)(proofLen), pubInputPtr, (C.uint)(pubInputLen))) + return (bool)(C.verify_account_inclusion_ffi(proofPtr, (C.uint)(proofLen), pubInputPtr, (C.uint)(pubInputLen))) } diff --git a/operator/mina_account/mina_account_test.go b/operator/mina_account/mina_account_test.go index 697f7c005..7ed9165b3 100644 --- a/operator/mina_account/mina_account_test.go +++ b/operator/mina_account/mina_account_test.go @@ -5,33 +5,33 @@ import ( "os" "testing" - "github.com/yetanotherco/aligned_layer/operator/mina" + "github.com/lambdaclass/aligned_layer/operator/mina_account" ) func TestMinaStateProofVerifies(t *testing.T) { fmt.Println(os.Getwd()) - proofFile, err := os.Open("../../batcher/aligned/test_files/mina/protocol_state.proof") + proofFile, err := os.Open("../../batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.proof") if err != nil { - t.Errorf("could not open mina state proof file") + t.Errorf("could not open mina account proof file") } proofBuffer := make([]byte, mina.MAX_PROOF_SIZE) proofLen, err := proofFile.Read(proofBuffer) if err != nil { - t.Errorf("could not read bytes from mina state proof file") + t.Errorf("could not read bytes from mina account proof file") } - pubInputFile, err := os.Open("../../batcher/aligned/test_files/mina/protocol_state.pub") + pubInputFile, err := os.Open("../../batcher/aligned/test_files/mina/account_B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9.pub") if err != nil { - t.Errorf("could not open mina state hash file") + t.Errorf("could not open mina account pub inputs file") } pubInputBuffer := make([]byte, mina.MAX_PUB_INPUT_SIZE) pubInputLen, err := pubInputFile.Read(pubInputBuffer) if err != nil { - t.Errorf("could not read bytes from mina state hash") + t.Errorf("could not read bytes from mina account pub inputs hash") } - if !mina.VerifyProtocolStateProof(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), uint(proofLen), ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), uint(pubInputLen)) { + if !mina_account.VerifyAccountInclusion(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), uint(proofLen), ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), uint(pubInputLen)) { t.Errorf("proof did not verify") } } diff --git a/operator/pkg/operator.go b/operator/pkg/operator.go index 6d8339da2..895e60c9f 100644 --- a/operator/pkg/operator.go +++ b/operator/pkg/operator.go @@ -367,6 +367,17 @@ func (o *Operator) verify(verificationData VerificationData, results chan bool) verificationResult := mina.VerifyProtocolStateProof(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), proofLen, ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), (uint)(pubInputLen)) o.Logger.Infof("Mina state proof verification result: %t", verificationResult) results <- verificationResult + case common.MinaAccount: + proofLen := (uint)(len(verificationData.Proof)) + pubInputLen := (uint)(len(verificationData.PubInput)) + proofBuffer := make([]byte, mina.MAX_PROOF_SIZE) + copy(proofBuffer, verificationData.Proof) + pubInputBuffer := make([]byte, mina.MAX_PUB_INPUT_SIZE) + copy(pubInputBuffer, verificationData.PubInput) + + verificationResult := mina.VerifyAccountInclusion(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), proofLen, ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), (uint)(pubInputLen)) + o.Logger.Infof("Mina account inclusion proof verification result: %t", verificationResult) + results <- verificationResult default: o.Logger.Error("Unrecognized proving system ID") results <- false