-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
word checking, line checking, padding support etc.
- Loading branch information
1 parent
b7c2704
commit 2019af4
Showing
16 changed files
with
7,122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# node | ||
node_modules/ | ||
|
||
# hardhat | ||
cache | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# wordlines | ||
# wordlines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
include "../node_modules/circomlib/circuits/gates.circom" | ||
include "../node_modules/circomlib/circuits/comparators.circom" | ||
|
||
template IsContinual(LINE_SIZE, WORD_SIZE) { | ||
signal input words[LINE_SIZE][WORD_SIZE]; | ||
signal input padding[LINE_SIZE]; | ||
signal output out; | ||
|
||
component is_prefix_continual[LINE_SIZE]; | ||
component is_index_continued[LINE_SIZE]; | ||
component is_padding_or_continued[LINE_SIZE]; | ||
|
||
for (var i = 0;i < LINE_SIZE;i++) { | ||
is_prefix_continual[i] = AND(); | ||
is_index_continued[i] = IsEqual(); | ||
is_padding_or_continued[i] = OR(); | ||
} | ||
|
||
for (var i = 0;i < LINE_SIZE;i++) { | ||
is_index_continued[i].in[0] <== words[i][0]; | ||
is_index_continued[i].in[1] <== (i == 0) ? words[i][0] : words[i-1][WORD_SIZE-1]; | ||
|
||
is_padding_or_continued[i].a <== is_index_continued[i].out; | ||
is_padding_or_continued[i].b <== padding[i]; | ||
|
||
is_prefix_continual[i].a <== (i == 0) ? 1 : is_prefix_continual[i-1].out; | ||
is_prefix_continual[i].b <== is_padding_or_continued[i].out; | ||
} | ||
|
||
out <== is_prefix_continual[LINE_SIZE-1].out; | ||
} | ||
|
||
template IsNotCrossing(WORD_SIZE, FIG_SIZE, SIDE_SIZE) { | ||
signal input word[WORD_SIZE]; | ||
signal input figure[FIG_SIZE][SIDE_SIZE]; | ||
signal output out; | ||
|
||
component are_all_not_crossing = MultiAND((WORD_SIZE-1)*FIG_SIZE*SIDE_SIZE*SIDE_SIZE); | ||
component is_char_same[WORD_SIZE-1][FIG_SIZE][SIDE_SIZE][SIDE_SIZE][2]; | ||
component is_prefix_crossing[WORD_SIZE-1][FIG_SIZE][SIDE_SIZE][SIDE_SIZE]; | ||
component is_prefix_not_crossing[WORD_SIZE-1][FIG_SIZE][SIDE_SIZE][SIDE_SIZE]; | ||
|
||
for (var i = 0;i < WORD_SIZE-1;i++) { | ||
for (var j = 0;j < FIG_SIZE;j++) { | ||
for (var k = 0;k < SIDE_SIZE;k++) { | ||
for (var l = 0;l < SIDE_SIZE;l++) { | ||
for (var m = 0;m < 2;m++) is_char_same[i][j][k][l][m] = IsEqual(); | ||
is_prefix_crossing[i][j][k][l] = AND(); | ||
is_prefix_not_crossing[i][j][k][l] = NOT(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
var idx = 0; | ||
for (var i = 0;i < WORD_SIZE-1;i++) { | ||
for (var j = 0;j < FIG_SIZE;j++) { | ||
for (var k = 0;k < SIDE_SIZE;k++) { | ||
for (var l = 0;l < SIDE_SIZE;l++) { | ||
is_char_same[i][j][k][l][0].in[0] <== word[i]; | ||
is_char_same[i][j][k][l][0].in[1] <== figure[j][k]; | ||
is_char_same[i][j][k][l][1].in[0] <== word[i+1]; | ||
is_char_same[i][j][k][l][1].in[1] <== figure[j][l]; | ||
|
||
|
||
is_prefix_crossing[i][j][k][l].a <== is_char_same[i][j][k][l][0].out; | ||
is_prefix_crossing[i][j][k][l].b <== is_char_same[i][j][k][l][1].out; | ||
is_prefix_not_crossing[i][j][k][l].in <== is_prefix_crossing[i][j][k][l].out; | ||
are_all_not_crossing.in[idx] <== is_prefix_not_crossing[i][j][k][l].out; | ||
idx++; | ||
} | ||
} | ||
} | ||
} | ||
|
||
out <== are_all_not_crossing.out; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
include "words.circom" | ||
include "lines.circom" | ||
|
||
template Main(LINE_SIZE, DICTIONARY_SIZE, WORD_SIZE, FIG_SIZE, SIDE_SIZE) { | ||
signal private input line[LINE_SIZE][WORD_SIZE]; | ||
signal input figure[FIG_SIZE][SIDE_SIZE]; | ||
signal input dictionary[DICTIONARY_SIZE][WORD_SIZE]; | ||
|
||
component is_padding[LINE_SIZE]; | ||
for (var i = 0;i < LINE_SIZE;i++) is_padding[i] = IsPadding(); | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
is_padding[i].first_char <== line[i][0]; | ||
} | ||
|
||
component validator[LINE_SIZE]; | ||
component validator_or_padding[LINE_SIZE]; | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
validator[i] = IsWordValid(WORD_SIZE); | ||
validator_or_padding[i] = OR(); | ||
} | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
for (var j = 0;j < WORD_SIZE;j++) validator[i].word[j] <== line[i][j]; | ||
validator_or_padding[i].a <== validator[i].out; | ||
validator_or_padding[i].b <== is_padding[i].out; | ||
validator_or_padding[i].out === 1; | ||
} | ||
|
||
component checker[LINE_SIZE]; | ||
component checker_or_padding[LINE_SIZE]; | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
checker[i] = InDictionary(DICTIONARY_SIZE, WORD_SIZE); | ||
checker_or_padding[i] = OR(); | ||
} | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
for (var j = 0;j < DICTIONARY_SIZE;j++) { | ||
for (var k = 0;k < WORD_SIZE;k++) { | ||
checker[i].dictionary[j][k] <== dictionary[j][k]; | ||
} | ||
} | ||
|
||
for (var j = 0;j < WORD_SIZE;j++) { | ||
checker[i].word[j] <== line[i][j]; | ||
} | ||
checker_or_padding[i].a <== checker[i].out; | ||
checker_or_padding[i].b <== is_padding[i].out; | ||
checker_or_padding[i].out === 1; | ||
} | ||
|
||
component continuity = IsContinual(LINE_SIZE, WORD_SIZE); | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
continuity.padding[i] <== is_padding[i].out; | ||
for (var j = 0;j < WORD_SIZE;j++) continuity.words[i][j] <== line[i][j]; | ||
} | ||
continuity.out === 1; | ||
|
||
component crossing[LINE_SIZE]; | ||
component crossing_or_padding[LINE_SIZE]; | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
crossing[i] = IsNotCrossing(WORD_SIZE, FIG_SIZE, SIDE_SIZE); | ||
crossing_or_padding[i] = OR(); | ||
} | ||
for (var i = 0;i < LINE_SIZE;i++) { | ||
for (var j = 0;j < WORD_SIZE;j++) crossing[i].word[j] <== line[i][j]; | ||
for (var j = 0;j < FIG_SIZE;j++) { | ||
for (var k = 0;k < SIDE_SIZE;k++) crossing[i].figure[j][k] <== figure[j][k]; | ||
} | ||
crossing_or_padding[i].a <== crossing[i].out; | ||
crossing_or_padding[i].b <== is_padding[i].out; | ||
crossing_or_padding[i].out === 1; | ||
} | ||
} | ||
|
||
component main = Main(3, 3, 3, 3, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"line": [[2, 0, 1], [1, 0, 2], [28, 28, 28]], | ||
"figure": [[0, 3], [1, 4], [2, 5]], | ||
"dictionary": [[2, 0, 1], [0, 1, 27], [1, 0, 2]] | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
{ | ||
"protocol": "groth16", | ||
"curve": "bn128", | ||
"nPublic": 15, | ||
"vk_alpha_1": [ | ||
"19642524115522290447760970021746675789341356000653265441069630957431566301675", | ||
"15809037446102219312954435152879098683824559980020626143453387822004586242317", | ||
"1" | ||
], | ||
"vk_beta_2": [ | ||
[ | ||
"3306678135584565297353192801602995509515651571902196852074598261262327790404", | ||
"6402738102853475583969787773506197858266321704623454181848954418090577674938" | ||
], | ||
[ | ||
"4983765881427969364617654516554524254158908221590807345159959200407712579883", | ||
"15158588411628049902562758796812667714664232742372443470614751812018801551665" | ||
], | ||
[ | ||
"1", | ||
"0" | ||
] | ||
], | ||
"vk_gamma_2": [ | ||
[ | ||
"10857046999023057135944570762232829481370756359578518086990519993285655852781", | ||
"11559732032986387107991004021392285783925812861821192530917403151452391805634" | ||
], | ||
[ | ||
"8495653923123431417604973247489272438418190587263600148770280649306958101930", | ||
"4082367875863433681332203403145435568316851327593401208105741076214120093531" | ||
], | ||
[ | ||
"1", | ||
"0" | ||
] | ||
], | ||
"vk_delta_2": [ | ||
[ | ||
"2331074035208661256364667123862169704061449951851910379325063964198285430221", | ||
"21173502052847522712343920695345049565520895905384250222105697507142194555901" | ||
], | ||
[ | ||
"961901284356507153388088069199380552581103880001797976871193700998289486054", | ||
"1921085277078744684511176971830319952173319902281081603728474458216922605612" | ||
], | ||
[ | ||
"1", | ||
"0" | ||
] | ||
], | ||
"vk_alphabeta_12": [ | ||
[ | ||
[ | ||
"5990981426838611487817331801723298853689232371402636505882752025826717861263", | ||
"6471600557194756298005957410208198947034348214534657394165503369790309076215" | ||
], | ||
[ | ||
"15002700749801870140343913307313851505416165248926784119266834715141460279528", | ||
"3830910611342760800353177932876565223705290639657811356514431363408808083245" | ||
], | ||
[ | ||
"16213272029928492311641815345584648151738099578429924053941653329679116056011", | ||
"11521059852145391195901894023171250860281638548552692281491114389569775909273" | ||
] | ||
], | ||
[ | ||
[ | ||
"21473208233673181545713372461262158409524966660539444635240255266528451743613", | ||
"12831374732506919217314780439582796881729424911714976211545279975915712437524" | ||
], | ||
[ | ||
"6384272187442204077342066657702496903903539015888454871400719146512483196930", | ||
"11896033867460826226898768849934024947887432723445089197160889467704536005586" | ||
], | ||
[ | ||
"4320872437228236846208766625647342285071164667482133950438695528545836489222", | ||
"13210525034366360416090582915961576197528924758377030567364985602065069567971" | ||
] | ||
] | ||
], | ||
"IC": [ | ||
[ | ||
"19910717608385345465430661353282864116981870200851087108442418874855087497048", | ||
"16533848745494452079886979136687543106167068088067167223407894638313879091316", | ||
"1" | ||
], | ||
[ | ||
"9347996344770043421381582116485449157855067008678942220301112616008433906116", | ||
"7235757877566316073124305233607429794225405882236709177392558334962826246138", | ||
"1" | ||
], | ||
[ | ||
"16681998564578125529513133710943189749479768270183328224283744340647184222866", | ||
"268201434265411205353592549872369012988544481543016169300950143882665051491", | ||
"1" | ||
], | ||
[ | ||
"12093265466198281051623096377915432695009618528877946688917401588302332112742", | ||
"3078250256379617795248747533145051001874145372955589495955378029067548724161", | ||
"1" | ||
], | ||
[ | ||
"12833325526124733994458283928774090692111268037307718367681869903976258186442", | ||
"10683924955014883439648076983571910056680985251661751228427727614886618975835", | ||
"1" | ||
], | ||
[ | ||
"5548070349320240153536699701618144617568137900701696250761645495746201981031", | ||
"931261795071260092048680303130005618770394492878617090976618161030097479456", | ||
"1" | ||
], | ||
[ | ||
"6520463894150788678833188706662093953601387882948442361782718117245903856239", | ||
"21380314642166759121739729939122834340641675704116046463819925127938214950704", | ||
"1" | ||
], | ||
[ | ||
"10201339127814082932392746100628266555549269993890956459543320176450866920201", | ||
"8506179958440543054864882311968160396010225192817615875278690611745415747562", | ||
"1" | ||
], | ||
[ | ||
"11295379328066808656424333560885901672867983036887242166121297783528194770743", | ||
"10257203891289491544888125058924265483943894267544592701612690763485490848596", | ||
"1" | ||
], | ||
[ | ||
"17641972776957804918441234486884560391790792695884616119063603043573693483071", | ||
"6563396283433964855714399947091336283190067705234290643506191708260841768695", | ||
"1" | ||
], | ||
[ | ||
"9498960656487376092417608574752517436459905527198604401160649657591559450001", | ||
"7469816278187034089365792211806139775024764828402969236006708827429185425386", | ||
"1" | ||
], | ||
[ | ||
"14017251591825307453316717929054570769715008173038687761298634619596314582137", | ||
"10104992616086628997460488522675044845033616839310485410435299308460160327229", | ||
"1" | ||
], | ||
[ | ||
"10579315958043019667105406610244435479851875543280379764556184507071644748607", | ||
"8542670399844720266322018591174317638155423364934146346006594984623224898170", | ||
"1" | ||
], | ||
[ | ||
"21722871621653548694873470273878928072849964405302801495582788024070361320508", | ||
"1986534423245344230587245766166848641937320243068890151414904658046554972624", | ||
"1" | ||
], | ||
[ | ||
"5601814714628163578642053629943827841673371139984637216877169507860146212712", | ||
"18647309436110419983621565828526279735685331026135485726772204511589265498721", | ||
"1" | ||
], | ||
[ | ||
"11068937107696178322403078620597678272491630546671587073598578854181691035401", | ||
"3319868391847813685630487368133268027080915108626226931508605131400199249", | ||
"1" | ||
] | ||
] | ||
} |
Oops, something went wrong.