forked from yetanotherco/aligned_layer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkimchi.go
More file actions
24 lines (20 loc) · 893 Bytes
/
kimchi.go
File metadata and controls
24 lines (20 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package kimchi
/*
#cgo darwin LDFLAGS: -L./lib -lkimchi_verifier
#cgo linux LDFLAGS: -L./lib -lkimchi_verifier -ldl -lrt -lm
#include "lib/kimchi.h"
*/
import "C"
import (
"unsafe"
)
// TODO(xqft): check proof size
const MAX_PROOF_SIZE = 16 * 1024
const MAX_PUB_INPUT_SIZE = 50 * 1024
const MAX_VERIFIER_INDEX_SIZE = 50 * 1024
func VerifyKimchiProof(proofBuffer [MAX_PROOF_SIZE]byte, proofLen uint, pubInputBuffer [MAX_PUB_INPUT_SIZE]byte, pubInputLen uint, verifierIndexBuffer [MAX_VERIFIER_INDEX_SIZE]byte, verifierIndexLen uint) bool {
proofPtr := (*C.uchar)(unsafe.Pointer(&proofBuffer[0]))
pubInputPtr := (*C.uchar)(unsafe.Pointer(&pubInputBuffer[0]))
verifierIndexPtr := (*C.uchar)(unsafe.Pointer(&verifierIndexBuffer[0]))
return (bool)(C.verify_kimchi_proof_ffi(proofPtr, (C.uint)(proofLen), pubInputPtr, (C.uint)(pubInputLen), verifierIndexPtr, (C.uint)(verifierIndexLen)))
}