-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathprotocol.lurk
27 lines (24 loc) · 1.05 KB
/
protocol.lurk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;; A protocol that requires knowledge of a hash that opens to a pair such that
;; its components add up to 30. If the proof is accepted, further require that
;; the first component of the pair be greater than 10.
!(defprotocol my-protocol (hash pair)
(let ((list6 (lambda (a b c d e f) (cons a (cons b (cons c (cons d (cons e (cons f nil))))))))
(mk-open-expr (lambda (hash) (cons 'open (cons hash nil)))))
(cons
(if (= (+ (car pair) (cdr pair)) 30)
(list6 (mk-open-expr hash) (empty-env) :outermost pair (empty-env) :terminal)
nil)
(lambda () (> (car pair) 10))))
:backend "supernova"
:rc 10
:descr "demo protocol")
;; This is the prover's pair, whose hash is
;; 0x237fe43a25f3830ab6ac86451b93e74e8ef6ef1e8735a3f53478b7fe76b1a466
(commit '(13 . 17))
;; Let's prove it and write the proof to the file protocol-proof
!(prove-protocol my-protocol
"protocol-proof"
0x237fe43a25f3830ab6ac86451b93e74e8ef6ef1e8735a3f53478b7fe76b1a466
'(13 . 17))
;; Now it can be verified
!(verify-protocol my-protocol "protocol-proof")