Skip to content

Commit 748505c

Browse files
authored
fix (operator): handle empty inputs (yetanotherco#740)
1 parent f2d8231 commit 748505c

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

operator/risc_zero/risc_zero.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ import (
1212
)
1313

1414
func VerifyRiscZeroReceipt(receiptBuffer []byte, receiptLen uint32, imageIdBuffer []byte, imageIdLen uint32, publicInput []byte, publicInputLen uint32) bool {
15+
if len(receiptBuffer) == 0 || len(imageIdBuffer) == 0 {
16+
return false
17+
}
18+
1519
receiptPtr := (*C.uchar)(unsafe.Pointer(&receiptBuffer[0]))
1620
imageIdPtr := (*C.uchar)(unsafe.Pointer(&imageIdBuffer[0]))
21+
22+
if len(publicInput) == 0 { // allow empty public input
23+
return (bool)(C.verify_risc_zero_receipt_ffi(receiptPtr, (C.uint32_t)(receiptLen), imageIdPtr, (C.uint32_t)(imageIdLen), nil, (C.uint32_t)(0)))
24+
}
25+
1726
publicInputPtr := (*C.uchar)(unsafe.Pointer(&publicInput[0]))
1827
return (bool)(C.verify_risc_zero_receipt_ffi(receiptPtr, (C.uint32_t)(receiptLen), imageIdPtr, (C.uint32_t)(imageIdLen), publicInputPtr, (C.uint32_t)(publicInputLen)))
1928
}

operator/sp1/sp1.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import "C"
1010
import "unsafe"
1111

1212
func VerifySp1Proof(proofBuffer []byte, proofLen uint32, elfBuffer []byte, elfLen uint32) bool {
13+
if len(proofBuffer) == 0 || len(elfBuffer) == 0 {
14+
return false
15+
}
16+
1317
proofPtr := (*C.uchar)(unsafe.Pointer(&proofBuffer[0]))
1418
elfPtr := (*C.uchar)(unsafe.Pointer(&elfBuffer[0]))
1519

0 commit comments

Comments
 (0)