mirror of
https://github.com/arnaucube/go-snark-study.git
synced 2026-02-02 17:26:41 +01:00
update readme, add circuit examples dir, add vim/nvim .circuit syntax highlighter
This commit is contained in:
14
README.md
14
README.md
@@ -11,6 +11,17 @@ Implementation of the zkSNARK [Pinocchio protocol](https://eprint.iacr.org/2013/
|
||||
|
||||
Not finished, implementing this in my free time to understand it better, so I don't have much time.
|
||||
|
||||
Currently allows to do the complete path with [Pinocchio protocol](https://eprint.iacr.org/2013/279.pdf) :
|
||||
- compile circuuit
|
||||
- parsers
|
||||
- R1CS
|
||||
- QAP
|
||||
- generate trusted setup
|
||||
- calculate witness
|
||||
- generate proofs
|
||||
- verify proofs
|
||||
- with BN128 pairing
|
||||
|
||||
Current implementation status:
|
||||
- [x] Finite Fields (1, 2, 6, 12) operations
|
||||
- [x] G1 and G2 curve operations
|
||||
@@ -165,6 +176,9 @@ assert.True(t, VerifyProof(*circuit, setup, proof, publicSignalsVerif, true))
|
||||
go test ./... -v
|
||||
```
|
||||
|
||||
## vim/nvim circuit syntax highlighter
|
||||
For more details and installation instructions see https://github.com/arnaucube/go-snark/tree/master/vim-syntax
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
4
circuitexamples/factor.circuit
Normal file
4
circuitexamples/factor.circuit
Normal file
@@ -0,0 +1,4 @@
|
||||
func test(private a, private b, public c):
|
||||
d = a * b
|
||||
equals(c, d)
|
||||
out = 1 * 1
|
||||
8
circuitexamples/function.circuit
Normal file
8
circuitexamples/function.circuit
Normal file
@@ -0,0 +1,8 @@
|
||||
func test(private s0, public s1):
|
||||
s2 = s0 * s0
|
||||
s3 = s2 * s0
|
||||
s4 = s3 + s0
|
||||
s5 = s4 + 5
|
||||
equals(s1, s5)
|
||||
out = 1 * 1
|
||||
|
||||
10
vim-syntax/README.md
Normal file
10
vim-syntax/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# circuit vim syntax
|
||||
|
||||
## Installation in vim/nvim using plug
|
||||
Using [Plug](https://github.com/junegunn/vim-plug), add this lines into the `.vimrc`/`init.vim`:
|
||||
```
|
||||
Plug 'arnaucube/go-snark'
|
||||
Plug 'arnaucube/go-snark', {'rtp': 'vim-syntax'}
|
||||
```
|
||||
|
||||

|
||||
1
vim-syntax/ftdetect/go-snark-circuit.vim
Normal file
1
vim-syntax/ftdetect/go-snark-circuit.vim
Normal file
@@ -0,0 +1 @@
|
||||
au BufRead,BufNewFile *.circuit set filetype=go-snark-circuit
|
||||
BIN
vim-syntax/screenshot.png
Normal file
BIN
vim-syntax/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
61
vim-syntax/syntax/go-snark-circuit.vim
Normal file
61
vim-syntax/syntax/go-snark-circuit.vim
Normal file
@@ -0,0 +1,61 @@
|
||||
" Vim syntax file
|
||||
" Language: go-snark-circuit
|
||||
" URL: https://github.com/arnaucube/go-snark/blob/master/vim-syntax/syntax/go-snark-circuit.vim
|
||||
|
||||
if !exists("main_syntax")
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
let main_syntax = 'go-snark-circuit'
|
||||
elseif exists("b:current_syntax") && b:current_syntax == "go-snark-circuit"
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
syn keyword goSnarkCircuitCommentTodo TODO FIXME XXX TBD contained
|
||||
syn match goSnarkCircuitLineComment "\/\/.*" contains=@Spell,goSnarkCircuitCommentTodo
|
||||
syn match goSnarkCircuitSpecialCharacter "'\\.'"
|
||||
syn match goSnarkCircuitNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
|
||||
syn match goSnarkCircuitOpSymbols "+\|-\|\*\|:\|)\|(\|="
|
||||
syn keyword goSnarkCircuitPrivatePublic private public
|
||||
syn keyword goSnarkCircuitOut out
|
||||
syn keyword goSnarkCircuitEquals equals
|
||||
syn keyword goSnarkCircuitFunction func
|
||||
syn match goSnarkCircuitFuncCall /\<\K\k*\ze\s*(/
|
||||
syn keyword goSnarkCircuitPrivate private nextgroup=goSnarkCircuitInputName skipwhite
|
||||
syn keyword goSnarkCircuitPublic public nextgroup=goSnarkCircuitInputName skipwhite
|
||||
syn match goSnarkCircuitInputName '\i\+' contained
|
||||
syn match goSnarkCircuitBraces "[{}\[\]]"
|
||||
syn match goSnarkCircuitParens "[()]"
|
||||
|
||||
syn sync fromstart
|
||||
syn sync maxlines=100
|
||||
|
||||
" Define the default highlighting.
|
||||
" Only when an item doesn't have highlighting yet
|
||||
hi def link goSnarkCircuitLineComment Comment
|
||||
hi def link goSnarkCircuitCommentTodo Todo
|
||||
hi def link goSnarkCircuitSpecialCharacter Special
|
||||
hi def link goSnarkCircuitNumber Number
|
||||
hi def link goSnarkCircuitOpSymbols Operator
|
||||
hi def link goSnarkCircuitFuncCall Function
|
||||
hi def link goSnarkCircuitEquals Identifier
|
||||
hi def link goSnarkCircuitFunction Keyword
|
||||
hi def link goSnarkCircuitBraces Function
|
||||
hi def link goSnarkCircuitPrivate Keyword
|
||||
hi def link goSnarkCircuitPublic Keyword
|
||||
hi def link goSnarkCircuitInputName Special
|
||||
hi def link goSnarkCircuitOut Special
|
||||
hi def link goSnarkCircuitPrivatePublic Keyword
|
||||
|
||||
let b:current_syntax = "go-snark-circuit"
|
||||
if main_syntax == 'go-snark-circuit'
|
||||
unlet main_syntax
|
||||
endif
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim: ts=8
|
||||
Reference in New Issue
Block a user