Skip to content

Commit

Permalink
Update go modules
Browse files Browse the repository at this point in the history
  • Loading branch information
xqft committed Aug 20, 2024
1 parent 66fc5d3 commit a90a4ca
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�1�A��F�̰.��~)�s-K��.��s�/�nV�6�z[2�5��)l�˄nP���-:]��r4�b'
9 changes: 8 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 @@ -41,6 +42,9 @@ func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) {
case "Mina":
return Mina, nil
}
case "MinaAccount":

Check failure on line 45 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected case, expected }

Check failure on line 45 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / lint

expected '}', found 'case' (typecheck)

Check failure on line 45 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected case, expected }

Check failure on line 45 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected case, expected }
return MinaAccount, nil

Check failure on line 46 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / lint

expected declaration, found 'return' (typecheck)
}

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

Check failure on line 71 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected case, expected } (typecheck)

Check failure on line 71 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected case, expected }) (typecheck)

Check failure on line 71 in common/proving_systems.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected case, expected }
return "MinaAccount", nil
}

return "", fmt.Errorf("unknown proving system: %d", provingSystem)
}
Expand Down
14 changes: 7 additions & 7 deletions operator/mina_account/mina_account.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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)))
}
16 changes: 8 additions & 8 deletions operator/mina_account/mina_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
11 changes: 11 additions & 0 deletions operator/pkg/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check failure on line 378 in operator/pkg/operator.go

View workflow job for this annotation

GitHub Actions / lint

undefined: mina.VerifyAccountInclusion (typecheck)
o.Logger.Infof("Mina account inclusion proof verification result: %t", verificationResult)
results <- verificationResult
default:
o.Logger.Error("Unrecognized proving system ID")
results <- false
Expand Down

0 comments on commit a90a4ca

Please sign in to comment.