From 286050a568303f34ad0cb1c878383a7abc50b7e6 Mon Sep 17 00:00:00 2001 From: NContinanza Date: Tue, 19 Jul 2022 18:01:53 -0300 Subject: [PATCH] Not-yet-functional implementation of array sum --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + circuits/array_add/.gitignore | 1 + circuits/array_add/README.md | 8 + .../array_add/auxiliary_code_generator.py | 22 + circuits/array_add/main.aleo | 515 ++++++++++++++++++ circuits/array_add/program.json | 10 + 7 files changed, 557 insertions(+) delete mode 100644 .DS_Store create mode 100644 circuits/array_add/.gitignore create mode 100644 circuits/array_add/README.md create mode 100644 circuits/array_add/auxiliary_code_generator.py create mode 100644 circuits/array_add/main.aleo create mode 100644 circuits/array_add/program.json diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 844608bb2f094b26e6ef94b829ecacb4b9f4fb02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK&2G~`5S~p^x(-6*fJ8YU`NA!VY9yj?KyuUM5Q!p$5gY)uc5R4-Ye%s|3L(gM z-T)qg_u!6r7EbW(52$wO5k%2WwENA@&djdAjd#67#DL^>me0mHz*&VYD#o8;4s;z?3@e|ON+`z}R31gAraX^wgUEGVz} zf2#R!&~tcalu}XkWY^F343_y!?;)RqSrX^P_V!oSXtp*kY;xY_?Mv-v-ZWc!gJ%l*!k-7GEqIF05qI1VGYJbfIeVYVD*i!{t-9#3^} zZgFeBb8WS9`h!8&zBO2P?Um#7ovz)#eRI9G_|+TEoyoz`>o=>n>vta{Kg6&HO1Z4@ zCwzo*f{j<+JWaCn1*{@slkU=lc4m@~CH>QN5n*X<&zeNv_ zd51={2kg-ih1H0Ln8(QxEXrw${0V+NtX@pVwTLgZ2sDkHLk9H!m0vuEb2n2q3>XIf zECXVHuu%lM8cT(8>p&&10KgW^QlQI^f1oW4Kv!d_5Eckip+FVN^c92Yy8~0<=y$b$ zsZfOzlOrRK9+~MI3e#5)W=nTsu0m5A1`GpL2AZnb5$FH-?E8N;$g~UthJpWz0oEFM zqahwipRK1JPMozi$^nWH;a4h@A*l3mEERDSZ=py*pDh%itFcrF3&eZ~NE%FK82GCU F`~boXs2l(Q diff --git a/.gitignore b/.gitignore index 039ee27..fb66a89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .elixir_ls .vscode +.DS_Store diff --git a/circuits/array_add/.gitignore b/circuits/array_add/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/circuits/array_add/.gitignore @@ -0,0 +1 @@ +build diff --git a/circuits/array_add/README.md b/circuits/array_add/README.md new file mode 100644 index 0000000..6d86b3d --- /dev/null +++ b/circuits/array_add/README.md @@ -0,0 +1,8 @@ +# array_sum.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +aleo build +``` diff --git a/circuits/array_add/auxiliary_code_generator.py b/circuits/array_add/auxiliary_code_generator.py new file mode 100644 index 0000000..48e13b2 --- /dev/null +++ b/circuits/array_add/auxiliary_code_generator.py @@ -0,0 +1,22 @@ +# Here the output is: +# input r0 as field; +# input r1 as field; +# ... +# input r253 as field; +for i in range(254): + print("\tinput r{} as field.public;".format(i)) + +# Here the output is: +# add r0 r1 into r254; +# add r254 r2 into r255; +# ... +# add r0.a253 r252 into r253; +print("\n\tadd r0 r1 into r254;") +for i in range(254, 507): + print("\tadd r{} r{} into r{};".format(i, i-253, i+1)) +print("\n\toutput r507 as field.public;") + +# The command for running a simple test: +print("aleo run hash_array_add ", end='') +for i in range(254): + print("{}field ".format(i), end='') diff --git a/circuits/array_add/main.aleo b/circuits/array_add/main.aleo new file mode 100644 index 0000000..95e96ea --- /dev/null +++ b/circuits/array_add/main.aleo @@ -0,0 +1,515 @@ +// The 'array_add.aleo' program. +program array_add.aleo; + +function hash_array_add: + input r0 as field.public; + input r1 as field.public; + input r2 as field.public; + input r3 as field.public; + input r4 as field.public; + input r5 as field.public; + input r6 as field.public; + input r7 as field.public; + input r8 as field.public; + input r9 as field.public; + input r10 as field.public; + input r11 as field.public; + input r12 as field.public; + input r13 as field.public; + input r14 as field.public; + input r15 as field.public; + input r16 as field.public; + input r17 as field.public; + input r18 as field.public; + input r19 as field.public; + input r20 as field.public; + input r21 as field.public; + input r22 as field.public; + input r23 as field.public; + input r24 as field.public; + input r25 as field.public; + input r26 as field.public; + input r27 as field.public; + input r28 as field.public; + input r29 as field.public; + input r30 as field.public; + input r31 as field.public; + input r32 as field.public; + input r33 as field.public; + input r34 as field.public; + input r35 as field.public; + input r36 as field.public; + input r37 as field.public; + input r38 as field.public; + input r39 as field.public; + input r40 as field.public; + input r41 as field.public; + input r42 as field.public; + input r43 as field.public; + input r44 as field.public; + input r45 as field.public; + input r46 as field.public; + input r47 as field.public; + input r48 as field.public; + input r49 as field.public; + input r50 as field.public; + input r51 as field.public; + input r52 as field.public; + input r53 as field.public; + input r54 as field.public; + input r55 as field.public; + input r56 as field.public; + input r57 as field.public; + input r58 as field.public; + input r59 as field.public; + input r60 as field.public; + input r61 as field.public; + input r62 as field.public; + input r63 as field.public; + input r64 as field.public; + input r65 as field.public; + input r66 as field.public; + input r67 as field.public; + input r68 as field.public; + input r69 as field.public; + input r70 as field.public; + input r71 as field.public; + input r72 as field.public; + input r73 as field.public; + input r74 as field.public; + input r75 as field.public; + input r76 as field.public; + input r77 as field.public; + input r78 as field.public; + input r79 as field.public; + input r80 as field.public; + input r81 as field.public; + input r82 as field.public; + input r83 as field.public; + input r84 as field.public; + input r85 as field.public; + input r86 as field.public; + input r87 as field.public; + input r88 as field.public; + input r89 as field.public; + input r90 as field.public; + input r91 as field.public; + input r92 as field.public; + input r93 as field.public; + input r94 as field.public; + input r95 as field.public; + input r96 as field.public; + input r97 as field.public; + input r98 as field.public; + input r99 as field.public; + input r100 as field.public; + input r101 as field.public; + input r102 as field.public; + input r103 as field.public; + input r104 as field.public; + input r105 as field.public; + input r106 as field.public; + input r107 as field.public; + input r108 as field.public; + input r109 as field.public; + input r110 as field.public; + input r111 as field.public; + input r112 as field.public; + input r113 as field.public; + input r114 as field.public; + input r115 as field.public; + input r116 as field.public; + input r117 as field.public; + input r118 as field.public; + input r119 as field.public; + input r120 as field.public; + input r121 as field.public; + input r122 as field.public; + input r123 as field.public; + input r124 as field.public; + input r125 as field.public; + input r126 as field.public; + input r127 as field.public; + input r128 as field.public; + input r129 as field.public; + input r130 as field.public; + input r131 as field.public; + input r132 as field.public; + input r133 as field.public; + input r134 as field.public; + input r135 as field.public; + input r136 as field.public; + input r137 as field.public; + input r138 as field.public; + input r139 as field.public; + input r140 as field.public; + input r141 as field.public; + input r142 as field.public; + input r143 as field.public; + input r144 as field.public; + input r145 as field.public; + input r146 as field.public; + input r147 as field.public; + input r148 as field.public; + input r149 as field.public; + input r150 as field.public; + input r151 as field.public; + input r152 as field.public; + input r153 as field.public; + input r154 as field.public; + input r155 as field.public; + input r156 as field.public; + input r157 as field.public; + input r158 as field.public; + input r159 as field.public; + input r160 as field.public; + input r161 as field.public; + input r162 as field.public; + input r163 as field.public; + input r164 as field.public; + input r165 as field.public; + input r166 as field.public; + input r167 as field.public; + input r168 as field.public; + input r169 as field.public; + input r170 as field.public; + input r171 as field.public; + input r172 as field.public; + input r173 as field.public; + input r174 as field.public; + input r175 as field.public; + input r176 as field.public; + input r177 as field.public; + input r178 as field.public; + input r179 as field.public; + input r180 as field.public; + input r181 as field.public; + input r182 as field.public; + input r183 as field.public; + input r184 as field.public; + input r185 as field.public; + input r186 as field.public; + input r187 as field.public; + input r188 as field.public; + input r189 as field.public; + input r190 as field.public; + input r191 as field.public; + input r192 as field.public; + input r193 as field.public; + input r194 as field.public; + input r195 as field.public; + input r196 as field.public; + input r197 as field.public; + input r198 as field.public; + input r199 as field.public; + input r200 as field.public; + input r201 as field.public; + input r202 as field.public; + input r203 as field.public; + input r204 as field.public; + input r205 as field.public; + input r206 as field.public; + input r207 as field.public; + input r208 as field.public; + input r209 as field.public; + input r210 as field.public; + input r211 as field.public; + input r212 as field.public; + input r213 as field.public; + input r214 as field.public; + input r215 as field.public; + input r216 as field.public; + input r217 as field.public; + input r218 as field.public; + input r219 as field.public; + input r220 as field.public; + input r221 as field.public; + input r222 as field.public; + input r223 as field.public; + input r224 as field.public; + input r225 as field.public; + input r226 as field.public; + input r227 as field.public; + input r228 as field.public; + input r229 as field.public; + input r230 as field.public; + input r231 as field.public; + input r232 as field.public; + input r233 as field.public; + input r234 as field.public; + input r235 as field.public; + input r236 as field.public; + input r237 as field.public; + input r238 as field.public; + input r239 as field.public; + input r240 as field.public; + input r241 as field.public; + input r242 as field.public; + input r243 as field.public; + input r244 as field.public; + input r245 as field.public; + input r246 as field.public; + input r247 as field.public; + input r248 as field.public; + input r249 as field.public; + input r250 as field.public; + input r251 as field.public; + input r252 as field.public; + input r253 as field.public; + + add r0 r1 into r254; + add r254 r1 into r255; + add r255 r2 into r256; + add r256 r3 into r257; + add r257 r4 into r258; + add r258 r5 into r259; + add r259 r6 into r260; + add r260 r7 into r261; + add r261 r8 into r262; + add r262 r9 into r263; + add r263 r10 into r264; + add r264 r11 into r265; + add r265 r12 into r266; + add r266 r13 into r267; + add r267 r14 into r268; + add r268 r15 into r269; + add r269 r16 into r270; + add r270 r17 into r271; + add r271 r18 into r272; + add r272 r19 into r273; + add r273 r20 into r274; + add r274 r21 into r275; + add r275 r22 into r276; + add r276 r23 into r277; + add r277 r24 into r278; + add r278 r25 into r279; + add r279 r26 into r280; + add r280 r27 into r281; + add r281 r28 into r282; + add r282 r29 into r283; + add r283 r30 into r284; + add r284 r31 into r285; + add r285 r32 into r286; + add r286 r33 into r287; + add r287 r34 into r288; + add r288 r35 into r289; + add r289 r36 into r290; + add r290 r37 into r291; + add r291 r38 into r292; + add r292 r39 into r293; + add r293 r40 into r294; + add r294 r41 into r295; + add r295 r42 into r296; + add r296 r43 into r297; + add r297 r44 into r298; + add r298 r45 into r299; + add r299 r46 into r300; + add r300 r47 into r301; + add r301 r48 into r302; + add r302 r49 into r303; + add r303 r50 into r304; + add r304 r51 into r305; + add r305 r52 into r306; + add r306 r53 into r307; + add r307 r54 into r308; + add r308 r55 into r309; + add r309 r56 into r310; + add r310 r57 into r311; + add r311 r58 into r312; + add r312 r59 into r313; + add r313 r60 into r314; + add r314 r61 into r315; + add r315 r62 into r316; + add r316 r63 into r317; + add r317 r64 into r318; + add r318 r65 into r319; + add r319 r66 into r320; + add r320 r67 into r321; + add r321 r68 into r322; + add r322 r69 into r323; + add r323 r70 into r324; + add r324 r71 into r325; + add r325 r72 into r326; + add r326 r73 into r327; + add r327 r74 into r328; + add r328 r75 into r329; + add r329 r76 into r330; + add r330 r77 into r331; + add r331 r78 into r332; + add r332 r79 into r333; + add r333 r80 into r334; + add r334 r81 into r335; + add r335 r82 into r336; + add r336 r83 into r337; + add r337 r84 into r338; + add r338 r85 into r339; + add r339 r86 into r340; + add r340 r87 into r341; + add r341 r88 into r342; + add r342 r89 into r343; + add r343 r90 into r344; + add r344 r91 into r345; + add r345 r92 into r346; + add r346 r93 into r347; + add r347 r94 into r348; + add r348 r95 into r349; + add r349 r96 into r350; + add r350 r97 into r351; + add r351 r98 into r352; + add r352 r99 into r353; + add r353 r100 into r354; + add r354 r101 into r355; + add r355 r102 into r356; + add r356 r103 into r357; + add r357 r104 into r358; + add r358 r105 into r359; + add r359 r106 into r360; + add r360 r107 into r361; + add r361 r108 into r362; + add r362 r109 into r363; + add r363 r110 into r364; + add r364 r111 into r365; + add r365 r112 into r366; + add r366 r113 into r367; + add r367 r114 into r368; + add r368 r115 into r369; + add r369 r116 into r370; + add r370 r117 into r371; + add r371 r118 into r372; + add r372 r119 into r373; + add r373 r120 into r374; + add r374 r121 into r375; + add r375 r122 into r376; + add r376 r123 into r377; + add r377 r124 into r378; + add r378 r125 into r379; + add r379 r126 into r380; + add r380 r127 into r381; + add r381 r128 into r382; + add r382 r129 into r383; + add r383 r130 into r384; + add r384 r131 into r385; + add r385 r132 into r386; + add r386 r133 into r387; + add r387 r134 into r388; + add r388 r135 into r389; + add r389 r136 into r390; + add r390 r137 into r391; + add r391 r138 into r392; + add r392 r139 into r393; + add r393 r140 into r394; + add r394 r141 into r395; + add r395 r142 into r396; + add r396 r143 into r397; + add r397 r144 into r398; + add r398 r145 into r399; + add r399 r146 into r400; + add r400 r147 into r401; + add r401 r148 into r402; + add r402 r149 into r403; + add r403 r150 into r404; + add r404 r151 into r405; + add r405 r152 into r406; + add r406 r153 into r407; + add r407 r154 into r408; + add r408 r155 into r409; + add r409 r156 into r410; + add r410 r157 into r411; + add r411 r158 into r412; + add r412 r159 into r413; + add r413 r160 into r414; + add r414 r161 into r415; + add r415 r162 into r416; + add r416 r163 into r417; + add r417 r164 into r418; + add r418 r165 into r419; + add r419 r166 into r420; + add r420 r167 into r421; + add r421 r168 into r422; + add r422 r169 into r423; + add r423 r170 into r424; + add r424 r171 into r425; + add r425 r172 into r426; + add r426 r173 into r427; + add r427 r174 into r428; + add r428 r175 into r429; + add r429 r176 into r430; + add r430 r177 into r431; + add r431 r178 into r432; + add r432 r179 into r433; + add r433 r180 into r434; + add r434 r181 into r435; + add r435 r182 into r436; + add r436 r183 into r437; + add r437 r184 into r438; + add r438 r185 into r439; + add r439 r186 into r440; + add r440 r187 into r441; + add r441 r188 into r442; + add r442 r189 into r443; + add r443 r190 into r444; + add r444 r191 into r445; + add r445 r192 into r446; + add r446 r193 into r447; + add r447 r194 into r448; + add r448 r195 into r449; + add r449 r196 into r450; + add r450 r197 into r451; + add r451 r198 into r452; + add r452 r199 into r453; + add r453 r200 into r454; + add r454 r201 into r455; + add r455 r202 into r456; + add r456 r203 into r457; + add r457 r204 into r458; + add r458 r205 into r459; + add r459 r206 into r460; + add r460 r207 into r461; + add r461 r208 into r462; + add r462 r209 into r463; + add r463 r210 into r464; + add r464 r211 into r465; + add r465 r212 into r466; + add r466 r213 into r467; + add r467 r214 into r468; + add r468 r215 into r469; + add r469 r216 into r470; + add r470 r217 into r471; + add r471 r218 into r472; + add r472 r219 into r473; + add r473 r220 into r474; + add r474 r221 into r475; + add r475 r222 into r476; + add r476 r223 into r477; + add r477 r224 into r478; + add r478 r225 into r479; + add r479 r226 into r480; + add r480 r227 into r481; + add r481 r228 into r482; + add r482 r229 into r483; + add r483 r230 into r484; + add r484 r231 into r485; + add r485 r232 into r486; + add r486 r233 into r487; + add r487 r234 into r488; + add r488 r235 into r489; + add r489 r236 into r490; + add r490 r237 into r491; + add r491 r238 into r492; + add r492 r239 into r493; + add r493 r240 into r494; + add r494 r241 into r495; + add r495 r242 into r496; + add r496 r243 into r497; + add r497 r244 into r498; + add r498 r245 into r499; + add r499 r246 into r500; + add r500 r247 into r501; + add r501 r248 into r502; + add r502 r249 into r503; + add r503 r250 into r504; + add r504 r251 into r505; + add r505 r252 into r506; + add r506 r253 into r507; + + output r507 as field.public; diff --git a/circuits/array_add/program.json b/circuits/array_add/program.json new file mode 100644 index 0000000..9ed70e5 --- /dev/null +++ b/circuits/array_add/program.json @@ -0,0 +1,10 @@ +{ + "program": "array_add.aleo", + "version": "0.0.0", + "description": "", + "development": { + "private_key": "APrivateKey1zkpBK913EGiBfwHAB3pmsiuaSECuxeuhDjp1MWvSvNdWDSG", + "address": "aleo1p38ru20e93tjjed5sd9r5zz8svzg8t0658cfzc9zhqau2z0rlgrshaf65c" + }, + "license": "MIT" +}