profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/defuse/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Taylor Hornby defuse Electric Coin Company Calgary, Canada https://defuse.ca/

defuse/crackstation-hashdb 250

CrackStation.net's Lookup Table Implementation.

defuse/crackstation 85

Source code for my crackstation.net website.

defuse/defuse.ca 44

The source code to my defuse.ca website.

defuse/email-spoofing 34

Ruby script for spoofing SMTP emails.

defuse/dnsfs 33

Host files with DNS

defuse/airgap 26

Design for an economical and simple air-gapped system.

defuse/gas-obfuscation 23

Extremely simple but inefficient x86-64 assembly obfuscation.

defuse/DAWr 17

The start of a library for building a DAW and/or sound experiments in Rust

defuse/encutil 17

Example of how to build a command-line file encryption utility with defuse/php-encryption.

starteddefuse/sockstress

started time in 5 hours

delete branch zcash-hackworks/zcash-test-vectors

delete branch : poseidon

delete time in 6 hours

push eventzcash-hackworks/zcash-test-vectors

therealyingtong

commit sha 48fca9ad62b1d98a5d3fda6593a05a1d14b70bfb

Add Poseidon implementation

view details

therealyingtong

commit sha 99feaed0f41818eac33bee655bd5f85b29280266

Render array of bytearrays in tv_output

view details

therealyingtong

commit sha 6184981ccd34242c092726f7379e048ed5d0ba08

Generate Poseidon perm test vectors

view details

therealyingtong

commit sha 25f5ccd445bea87d896b078f32d3eeee5026a402

Generate Poseidon hash test vectors

view details

ying tong

commit sha bb16eca2c0acbbd1e744339ae1c8c4ed30f4c472

Only return first state element from Poseidon hash Co-authored-by: str4d <jack@z.cash>

view details

str4d

commit sha cb9348e7a9c6256cd315c979b071f1782740de9c

Apply suggestions from code review

view details

str4d

commit sha deee2464202fbdcf2a4209327d91505fe4fe803d

Add numpy dependency to README

view details

str4d

commit sha 03157edaf2b749fe1762c7618a3a786e32712261

Merge pull request #27 from zcash-hackworks/poseidon Poseidon implementation

view details

push time in 6 hours

PR merged zcash-hackworks/zcash-test-vectors

Poseidon implementation

Closes #22.

Uses test vectors from https://github.com/daira/pasta-hadeshash/commit/cdab5252d0ec675780e9f8c3d09fdb7a0a71d3ff.

+396 -3

0 comment

4 changed files

therealyingtong

pr closed time in 6 hours

push eventzcash-hackworks/zcash-test-vectors

str4d

commit sha deee2464202fbdcf2a4209327d91505fe4fe803d

Add numpy dependency to README

view details

push time in 6 hours

push eventzcash-hackworks/zcash-test-vectors

str4d

commit sha cb9348e7a9c6256cd315c979b071f1782740de9c

Apply suggestions from code review

view details

push time in 6 hours

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+import numpy as np+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Number of full rounds+R_F = 8+# Number of partial rounds+R_P = 58+# Width+t = 3++def perm(input_words):+    R_f = int(R_F / 2)++    round_constants_counter = 0++    state_words = list(input_words)+    assert len(state_words) == t++    # First full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Middle partial rounds+    for r in range(0, R_P):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        state_words[0] = (state_words[0]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Last full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))+    +    return state_words++# Round constants generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+ROUND_CONSTANTS = [+    Fp(0x2f2c2bfbd7070f5321f103387216cb9137df4021c68b5eef61904c0511b737a4),+    Fp(0x04ec2fc5c55d67746ccdd22b2bbdead13645b63b123b613afb311b7d0f35b058),+    Fp(0x3c624cfc4c994eb2fa9b924125223a7163e46dfb62f3522b6771be5f74ecb0b6),+    Fp(0x3476744a626a1813dd9b91a3d9031e29ccecd6c12a34927a5a936dc45b059511),+    Fp(0x3e8e3c1b8e9f1e1809d3b2dc9dc078894e4c8c3fdf34ea1a033e60bd7a63cf16),+    Fp(0x1439f41af8953e20247a437c362bba132af9c485bc73d98a4be1bb1b9efd907c),+    Fp(0x2184e123d6f4e5e9fea44f9f1ee27531af57eb3128f8662193ac3d2ca4ac6c7a),+    Fp(0x331019b909d6c87d8cc034f568aedbe1f8e05b9293c9b396a3eda4c816729416),+    Fp(0x00078b16de3fa3a0c6ec9cff8656ad7ed1eba2586b779d45a53f26c9a84fa24e),+    Fp(0x394f742117539cad1d44ff024f9f4e7a85782423cf7fd1305bc1b2926f39601e),+    Fp(0x261e237d617e261a6e65df293f2725e00311e30e0ba5c3008ed576fd4d43d779),+    Fp(0x252d1389b3aefdd233dccb6f7c448319857d2f7b4075d28b4513b401f48a3668),+    Fp(0x025ca9dda3db70df67bf7e430350923d38d635392451923af69df9e788a5fe24),+    Fp(0x1d2c2ace140ad5b617e517edd753f0b18d152f5c95421ab6c18c127223501f93),+    Fp(0x0ba495c1f7b77dbf654c7abd86a684434079eb21f42e4af06768c8403f50ac2c),+    Fp(0x2cbce44950324cba5bb2f8664192273205f15752efc3ebe1d8af60702eef9e28),+    Fp(0x24767e0d3abf426d95e4242db16d3a33fe5e302a8a71c31c671afb22aeae9d14),+    Fp(0x1acd6ef0e60e4b14146d53fcc83aea81b8a971e0ba9daab50d928670de2a3031),+    Fp(0x340f94d400bd0a3119942055672d627da17e77a8a72e7eedcc1c86114da6a1eb),+    Fp(0x0327373cca3dd2f8d60711e33e0c6b82472c8da29209c94dd51e2326061e22c0),+    Fp(0x1d1041d82c9d480f17c2d6ae049061e939ee18190c5c20805fdb2ffcf0161350),+    Fp(0x0de4750f968b5257895e8c73611059f8b7d135501d3d911f51bc31436ab5a574),+    Fp(0x359290a3786196bbc7fc9a99c916ccba11454b0cd0eb7d3fb2414383ee1a5794),+    Fp(0x28ffcdddf417cbabba580e1453f3094ddd4460b67aef036418c20b5cec2e8036),+    Fp(0x0e76c3df688ed3f5de99a4e4dcc1308486010174246d3c89322d2c6afaab6a00),+    Fp(0x172ca76af974367abde18a6b3a19c2ef7c42ac6e80e97c5b78922912d57f57c7),+    Fp(0x12ed4668b1543521662601e168f1a7aa8951a8407b00fd3f9b64fa4dc692195f),+    Fp(0x0c2ea06a9894cea56fd7211f8354d5092f614f7bcf8232ef90f2a829e538d398),+    Fp(0x0faea60318136b64e54759689b038ae3b55d8ea1305494517c7fea109bb09622),+    Fp(0x1beaeb465cd4c711b93eebf4dd9a414f1e7b90098c78a371287bfe86a1e66b27),+    Fp(0x351c94b9bcca5b1a2c2b06ede8114d463b6f7bdd6b37dd97a81add76cd42a4e3),+    Fp(0x2a1838fac1749e4fe68f84dcf259a459bb6ed62b92328294dcfc4ebaa75a4d92),+    Fp(0x3f875c2cd7e1d69ea4f88c06ea9c2ab893418cf02a66ea98cd230bfae2f670fb),+    Fp(0x31224a3412529b86145fe811a3fc44860ddd35b287fdc7986ce237b7c99f07a1),+    Fp(0x1556b2b9633ae623b42a1119bfbae23e0d6ee24b4e39c55c615b6db29fd9314e),+    Fp(0x399bacd8f54ccc4d1ce8ca1c71e5fb346aff3ab03e93551975225cd9ed99f2c2),+    Fp(0x389877368a5c321ea02d7dabc1444ad131c43e3ad4d20ebaf2f0997bbbaf80e3),+    Fp(0x0ef32660742991bbc6d17e9a4132067f6f78fa39361a74ccaebc66a50a73b506),+    Fp(0x1e491a5fdda824e26eb3d15a465c9221fb7a99f01266cbe86d97adb2c1139c94),+    Fp(0x2de4d6ff6ff2634b6ae7ab72cc34eb48c6ad0f62f31397e8a07d60fafe7f0aa7),+    Fp(0x1283a38005b8f0a7f2a5b56138dd2a5bbf319eac78d2c93506dbddfcdba52766),+    Fp(0x19e2efea5020aa4be092ca71681d8050b3c91a960025c6acdf23b7b398f061b6),+    Fp(0x287fb567ece35108f55719af51c11b6b610968a14a94ce030b7f48248fec885d),+    Fp(0x2761ea586e5d500d5202d4483f10d32a587f25e1e974432d59800355f507bb83),+    Fp(0x2f77d7a4f74db35eaf18b1bd8786f740f85d793979ae02c46d529cb31dff100e),+    Fp(0x0390862d7e6e7a690d4a5e120b9dc8f13200eb324f5d7c33d34b68245ebf1dc2),+    Fp(0x14d5b21da4b45c808c2a51c11a9cc97fd5196ea5d70bbdb6352e4174565c5a52),+    Fp(0x2974ad78ec5d90fbd088112a178403a1acb796e31fc8737f3f8566c9d7d1e755),+    Fp(0x36b58f7052adcc1fa3a1c290f0b04b7a28b413c7a3bb7e68ffb53b785334ee3c),+    Fp(0x2efb0a9efd6c60a1aeb870093f64363919c4993eb1fd95ae97159cc8a97339c2),+    Fp(0x1f04ae7df249c70c3f19a23c72a2a102d1528ff7aa4bb02229b61e805c98c1ff),+    Fp(0x278d44fe8f8c299659642e54f819858991fd0d3b8c617d8a1363315c4d8e0cb0),+    Fp(0x1a2bbd022168061c49b45714ae1b0f6a6ded5b7f8cefc2a2e3344dc1c1592406),+    Fp(0x0f0de2f73193a97edf8a91de8e688793f93cb4ed2236639813ebf947a3559f9c),+    Fp(0x3ac47dc248f16ac55092c3d232a09399b76cd699d0b30adf0072ef68ea438f92),+    Fp(0x1f7f927daef5fc95f4a0c96759812f90002c2347a222043cb3c779653e34a054),+    Fp(0x250b4faf86d72618e6e3cd02b1adcb7c945c315ce93dfc00c0b179e1cc950b85),+    Fp(0x07c64646dee2604b62528967df12153f7288bcc4fab6750d65d20118981ade0e),+    Fp(0x24cbbd234c0ef70078fa143ca1158bbba05c8ca1dd7132efee93af96dbadff1d),+    Fp(0x208edf94ef339a27fdbbf3cc08b7adecc5362d39b6348ecc54bb4e6cf7fa521b),+    Fp(0x3ea2a73f40f1f3d20a589d3d2c4d14dbf45f11963d6c1806f96c7fd82a46da35),+    Fp(0x36ccb8567075d3a0771bb857f4c51f58e79cb26ff91b9be15973a73ea2752c7a),+    Fp(0x08654b649a5091baa9cdf91ce7f831473adc95de617cfa32fc8681d17000408c),+    Fp(0x2b58a76bcbfb8500f28b308ee52a8e0ea5fac865c5b6ee7da9898bed507f18ea),+    Fp(0x1001d34a284e2b254614b66105ccb699e2ed8f2533be8e737d15896225d59a2e),+    Fp(0x13375ab0b5350afb2f1e63d230afa70c2a61dece93b1651c9c4286cc6354bc9c),+    Fp(0x2a7169d46ff2ffbaec72491a04c64702ac5b9ccb5216abda5622b222a0f0aacb),+    Fp(0x033eb55bedfd6b29986094724c1852f651d214174045e6fc55eace8b62101ae0),+    Fp(0x10ca1ffa20260f4019e31226ee751c71795c7f74d5d1c53b5ec053879568fad1),+    Fp(0x06c1da78f2f5f0fde46172c42bbc83e3495d5082cf47489df1f0980430bd6854),+    Fp(0x1ae9bf0085d1a2b7fdd8999c542447243b4e83b509a3975cf74a4bab5a21c53f),+    Fp(0x368599e0cc709b2d07542c631e002e81d38be406010a91c1cbdbeb71eec5383c),+    Fp(0x02e79429cc4d4a362e02d60c365dcb49898f32679397244222788138e9584f32),+    Fp(0x18c541e9d2751b8000d3998ad9c220db4a4315eb87d99b67a0a82bd61d49d14d),+    Fp(0x197507d5e313e2e3b49b9fb54a89a586447443b5f9d9292b01c9bf579600678e),+    Fp(0x26b1bd92ee8931886696164e25e700926f470f7041be91abbffc4f5fddbdc07f),+    Fp(0x0efdb615f564ee4698d8f8f44deaed092681d0a23a4577724d8cad71a7e5fdbe),+    Fp(0x266a5dddc5f832887a71bdbe32594a48ac9f2bccf1fa8d4368144a5fc771da1c),+    Fp(0x34f356e3badb42d5e17d8e2df0917f29b575fb420a344f56b32a9caaf6168330),+    Fp(0x2fa9ad6f882f66ccddd716c5b3f04c48f138f015bc0d0d5a258b3a63f45ebcaf),+    Fp(0x210b633386cdd22784f4fc53939bed4d7350958aac95be44b2ab8c35890dcd99),+    Fp(0x34dc0f069165b00e4e80ab1639afaf610937f9d6cf91437dd6a56d62f6ad9eb3),+    Fp(0x259b4cb0b0861d0782d0614ae013d8c7913fa6f411c7dc733326b0455cf8778c),+    Fp(0x0f88d8b6c5d9073dc660788b3e78bd62315abaf489d41b29a7d0770ead395746),+    Fp(0x30abd11ecb73119f5baef3db5d9337853282e45af42d83c72084d439504c1fc6),+    Fp(0x3152ce325264529cf302af09d5baec045efc980abba7cc3363a18839c6f6446f),+    Fp(0x00bd3146554e552abe94978eddc451ede2954fc59859ff6c34f7c1613c270e35),+    Fp(0x2c1ef4c8ef911a32ee1cea96ee50922815a93afae282c149b7f24921d8d4a0fe),+    Fp(0x23869adb5876af5f29721a01deb5335bbdd8bc446d7bebcd32966e61c7ad12b3),+    Fp(0x2af88e261ca1217caccdf61ac128cb35f372cb64c6bed49de2ea4991a83e5559),+    Fp(0x1b5d76d6c03da588a257ecf10b3daaf6a40dcea8f7f097f180c9c434914cb08a),+    Fp(0x1c76daae2af0990fcfc6bd3d2f027c3afe599fc476202d0a37d08e8f023b6285),+    Fp(0x2f5893f6a6e2ef3d3bbb3577ca09d9f059e5b761f25218adb85ea92c8328797f),+    Fp(0x1a11a3dc16874116e894488c79ff537033278958606472301833029f73094c23),+    Fp(0x22b2a9a84c555a46ed9149261eac2db8cde06b75292c4777f7c9a6bd81c2000e),+    Fp(0x1f7201ee492876c172204d8f5e4ee22e6f6f98348d77c85b93398ca5a5e8bbaa),+    Fp(0x08e2edc6fbdc691f2512ee311910c8f8211eab318f4142dcf636c50cf6fdd861),+    Fp(0x173726c1c53a38abb250c6578359c6a4df0a181b9932230703df22f761e06616),+    Fp(0x2ffe9110497cdee27d1ed33019291435729a8410c1e2548989580351e3878456),+    Fp(0x02f1f99037148d41dad15fb86a6279d9e4fd5bd65a738f7f8de1001ed1cc4478),+    Fp(0x0a2c4dbf4da2980ef04af6cfb2e6f0a897d0126dc4eb15da86b3f413408e73c7),+    Fp(0x2970b9d63a8db9247913597bd93be23a14fa3c81edcfcf8d363cf0c61f2bc143),+    Fp(0x0400e59387ee438d69a2bf80aa738769de9a8b955210901a771ed118571f65c1),+    Fp(0x25be6a88f910a398bc614b938890be42dad6b1ac8ec6fe112a613b399eef6665),+    Fp(0x03ea4bdf101fd9344899d113fc1741fbad74ca8b334dc53a6b729a6a5fc89279),+    Fp(0x1047fad9b32efea09b218f282aa1c2dfd3077303195f57fc41418934d16f1c4f),+    Fp(0x0a8765e82791f0faf6ffcf3f7dde261ccc6aa4c2a2de1b55342174c08f0e99ac),+    Fp(0x2326fa25a0ebdced43fd78b1caa01bc4c6a1dde08c7df91df5898f39574e3d46),+    Fp(0x1b1a9c596960319532ab8d8ef1ccc26863c469e98f0e7f429dec33c3a37a4a02),+    Fp(0x3b298d20b11005609eaa5f9acf0a480936c068f6550ffea10c21ae5e15d6dcf4),+    Fp(0x15776a393f3d75ee488a42e8d5f26f94aaca4d924128005ea7c870bb617025f3),+    Fp(0x062e8dab4d237e8aac0cf2e2d173cedf70cecf5a6a12220e27d197845e9b8bff),+    Fp(0x00719d1b34cda84f510cc767022945e2f68588e8f5e42277292036c710a489b7),+    Fp(0x0f901761fa7e00162f1792c3e496c93af19e59a3cb7150c434bddbb672467d41),+    Fp(0x18f39bd02bcc22f43f769a14a7c3d54f88705c9760c58f3260264363487fe0c4),+    Fp(0x167608824f7f125fee60341f3c2f281fc25d04280d69a9bb082060d5bef32e60),+    Fp(0x2f9d3358af7e3bcfd8eaa88240f1c586a5bf90eaab88e7168ba0a876454c3de2),+    Fp(0x32ac45a37e1686ae18a69f252ba9c5136adc6096c706e318079d6a3febcf9e3b),+    Fp(0x2f8951ae3f289d7e113dcb80a1fa1bd8ebae53212e629d3355ccd0c322d7de32),+    Fp(0x33a9c0aa4190b15f92dce5f89ae2377c8673f2235a4efc40ef6dd647040a65fe),+    Fp(0x16dc7bbb45d732435378dd6ee7ee0e554f6712f07f43ad5d98e814d28ef68fc0),+    Fp(0x2859b4d0a15abff3a2dc781fdc4b935214b694d3a60b6d6106b016f2516b9ff7),+    Fp(0x291e7534b1ac0d4406761253e857b2179607c6dba3dc47ec32c27f4cf8384cb1),+    Fp(0x25cab0613937bf2c23ce32f9566f0613afcadfe206a9a1149bce91aef428bf67),+    Fp(0x05d75d4ba225bd59f3331b3d67b41c7b9dab05fef552102193119a37cf39651d),+    Fp(0x08f1ac492aeaeb4097fd3b925c1cb260dd1b0de49f51890f6c4280c5c8fffdb2),+    Fp(0x1930f19bb3162224797e85bde05fbe51fb0fb9498581ea286d420f57bbac4a5c),+    Fp(0x30976bf9c5ba0385aacfabdf761ac8dbe36b4db7d6d3cf54bf01921c50187dad),+    Fp(0x24565e3c889e675e3d0bcdfaa7bce677dfecea8651ec61a4c750da24f2957c5d),+    Fp(0x1b4963d6634d1aa4e94f3558cc6ef85b0ebb63d1313e6f414c0688bb35b4a84d),+    Fp(0x11c6317226ebefe1861b3c281de88796102a81c5275019fed8b855e1fec7601c),+    Fp(0x31e4caa72b128088d729b7ac24f75e3efdd4494111f52a2fe03f84aa7a812b35),+    Fp(0x28f0c2c9dc75d8595d3d0534c8f653c59d78c4f1d61a6d01f79600fa0211a509),+    Fp(0x2d2ed9e6560537731793ba72151ed438c589d66d722f11179c6f63ff9ba1a43d),+    Fp(0x2d82d12d5502c57ef739aa08c19863ec2e8d9047e90b4a36db9885982dec47a0),+    Fp(0x37ca663122f8f8c3a37b3550d9e209e01695e6fe0408ed4c37e04c1235607016),+    Fp(0x23aea613927e92f3fdaa11f448aa594e9e41f1f98fdd90e8752299919a064262),+    Fp(0x35a32d064403f6c210a8afcd345d4e1224e6f95457b7ea81ef5f02a7ddca9494),+    Fp(0x10dd3772c90dfb82066fe616175cbc524dd89298011e50963a1c403f537409db),+    Fp(0x16888fc7306379753b28c52902a5dee5f477c341db2de6a33e11d8aeb0ace075),+    Fp(0x157487d36ab5b7c6198597efa84f66ef6ec597050032a368f561d150c7313263),+    Fp(0x09db68595b17923ba8a23d8903f5c74509625055fe9bcb616227c476ee639d21),+    Fp(0x268093fe30f176392b15441318708c596d785da591fe71044f6bb0bb740131bf),+    Fp(0x2bcdbeb28b4ace35527bcdc578eec161c123c2bcf66eae255f531cd376953963),+    Fp(0x15fb7e0badca6d8712d1af8b0008b7bafbe39694bb5bb4e4de6192fa1a7457e0),+    Fp(0x17bc5b91ab0d42c97986e17f662463d094299bb9637561d9b972bf424ec6a34d),+    Fp(0x28ba3b752ddd1219fbad933f9509769ac5bfef2caf73a21bb906b04df55e3332),+    Fp(0x08c21be5da0797c93a9e9daf6c264cd477383c7661434bc7c2f3a5352ba0a6a6),+    Fp(0x1368f9ecd178721b5da1a907b0f3d71e200f12f522980391f20f0093dd5bfa1d),+    Fp(0x3964872808c60d5e11816d402f286afba6124eae232767d0aa338c8598170874),+    Fp(0x1980d8064cb2b4054394a51fe4399eabafe85e7ff4708b5a4719a8ea4c4d7c8b),+    Fp(0x17d3146dfdcc73a6e08468feea777763e92d094a07af1dc5a4dacee9bba18392),+    Fp(0x096dd2795c0238507f51a9768d9b1016c7ba5faf4b62466051929aaeaa1f059f),+    Fp(0x253d45b9f0ba5d8e51715eb65d213af10eda2f755fab8728905f76534b6e4d0b),+    Fp(0x0c43204d8daf1fcf7dfe6b82afaa9233659a2a33fe857c5b49d0fcad93df0814),+    Fp(0x1c896e0a96d7fd26fe24af6714ff5ac1da9d65a87f2627369164030f84f4f704),+    Fp(0x294086bc2cea0bc9d4789b02f826e55671927b6af97f22e6a7b9e18334de48b9),+    Fp(0x23e409c460e1df98f65ad1838207d9072085c987b907ed49669fabec34dfde7d),+    Fp(0x0474f59587e52aba53892fdc8946d032b7d6fac1e5483f42be71f83c2a4c3aa6),+    Fp(0x3cbaf27040837d2ea1dd59a9b58b11aaf86d966d85873a5ea2368fb2845c0058),+    Fp(0x363f69f61694ce239688c02475cdde1812532d7c27d865c20226357c51d8caa9),+    Fp(0x1a1906f6e6948159a14692c58aab7b8e2e9737617d4c6d77bd6d470d0b0eaba9),+    Fp(0x3f55112d29d0cd0a9ea3aae537dc9f49474dac9ea9413da7b13524a8891189e2),+    Fp(0x35ac2c37ec045706ba15b5947c45bda8f438b525608ac8bba02dd7168474ccde),+    Fp(0x0c7687e1da1a9ab943d4a724cc4def7f7825dc7a2f52dffe6b8b23f394c331eb),+    Fp(0x05e98545421d5e7675d54080f03e1f99afca04fee1d626b4057584c00e3821cb),+    Fp(0x2e0b8eaafcab9b619a0ee226784693fb926285b86c63187cd9b78df979c137ac),+    Fp(0x05c76e8712141f4a273c7823c42dccc2d35b9e4fa3999a6a9607aa13ed44daf0),+    Fp(0x2fa7be72d0672174ea06940be2c634d63a17a833b534d6fe8b2a481c56ba9c0c),+    Fp(0x0fb76439139350676499dfa370c128a81210de574d4c2fee6f7811f5054cdbde),+    Fp(0x25ad36d3824b9c3c8fa469f96a5c0dc1ebd3f4455a2436ce596e2345784f68d0),+    Fp(0x2ea618635d2a84e31019fef58cc70312876f6a03f6d14fc75c0232e3bcd86646),+    Fp(0x0a933a7699746381c04de2d48886b1b812868044b458cb5ad5f176c628464f21),+    Fp(0x1fc6239cbbc29822338b6074929322b406edf6fcefd1348143131baccc08b134),+    Fp(0x193c32e133cf528a86cb203712db7076337ffca197d02ef3b3a11859ee5fd06c),+    Fp(0x30d5c435da0e541f283675b526312a9c253c589f5e755dacfc21f04634ea4f51),+    Fp(0x1c13311054b300af3d1d960ab3bad127795c963c687d26faee16fd3a6ae75a8a),+    Fp(0x037af3e4d8a5d338195f1302cc689dc5d2475b375733cb1e319bef549efedc8f),+    Fp(0x061fc5d5b4e67dd100503e21915502159e7b7465656512c3ff11799a7caad0fa),+    Fp(0x2e9d62d787b4ddd9e520f78200eab0b1ee86b7455720c6192e4745475bb8d98d),+    Fp(0x260b46ed156d2ab096759a7078137f7d561257719b44b41f366422a8a9fed3f1),+    Fp(0x004686cfcd1f9f1f86f89d31140b9246966cc8c22a358012ce6e5ea49f6e3e60),+    Fp(0x332edeaa879008c6a6865ccdc93ddc30b58882d346b409a6bf4a0139570f5744),+    Fp(0x01ba4b76d0d08294a5546d21e7dfe47407fed94c329c0b11e6cbbc56a1cc0a00),+    Fp(0x2eac30427fcf4f551c2eed718f9949d5f8914a820dcc8548e6db8d3b60455b92),+    Fp(0x303c32bf49d73ea9bd95119666e4aa96fdd1cc8ba0e38bd02c3dba8195ee2eee),+    Fp(0x0e1cc1e02632ef1abb31810712c3fb08c94b0b3569cf7446cbd8e21b9841fb66),+    Fp(0x33051496b670bebaba4fc21b529556cb4ba2045e3347c6105cafdaf696e67e7e),+    Fp(0x0eaba3f40a2c53cd90a7f44431e217ea01e7572aca00e12465f908808b4202f0),+    Fp(0x0b01e425270ec4f3d4810b0395cd422ac96ed1a3c8eedc8c8b02bc51ec68a656),+    Fp(0x133f84bf2658613979ceca9514f5c4c3fe8448e7d92088c17ebcffa2b473a674),+    Fp(0x3cbdf49b42e4c2a512987260f2327ea02739e1e2db9a462a7fe1f95e8b8c3dd2),+    Fp(0x2d38b041fc5379cc67db3544a2bf6a17d63396b16af9a2ba30492c0982ebed07),+    Fp(0x3ae6480f450154a60be0da12998d3bdeadfcfee0c8fac2167c091bfb3d26dd25),+    Fp(0x01ace40f25423f2c2a7005641a6a1d2d3066e72bb10b457010579b58eac52105),+    Fp(0x1212fa565936b14ffea2b74ba21379ccb28ce22d6ad899932ef97c7899c68028),+    Fp(0x2166389a0e4e1f364627f44f183c91e19a0f302972d3b542faae23893d5f50fd),+    Fp(0x0ade42a791fef5cf2c386d2df993e84538576cf565d379e8a3be16b562d755c2)+]++# MDS matrix generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+MDS_MATRIX = [+    [+        Fp(0x2cebbe1217e122842b2b44a0ae977970cec9f15275e151dd5480ad1404165bb7),+        Fp(0x3110b59ae4e814cf0aa4a254996d009a71a0a9a85c2faf79dc655cba595f6be2),+        Fp(0x12e2f0714a5cca1df6113fb1e6f9d58fccbd6da8a74dd18a6a7edd65fbe71f3a)+    ],+    [+        Fp(0x105843a552c0f9b98422eacaccb4e3cd1ef3c5b7712d8a4d60cfaae4ab4ac980),+        Fp(0x3ce87897c427fcea40080459729c0a350956b6541965fc7e853ad5ef4fc3c705),+        Fp(0x1d06d6ddc91585c68681544367a147943d473e48acfafc5a3185211502184691)+    ],+    [+        Fp(0x2e73a08701c0f7e906387e6a377030919e53df433c9b311dc9ced954a22540b2),+        Fp(0x3f250fa921f576983424f185565fe5b4b21eb75a1f46501c1240f8d2a183d3d5),+        Fp(0x2f37602cd4d8f52df318f9d0723be105989a59402f581c3eaa6315cf8d657550)+    ]+]++def main():++    # These are test vectors from https://github.com/daira/pasta-hadeshash/commit/cdab5252d0ec675780e9f8c3d09fdb7a0a71d3ff.+    fixed_test_input = [+        Fp(0x0000000000000000000000000000000000000000000000000000000000000000),+        Fp(0x0000000000000000000000000000000000000000000000000000000000000001),+        Fp(0x0000000000000000000000000000000000000000000000000000000000000002)+    ]+    fixed_test_output = [+        Fp(0x19a264dbf840aaeae2d33be07ee5db5c6ad21f3e05112d6e45860cdfc1224c90),+        Fp(0x11b823d66e94c285813686b6df10cf9931cc06bfdf6bd5fd3dc3ed1c3434091e),+        Fp(0x111104f41966d2ce68a635c3b4cbb608cbaa5caeabc596e3c5dc3d6d756ede28)+    ]++    assert perm(fixed_test_input) == fixed_test_output++    test_vectors = [fixed_test_input]++    from random import Random+    rng = Random(0xabad533d)+    def randbytes(l):+        ret = []+        while len(ret) < l:+            ret.append(rng.randrange(0, 256))+        return bytes(ret)+    rand = Rand(randbytes)++    # Generate random test vectors+    for _ in range(10):+        test_vectors.append([+            Fp(leos2ip(rand.b(32))),+            Fp(leos2ip(rand.b(32))),+            Fp(leos2ip(rand.b(32)))+        ])++    render_tv(+        render_args(),+        'orchard_poseidon',+        (+            ('input', '[[u8; 32]; 3]'),+            ('output', '[[u8; 32]; 3]'),+        ),+        [{+            'input': list(map(bytes, input)),+            'output': list(map(bytes, perm(input))),
            ('initial_state', '[[u8; 32]; 3]'),
            ('final_state', '[[u8; 32]; 3]'),
        ),
        [{
            'initial_state': list(map(bytes, input)),
            'final_state': list(map(bytes, perm(input))),
therealyingtong

comment created time in a day

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+import numpy as np+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Number of full rounds+R_F = 8+# Number of partial rounds+R_P = 58+# Width+t = 3++def perm(input_words):+    R_f = int(R_F / 2)++    round_constants_counter = 0++    state_words = list(input_words)+    assert len(state_words) == t++    # First full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Middle partial rounds+    for r in range(0, R_P):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        state_words[0] = (state_words[0]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Last full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))+    +    return state_words++# Round constants generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+ROUND_CONSTANTS = [+    Fp(0x2f2c2bfbd7070f5321f103387216cb9137df4021c68b5eef61904c0511b737a4),+    Fp(0x04ec2fc5c55d67746ccdd22b2bbdead13645b63b123b613afb311b7d0f35b058),+    Fp(0x3c624cfc4c994eb2fa9b924125223a7163e46dfb62f3522b6771be5f74ecb0b6),+    Fp(0x3476744a626a1813dd9b91a3d9031e29ccecd6c12a34927a5a936dc45b059511),+    Fp(0x3e8e3c1b8e9f1e1809d3b2dc9dc078894e4c8c3fdf34ea1a033e60bd7a63cf16),+    Fp(0x1439f41af8953e20247a437c362bba132af9c485bc73d98a4be1bb1b9efd907c),+    Fp(0x2184e123d6f4e5e9fea44f9f1ee27531af57eb3128f8662193ac3d2ca4ac6c7a),+    Fp(0x331019b909d6c87d8cc034f568aedbe1f8e05b9293c9b396a3eda4c816729416),+    Fp(0x00078b16de3fa3a0c6ec9cff8656ad7ed1eba2586b779d45a53f26c9a84fa24e),+    Fp(0x394f742117539cad1d44ff024f9f4e7a85782423cf7fd1305bc1b2926f39601e),+    Fp(0x261e237d617e261a6e65df293f2725e00311e30e0ba5c3008ed576fd4d43d779),+    Fp(0x252d1389b3aefdd233dccb6f7c448319857d2f7b4075d28b4513b401f48a3668),+    Fp(0x025ca9dda3db70df67bf7e430350923d38d635392451923af69df9e788a5fe24),+    Fp(0x1d2c2ace140ad5b617e517edd753f0b18d152f5c95421ab6c18c127223501f93),+    Fp(0x0ba495c1f7b77dbf654c7abd86a684434079eb21f42e4af06768c8403f50ac2c),+    Fp(0x2cbce44950324cba5bb2f8664192273205f15752efc3ebe1d8af60702eef9e28),+    Fp(0x24767e0d3abf426d95e4242db16d3a33fe5e302a8a71c31c671afb22aeae9d14),+    Fp(0x1acd6ef0e60e4b14146d53fcc83aea81b8a971e0ba9daab50d928670de2a3031),+    Fp(0x340f94d400bd0a3119942055672d627da17e77a8a72e7eedcc1c86114da6a1eb),+    Fp(0x0327373cca3dd2f8d60711e33e0c6b82472c8da29209c94dd51e2326061e22c0),+    Fp(0x1d1041d82c9d480f17c2d6ae049061e939ee18190c5c20805fdb2ffcf0161350),+    Fp(0x0de4750f968b5257895e8c73611059f8b7d135501d3d911f51bc31436ab5a574),+    Fp(0x359290a3786196bbc7fc9a99c916ccba11454b0cd0eb7d3fb2414383ee1a5794),+    Fp(0x28ffcdddf417cbabba580e1453f3094ddd4460b67aef036418c20b5cec2e8036),+    Fp(0x0e76c3df688ed3f5de99a4e4dcc1308486010174246d3c89322d2c6afaab6a00),+    Fp(0x172ca76af974367abde18a6b3a19c2ef7c42ac6e80e97c5b78922912d57f57c7),+    Fp(0x12ed4668b1543521662601e168f1a7aa8951a8407b00fd3f9b64fa4dc692195f),+    Fp(0x0c2ea06a9894cea56fd7211f8354d5092f614f7bcf8232ef90f2a829e538d398),+    Fp(0x0faea60318136b64e54759689b038ae3b55d8ea1305494517c7fea109bb09622),+    Fp(0x1beaeb465cd4c711b93eebf4dd9a414f1e7b90098c78a371287bfe86a1e66b27),+    Fp(0x351c94b9bcca5b1a2c2b06ede8114d463b6f7bdd6b37dd97a81add76cd42a4e3),+    Fp(0x2a1838fac1749e4fe68f84dcf259a459bb6ed62b92328294dcfc4ebaa75a4d92),+    Fp(0x3f875c2cd7e1d69ea4f88c06ea9c2ab893418cf02a66ea98cd230bfae2f670fb),+    Fp(0x31224a3412529b86145fe811a3fc44860ddd35b287fdc7986ce237b7c99f07a1),+    Fp(0x1556b2b9633ae623b42a1119bfbae23e0d6ee24b4e39c55c615b6db29fd9314e),+    Fp(0x399bacd8f54ccc4d1ce8ca1c71e5fb346aff3ab03e93551975225cd9ed99f2c2),+    Fp(0x389877368a5c321ea02d7dabc1444ad131c43e3ad4d20ebaf2f0997bbbaf80e3),+    Fp(0x0ef32660742991bbc6d17e9a4132067f6f78fa39361a74ccaebc66a50a73b506),+    Fp(0x1e491a5fdda824e26eb3d15a465c9221fb7a99f01266cbe86d97adb2c1139c94),+    Fp(0x2de4d6ff6ff2634b6ae7ab72cc34eb48c6ad0f62f31397e8a07d60fafe7f0aa7),+    Fp(0x1283a38005b8f0a7f2a5b56138dd2a5bbf319eac78d2c93506dbddfcdba52766),+    Fp(0x19e2efea5020aa4be092ca71681d8050b3c91a960025c6acdf23b7b398f061b6),+    Fp(0x287fb567ece35108f55719af51c11b6b610968a14a94ce030b7f48248fec885d),+    Fp(0x2761ea586e5d500d5202d4483f10d32a587f25e1e974432d59800355f507bb83),+    Fp(0x2f77d7a4f74db35eaf18b1bd8786f740f85d793979ae02c46d529cb31dff100e),+    Fp(0x0390862d7e6e7a690d4a5e120b9dc8f13200eb324f5d7c33d34b68245ebf1dc2),+    Fp(0x14d5b21da4b45c808c2a51c11a9cc97fd5196ea5d70bbdb6352e4174565c5a52),+    Fp(0x2974ad78ec5d90fbd088112a178403a1acb796e31fc8737f3f8566c9d7d1e755),+    Fp(0x36b58f7052adcc1fa3a1c290f0b04b7a28b413c7a3bb7e68ffb53b785334ee3c),+    Fp(0x2efb0a9efd6c60a1aeb870093f64363919c4993eb1fd95ae97159cc8a97339c2),+    Fp(0x1f04ae7df249c70c3f19a23c72a2a102d1528ff7aa4bb02229b61e805c98c1ff),+    Fp(0x278d44fe8f8c299659642e54f819858991fd0d3b8c617d8a1363315c4d8e0cb0),+    Fp(0x1a2bbd022168061c49b45714ae1b0f6a6ded5b7f8cefc2a2e3344dc1c1592406),+    Fp(0x0f0de2f73193a97edf8a91de8e688793f93cb4ed2236639813ebf947a3559f9c),+    Fp(0x3ac47dc248f16ac55092c3d232a09399b76cd699d0b30adf0072ef68ea438f92),+    Fp(0x1f7f927daef5fc95f4a0c96759812f90002c2347a222043cb3c779653e34a054),+    Fp(0x250b4faf86d72618e6e3cd02b1adcb7c945c315ce93dfc00c0b179e1cc950b85),+    Fp(0x07c64646dee2604b62528967df12153f7288bcc4fab6750d65d20118981ade0e),+    Fp(0x24cbbd234c0ef70078fa143ca1158bbba05c8ca1dd7132efee93af96dbadff1d),+    Fp(0x208edf94ef339a27fdbbf3cc08b7adecc5362d39b6348ecc54bb4e6cf7fa521b),+    Fp(0x3ea2a73f40f1f3d20a589d3d2c4d14dbf45f11963d6c1806f96c7fd82a46da35),+    Fp(0x36ccb8567075d3a0771bb857f4c51f58e79cb26ff91b9be15973a73ea2752c7a),+    Fp(0x08654b649a5091baa9cdf91ce7f831473adc95de617cfa32fc8681d17000408c),+    Fp(0x2b58a76bcbfb8500f28b308ee52a8e0ea5fac865c5b6ee7da9898bed507f18ea),+    Fp(0x1001d34a284e2b254614b66105ccb699e2ed8f2533be8e737d15896225d59a2e),+    Fp(0x13375ab0b5350afb2f1e63d230afa70c2a61dece93b1651c9c4286cc6354bc9c),+    Fp(0x2a7169d46ff2ffbaec72491a04c64702ac5b9ccb5216abda5622b222a0f0aacb),+    Fp(0x033eb55bedfd6b29986094724c1852f651d214174045e6fc55eace8b62101ae0),+    Fp(0x10ca1ffa20260f4019e31226ee751c71795c7f74d5d1c53b5ec053879568fad1),+    Fp(0x06c1da78f2f5f0fde46172c42bbc83e3495d5082cf47489df1f0980430bd6854),+    Fp(0x1ae9bf0085d1a2b7fdd8999c542447243b4e83b509a3975cf74a4bab5a21c53f),+    Fp(0x368599e0cc709b2d07542c631e002e81d38be406010a91c1cbdbeb71eec5383c),+    Fp(0x02e79429cc4d4a362e02d60c365dcb49898f32679397244222788138e9584f32),+    Fp(0x18c541e9d2751b8000d3998ad9c220db4a4315eb87d99b67a0a82bd61d49d14d),+    Fp(0x197507d5e313e2e3b49b9fb54a89a586447443b5f9d9292b01c9bf579600678e),+    Fp(0x26b1bd92ee8931886696164e25e700926f470f7041be91abbffc4f5fddbdc07f),+    Fp(0x0efdb615f564ee4698d8f8f44deaed092681d0a23a4577724d8cad71a7e5fdbe),+    Fp(0x266a5dddc5f832887a71bdbe32594a48ac9f2bccf1fa8d4368144a5fc771da1c),+    Fp(0x34f356e3badb42d5e17d8e2df0917f29b575fb420a344f56b32a9caaf6168330),+    Fp(0x2fa9ad6f882f66ccddd716c5b3f04c48f138f015bc0d0d5a258b3a63f45ebcaf),+    Fp(0x210b633386cdd22784f4fc53939bed4d7350958aac95be44b2ab8c35890dcd99),+    Fp(0x34dc0f069165b00e4e80ab1639afaf610937f9d6cf91437dd6a56d62f6ad9eb3),+    Fp(0x259b4cb0b0861d0782d0614ae013d8c7913fa6f411c7dc733326b0455cf8778c),+    Fp(0x0f88d8b6c5d9073dc660788b3e78bd62315abaf489d41b29a7d0770ead395746),+    Fp(0x30abd11ecb73119f5baef3db5d9337853282e45af42d83c72084d439504c1fc6),+    Fp(0x3152ce325264529cf302af09d5baec045efc980abba7cc3363a18839c6f6446f),+    Fp(0x00bd3146554e552abe94978eddc451ede2954fc59859ff6c34f7c1613c270e35),+    Fp(0x2c1ef4c8ef911a32ee1cea96ee50922815a93afae282c149b7f24921d8d4a0fe),+    Fp(0x23869adb5876af5f29721a01deb5335bbdd8bc446d7bebcd32966e61c7ad12b3),+    Fp(0x2af88e261ca1217caccdf61ac128cb35f372cb64c6bed49de2ea4991a83e5559),+    Fp(0x1b5d76d6c03da588a257ecf10b3daaf6a40dcea8f7f097f180c9c434914cb08a),+    Fp(0x1c76daae2af0990fcfc6bd3d2f027c3afe599fc476202d0a37d08e8f023b6285),+    Fp(0x2f5893f6a6e2ef3d3bbb3577ca09d9f059e5b761f25218adb85ea92c8328797f),+    Fp(0x1a11a3dc16874116e894488c79ff537033278958606472301833029f73094c23),+    Fp(0x22b2a9a84c555a46ed9149261eac2db8cde06b75292c4777f7c9a6bd81c2000e),+    Fp(0x1f7201ee492876c172204d8f5e4ee22e6f6f98348d77c85b93398ca5a5e8bbaa),+    Fp(0x08e2edc6fbdc691f2512ee311910c8f8211eab318f4142dcf636c50cf6fdd861),+    Fp(0x173726c1c53a38abb250c6578359c6a4df0a181b9932230703df22f761e06616),+    Fp(0x2ffe9110497cdee27d1ed33019291435729a8410c1e2548989580351e3878456),+    Fp(0x02f1f99037148d41dad15fb86a6279d9e4fd5bd65a738f7f8de1001ed1cc4478),+    Fp(0x0a2c4dbf4da2980ef04af6cfb2e6f0a897d0126dc4eb15da86b3f413408e73c7),+    Fp(0x2970b9d63a8db9247913597bd93be23a14fa3c81edcfcf8d363cf0c61f2bc143),+    Fp(0x0400e59387ee438d69a2bf80aa738769de9a8b955210901a771ed118571f65c1),+    Fp(0x25be6a88f910a398bc614b938890be42dad6b1ac8ec6fe112a613b399eef6665),+    Fp(0x03ea4bdf101fd9344899d113fc1741fbad74ca8b334dc53a6b729a6a5fc89279),+    Fp(0x1047fad9b32efea09b218f282aa1c2dfd3077303195f57fc41418934d16f1c4f),+    Fp(0x0a8765e82791f0faf6ffcf3f7dde261ccc6aa4c2a2de1b55342174c08f0e99ac),+    Fp(0x2326fa25a0ebdced43fd78b1caa01bc4c6a1dde08c7df91df5898f39574e3d46),+    Fp(0x1b1a9c596960319532ab8d8ef1ccc26863c469e98f0e7f429dec33c3a37a4a02),+    Fp(0x3b298d20b11005609eaa5f9acf0a480936c068f6550ffea10c21ae5e15d6dcf4),+    Fp(0x15776a393f3d75ee488a42e8d5f26f94aaca4d924128005ea7c870bb617025f3),+    Fp(0x062e8dab4d237e8aac0cf2e2d173cedf70cecf5a6a12220e27d197845e9b8bff),+    Fp(0x00719d1b34cda84f510cc767022945e2f68588e8f5e42277292036c710a489b7),+    Fp(0x0f901761fa7e00162f1792c3e496c93af19e59a3cb7150c434bddbb672467d41),+    Fp(0x18f39bd02bcc22f43f769a14a7c3d54f88705c9760c58f3260264363487fe0c4),+    Fp(0x167608824f7f125fee60341f3c2f281fc25d04280d69a9bb082060d5bef32e60),+    Fp(0x2f9d3358af7e3bcfd8eaa88240f1c586a5bf90eaab88e7168ba0a876454c3de2),+    Fp(0x32ac45a37e1686ae18a69f252ba9c5136adc6096c706e318079d6a3febcf9e3b),+    Fp(0x2f8951ae3f289d7e113dcb80a1fa1bd8ebae53212e629d3355ccd0c322d7de32),+    Fp(0x33a9c0aa4190b15f92dce5f89ae2377c8673f2235a4efc40ef6dd647040a65fe),+    Fp(0x16dc7bbb45d732435378dd6ee7ee0e554f6712f07f43ad5d98e814d28ef68fc0),+    Fp(0x2859b4d0a15abff3a2dc781fdc4b935214b694d3a60b6d6106b016f2516b9ff7),+    Fp(0x291e7534b1ac0d4406761253e857b2179607c6dba3dc47ec32c27f4cf8384cb1),+    Fp(0x25cab0613937bf2c23ce32f9566f0613afcadfe206a9a1149bce91aef428bf67),+    Fp(0x05d75d4ba225bd59f3331b3d67b41c7b9dab05fef552102193119a37cf39651d),+    Fp(0x08f1ac492aeaeb4097fd3b925c1cb260dd1b0de49f51890f6c4280c5c8fffdb2),+    Fp(0x1930f19bb3162224797e85bde05fbe51fb0fb9498581ea286d420f57bbac4a5c),+    Fp(0x30976bf9c5ba0385aacfabdf761ac8dbe36b4db7d6d3cf54bf01921c50187dad),+    Fp(0x24565e3c889e675e3d0bcdfaa7bce677dfecea8651ec61a4c750da24f2957c5d),+    Fp(0x1b4963d6634d1aa4e94f3558cc6ef85b0ebb63d1313e6f414c0688bb35b4a84d),+    Fp(0x11c6317226ebefe1861b3c281de88796102a81c5275019fed8b855e1fec7601c),+    Fp(0x31e4caa72b128088d729b7ac24f75e3efdd4494111f52a2fe03f84aa7a812b35),+    Fp(0x28f0c2c9dc75d8595d3d0534c8f653c59d78c4f1d61a6d01f79600fa0211a509),+    Fp(0x2d2ed9e6560537731793ba72151ed438c589d66d722f11179c6f63ff9ba1a43d),+    Fp(0x2d82d12d5502c57ef739aa08c19863ec2e8d9047e90b4a36db9885982dec47a0),+    Fp(0x37ca663122f8f8c3a37b3550d9e209e01695e6fe0408ed4c37e04c1235607016),+    Fp(0x23aea613927e92f3fdaa11f448aa594e9e41f1f98fdd90e8752299919a064262),+    Fp(0x35a32d064403f6c210a8afcd345d4e1224e6f95457b7ea81ef5f02a7ddca9494),+    Fp(0x10dd3772c90dfb82066fe616175cbc524dd89298011e50963a1c403f537409db),+    Fp(0x16888fc7306379753b28c52902a5dee5f477c341db2de6a33e11d8aeb0ace075),+    Fp(0x157487d36ab5b7c6198597efa84f66ef6ec597050032a368f561d150c7313263),+    Fp(0x09db68595b17923ba8a23d8903f5c74509625055fe9bcb616227c476ee639d21),+    Fp(0x268093fe30f176392b15441318708c596d785da591fe71044f6bb0bb740131bf),+    Fp(0x2bcdbeb28b4ace35527bcdc578eec161c123c2bcf66eae255f531cd376953963),+    Fp(0x15fb7e0badca6d8712d1af8b0008b7bafbe39694bb5bb4e4de6192fa1a7457e0),+    Fp(0x17bc5b91ab0d42c97986e17f662463d094299bb9637561d9b972bf424ec6a34d),+    Fp(0x28ba3b752ddd1219fbad933f9509769ac5bfef2caf73a21bb906b04df55e3332),+    Fp(0x08c21be5da0797c93a9e9daf6c264cd477383c7661434bc7c2f3a5352ba0a6a6),+    Fp(0x1368f9ecd178721b5da1a907b0f3d71e200f12f522980391f20f0093dd5bfa1d),+    Fp(0x3964872808c60d5e11816d402f286afba6124eae232767d0aa338c8598170874),+    Fp(0x1980d8064cb2b4054394a51fe4399eabafe85e7ff4708b5a4719a8ea4c4d7c8b),+    Fp(0x17d3146dfdcc73a6e08468feea777763e92d094a07af1dc5a4dacee9bba18392),+    Fp(0x096dd2795c0238507f51a9768d9b1016c7ba5faf4b62466051929aaeaa1f059f),+    Fp(0x253d45b9f0ba5d8e51715eb65d213af10eda2f755fab8728905f76534b6e4d0b),+    Fp(0x0c43204d8daf1fcf7dfe6b82afaa9233659a2a33fe857c5b49d0fcad93df0814),+    Fp(0x1c896e0a96d7fd26fe24af6714ff5ac1da9d65a87f2627369164030f84f4f704),+    Fp(0x294086bc2cea0bc9d4789b02f826e55671927b6af97f22e6a7b9e18334de48b9),+    Fp(0x23e409c460e1df98f65ad1838207d9072085c987b907ed49669fabec34dfde7d),+    Fp(0x0474f59587e52aba53892fdc8946d032b7d6fac1e5483f42be71f83c2a4c3aa6),+    Fp(0x3cbaf27040837d2ea1dd59a9b58b11aaf86d966d85873a5ea2368fb2845c0058),+    Fp(0x363f69f61694ce239688c02475cdde1812532d7c27d865c20226357c51d8caa9),+    Fp(0x1a1906f6e6948159a14692c58aab7b8e2e9737617d4c6d77bd6d470d0b0eaba9),+    Fp(0x3f55112d29d0cd0a9ea3aae537dc9f49474dac9ea9413da7b13524a8891189e2),+    Fp(0x35ac2c37ec045706ba15b5947c45bda8f438b525608ac8bba02dd7168474ccde),+    Fp(0x0c7687e1da1a9ab943d4a724cc4def7f7825dc7a2f52dffe6b8b23f394c331eb),+    Fp(0x05e98545421d5e7675d54080f03e1f99afca04fee1d626b4057584c00e3821cb),+    Fp(0x2e0b8eaafcab9b619a0ee226784693fb926285b86c63187cd9b78df979c137ac),+    Fp(0x05c76e8712141f4a273c7823c42dccc2d35b9e4fa3999a6a9607aa13ed44daf0),+    Fp(0x2fa7be72d0672174ea06940be2c634d63a17a833b534d6fe8b2a481c56ba9c0c),+    Fp(0x0fb76439139350676499dfa370c128a81210de574d4c2fee6f7811f5054cdbde),+    Fp(0x25ad36d3824b9c3c8fa469f96a5c0dc1ebd3f4455a2436ce596e2345784f68d0),+    Fp(0x2ea618635d2a84e31019fef58cc70312876f6a03f6d14fc75c0232e3bcd86646),+    Fp(0x0a933a7699746381c04de2d48886b1b812868044b458cb5ad5f176c628464f21),+    Fp(0x1fc6239cbbc29822338b6074929322b406edf6fcefd1348143131baccc08b134),+    Fp(0x193c32e133cf528a86cb203712db7076337ffca197d02ef3b3a11859ee5fd06c),+    Fp(0x30d5c435da0e541f283675b526312a9c253c589f5e755dacfc21f04634ea4f51),+    Fp(0x1c13311054b300af3d1d960ab3bad127795c963c687d26faee16fd3a6ae75a8a),+    Fp(0x037af3e4d8a5d338195f1302cc689dc5d2475b375733cb1e319bef549efedc8f),+    Fp(0x061fc5d5b4e67dd100503e21915502159e7b7465656512c3ff11799a7caad0fa),+    Fp(0x2e9d62d787b4ddd9e520f78200eab0b1ee86b7455720c6192e4745475bb8d98d),+    Fp(0x260b46ed156d2ab096759a7078137f7d561257719b44b41f366422a8a9fed3f1),+    Fp(0x004686cfcd1f9f1f86f89d31140b9246966cc8c22a358012ce6e5ea49f6e3e60),+    Fp(0x332edeaa879008c6a6865ccdc93ddc30b58882d346b409a6bf4a0139570f5744),+    Fp(0x01ba4b76d0d08294a5546d21e7dfe47407fed94c329c0b11e6cbbc56a1cc0a00),+    Fp(0x2eac30427fcf4f551c2eed718f9949d5f8914a820dcc8548e6db8d3b60455b92),+    Fp(0x303c32bf49d73ea9bd95119666e4aa96fdd1cc8ba0e38bd02c3dba8195ee2eee),+    Fp(0x0e1cc1e02632ef1abb31810712c3fb08c94b0b3569cf7446cbd8e21b9841fb66),+    Fp(0x33051496b670bebaba4fc21b529556cb4ba2045e3347c6105cafdaf696e67e7e),+    Fp(0x0eaba3f40a2c53cd90a7f44431e217ea01e7572aca00e12465f908808b4202f0),+    Fp(0x0b01e425270ec4f3d4810b0395cd422ac96ed1a3c8eedc8c8b02bc51ec68a656),+    Fp(0x133f84bf2658613979ceca9514f5c4c3fe8448e7d92088c17ebcffa2b473a674),+    Fp(0x3cbdf49b42e4c2a512987260f2327ea02739e1e2db9a462a7fe1f95e8b8c3dd2),+    Fp(0x2d38b041fc5379cc67db3544a2bf6a17d63396b16af9a2ba30492c0982ebed07),+    Fp(0x3ae6480f450154a60be0da12998d3bdeadfcfee0c8fac2167c091bfb3d26dd25),+    Fp(0x01ace40f25423f2c2a7005641a6a1d2d3066e72bb10b457010579b58eac52105),+    Fp(0x1212fa565936b14ffea2b74ba21379ccb28ce22d6ad899932ef97c7899c68028),+    Fp(0x2166389a0e4e1f364627f44f183c91e19a0f302972d3b542faae23893d5f50fd),+    Fp(0x0ade42a791fef5cf2c386d2df993e84538576cf565d379e8a3be16b562d755c2)+]++# MDS matrix generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+MDS_MATRIX = [

I checked this.

therealyingtong

comment created time in a day

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+import numpy as np+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Number of full rounds+R_F = 8+# Number of partial rounds+R_P = 58+# Width+t = 3++def perm(input_words):+    R_f = int(R_F / 2)++    round_constants_counter = 0++    state_words = list(input_words)+    assert len(state_words) == t++    # First full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Middle partial rounds+    for r in range(0, R_P):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        state_words[0] = (state_words[0]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Last full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))+    +    return state_words++# Round constants generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+ROUND_CONSTANTS = [+    Fp(0x2f2c2bfbd7070f5321f103387216cb9137df4021c68b5eef61904c0511b737a4),+    Fp(0x04ec2fc5c55d67746ccdd22b2bbdead13645b63b123b613afb311b7d0f35b058),+    Fp(0x3c624cfc4c994eb2fa9b924125223a7163e46dfb62f3522b6771be5f74ecb0b6),+    Fp(0x3476744a626a1813dd9b91a3d9031e29ccecd6c12a34927a5a936dc45b059511),+    Fp(0x3e8e3c1b8e9f1e1809d3b2dc9dc078894e4c8c3fdf34ea1a033e60bd7a63cf16),+    Fp(0x1439f41af8953e20247a437c362bba132af9c485bc73d98a4be1bb1b9efd907c),+    Fp(0x2184e123d6f4e5e9fea44f9f1ee27531af57eb3128f8662193ac3d2ca4ac6c7a),+    Fp(0x331019b909d6c87d8cc034f568aedbe1f8e05b9293c9b396a3eda4c816729416),+    Fp(0x00078b16de3fa3a0c6ec9cff8656ad7ed1eba2586b779d45a53f26c9a84fa24e),+    Fp(0x394f742117539cad1d44ff024f9f4e7a85782423cf7fd1305bc1b2926f39601e),+    Fp(0x261e237d617e261a6e65df293f2725e00311e30e0ba5c3008ed576fd4d43d779),+    Fp(0x252d1389b3aefdd233dccb6f7c448319857d2f7b4075d28b4513b401f48a3668),+    Fp(0x025ca9dda3db70df67bf7e430350923d38d635392451923af69df9e788a5fe24),+    Fp(0x1d2c2ace140ad5b617e517edd753f0b18d152f5c95421ab6c18c127223501f93),+    Fp(0x0ba495c1f7b77dbf654c7abd86a684434079eb21f42e4af06768c8403f50ac2c),+    Fp(0x2cbce44950324cba5bb2f8664192273205f15752efc3ebe1d8af60702eef9e28),+    Fp(0x24767e0d3abf426d95e4242db16d3a33fe5e302a8a71c31c671afb22aeae9d14),+    Fp(0x1acd6ef0e60e4b14146d53fcc83aea81b8a971e0ba9daab50d928670de2a3031),+    Fp(0x340f94d400bd0a3119942055672d627da17e77a8a72e7eedcc1c86114da6a1eb),+    Fp(0x0327373cca3dd2f8d60711e33e0c6b82472c8da29209c94dd51e2326061e22c0),+    Fp(0x1d1041d82c9d480f17c2d6ae049061e939ee18190c5c20805fdb2ffcf0161350),+    Fp(0x0de4750f968b5257895e8c73611059f8b7d135501d3d911f51bc31436ab5a574),+    Fp(0x359290a3786196bbc7fc9a99c916ccba11454b0cd0eb7d3fb2414383ee1a5794),+    Fp(0x28ffcdddf417cbabba580e1453f3094ddd4460b67aef036418c20b5cec2e8036),+    Fp(0x0e76c3df688ed3f5de99a4e4dcc1308486010174246d3c89322d2c6afaab6a00),+    Fp(0x172ca76af974367abde18a6b3a19c2ef7c42ac6e80e97c5b78922912d57f57c7),+    Fp(0x12ed4668b1543521662601e168f1a7aa8951a8407b00fd3f9b64fa4dc692195f),+    Fp(0x0c2ea06a9894cea56fd7211f8354d5092f614f7bcf8232ef90f2a829e538d398),+    Fp(0x0faea60318136b64e54759689b038ae3b55d8ea1305494517c7fea109bb09622),+    Fp(0x1beaeb465cd4c711b93eebf4dd9a414f1e7b90098c78a371287bfe86a1e66b27),+    Fp(0x351c94b9bcca5b1a2c2b06ede8114d463b6f7bdd6b37dd97a81add76cd42a4e3),+    Fp(0x2a1838fac1749e4fe68f84dcf259a459bb6ed62b92328294dcfc4ebaa75a4d92),+    Fp(0x3f875c2cd7e1d69ea4f88c06ea9c2ab893418cf02a66ea98cd230bfae2f670fb),+    Fp(0x31224a3412529b86145fe811a3fc44860ddd35b287fdc7986ce237b7c99f07a1),+    Fp(0x1556b2b9633ae623b42a1119bfbae23e0d6ee24b4e39c55c615b6db29fd9314e),+    Fp(0x399bacd8f54ccc4d1ce8ca1c71e5fb346aff3ab03e93551975225cd9ed99f2c2),+    Fp(0x389877368a5c321ea02d7dabc1444ad131c43e3ad4d20ebaf2f0997bbbaf80e3),+    Fp(0x0ef32660742991bbc6d17e9a4132067f6f78fa39361a74ccaebc66a50a73b506),+    Fp(0x1e491a5fdda824e26eb3d15a465c9221fb7a99f01266cbe86d97adb2c1139c94),+    Fp(0x2de4d6ff6ff2634b6ae7ab72cc34eb48c6ad0f62f31397e8a07d60fafe7f0aa7),+    Fp(0x1283a38005b8f0a7f2a5b56138dd2a5bbf319eac78d2c93506dbddfcdba52766),+    Fp(0x19e2efea5020aa4be092ca71681d8050b3c91a960025c6acdf23b7b398f061b6),+    Fp(0x287fb567ece35108f55719af51c11b6b610968a14a94ce030b7f48248fec885d),+    Fp(0x2761ea586e5d500d5202d4483f10d32a587f25e1e974432d59800355f507bb83),+    Fp(0x2f77d7a4f74db35eaf18b1bd8786f740f85d793979ae02c46d529cb31dff100e),+    Fp(0x0390862d7e6e7a690d4a5e120b9dc8f13200eb324f5d7c33d34b68245ebf1dc2),+    Fp(0x14d5b21da4b45c808c2a51c11a9cc97fd5196ea5d70bbdb6352e4174565c5a52),+    Fp(0x2974ad78ec5d90fbd088112a178403a1acb796e31fc8737f3f8566c9d7d1e755),+    Fp(0x36b58f7052adcc1fa3a1c290f0b04b7a28b413c7a3bb7e68ffb53b785334ee3c),+    Fp(0x2efb0a9efd6c60a1aeb870093f64363919c4993eb1fd95ae97159cc8a97339c2),+    Fp(0x1f04ae7df249c70c3f19a23c72a2a102d1528ff7aa4bb02229b61e805c98c1ff),+    Fp(0x278d44fe8f8c299659642e54f819858991fd0d3b8c617d8a1363315c4d8e0cb0),+    Fp(0x1a2bbd022168061c49b45714ae1b0f6a6ded5b7f8cefc2a2e3344dc1c1592406),+    Fp(0x0f0de2f73193a97edf8a91de8e688793f93cb4ed2236639813ebf947a3559f9c),+    Fp(0x3ac47dc248f16ac55092c3d232a09399b76cd699d0b30adf0072ef68ea438f92),+    Fp(0x1f7f927daef5fc95f4a0c96759812f90002c2347a222043cb3c779653e34a054),+    Fp(0x250b4faf86d72618e6e3cd02b1adcb7c945c315ce93dfc00c0b179e1cc950b85),+    Fp(0x07c64646dee2604b62528967df12153f7288bcc4fab6750d65d20118981ade0e),+    Fp(0x24cbbd234c0ef70078fa143ca1158bbba05c8ca1dd7132efee93af96dbadff1d),+    Fp(0x208edf94ef339a27fdbbf3cc08b7adecc5362d39b6348ecc54bb4e6cf7fa521b),+    Fp(0x3ea2a73f40f1f3d20a589d3d2c4d14dbf45f11963d6c1806f96c7fd82a46da35),+    Fp(0x36ccb8567075d3a0771bb857f4c51f58e79cb26ff91b9be15973a73ea2752c7a),+    Fp(0x08654b649a5091baa9cdf91ce7f831473adc95de617cfa32fc8681d17000408c),+    Fp(0x2b58a76bcbfb8500f28b308ee52a8e0ea5fac865c5b6ee7da9898bed507f18ea),+    Fp(0x1001d34a284e2b254614b66105ccb699e2ed8f2533be8e737d15896225d59a2e),+    Fp(0x13375ab0b5350afb2f1e63d230afa70c2a61dece93b1651c9c4286cc6354bc9c),+    Fp(0x2a7169d46ff2ffbaec72491a04c64702ac5b9ccb5216abda5622b222a0f0aacb),+    Fp(0x033eb55bedfd6b29986094724c1852f651d214174045e6fc55eace8b62101ae0),+    Fp(0x10ca1ffa20260f4019e31226ee751c71795c7f74d5d1c53b5ec053879568fad1),+    Fp(0x06c1da78f2f5f0fde46172c42bbc83e3495d5082cf47489df1f0980430bd6854),+    Fp(0x1ae9bf0085d1a2b7fdd8999c542447243b4e83b509a3975cf74a4bab5a21c53f),+    Fp(0x368599e0cc709b2d07542c631e002e81d38be406010a91c1cbdbeb71eec5383c),+    Fp(0x02e79429cc4d4a362e02d60c365dcb49898f32679397244222788138e9584f32),+    Fp(0x18c541e9d2751b8000d3998ad9c220db4a4315eb87d99b67a0a82bd61d49d14d),+    Fp(0x197507d5e313e2e3b49b9fb54a89a586447443b5f9d9292b01c9bf579600678e),+    Fp(0x26b1bd92ee8931886696164e25e700926f470f7041be91abbffc4f5fddbdc07f),+    Fp(0x0efdb615f564ee4698d8f8f44deaed092681d0a23a4577724d8cad71a7e5fdbe),+    Fp(0x266a5dddc5f832887a71bdbe32594a48ac9f2bccf1fa8d4368144a5fc771da1c),+    Fp(0x34f356e3badb42d5e17d8e2df0917f29b575fb420a344f56b32a9caaf6168330),+    Fp(0x2fa9ad6f882f66ccddd716c5b3f04c48f138f015bc0d0d5a258b3a63f45ebcaf),+    Fp(0x210b633386cdd22784f4fc53939bed4d7350958aac95be44b2ab8c35890dcd99),+    Fp(0x34dc0f069165b00e4e80ab1639afaf610937f9d6cf91437dd6a56d62f6ad9eb3),+    Fp(0x259b4cb0b0861d0782d0614ae013d8c7913fa6f411c7dc733326b0455cf8778c),+    Fp(0x0f88d8b6c5d9073dc660788b3e78bd62315abaf489d41b29a7d0770ead395746),+    Fp(0x30abd11ecb73119f5baef3db5d9337853282e45af42d83c72084d439504c1fc6),+    Fp(0x3152ce325264529cf302af09d5baec045efc980abba7cc3363a18839c6f6446f),+    Fp(0x00bd3146554e552abe94978eddc451ede2954fc59859ff6c34f7c1613c270e35),+    Fp(0x2c1ef4c8ef911a32ee1cea96ee50922815a93afae282c149b7f24921d8d4a0fe),+    Fp(0x23869adb5876af5f29721a01deb5335bbdd8bc446d7bebcd32966e61c7ad12b3),+    Fp(0x2af88e261ca1217caccdf61ac128cb35f372cb64c6bed49de2ea4991a83e5559),+    Fp(0x1b5d76d6c03da588a257ecf10b3daaf6a40dcea8f7f097f180c9c434914cb08a),+    Fp(0x1c76daae2af0990fcfc6bd3d2f027c3afe599fc476202d0a37d08e8f023b6285),+    Fp(0x2f5893f6a6e2ef3d3bbb3577ca09d9f059e5b761f25218adb85ea92c8328797f),+    Fp(0x1a11a3dc16874116e894488c79ff537033278958606472301833029f73094c23),+    Fp(0x22b2a9a84c555a46ed9149261eac2db8cde06b75292c4777f7c9a6bd81c2000e),+    Fp(0x1f7201ee492876c172204d8f5e4ee22e6f6f98348d77c85b93398ca5a5e8bbaa),+    Fp(0x08e2edc6fbdc691f2512ee311910c8f8211eab318f4142dcf636c50cf6fdd861),+    Fp(0x173726c1c53a38abb250c6578359c6a4df0a181b9932230703df22f761e06616),+    Fp(0x2ffe9110497cdee27d1ed33019291435729a8410c1e2548989580351e3878456),+    Fp(0x02f1f99037148d41dad15fb86a6279d9e4fd5bd65a738f7f8de1001ed1cc4478),+    Fp(0x0a2c4dbf4da2980ef04af6cfb2e6f0a897d0126dc4eb15da86b3f413408e73c7),+    Fp(0x2970b9d63a8db9247913597bd93be23a14fa3c81edcfcf8d363cf0c61f2bc143),+    Fp(0x0400e59387ee438d69a2bf80aa738769de9a8b955210901a771ed118571f65c1),+    Fp(0x25be6a88f910a398bc614b938890be42dad6b1ac8ec6fe112a613b399eef6665),+    Fp(0x03ea4bdf101fd9344899d113fc1741fbad74ca8b334dc53a6b729a6a5fc89279),+    Fp(0x1047fad9b32efea09b218f282aa1c2dfd3077303195f57fc41418934d16f1c4f),+    Fp(0x0a8765e82791f0faf6ffcf3f7dde261ccc6aa4c2a2de1b55342174c08f0e99ac),+    Fp(0x2326fa25a0ebdced43fd78b1caa01bc4c6a1dde08c7df91df5898f39574e3d46),+    Fp(0x1b1a9c596960319532ab8d8ef1ccc26863c469e98f0e7f429dec33c3a37a4a02),+    Fp(0x3b298d20b11005609eaa5f9acf0a480936c068f6550ffea10c21ae5e15d6dcf4),+    Fp(0x15776a393f3d75ee488a42e8d5f26f94aaca4d924128005ea7c870bb617025f3),+    Fp(0x062e8dab4d237e8aac0cf2e2d173cedf70cecf5a6a12220e27d197845e9b8bff),+    Fp(0x00719d1b34cda84f510cc767022945e2f68588e8f5e42277292036c710a489b7),+    Fp(0x0f901761fa7e00162f1792c3e496c93af19e59a3cb7150c434bddbb672467d41),+    Fp(0x18f39bd02bcc22f43f769a14a7c3d54f88705c9760c58f3260264363487fe0c4),+    Fp(0x167608824f7f125fee60341f3c2f281fc25d04280d69a9bb082060d5bef32e60),+    Fp(0x2f9d3358af7e3bcfd8eaa88240f1c586a5bf90eaab88e7168ba0a876454c3de2),+    Fp(0x32ac45a37e1686ae18a69f252ba9c5136adc6096c706e318079d6a3febcf9e3b),+    Fp(0x2f8951ae3f289d7e113dcb80a1fa1bd8ebae53212e629d3355ccd0c322d7de32),+    Fp(0x33a9c0aa4190b15f92dce5f89ae2377c8673f2235a4efc40ef6dd647040a65fe),+    Fp(0x16dc7bbb45d732435378dd6ee7ee0e554f6712f07f43ad5d98e814d28ef68fc0),+    Fp(0x2859b4d0a15abff3a2dc781fdc4b935214b694d3a60b6d6106b016f2516b9ff7),+    Fp(0x291e7534b1ac0d4406761253e857b2179607c6dba3dc47ec32c27f4cf8384cb1),+    Fp(0x25cab0613937bf2c23ce32f9566f0613afcadfe206a9a1149bce91aef428bf67),+    Fp(0x05d75d4ba225bd59f3331b3d67b41c7b9dab05fef552102193119a37cf39651d),+    Fp(0x08f1ac492aeaeb4097fd3b925c1cb260dd1b0de49f51890f6c4280c5c8fffdb2),+    Fp(0x1930f19bb3162224797e85bde05fbe51fb0fb9498581ea286d420f57bbac4a5c),+    Fp(0x30976bf9c5ba0385aacfabdf761ac8dbe36b4db7d6d3cf54bf01921c50187dad),+    Fp(0x24565e3c889e675e3d0bcdfaa7bce677dfecea8651ec61a4c750da24f2957c5d),+    Fp(0x1b4963d6634d1aa4e94f3558cc6ef85b0ebb63d1313e6f414c0688bb35b4a84d),+    Fp(0x11c6317226ebefe1861b3c281de88796102a81c5275019fed8b855e1fec7601c),+    Fp(0x31e4caa72b128088d729b7ac24f75e3efdd4494111f52a2fe03f84aa7a812b35),+    Fp(0x28f0c2c9dc75d8595d3d0534c8f653c59d78c4f1d61a6d01f79600fa0211a509),+    Fp(0x2d2ed9e6560537731793ba72151ed438c589d66d722f11179c6f63ff9ba1a43d),+    Fp(0x2d82d12d5502c57ef739aa08c19863ec2e8d9047e90b4a36db9885982dec47a0),+    Fp(0x37ca663122f8f8c3a37b3550d9e209e01695e6fe0408ed4c37e04c1235607016),+    Fp(0x23aea613927e92f3fdaa11f448aa594e9e41f1f98fdd90e8752299919a064262),+    Fp(0x35a32d064403f6c210a8afcd345d4e1224e6f95457b7ea81ef5f02a7ddca9494),+    Fp(0x10dd3772c90dfb82066fe616175cbc524dd89298011e50963a1c403f537409db),+    Fp(0x16888fc7306379753b28c52902a5dee5f477c341db2de6a33e11d8aeb0ace075),+    Fp(0x157487d36ab5b7c6198597efa84f66ef6ec597050032a368f561d150c7313263),+    Fp(0x09db68595b17923ba8a23d8903f5c74509625055fe9bcb616227c476ee639d21),+    Fp(0x268093fe30f176392b15441318708c596d785da591fe71044f6bb0bb740131bf),+    Fp(0x2bcdbeb28b4ace35527bcdc578eec161c123c2bcf66eae255f531cd376953963),+    Fp(0x15fb7e0badca6d8712d1af8b0008b7bafbe39694bb5bb4e4de6192fa1a7457e0),+    Fp(0x17bc5b91ab0d42c97986e17f662463d094299bb9637561d9b972bf424ec6a34d),+    Fp(0x28ba3b752ddd1219fbad933f9509769ac5bfef2caf73a21bb906b04df55e3332),+    Fp(0x08c21be5da0797c93a9e9daf6c264cd477383c7661434bc7c2f3a5352ba0a6a6),+    Fp(0x1368f9ecd178721b5da1a907b0f3d71e200f12f522980391f20f0093dd5bfa1d),+    Fp(0x3964872808c60d5e11816d402f286afba6124eae232767d0aa338c8598170874),+    Fp(0x1980d8064cb2b4054394a51fe4399eabafe85e7ff4708b5a4719a8ea4c4d7c8b),+    Fp(0x17d3146dfdcc73a6e08468feea777763e92d094a07af1dc5a4dacee9bba18392),+    Fp(0x096dd2795c0238507f51a9768d9b1016c7ba5faf4b62466051929aaeaa1f059f),+    Fp(0x253d45b9f0ba5d8e51715eb65d213af10eda2f755fab8728905f76534b6e4d0b),+    Fp(0x0c43204d8daf1fcf7dfe6b82afaa9233659a2a33fe857c5b49d0fcad93df0814),+    Fp(0x1c896e0a96d7fd26fe24af6714ff5ac1da9d65a87f2627369164030f84f4f704),+    Fp(0x294086bc2cea0bc9d4789b02f826e55671927b6af97f22e6a7b9e18334de48b9),+    Fp(0x23e409c460e1df98f65ad1838207d9072085c987b907ed49669fabec34dfde7d),+    Fp(0x0474f59587e52aba53892fdc8946d032b7d6fac1e5483f42be71f83c2a4c3aa6),+    Fp(0x3cbaf27040837d2ea1dd59a9b58b11aaf86d966d85873a5ea2368fb2845c0058),+    Fp(0x363f69f61694ce239688c02475cdde1812532d7c27d865c20226357c51d8caa9),+    Fp(0x1a1906f6e6948159a14692c58aab7b8e2e9737617d4c6d77bd6d470d0b0eaba9),+    Fp(0x3f55112d29d0cd0a9ea3aae537dc9f49474dac9ea9413da7b13524a8891189e2),+    Fp(0x35ac2c37ec045706ba15b5947c45bda8f438b525608ac8bba02dd7168474ccde),+    Fp(0x0c7687e1da1a9ab943d4a724cc4def7f7825dc7a2f52dffe6b8b23f394c331eb),+    Fp(0x05e98545421d5e7675d54080f03e1f99afca04fee1d626b4057584c00e3821cb),+    Fp(0x2e0b8eaafcab9b619a0ee226784693fb926285b86c63187cd9b78df979c137ac),+    Fp(0x05c76e8712141f4a273c7823c42dccc2d35b9e4fa3999a6a9607aa13ed44daf0),+    Fp(0x2fa7be72d0672174ea06940be2c634d63a17a833b534d6fe8b2a481c56ba9c0c),+    Fp(0x0fb76439139350676499dfa370c128a81210de574d4c2fee6f7811f5054cdbde),+    Fp(0x25ad36d3824b9c3c8fa469f96a5c0dc1ebd3f4455a2436ce596e2345784f68d0),+    Fp(0x2ea618635d2a84e31019fef58cc70312876f6a03f6d14fc75c0232e3bcd86646),+    Fp(0x0a933a7699746381c04de2d48886b1b812868044b458cb5ad5f176c628464f21),+    Fp(0x1fc6239cbbc29822338b6074929322b406edf6fcefd1348143131baccc08b134),+    Fp(0x193c32e133cf528a86cb203712db7076337ffca197d02ef3b3a11859ee5fd06c),+    Fp(0x30d5c435da0e541f283675b526312a9c253c589f5e755dacfc21f04634ea4f51),+    Fp(0x1c13311054b300af3d1d960ab3bad127795c963c687d26faee16fd3a6ae75a8a),+    Fp(0x037af3e4d8a5d338195f1302cc689dc5d2475b375733cb1e319bef549efedc8f),+    Fp(0x061fc5d5b4e67dd100503e21915502159e7b7465656512c3ff11799a7caad0fa),+    Fp(0x2e9d62d787b4ddd9e520f78200eab0b1ee86b7455720c6192e4745475bb8d98d),+    Fp(0x260b46ed156d2ab096759a7078137f7d561257719b44b41f366422a8a9fed3f1),+    Fp(0x004686cfcd1f9f1f86f89d31140b9246966cc8c22a358012ce6e5ea49f6e3e60),+    Fp(0x332edeaa879008c6a6865ccdc93ddc30b58882d346b409a6bf4a0139570f5744),+    Fp(0x01ba4b76d0d08294a5546d21e7dfe47407fed94c329c0b11e6cbbc56a1cc0a00),+    Fp(0x2eac30427fcf4f551c2eed718f9949d5f8914a820dcc8548e6db8d3b60455b92),+    Fp(0x303c32bf49d73ea9bd95119666e4aa96fdd1cc8ba0e38bd02c3dba8195ee2eee),+    Fp(0x0e1cc1e02632ef1abb31810712c3fb08c94b0b3569cf7446cbd8e21b9841fb66),+    Fp(0x33051496b670bebaba4fc21b529556cb4ba2045e3347c6105cafdaf696e67e7e),+    Fp(0x0eaba3f40a2c53cd90a7f44431e217ea01e7572aca00e12465f908808b4202f0),+    Fp(0x0b01e425270ec4f3d4810b0395cd422ac96ed1a3c8eedc8c8b02bc51ec68a656),+    Fp(0x133f84bf2658613979ceca9514f5c4c3fe8448e7d92088c17ebcffa2b473a674),+    Fp(0x3cbdf49b42e4c2a512987260f2327ea02739e1e2db9a462a7fe1f95e8b8c3dd2),+    Fp(0x2d38b041fc5379cc67db3544a2bf6a17d63396b16af9a2ba30492c0982ebed07),+    Fp(0x3ae6480f450154a60be0da12998d3bdeadfcfee0c8fac2167c091bfb3d26dd25),+    Fp(0x01ace40f25423f2c2a7005641a6a1d2d3066e72bb10b457010579b58eac52105),+    Fp(0x1212fa565936b14ffea2b74ba21379ccb28ce22d6ad899932ef97c7899c68028),+    Fp(0x2166389a0e4e1f364627f44f183c91e19a0f302972d3b542faae23893d5f50fd),+    Fp(0x0ade42a791fef5cf2c386d2df993e84538576cf565d379e8a3be16b562d755c2)+]
]
assert len(ROUND_CONSTANTS) == (R_F + R_P) * t
therealyingtong

comment created time in a day

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+import numpy as np+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Number of full rounds+R_F = 8+# Number of partial rounds+R_P = 58+# Width+t = 3++def perm(input_words):+    R_f = int(R_F / 2)++    round_constants_counter = 0++    state_words = list(input_words)+    assert len(state_words) == t++    # First full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Middle partial rounds+    for r in range(0, R_P):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        state_words[0] = (state_words[0]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Last full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))+    +    return state_words++# Round constants generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+ROUND_CONSTANTS = [

I checked this.

therealyingtong

comment created time in a day

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+import numpy as np

Document this dependency in README.md.

therealyingtong

comment created time in a day

issue commentzcash/lightwalletd

Restore my wallet with the seeds and a balance does not appear

PROBLEM SOLVED

  • Enter my seeds
  • I clicked on "New Shielded Address" and "New Transparent Address" until the address to which I transferred appeared
  • I clicked on "rescue" and when I finished the last block my balance appeared.

I hope it helps you if you have the same problem!

Long live ZCASH ... Good day to all!

Cachari

comment created time in a day

issue openedzcash/lightwalletd

Restore my wallet with the seeds and a balance does not appear

I created two wallets, both of my property, I sent one to the other in t> z format .... the money came from my wallet A to B, I had my money in B, but I decided to reset the application with the seeds and to my surprise my balance was not restored, my balance appears at zero 0

In the file that appears in APPDATA called "zecwallet-light-wallet.debug.log" there appears the transaction registered and with a certain block

I recovered my wallet with version 1.6 and 1.3 and my balance does not appear, it is still at zero and I transferred 2.7 ZEC

I'm anguished, I feel that the money was lost and what a bad day that the first time I try zecwallet, this happens to me, I don't know what to do

This is the TIXD of the transaction you make https://blockchair.com/zcash/transaction/80fd2b6b827ddcd271d04e7c06cd1f48cfd6a3902412cd575e3164730525875a

I appreciate your help please, it is not fair that my money is lost. Thank you!

created time in a day

starteddefuse/php-encryption

started time in 2 days

starteddefuse/php-encryption

started time in 2 days

push eventzcash-hackworks/zcash-test-vectors

ying tong

commit sha bb16eca2c0acbbd1e744339ae1c8c4ed30f4c472

Only return first state element from Poseidon hash Co-authored-by: str4d <jack@z.cash>

view details

push time in 2 days

push eventzcash-hackworks/zcash-test-vectors

therealyingtong

commit sha c73aabd641b26988f00bd43b7c1562090fed7331

Add Orchard MerkleCRH

view details

Daira Hopwood

commit sha 5a820ad1130137df21b2650857339f456ea67925

Fix length of layer prefix in orchard_merkle_tree.py. Signed-off-by: Daira Hopwood <daira@jacaranda.org>

view details

ying tong

commit sha b2c074a8d1e10eeabe4e02a55eac549be48881a3

Merge pull request #21 from zcash-hackworks/orchard-merkle-crh Add Orchard MerkleCRH

view details

therealyingtong

commit sha 48fca9ad62b1d98a5d3fda6593a05a1d14b70bfb

Add Poseidon implementation

view details

therealyingtong

commit sha 99feaed0f41818eac33bee655bd5f85b29280266

Render array of bytearrays in tv_output

view details

therealyingtong

commit sha 6184981ccd34242c092726f7379e048ed5d0ba08

Generate Poseidon perm test vectors

view details

therealyingtong

commit sha 25f5ccd445bea87d896b078f32d3eeee5026a402

Generate Poseidon hash test vectors

view details

push time in 2 days

push eventzcash-hackworks/zcash-test-vectors

ying tong

commit sha 82c8e8f79980b93e0218ea7ce59d270ceeb0bbcf

Only return first state element from Poseidon hash Co-authored-by: str4d <jack@z.cash>

view details

push time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+from orchard_poseidon import perm+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Initial capacity element+CAPACITY_ELEMENT = Fp(1 << 65)++def poseidon_hash(x, y):+    assert isinstance(x, Fp)+    assert isinstance(y, Fp)+    return perm([x, y, CAPACITY_ELEMENT])

The hash function only returns the first element of the state:

    return perm([x, y, CAPACITY_ELEMENT])[0]
therealyingtong

comment created time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+from orchard_poseidon import perm+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Initial capacity element+CAPACITY_ELEMENT = Fp(1 << 65)++def poseidon_hash(x, y):+    assert isinstance(x, Fp)+    assert isinstance(y, Fp)+    return perm([x, y, CAPACITY_ELEMENT])++def main():+    test_vectors = [[Fp.ZERO, Fp(1)]]++    from random import Random+    rng = Random(0xabad533d)+    def randbytes(l):+        ret = []+        while len(ret) < l:+            ret.append(rng.randrange(0, 256))+        return bytes(ret)+    rand = Rand(randbytes)++    # Generate random test vectors+    for _ in range(10):+        test_vectors.append([+            Fp(leos2ip(rand.b(32))),+            Fp(leos2ip(rand.b(32))),+        ])++    render_tv(+        render_args(),+        'poseidon_hash',+        (+            ('input', '[[u8; 32]; 2]'),+            ('output', '[[u8; 32]; 3]'),+        ),+        [{+            'input': list(map(bytes, input)),+            'output': list(map(bytes, poseidon_hash(input[0], input[1]))),
            'output': bytes(poseidon_hash(input[0], input[1])),
therealyingtong

comment created time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+import numpy as np+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Number of full rounds+R_F = 8+# Number of partial rounds+R_P = 58+# Width+t = 3++def perm(input_words):+    R_f = int(R_F / 2)++    round_constants_counter = 0++    state_words = list(input_words)
    state_words = list(input_words)
    assert len(state_words) == t
therealyingtong

comment created time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+from orchard_poseidon import perm+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Initial capacity element+CAPACITY_ELEMENT = Fp(1 << 65)++def poseidon_hash(x, y):+    assert isinstance(x, Fp)+    assert isinstance(y, Fp)+    return perm([x, y, CAPACITY_ELEMENT])++def main():+    test_vectors = [[Fp.ZERO, Fp(1)]]++    from random import Random+    rng = Random(0xabad533d)+    def randbytes(l):+        ret = []+        while len(ret) < l:+            ret.append(rng.randrange(0, 256))+        return bytes(ret)+    rand = Rand(randbytes)++    # Generate random test vectors+    for _ in range(10):+        test_vectors.append([+            Fp(leos2ip(rand.b(32))),+            Fp(leos2ip(rand.b(32))),+        ])++    render_tv(+        render_args(),+        'poseidon_hash',+        (+            ('input', '[[u8; 32]; 2]'),+            ('output', '[[u8; 32]; 3]'),
            ('output', '[u8; 32]'),
therealyingtong

comment created time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+import numpy as np+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Number of full rounds+R_F = 8+# Number of partial rounds+R_P = 58+# Width+t = 3++def perm(input_words):+    R_f = int(R_F / 2)++    round_constants_counter = 0++    state_words = list(input_words)++    # First full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Middle partial rounds+    for r in range(0, R_P):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        state_words[0] = (state_words[0]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))++    # Last full rounds+    for r in range(0, R_f):+        # Round constants, nonlinear layer, matrix multiplication+        for i in range(0, t):+            state_words[i] = state_words[i] + ROUND_CONSTANTS[round_constants_counter]+            round_constants_counter += 1+        for i in range(0, t):+            state_words[i] = (state_words[i]).exp(5)+        state_words = list(np.array(MDS_MATRIX).dot(np.array(state_words, dtype=object)))+    +    return state_words++# Round constants generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+ROUND_CONSTANTS = [+    Fp(0x2f2c2bfbd7070f5321f103387216cb9137df4021c68b5eef61904c0511b737a4),+    Fp(0x04ec2fc5c55d67746ccdd22b2bbdead13645b63b123b613afb311b7d0f35b058),+    Fp(0x3c624cfc4c994eb2fa9b924125223a7163e46dfb62f3522b6771be5f74ecb0b6),+    Fp(0x3476744a626a1813dd9b91a3d9031e29ccecd6c12a34927a5a936dc45b059511),+    Fp(0x3e8e3c1b8e9f1e1809d3b2dc9dc078894e4c8c3fdf34ea1a033e60bd7a63cf16),+    Fp(0x1439f41af8953e20247a437c362bba132af9c485bc73d98a4be1bb1b9efd907c),+    Fp(0x2184e123d6f4e5e9fea44f9f1ee27531af57eb3128f8662193ac3d2ca4ac6c7a),+    Fp(0x331019b909d6c87d8cc034f568aedbe1f8e05b9293c9b396a3eda4c816729416),+    Fp(0x00078b16de3fa3a0c6ec9cff8656ad7ed1eba2586b779d45a53f26c9a84fa24e),+    Fp(0x394f742117539cad1d44ff024f9f4e7a85782423cf7fd1305bc1b2926f39601e),+    Fp(0x261e237d617e261a6e65df293f2725e00311e30e0ba5c3008ed576fd4d43d779),+    Fp(0x252d1389b3aefdd233dccb6f7c448319857d2f7b4075d28b4513b401f48a3668),+    Fp(0x025ca9dda3db70df67bf7e430350923d38d635392451923af69df9e788a5fe24),+    Fp(0x1d2c2ace140ad5b617e517edd753f0b18d152f5c95421ab6c18c127223501f93),+    Fp(0x0ba495c1f7b77dbf654c7abd86a684434079eb21f42e4af06768c8403f50ac2c),+    Fp(0x2cbce44950324cba5bb2f8664192273205f15752efc3ebe1d8af60702eef9e28),+    Fp(0x24767e0d3abf426d95e4242db16d3a33fe5e302a8a71c31c671afb22aeae9d14),+    Fp(0x1acd6ef0e60e4b14146d53fcc83aea81b8a971e0ba9daab50d928670de2a3031),+    Fp(0x340f94d400bd0a3119942055672d627da17e77a8a72e7eedcc1c86114da6a1eb),+    Fp(0x0327373cca3dd2f8d60711e33e0c6b82472c8da29209c94dd51e2326061e22c0),+    Fp(0x1d1041d82c9d480f17c2d6ae049061e939ee18190c5c20805fdb2ffcf0161350),+    Fp(0x0de4750f968b5257895e8c73611059f8b7d135501d3d911f51bc31436ab5a574),+    Fp(0x359290a3786196bbc7fc9a99c916ccba11454b0cd0eb7d3fb2414383ee1a5794),+    Fp(0x28ffcdddf417cbabba580e1453f3094ddd4460b67aef036418c20b5cec2e8036),+    Fp(0x0e76c3df688ed3f5de99a4e4dcc1308486010174246d3c89322d2c6afaab6a00),+    Fp(0x172ca76af974367abde18a6b3a19c2ef7c42ac6e80e97c5b78922912d57f57c7),+    Fp(0x12ed4668b1543521662601e168f1a7aa8951a8407b00fd3f9b64fa4dc692195f),+    Fp(0x0c2ea06a9894cea56fd7211f8354d5092f614f7bcf8232ef90f2a829e538d398),+    Fp(0x0faea60318136b64e54759689b038ae3b55d8ea1305494517c7fea109bb09622),+    Fp(0x1beaeb465cd4c711b93eebf4dd9a414f1e7b90098c78a371287bfe86a1e66b27),+    Fp(0x351c94b9bcca5b1a2c2b06ede8114d463b6f7bdd6b37dd97a81add76cd42a4e3),+    Fp(0x2a1838fac1749e4fe68f84dcf259a459bb6ed62b92328294dcfc4ebaa75a4d92),+    Fp(0x3f875c2cd7e1d69ea4f88c06ea9c2ab893418cf02a66ea98cd230bfae2f670fb),+    Fp(0x31224a3412529b86145fe811a3fc44860ddd35b287fdc7986ce237b7c99f07a1),+    Fp(0x1556b2b9633ae623b42a1119bfbae23e0d6ee24b4e39c55c615b6db29fd9314e),+    Fp(0x399bacd8f54ccc4d1ce8ca1c71e5fb346aff3ab03e93551975225cd9ed99f2c2),+    Fp(0x389877368a5c321ea02d7dabc1444ad131c43e3ad4d20ebaf2f0997bbbaf80e3),+    Fp(0x0ef32660742991bbc6d17e9a4132067f6f78fa39361a74ccaebc66a50a73b506),+    Fp(0x1e491a5fdda824e26eb3d15a465c9221fb7a99f01266cbe86d97adb2c1139c94),+    Fp(0x2de4d6ff6ff2634b6ae7ab72cc34eb48c6ad0f62f31397e8a07d60fafe7f0aa7),+    Fp(0x1283a38005b8f0a7f2a5b56138dd2a5bbf319eac78d2c93506dbddfcdba52766),+    Fp(0x19e2efea5020aa4be092ca71681d8050b3c91a960025c6acdf23b7b398f061b6),+    Fp(0x287fb567ece35108f55719af51c11b6b610968a14a94ce030b7f48248fec885d),+    Fp(0x2761ea586e5d500d5202d4483f10d32a587f25e1e974432d59800355f507bb83),+    Fp(0x2f77d7a4f74db35eaf18b1bd8786f740f85d793979ae02c46d529cb31dff100e),+    Fp(0x0390862d7e6e7a690d4a5e120b9dc8f13200eb324f5d7c33d34b68245ebf1dc2),+    Fp(0x14d5b21da4b45c808c2a51c11a9cc97fd5196ea5d70bbdb6352e4174565c5a52),+    Fp(0x2974ad78ec5d90fbd088112a178403a1acb796e31fc8737f3f8566c9d7d1e755),+    Fp(0x36b58f7052adcc1fa3a1c290f0b04b7a28b413c7a3bb7e68ffb53b785334ee3c),+    Fp(0x2efb0a9efd6c60a1aeb870093f64363919c4993eb1fd95ae97159cc8a97339c2),+    Fp(0x1f04ae7df249c70c3f19a23c72a2a102d1528ff7aa4bb02229b61e805c98c1ff),+    Fp(0x278d44fe8f8c299659642e54f819858991fd0d3b8c617d8a1363315c4d8e0cb0),+    Fp(0x1a2bbd022168061c49b45714ae1b0f6a6ded5b7f8cefc2a2e3344dc1c1592406),+    Fp(0x0f0de2f73193a97edf8a91de8e688793f93cb4ed2236639813ebf947a3559f9c),+    Fp(0x3ac47dc248f16ac55092c3d232a09399b76cd699d0b30adf0072ef68ea438f92),+    Fp(0x1f7f927daef5fc95f4a0c96759812f90002c2347a222043cb3c779653e34a054),+    Fp(0x250b4faf86d72618e6e3cd02b1adcb7c945c315ce93dfc00c0b179e1cc950b85),+    Fp(0x07c64646dee2604b62528967df12153f7288bcc4fab6750d65d20118981ade0e),+    Fp(0x24cbbd234c0ef70078fa143ca1158bbba05c8ca1dd7132efee93af96dbadff1d),+    Fp(0x208edf94ef339a27fdbbf3cc08b7adecc5362d39b6348ecc54bb4e6cf7fa521b),+    Fp(0x3ea2a73f40f1f3d20a589d3d2c4d14dbf45f11963d6c1806f96c7fd82a46da35),+    Fp(0x36ccb8567075d3a0771bb857f4c51f58e79cb26ff91b9be15973a73ea2752c7a),+    Fp(0x08654b649a5091baa9cdf91ce7f831473adc95de617cfa32fc8681d17000408c),+    Fp(0x2b58a76bcbfb8500f28b308ee52a8e0ea5fac865c5b6ee7da9898bed507f18ea),+    Fp(0x1001d34a284e2b254614b66105ccb699e2ed8f2533be8e737d15896225d59a2e),+    Fp(0x13375ab0b5350afb2f1e63d230afa70c2a61dece93b1651c9c4286cc6354bc9c),+    Fp(0x2a7169d46ff2ffbaec72491a04c64702ac5b9ccb5216abda5622b222a0f0aacb),+    Fp(0x033eb55bedfd6b29986094724c1852f651d214174045e6fc55eace8b62101ae0),+    Fp(0x10ca1ffa20260f4019e31226ee751c71795c7f74d5d1c53b5ec053879568fad1),+    Fp(0x06c1da78f2f5f0fde46172c42bbc83e3495d5082cf47489df1f0980430bd6854),+    Fp(0x1ae9bf0085d1a2b7fdd8999c542447243b4e83b509a3975cf74a4bab5a21c53f),+    Fp(0x368599e0cc709b2d07542c631e002e81d38be406010a91c1cbdbeb71eec5383c),+    Fp(0x02e79429cc4d4a362e02d60c365dcb49898f32679397244222788138e9584f32),+    Fp(0x18c541e9d2751b8000d3998ad9c220db4a4315eb87d99b67a0a82bd61d49d14d),+    Fp(0x197507d5e313e2e3b49b9fb54a89a586447443b5f9d9292b01c9bf579600678e),+    Fp(0x26b1bd92ee8931886696164e25e700926f470f7041be91abbffc4f5fddbdc07f),+    Fp(0x0efdb615f564ee4698d8f8f44deaed092681d0a23a4577724d8cad71a7e5fdbe),+    Fp(0x266a5dddc5f832887a71bdbe32594a48ac9f2bccf1fa8d4368144a5fc771da1c),+    Fp(0x34f356e3badb42d5e17d8e2df0917f29b575fb420a344f56b32a9caaf6168330),+    Fp(0x2fa9ad6f882f66ccddd716c5b3f04c48f138f015bc0d0d5a258b3a63f45ebcaf),+    Fp(0x210b633386cdd22784f4fc53939bed4d7350958aac95be44b2ab8c35890dcd99),+    Fp(0x34dc0f069165b00e4e80ab1639afaf610937f9d6cf91437dd6a56d62f6ad9eb3),+    Fp(0x259b4cb0b0861d0782d0614ae013d8c7913fa6f411c7dc733326b0455cf8778c),+    Fp(0x0f88d8b6c5d9073dc660788b3e78bd62315abaf489d41b29a7d0770ead395746),+    Fp(0x30abd11ecb73119f5baef3db5d9337853282e45af42d83c72084d439504c1fc6),+    Fp(0x3152ce325264529cf302af09d5baec045efc980abba7cc3363a18839c6f6446f),+    Fp(0x00bd3146554e552abe94978eddc451ede2954fc59859ff6c34f7c1613c270e35),+    Fp(0x2c1ef4c8ef911a32ee1cea96ee50922815a93afae282c149b7f24921d8d4a0fe),+    Fp(0x23869adb5876af5f29721a01deb5335bbdd8bc446d7bebcd32966e61c7ad12b3),+    Fp(0x2af88e261ca1217caccdf61ac128cb35f372cb64c6bed49de2ea4991a83e5559),+    Fp(0x1b5d76d6c03da588a257ecf10b3daaf6a40dcea8f7f097f180c9c434914cb08a),+    Fp(0x1c76daae2af0990fcfc6bd3d2f027c3afe599fc476202d0a37d08e8f023b6285),+    Fp(0x2f5893f6a6e2ef3d3bbb3577ca09d9f059e5b761f25218adb85ea92c8328797f),+    Fp(0x1a11a3dc16874116e894488c79ff537033278958606472301833029f73094c23),+    Fp(0x22b2a9a84c555a46ed9149261eac2db8cde06b75292c4777f7c9a6bd81c2000e),+    Fp(0x1f7201ee492876c172204d8f5e4ee22e6f6f98348d77c85b93398ca5a5e8bbaa),+    Fp(0x08e2edc6fbdc691f2512ee311910c8f8211eab318f4142dcf636c50cf6fdd861),+    Fp(0x173726c1c53a38abb250c6578359c6a4df0a181b9932230703df22f761e06616),+    Fp(0x2ffe9110497cdee27d1ed33019291435729a8410c1e2548989580351e3878456),+    Fp(0x02f1f99037148d41dad15fb86a6279d9e4fd5bd65a738f7f8de1001ed1cc4478),+    Fp(0x0a2c4dbf4da2980ef04af6cfb2e6f0a897d0126dc4eb15da86b3f413408e73c7),+    Fp(0x2970b9d63a8db9247913597bd93be23a14fa3c81edcfcf8d363cf0c61f2bc143),+    Fp(0x0400e59387ee438d69a2bf80aa738769de9a8b955210901a771ed118571f65c1),+    Fp(0x25be6a88f910a398bc614b938890be42dad6b1ac8ec6fe112a613b399eef6665),+    Fp(0x03ea4bdf101fd9344899d113fc1741fbad74ca8b334dc53a6b729a6a5fc89279),+    Fp(0x1047fad9b32efea09b218f282aa1c2dfd3077303195f57fc41418934d16f1c4f),+    Fp(0x0a8765e82791f0faf6ffcf3f7dde261ccc6aa4c2a2de1b55342174c08f0e99ac),+    Fp(0x2326fa25a0ebdced43fd78b1caa01bc4c6a1dde08c7df91df5898f39574e3d46),+    Fp(0x1b1a9c596960319532ab8d8ef1ccc26863c469e98f0e7f429dec33c3a37a4a02),+    Fp(0x3b298d20b11005609eaa5f9acf0a480936c068f6550ffea10c21ae5e15d6dcf4),+    Fp(0x15776a393f3d75ee488a42e8d5f26f94aaca4d924128005ea7c870bb617025f3),+    Fp(0x062e8dab4d237e8aac0cf2e2d173cedf70cecf5a6a12220e27d197845e9b8bff),+    Fp(0x00719d1b34cda84f510cc767022945e2f68588e8f5e42277292036c710a489b7),+    Fp(0x0f901761fa7e00162f1792c3e496c93af19e59a3cb7150c434bddbb672467d41),+    Fp(0x18f39bd02bcc22f43f769a14a7c3d54f88705c9760c58f3260264363487fe0c4),+    Fp(0x167608824f7f125fee60341f3c2f281fc25d04280d69a9bb082060d5bef32e60),+    Fp(0x2f9d3358af7e3bcfd8eaa88240f1c586a5bf90eaab88e7168ba0a876454c3de2),+    Fp(0x32ac45a37e1686ae18a69f252ba9c5136adc6096c706e318079d6a3febcf9e3b),+    Fp(0x2f8951ae3f289d7e113dcb80a1fa1bd8ebae53212e629d3355ccd0c322d7de32),+    Fp(0x33a9c0aa4190b15f92dce5f89ae2377c8673f2235a4efc40ef6dd647040a65fe),+    Fp(0x16dc7bbb45d732435378dd6ee7ee0e554f6712f07f43ad5d98e814d28ef68fc0),+    Fp(0x2859b4d0a15abff3a2dc781fdc4b935214b694d3a60b6d6106b016f2516b9ff7),+    Fp(0x291e7534b1ac0d4406761253e857b2179607c6dba3dc47ec32c27f4cf8384cb1),+    Fp(0x25cab0613937bf2c23ce32f9566f0613afcadfe206a9a1149bce91aef428bf67),+    Fp(0x05d75d4ba225bd59f3331b3d67b41c7b9dab05fef552102193119a37cf39651d),+    Fp(0x08f1ac492aeaeb4097fd3b925c1cb260dd1b0de49f51890f6c4280c5c8fffdb2),+    Fp(0x1930f19bb3162224797e85bde05fbe51fb0fb9498581ea286d420f57bbac4a5c),+    Fp(0x30976bf9c5ba0385aacfabdf761ac8dbe36b4db7d6d3cf54bf01921c50187dad),+    Fp(0x24565e3c889e675e3d0bcdfaa7bce677dfecea8651ec61a4c750da24f2957c5d),+    Fp(0x1b4963d6634d1aa4e94f3558cc6ef85b0ebb63d1313e6f414c0688bb35b4a84d),+    Fp(0x11c6317226ebefe1861b3c281de88796102a81c5275019fed8b855e1fec7601c),+    Fp(0x31e4caa72b128088d729b7ac24f75e3efdd4494111f52a2fe03f84aa7a812b35),+    Fp(0x28f0c2c9dc75d8595d3d0534c8f653c59d78c4f1d61a6d01f79600fa0211a509),+    Fp(0x2d2ed9e6560537731793ba72151ed438c589d66d722f11179c6f63ff9ba1a43d),+    Fp(0x2d82d12d5502c57ef739aa08c19863ec2e8d9047e90b4a36db9885982dec47a0),+    Fp(0x37ca663122f8f8c3a37b3550d9e209e01695e6fe0408ed4c37e04c1235607016),+    Fp(0x23aea613927e92f3fdaa11f448aa594e9e41f1f98fdd90e8752299919a064262),+    Fp(0x35a32d064403f6c210a8afcd345d4e1224e6f95457b7ea81ef5f02a7ddca9494),+    Fp(0x10dd3772c90dfb82066fe616175cbc524dd89298011e50963a1c403f537409db),+    Fp(0x16888fc7306379753b28c52902a5dee5f477c341db2de6a33e11d8aeb0ace075),+    Fp(0x157487d36ab5b7c6198597efa84f66ef6ec597050032a368f561d150c7313263),+    Fp(0x09db68595b17923ba8a23d8903f5c74509625055fe9bcb616227c476ee639d21),+    Fp(0x268093fe30f176392b15441318708c596d785da591fe71044f6bb0bb740131bf),+    Fp(0x2bcdbeb28b4ace35527bcdc578eec161c123c2bcf66eae255f531cd376953963),+    Fp(0x15fb7e0badca6d8712d1af8b0008b7bafbe39694bb5bb4e4de6192fa1a7457e0),+    Fp(0x17bc5b91ab0d42c97986e17f662463d094299bb9637561d9b972bf424ec6a34d),+    Fp(0x28ba3b752ddd1219fbad933f9509769ac5bfef2caf73a21bb906b04df55e3332),+    Fp(0x08c21be5da0797c93a9e9daf6c264cd477383c7661434bc7c2f3a5352ba0a6a6),+    Fp(0x1368f9ecd178721b5da1a907b0f3d71e200f12f522980391f20f0093dd5bfa1d),+    Fp(0x3964872808c60d5e11816d402f286afba6124eae232767d0aa338c8598170874),+    Fp(0x1980d8064cb2b4054394a51fe4399eabafe85e7ff4708b5a4719a8ea4c4d7c8b),+    Fp(0x17d3146dfdcc73a6e08468feea777763e92d094a07af1dc5a4dacee9bba18392),+    Fp(0x096dd2795c0238507f51a9768d9b1016c7ba5faf4b62466051929aaeaa1f059f),+    Fp(0x253d45b9f0ba5d8e51715eb65d213af10eda2f755fab8728905f76534b6e4d0b),+    Fp(0x0c43204d8daf1fcf7dfe6b82afaa9233659a2a33fe857c5b49d0fcad93df0814),+    Fp(0x1c896e0a96d7fd26fe24af6714ff5ac1da9d65a87f2627369164030f84f4f704),+    Fp(0x294086bc2cea0bc9d4789b02f826e55671927b6af97f22e6a7b9e18334de48b9),+    Fp(0x23e409c460e1df98f65ad1838207d9072085c987b907ed49669fabec34dfde7d),+    Fp(0x0474f59587e52aba53892fdc8946d032b7d6fac1e5483f42be71f83c2a4c3aa6),+    Fp(0x3cbaf27040837d2ea1dd59a9b58b11aaf86d966d85873a5ea2368fb2845c0058),+    Fp(0x363f69f61694ce239688c02475cdde1812532d7c27d865c20226357c51d8caa9),+    Fp(0x1a1906f6e6948159a14692c58aab7b8e2e9737617d4c6d77bd6d470d0b0eaba9),+    Fp(0x3f55112d29d0cd0a9ea3aae537dc9f49474dac9ea9413da7b13524a8891189e2),+    Fp(0x35ac2c37ec045706ba15b5947c45bda8f438b525608ac8bba02dd7168474ccde),+    Fp(0x0c7687e1da1a9ab943d4a724cc4def7f7825dc7a2f52dffe6b8b23f394c331eb),+    Fp(0x05e98545421d5e7675d54080f03e1f99afca04fee1d626b4057584c00e3821cb),+    Fp(0x2e0b8eaafcab9b619a0ee226784693fb926285b86c63187cd9b78df979c137ac),+    Fp(0x05c76e8712141f4a273c7823c42dccc2d35b9e4fa3999a6a9607aa13ed44daf0),+    Fp(0x2fa7be72d0672174ea06940be2c634d63a17a833b534d6fe8b2a481c56ba9c0c),+    Fp(0x0fb76439139350676499dfa370c128a81210de574d4c2fee6f7811f5054cdbde),+    Fp(0x25ad36d3824b9c3c8fa469f96a5c0dc1ebd3f4455a2436ce596e2345784f68d0),+    Fp(0x2ea618635d2a84e31019fef58cc70312876f6a03f6d14fc75c0232e3bcd86646),+    Fp(0x0a933a7699746381c04de2d48886b1b812868044b458cb5ad5f176c628464f21),+    Fp(0x1fc6239cbbc29822338b6074929322b406edf6fcefd1348143131baccc08b134),+    Fp(0x193c32e133cf528a86cb203712db7076337ffca197d02ef3b3a11859ee5fd06c),+    Fp(0x30d5c435da0e541f283675b526312a9c253c589f5e755dacfc21f04634ea4f51),+    Fp(0x1c13311054b300af3d1d960ab3bad127795c963c687d26faee16fd3a6ae75a8a),+    Fp(0x037af3e4d8a5d338195f1302cc689dc5d2475b375733cb1e319bef549efedc8f),+    Fp(0x061fc5d5b4e67dd100503e21915502159e7b7465656512c3ff11799a7caad0fa),+    Fp(0x2e9d62d787b4ddd9e520f78200eab0b1ee86b7455720c6192e4745475bb8d98d),+    Fp(0x260b46ed156d2ab096759a7078137f7d561257719b44b41f366422a8a9fed3f1),+    Fp(0x004686cfcd1f9f1f86f89d31140b9246966cc8c22a358012ce6e5ea49f6e3e60),+    Fp(0x332edeaa879008c6a6865ccdc93ddc30b58882d346b409a6bf4a0139570f5744),+    Fp(0x01ba4b76d0d08294a5546d21e7dfe47407fed94c329c0b11e6cbbc56a1cc0a00),+    Fp(0x2eac30427fcf4f551c2eed718f9949d5f8914a820dcc8548e6db8d3b60455b92),+    Fp(0x303c32bf49d73ea9bd95119666e4aa96fdd1cc8ba0e38bd02c3dba8195ee2eee),+    Fp(0x0e1cc1e02632ef1abb31810712c3fb08c94b0b3569cf7446cbd8e21b9841fb66),+    Fp(0x33051496b670bebaba4fc21b529556cb4ba2045e3347c6105cafdaf696e67e7e),+    Fp(0x0eaba3f40a2c53cd90a7f44431e217ea01e7572aca00e12465f908808b4202f0),+    Fp(0x0b01e425270ec4f3d4810b0395cd422ac96ed1a3c8eedc8c8b02bc51ec68a656),+    Fp(0x133f84bf2658613979ceca9514f5c4c3fe8448e7d92088c17ebcffa2b473a674),+    Fp(0x3cbdf49b42e4c2a512987260f2327ea02739e1e2db9a462a7fe1f95e8b8c3dd2),+    Fp(0x2d38b041fc5379cc67db3544a2bf6a17d63396b16af9a2ba30492c0982ebed07),+    Fp(0x3ae6480f450154a60be0da12998d3bdeadfcfee0c8fac2167c091bfb3d26dd25),+    Fp(0x01ace40f25423f2c2a7005641a6a1d2d3066e72bb10b457010579b58eac52105),+    Fp(0x1212fa565936b14ffea2b74ba21379ccb28ce22d6ad899932ef97c7899c68028),+    Fp(0x2166389a0e4e1f364627f44f183c91e19a0f302972d3b542faae23893d5f50fd),+    Fp(0x0ade42a791fef5cf2c386d2df993e84538576cf565d379e8a3be16b562d755c2)+]++# MDS matrix generated by the reference implementation script, commit 659de89+# https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage+#+# $ sage generate_parameters_grain.sage 1 0 255 3 8 58 0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001+MDS_MATRIX = [+    [+        Fp(0x2cebbe1217e122842b2b44a0ae977970cec9f15275e151dd5480ad1404165bb7),+        Fp(0x3110b59ae4e814cf0aa4a254996d009a71a0a9a85c2faf79dc655cba595f6be2),+        Fp(0x12e2f0714a5cca1df6113fb1e6f9d58fccbd6da8a74dd18a6a7edd65fbe71f3a)+    ],+    [+        Fp(0x105843a552c0f9b98422eacaccb4e3cd1ef3c5b7712d8a4d60cfaae4ab4ac980),+        Fp(0x3ce87897c427fcea40080459729c0a350956b6541965fc7e853ad5ef4fc3c705),+        Fp(0x1d06d6ddc91585c68681544367a147943d473e48acfafc5a3185211502184691)+    ],+    [+        Fp(0x2e73a08701c0f7e906387e6a377030919e53df433c9b311dc9ced954a22540b2),+        Fp(0x3f250fa921f576983424f185565fe5b4b21eb75a1f46501c1240f8d2a183d3d5),+        Fp(0x2f37602cd4d8f52df318f9d0723be105989a59402f581c3eaa6315cf8d657550)+    ]+]++def main():++    # These are test vectors from https://github.com/daira/pasta-hadeshash/commit/cdab5252d0ec675780e9f8c3d09fdb7a0a71d3ff.+    fixed_test_input = [+        Fp(0x0000000000000000000000000000000000000000000000000000000000000000),+        Fp(0x0000000000000000000000000000000000000000000000000000000000000001),+        Fp(0x0000000000000000000000000000000000000000000000000000000000000002)+    ]+    fixed_test_output = [+        Fp(0x19a264dbf840aaeae2d33be07ee5db5c6ad21f3e05112d6e45860cdfc1224c90),+        Fp(0x11b823d66e94c285813686b6df10cf9931cc06bfdf6bd5fd3dc3ed1c3434091e),+        Fp(0x111104f41966d2ce68a635c3b4cbb608cbaa5caeabc596e3c5dc3d6d756ede28)+    ]++    assert perm(fixed_test_input) == fixed_test_output++    test_vectors = [fixed_test_input]++    from random import Random+    rng = Random(0xabad533d)+    def randbytes(l):+        ret = []+        while len(ret) < l:+            ret.append(rng.randrange(0, 256))+        return bytes(ret)+    rand = Rand(randbytes)++    # Generate random test vectors+    for _ in range(10):+        test_vectors.append([+            Fp(leos2ip(rand.b(32))),+            Fp(leos2ip(rand.b(32))),+            Fp(leos2ip(rand.b(32)))+        ])++    render_tv(+        render_args(),+        'poseidon_perm',
        'orchard_poseidon',
therealyingtong

comment created time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Poseidon implementation

+from orchard_pallas import Fp+from orchard_poseidon import perm+from sapling_utils import leos2ip+from tv_output import render_args, render_tv+from tv_rand import Rand++# Initial capacity element+CAPACITY_ELEMENT = Fp(1 << 65)++def poseidon_hash(x, y):+    assert isinstance(x, Fp)+    assert isinstance(y, Fp)+    return perm([x, y, CAPACITY_ELEMENT])++def main():+    test_vectors = [[Fp.ZERO, Fp(1)]]++    from random import Random+    rng = Random(0xabad533d)+    def randbytes(l):+        ret = []+        while len(ret) < l:+            ret.append(rng.randrange(0, 256))+        return bytes(ret)+    rand = Rand(randbytes)++    # Generate random test vectors+    for _ in range(10):+        test_vectors.append([+            Fp(leos2ip(rand.b(32))),+            Fp(leos2ip(rand.b(32))),+        ])++    render_tv(+        render_args(),+        'poseidon_hash',

This is used in a comment; it should be the filename.

        'orchard_poseidon_hash',
therealyingtong

comment created time in 2 days

push eventzcash-hackworks/zcash-test-vectors

therealyingtong

commit sha fc6be99566388b74392874183b3661655f610e90

Generate Poseidon hash test vectors

view details

push time in 2 days

push eventzcash-hackworks/zcash-test-vectors

therealyingtong

commit sha e2ea275be7dbaa79cc5aa0e82849cdcf4e2ca941

Render array of bytearrays in tv_output

view details

therealyingtong

commit sha 8d62eb6e6546328a80ca8918e929395cce8a323f

Generate Poseidon perm test vectors

view details

therealyingtong

commit sha 1b9c9953d4b12be23dae1c987026e6ba3467409f

Generate Poseidon hash test vectors

view details

push time in 2 days

push eventzcash-hackworks/zcash-test-vectors

ying tong

commit sha 56f552cf807ec49f763f9374e9a66240eae8d641

Pass rand instead of randbytes Co-authored-by: str4d <jack@z.cash>

view details

push time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Add Orchard commitments

+#!/usr/bin/env python3+import sys; assert sys.version_info[0] >= 3, "Python 3 required."++from orchard_group_hash import group_hash+from orchard_pallas import Fp, Scalar+from orchard_sinsemilla import sinsemilla_hash_to_point+from utils import i2lebsp++# Commitment schemes used in Orchard https://zips.z.cash/protocol/nu5.pdf#concretecommit++# https://zips.z.cash/protocol/nu5.pdf#constants+L_ORCHARD_BASE = 255++# https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit+def homomorphic_pedersen_commitment(rcv: Scalar, D, v: Scalar):+    return group_hash(D, b"v") * v + group_hash(D, b"r") * rcv++def value_commit(rcv: Scalar, v: Scalar):+    return homomorphic_pedersen_commitment(rcv, b"z.cash:Orchard-cv", v)++def rcv_trapdoor(randbytes):+    return Scalar.random(randbytes)++# https://zips.z.cash/protocol/nu5.pdf#concretesinsemillacommit+def sinsemilla_commit(r: Scalar, D, M):+    assert isinstance(r, Scalar)+    return sinsemilla_hash_to_point(D + b"-M", M).checked_incomplete_add(+        group_hash(D + b"-r", b"") * r+    )++def sinsemilla_short_commit(r: Scalar, D, M):+    return sinsemilla_commit(r, D, M).extract()++# https://zips.z.cash/protocol/nu5.pdf#concreteorchardnotecommit+def note_commit(rcm, g_d, pk_d, v, rho, psi):+    return sinsemilla_commit(+        rcm,+        b"z.cash: Orchard-NoteCommit",+        g_d + pk_d + i2lebsp(64, v) + i2lebsp(L_ORCHARD_BASE, rho.s) + i2lebsp(L_ORCHARD_BASE, psi.s)+    )++def rcm_trapdoor(randbytes):+    return Scalar.random(randbytes)++# https://zips.z.cash/protocol/nu5.pdf#concreteorchardnotecommit+def commit_ivk(rivk: Scalar, ak: Fp, nk: Fp):+    return Scalar(sinsemilla_short_commit(+        rivk,+        b"z.cash: Orchard-CommitIvk",+        i2lebsp(L_ORCHARD_BASE, ak.s) + i2lebsp(L_ORCHARD_BASE, nk.s)+    ).s)++def rivk_trapdoor(randbytes):+    return Scalar.random(randbytes)++# Test consistency of ValueCommit^{Orchard} with precomputed generators+def test_value_commit():+    from random import Random+    from orchard_generators import VALUE_COMMITMENT_RANDOMNESS_BASE, VALUE_COMMITMENT_VALUE_BASE++    rng = Random(0xabad533d)+    def randbytes(l):+        ret = []+        while len(ret) < l:+            ret.append(rng.randrange(0, 256))+        return bytes(ret)++    rcv = rcv_trapdoor(randbytes)
    rcv = rcv_trapdoor(rand)
therealyingtong

comment created time in 2 days

Pull request review commentzcash-hackworks/zcash-test-vectors

Add Orchard commitments

+#!/usr/bin/env python3+import sys; assert sys.version_info[0] >= 3, "Python 3 required."++from orchard_group_hash import group_hash+from orchard_pallas import Fp, Scalar+from orchard_sinsemilla import sinsemilla_hash_to_point+from utils import i2lebsp++# Commitment schemes used in Orchard https://zips.z.cash/protocol/nu5.pdf#concretecommit++# https://zips.z.cash/protocol/nu5.pdf#constants+L_ORCHARD_BASE = 255++# https://zips.z.cash/protocol/nu5.pdf#concretehomomorphiccommit+def homomorphic_pedersen_commitment(rcv: Scalar, D, v: Scalar):+    return group_hash(D, b"v") * v + group_hash(D, b"r") * rcv++def value_commit(rcv: Scalar, v: Scalar):+    return homomorphic_pedersen_commitment(rcv, b"z.cash:Orchard-cv", v)++def rcv_trapdoor(randbytes):+    return Scalar.random(randbytes)++# https://zips.z.cash/protocol/nu5.pdf#concretesinsemillacommit+def sinsemilla_commit(r: Scalar, D, M):+    assert isinstance(r, Scalar)+    return sinsemilla_hash_to_point(D + b"-M", M).checked_incomplete_add(+        group_hash(D + b"-r", b"") * r+    )++def sinsemilla_short_commit(r: Scalar, D, M):+    return sinsemilla_commit(r, D, M).extract()++# https://zips.z.cash/protocol/nu5.pdf#concreteorchardnotecommit+def note_commit(rcm, g_d, pk_d, v, rho, psi):+    return sinsemilla_commit(+        rcm,+        b"z.cash: Orchard-NoteCommit",+        g_d + pk_d + i2lebsp(64, v) + i2lebsp(L_ORCHARD_BASE, rho.s) + i2lebsp(L_ORCHARD_BASE, psi.s)+    )++def rcm_trapdoor(randbytes):+    return Scalar.random(randbytes)
def rcm_trapdoor(rand):
    return Scalar.random(rand)
therealyingtong

comment created time in 2 days