Skip to content

Commit dbcb0d0

Browse files
committed
Fix operator for new Mina proof
1 parent 893bb71 commit dbcb0d0

File tree

7 files changed

+61
-69
lines changed

7 files changed

+61
-69
lines changed

operator/mina/lib/Cargo.lock

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/mina/lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bs58 = "0.5.1"
2626
lazy_static = "1.5.0"
2727
blake2 = "0.10.6"
2828
once_cell = "1.19.0"
29-
core = { git = "https://github.com/lambdaclass/mina_bridge", branch = "relative_finalization" }
29+
mina_bridge_core = { git = "https://github.com/lambdaclass/mina_bridge", branch = "relative_finalization" }
3030
bincode = "1.3.3"
3131

3232
[patch.crates-io]

operator/mina/lib/mina_verifier.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <stdbool.h>
22

3-
bool verify_protocol_state_proof_ffi(unsigned char *proof_buffer,
4-
unsigned int proof_len,
5-
unsigned char *public_input_buffer,
6-
unsigned int public_input_len);
3+
bool verify_mina_state_ffi(unsigned char *proof_buffer,
4+
unsigned int proof_len,
5+
unsigned char *pub_input_buffer,
6+
unsigned int pub_input_len);

operator/mina/lib/src/lib.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod consensus_state;
22

3-
use core::proof::state_proof::{MinaStateProof, MinaStatePubInputs};
3+
use mina_bridge_core::proof::state_proof::{MinaStateProof, MinaStatePubInputs};
44

55
use ark_ec::short_weierstrass_jacobian::GroupAffine;
66
use consensus_state::{select_longer_chain, LongerChainResult};
@@ -25,21 +25,21 @@ const MAX_PROOF_SIZE: usize = 48 * 1024;
2525
const MAX_PUB_INPUT_SIZE: usize = 6 * 1024;
2626

2727
#[no_mangle]
28-
pub extern "C" fn verify_protocol_state_proof_ffi(
29-
proof_bytes: &[u8; MAX_PROOF_SIZE],
28+
pub extern "C" fn verify_mina_state_ffi(
29+
proof_buffer: &[u8; MAX_PROOF_SIZE],
3030
proof_len: usize,
31-
pub_input_bytes: &[u8; MAX_PUB_INPUT_SIZE],
31+
pub_input_buffer: &[u8; MAX_PUB_INPUT_SIZE],
3232
pub_input_len: usize,
3333
) -> bool {
34-
let proof: MinaStateProof = match bincode::deserialize(&proof_bytes[..proof_len]) {
34+
let proof: MinaStateProof = match bincode::deserialize(&proof_buffer[..proof_len]) {
3535
Ok(proof) => proof,
3636
Err(err) => {
3737
eprintln!("Failed to deserialize state proof: {}", err);
3838
return false;
3939
}
4040
};
4141
let pub_inputs: MinaStatePubInputs =
42-
match bincode::deserialize(&pub_input_bytes[..pub_input_len]) {
42+
match bincode::deserialize(&pub_input_buffer[..pub_input_len]) {
4343
Ok(pub_inputs) => pub_inputs,
4444
Err(err) => {
4545
eprintln!("Failed to deserialize state pub inputs: {}", err);
@@ -208,12 +208,8 @@ mod test {
208208
assert!(pub_input_size <= pub_input_buffer.len());
209209
pub_input_buffer[..pub_input_size].clone_from_slice(PUB_INPUT_BYTES);
210210

211-
let result = verify_protocol_state_proof_ffi(
212-
&proof_buffer,
213-
proof_size,
214-
&pub_input_buffer,
215-
pub_input_size,
216-
);
211+
let result =
212+
verify_mina_state_ffi(&proof_buffer, proof_size, &pub_input_buffer, pub_input_size);
217213
assert!(result);
218214
}
219215

@@ -229,12 +225,8 @@ mod test {
229225
assert!(pub_input_size <= pub_input_buffer.len());
230226
pub_input_buffer[..pub_input_size].clone_from_slice(PROTOCOL_STATE_BAD_HASH_PUB_BYTES);
231227

232-
let result = verify_protocol_state_proof_ffi(
233-
&proof_buffer,
234-
proof_size,
235-
&pub_input_buffer,
236-
pub_input_size,
237-
);
228+
let result =
229+
verify_mina_state_ffi(&proof_buffer, proof_size, &pub_input_buffer, pub_input_size);
238230
assert!(!result);
239231
}
240232

operator/mina/mina.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
// TODO(xqft): check proof size
17-
const MAX_PROOF_SIZE = 16 * 1024
17+
const MAX_PROOF_SIZE = 48 * 1024
1818
const MAX_PUB_INPUT_SIZE = 6 * 1024
1919

2020
func timer() func() {
@@ -24,9 +24,9 @@ func timer() func() {
2424
}
2525
}
2626

27-
func VerifyProtocolStateProof(proofBuffer [MAX_PROOF_SIZE]byte, proofLen uint, pubInputBuffer [MAX_PUB_INPUT_SIZE]byte, pubInputLen uint) bool {
27+
func VerifyMinaState(proofBuffer [MAX_PROOF_SIZE]byte, proofLen uint, pubInputBuffer [MAX_PUB_INPUT_SIZE]byte, pubInputLen uint) bool {
2828
defer timer()()
2929
proofPtr := (*C.uchar)(unsafe.Pointer(&proofBuffer[0]))
3030
pubInputPtr := (*C.uchar)(unsafe.Pointer(&pubInputBuffer[0]))
31-
return (bool)(C.verify_protocol_state_proof_ffi(proofPtr, (C.uint)(proofLen), pubInputPtr, (C.uint)(pubInputLen)))
31+
return (bool)(C.verify_mina_state_ffi(proofPtr, (C.uint)(proofLen), pubInputPtr, (C.uint)(pubInputLen)))
3232
}

operator/mina/mina_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestMinaStateProofVerifies(t *testing.T) {
3131
t.Errorf("could not read bytes from mina state hash")
3232
}
3333

34-
if !mina.VerifyProtocolStateProof(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), uint(proofLen), ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), uint(pubInputLen)) {
34+
if !mina.VerifyMinaState(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), uint(proofLen), ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), uint(pubInputLen)) {
3535
t.Errorf("proof did not verify")
3636
}
3737
}

operator/pkg/operator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func (o *Operator) verify(verificationData VerificationData, results chan bool)
365365
pubInputBuffer := make([]byte, mina.MAX_PUB_INPUT_SIZE)
366366
copy(pubInputBuffer, verificationData.PubInput)
367367

368-
verificationResult := mina.VerifyProtocolStateProof(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), proofLen, ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), (uint)(pubInputLen))
368+
verificationResult := mina.VerifyMinaState(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), proofLen, ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), (uint)(pubInputLen))
369369
o.Logger.Infof("Mina state proof verification result: %t", verificationResult)
370370
results <- verificationResult
371371
case common.MinaAccount:
@@ -376,7 +376,7 @@ func (o *Operator) verify(verificationData VerificationData, results chan bool)
376376
pubInputBuffer := make([]byte, mina.MAX_PUB_INPUT_SIZE)
377377
copy(pubInputBuffer, verificationData.PubInput)
378378

379-
verificationResult := mina_account.VerifyAccountInclusion(([mina.MAX_PROOF_SIZE]byte)(proofBuffer), proofLen, ([mina.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), (uint)(pubInputLen))
379+
verificationResult := mina_account.VerifyAccountInclusion(([mina_account.MAX_PROOF_SIZE]byte)(proofBuffer), proofLen, ([mina_account.MAX_PUB_INPUT_SIZE]byte)(pubInputBuffer), (uint)(pubInputLen))
380380
o.Logger.Infof("Mina account inclusion proof verification result: %t", verificationResult)
381381
results <- verificationResult
382382
default:

0 commit comments

Comments
 (0)