forked from lurk-lab/lurk-beta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotocol.lurk
26 lines (23 loc) · 1.01 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
;; 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) nil :outermost pair nil :terminal)
nil)
(lambda () (> (car pair) 10))))
:rc 10
:descr "demo protocol")
;; This is the prover's pair, whose hash is
;; 0x09910d31a7568d66855bcc83fccc4826063dfdf93fe5e1f736c83ec892ed139e
(commit '(13 . 17))
;; Let's prove it and write the proof to the file protocol-proof
!(prove-protocol my-protocol
"protocol-proof"
0x09910d31a7568d66855bcc83fccc4826063dfdf93fe5e1f736c83ec892ed139e
'(13 . 17))
;; Now it can be verified
!(verify-protocol my-protocol "protocol-proof")