├── .gitignore ├── COPYRIGHT ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── README_zh.md ├── compute.sh ├── participants.md └── src └── bin ├── beacon.rs ├── compute.rs ├── new.rs ├── split_params.rs ├── verify.rs └── verify_transform.rs /.gitignore: -------------------------------------------------------------------------------- 1 | phase1* 2 | params 3 | /target/ 4 | **/*.rs.bk 5 | params 6 | new_params 7 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyrights in the "sapling-mpc" library are retained by their contributors. No 2 | copyright assignment is required to contribute to the "sapling-mpc" library. 3 | 4 | The "sapling-mpc" library is licensed under either of 5 | 6 | * Apache License, Version 2.0, (see ./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) 7 | * MIT license (see ./LICENSE-MIT or http://opensource.org/licenses/MIT) 8 | 9 | at your option. 10 | 11 | Unless you explicitly state otherwise, any contribution intentionally 12 | submitted for inclusion in the work by you, as defined in the Apache-2.0 13 | license, shall be dual licensed as above, without any additional terms or 14 | conditions. 15 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "arrayvec" 5 | version = "0.4.7" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | dependencies = [ 8 | "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", 9 | ] 10 | 11 | [[package]] 12 | name = "bellman" 13 | version = "0.1.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | dependencies = [ 16 | "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 17 | "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 18 | "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 19 | "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", 20 | "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 21 | "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 22 | "pairing 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", 23 | "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 24 | ] 25 | 26 | [[package]] 27 | name = "bit-vec" 28 | version = "0.4.4" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | 31 | [[package]] 32 | name = "bitflags" 33 | version = "1.0.3" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | 36 | [[package]] 37 | name = "blake2-rfc" 38 | version = "0.2.18" 39 | source = "git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9#7a5b5fc99ae483a0043db7547fb79a6fa44b88a9" 40 | dependencies = [ 41 | "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", 42 | "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 43 | "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 44 | ] 45 | 46 | [[package]] 47 | name = "blake2-rfc" 48 | version = "0.2.18" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | dependencies = [ 51 | "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", 52 | "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 53 | ] 54 | 55 | [[package]] 56 | name = "byteorder" 57 | version = "1.2.3" 58 | source = "registry+https://github.com/rust-lang/crates.io-index" 59 | 60 | [[package]] 61 | name = "constant_time_eq" 62 | version = "0.1.3" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | 65 | [[package]] 66 | name = "crossbeam" 67 | version = "0.3.2" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | 70 | [[package]] 71 | name = "digest" 72 | version = "0.7.2" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | dependencies = [ 75 | "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 76 | ] 77 | 78 | [[package]] 79 | name = "fuchsia-zircon" 80 | version = "0.3.3" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | dependencies = [ 83 | "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 84 | "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 85 | ] 86 | 87 | [[package]] 88 | name = "fuchsia-zircon-sys" 89 | version = "0.3.3" 90 | source = "registry+https://github.com/rust-lang/crates.io-index" 91 | 92 | [[package]] 93 | name = "futures" 94 | version = "0.1.21" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | 97 | [[package]] 98 | name = "futures-cpupool" 99 | version = "0.1.8" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | dependencies = [ 102 | "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", 103 | "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 104 | ] 105 | 106 | [[package]] 107 | name = "generic-array" 108 | version = "0.9.0" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | dependencies = [ 111 | "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 112 | ] 113 | 114 | [[package]] 115 | name = "hex-literal" 116 | version = "0.1.1" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | dependencies = [ 119 | "hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 120 | "proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 121 | ] 122 | 123 | [[package]] 124 | name = "hex-literal-impl" 125 | version = "0.1.1" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | dependencies = [ 128 | "proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 129 | ] 130 | 131 | [[package]] 132 | name = "libc" 133 | version = "0.2.40" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | 136 | [[package]] 137 | name = "nodrop" 138 | version = "0.1.12" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | 141 | [[package]] 142 | name = "num_cpus" 143 | version = "1.8.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | dependencies = [ 146 | "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", 147 | ] 148 | 149 | [[package]] 150 | name = "pairing" 151 | version = "0.14.2" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | dependencies = [ 154 | "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 155 | "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 156 | ] 157 | 158 | [[package]] 159 | name = "phase2" 160 | version = "0.2.2" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | dependencies = [ 163 | "bellman 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 164 | "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", 165 | "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 166 | "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 167 | "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 168 | "pairing 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", 169 | "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 170 | ] 171 | 172 | [[package]] 173 | name = "proc-macro-hack" 174 | version = "0.4.0" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | dependencies = [ 177 | "proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 178 | ] 179 | 180 | [[package]] 181 | name = "proc-macro-hack-impl" 182 | version = "0.4.0" 183 | source = "registry+https://github.com/rust-lang/crates.io-index" 184 | 185 | [[package]] 186 | name = "rand" 187 | version = "0.4.2" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | dependencies = [ 190 | "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 191 | "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", 192 | "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", 193 | ] 194 | 195 | [[package]] 196 | name = "sapling-crypto" 197 | version = "0.0.1" 198 | source = "git+https://github.com/zcash-hackworks/sapling-crypto?rev=eb409fa3cf8df215ae8d35f5e385751a0c5ffb85#eb409fa3cf8df215ae8d35f5e385751a0c5ffb85" 199 | dependencies = [ 200 | "bellman 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 201 | "blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)", 202 | "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 203 | "digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", 204 | "pairing 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", 205 | "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 206 | ] 207 | 208 | [[package]] 209 | name = "sapling-mpc" 210 | version = "0.2.0" 211 | dependencies = [ 212 | "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", 213 | "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 214 | "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 215 | "pairing 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", 216 | "phase2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 217 | "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 218 | "sapling-crypto 0.0.1 (git+https://github.com/zcash-hackworks/sapling-crypto?rev=eb409fa3cf8df215ae8d35f5e385751a0c5ffb85)", 219 | ] 220 | 221 | [[package]] 222 | name = "typenum" 223 | version = "1.10.0" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | 226 | [[package]] 227 | name = "winapi" 228 | version = "0.3.4" 229 | source = "registry+https://github.com/rust-lang/crates.io-index" 230 | dependencies = [ 231 | "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 232 | "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 233 | ] 234 | 235 | [[package]] 236 | name = "winapi-i686-pc-windows-gnu" 237 | version = "0.4.0" 238 | source = "registry+https://github.com/rust-lang/crates.io-index" 239 | 240 | [[package]] 241 | name = "winapi-x86_64-pc-windows-gnu" 242 | version = "0.4.0" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | 245 | [metadata] 246 | "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" 247 | "checksum bellman 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eae372472c7ea8f7c8fc6a62f7d5535db8302de7f1aafda2e13a97c4830d3bcf" 248 | "checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" 249 | "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" 250 | "checksum blake2-rfc 0.2.18 (git+https://github.com/gtank/blake2-rfc?rev=7a5b5fc99ae483a0043db7547fb79a6fa44b88a9)" = "" 251 | "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" 252 | "checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9" 253 | "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" 254 | "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" 255 | "checksum digest 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00a49051fef47a72c9623101b19bd71924a45cca838826caae3eaa4d00772603" 256 | "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 257 | "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 258 | "checksum futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "1a70b146671de62ec8c8ed572219ca5d594d9b06c0b364d5e67b722fc559b48c" 259 | "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" 260 | "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" 261 | "checksum hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4da5f0e01bd8a71a224a4eedecaacfcabda388dbb7a80faf04d3514287572d95" 262 | "checksum hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d340b6514f232f6db1bd16db65302a5278a04fef9ce867cb932e7e5fa21130a" 263 | "checksum libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b" 264 | "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" 265 | "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" 266 | "checksum pairing 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ceda21136251c6d5a422d3d798d8ac22515a6e8d3521bb60c59a8349d36d0d57" 267 | "checksum phase2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "606ceb505d6e61f0dfbbc1cd1df498c3e58ad17001f06cb874c3324dd5700e77" 268 | "checksum proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ba8d4f9257b85eb6cdf13f055cea3190520aab1409ca2ab43493ea4820c25f0" 269 | "checksum proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5cb6f960ad471404618e9817c0e5d10b1ae74cfdf01fab89ea0641fe7fb2892" 270 | "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" 271 | "checksum sapling-crypto 0.0.1 (git+https://github.com/zcash-hackworks/sapling-crypto?rev=eb409fa3cf8df215ae8d35f5e385751a0c5ffb85)" = "" 272 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" 273 | "checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" 274 | "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 275 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 276 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sapling-mpc" 3 | version = "0.2.0" 4 | authors = ["Sean Bowe "] 5 | 6 | [[bin]] 7 | name = "new" 8 | required-features = ["verification"] 9 | 10 | [[bin]] 11 | name = "verify" 12 | required-features = ["verification"] 13 | 14 | [[bin]] 15 | name = "beacon" 16 | required-features = ["beacon"] 17 | 18 | [[bin]] 19 | name = "compute" 20 | 21 | [[bin]] 22 | name = "verify_transform" 23 | 24 | [[bin]] 25 | name = "split_params" 26 | 27 | [dependencies] 28 | phase2 = "0.2.1" 29 | pairing = "0.14" 30 | rand = "0.4" 31 | blake2-rfc = "0.2" 32 | rust-crypto = "0.2" 33 | 34 | [dependencies.byteorder] 35 | version = "1" 36 | optional = true 37 | 38 | [dependencies.sapling-crypto] 39 | git = "https://github.com/zcash-hackworks/sapling-crypto" 40 | rev = "eb409fa3cf8df215ae8d35f5e385751a0c5ffb85" 41 | optional = true 42 | 43 | [dependencies.hex-literal] 44 | version = "0.1" 45 | optional = true 46 | 47 | [features] 48 | verification = ["sapling-crypto"] 49 | u128-support = ["pairing/u128-support"] 50 | beacon = ["byteorder", "hex-literal"] 51 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mpc 2 | 3 | This document is a guide to participate in Multi-party Computation(MPC) phase 2 and verify the result. 4 | 5 | ## What should I do ? 6 | 7 | 1. Send an application email to tronz_mpc@tronz.io in order to participate in MPC. Please introduce yourself in the email and tell us your available time. For example: 8 | ``` 9 | Hi Tronz, 10 | 11 | I'm Brown Jiang, applying to participate in the MPC project. My available time is 2020-01-20 ~ 2020-01-22, 08:00~10:00, UTC+8. As a student of Peking University, I'm living in Beijing China now, focusing on Blockchain technology. 12 | 13 | Yours Faithfully, 14 | Brown Jiang 15 | ``` 16 | 2. TRONZ will send you an email about the time for you to participate in MPC. 17 | 18 | 3. When it is your turn, TRONZ will send you a notification email and give you a params file link which you will need to download. 19 | 20 | 4. Download and install IM tool [keybase](https://keybase.io/). If you don't have an account yet, create an account and add TRONZ's account as your friend. TRONZ's account is `tronz_mpc`. 21 | 22 | 5. Prepare your server. Recommended server requirements: 23 | + Processor (CPU): Intel Core i5 (sixth generation or newer) or equivalent 24 | + Operating System: Linux (Recommended) / macOS / Windows 7+ 25 | + Memory: 8 GB RAM 26 | + Storage: 4 GB free Disk storage 27 | 28 |   On Windows, please go to [rust](https://www.rust-lang.org/learn/get-started) homepage for installation instruction, then install [Microsoft Visual C++ Build Tools](http://go.microsoft.com/fwlink/?LinkId=691126); at last, jump to next step. 29 | 30 |   On Mac, install xcode command line tools first: 31 | ``` 32 | # xcode-select --install 33 | ``` 34 |   On Mac/Linux, Run the following code in your terminal to download Rustup and install Rust, then follow the instructions if you are running on macOS / Linux / another Unix-like OS: 35 | ``` 36 | # curl https://sh.rustup.rs -sSf | sh 37 | ``` 38 | and choose 1 when prompted. After installation, run: 39 | ``` 40 | # source $HOME/.cargo/env 41 | ``` 42 | 43 | 6. Obtain the source code of project `mpc`: 44 | ``` 45 | # git clone https://github.com/tronprotocol/mpc 46 | ``` 47 |   If git has not been installed on your computer, please download and install [git](https://git-scm.com/downloads) first. 48 | 49 | 7. In the `mpc` directory, download `params` file, then run: 50 | ``` 51 | # cargo run --release --bin compute 52 | ``` 53 | 54 |   When it’s finished, you will get a `new_params` file and a `hash` which you must need to record. You can find the `hash` and `new_params` as shown below: 55 | ![](https://raw.githubusercontent.com/tronprotocol/documentation-en/master/docs_without_index/internal-test/mpc-output.jpg) 56 | 57 |   Notice: this process could take 0.5 ~ 1 hours depending on your hardware capacity and occupy 1.5 ~ 2GB of memory. 58 | 59 | 8. Send your result to TRONZ. Please send the file `new_params` by keybase; send `hash` string by email, feel free to state your os version in email, E.g. windows 7/centos 7. 60 | 61 | ## Dependency 62 | We reuse the phase 2 result of zcash https://download.z.cash/sapling-mpc/params as the first `params` of the process. In the end of the process, we generate a random beacon by using one Bitcoin block's hash as the seed of pseudo random number generator. The block's height will not be determined until the last participant completes his operation. After we've verified all participants' contributions, we will publish all the hashes on project [wiki](https://github.com/tronprotocol/mpc/wiki) page. 63 | 64 | ## How to verify my contribution ? 65 | 66 | After all participants have finished the process, we will announce the final params at AWS. Anyone can verify their contribution as below : 67 | ``` 68 | # cd mpc 69 | # wget https://mpcfilepub.s3.amazonaws.com/mpc/params 70 | # wget https://mpcfilepub.s3.amazonaws.com/powersoftau/powersoftau_phase1_files.tar 71 | # tar xvf powersoftau_phase1_files.tar && cp powersoftau_phase1_files/* . 72 | # cargo run --release --features="verification" --bin verify 73 | ``` 74 | This verification may take about 1 hour to output all participants' contributions. Find whether your hash is on the list. 75 | 76 | ## License 77 | 78 | Licensed under either of 79 | 80 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 81 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 82 | 83 | at your option. 84 | 85 | ### Contribution 86 | 87 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. 88 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | # 多方计算 2 | 3 | 多方计算(Multi-party Computation,MPC)是创建匿名交易需要的公共参数的的第二步,本文档说明如何参与TRONZ组织的mpc以及如何验证最终公共参数。 4 | 5 | ## 如何参与 ? 6 | 7 | 1. 请发送邮件到tronz_mpc@tronz.io申请参与mpc,请简要介绍自己,并说明合适的参与时间。 8 | 9 | 2. TRONZ会回复邮件告知你参与mpc的时间点。 10 | 11 | 3. 当轮到你参与的时候,TRONZ给你发送一封通知邮件,包括你的序号和`params`文件的链接。 12 | 4. 下载并安装IM工具 [keybase](https://keybase.io/),如果你没有账户新建一个。有任何问题,请添加`tronz_mpc`为好友来解决。 13 | 5. 准备好你的服务器,推荐的最小硬件要求如下: 14 | + Processor (CPU): Intel Core i5 (第六代或以上) or equivalent 15 | + Operating System: Linux (推荐) / macOS / Windows 7+ 16 | + Memory: 8 GB RAM 17 | + Storage: 500 GB internal storage drive 18 | 19 |   如果你使用Windows系统,参考[rust](https://www.rust-lang.org/learn/get-started) 官方主页来安装。 20 | 21 |   如果你使用macOS系统, 请先安装xcode命令行工具: 22 | ``` 23 | # xcode-select --install 24 | ``` 25 | 6. 下载mpc项目的源码: 26 | ``` 27 | # git clone https://github.com/tronprotocol/mpc 28 | ``` 29 |   如果你还没有安装git环境,先安装 [git](https://git-scm.com/downloads). 30 | 31 | 7. 如果你的系统是macOS/Linux,打开终端切换到mpc目录下,运行以下命令,如有提示请选择1. 32 | ``` 33 | # sh compute.sh 34 | ``` 35 | 如果你的系统是Windows, 下载`params`文件放在mpc目录下,然后在该目录下执行以下命令: 36 | ``` 37 | # cargo run --release --bin compute 38 | ``` 39 |   当计算完成后,程序输出一个`new_params`文件和hash,请保存该hash值。类似于以下: 40 | ![](https://raw.githubusercontent.com/tronprotocol/documentation-en/master/docs_without_index/internal-test/mpc-output.jpg) 41 | 42 |   这个计算过程大约耗时半小时~1小时,根据硬件环境可能稍有不同,占用1.5 ~ 2GB物理内存。 43 | 44 | 8. 请把你的结果告知TRONZ。通过Keybase来发送`new_params`文件,然后把hash值通过邮件告知我们,告知操作系统版本更好,例如Windows 7/Centos 7。 45 | 46 | ## 依赖 47 | 我们重用了zcash的多方计算第二阶段的最终结果 https://download.z.cash/sapling-mpc/params 作为我们的起始参数,添加额外一些参与者。每个参与者把结果发送给我们后,我们会验证生成的参数是否有效。在最后一个参与者结束迭代计算后,我们采用比特币最新区块的hash值作为伪随机函数的种子来生成随机信标(Random Beacon)。在mpc结束后,我们把所有参与者的贡献发布在本项目的[wiki](https://github.com/tronprotocol/mpc/wiki) 。所有参与者可以验证自己的贡献是否保存在最终参数中。 48 | 49 | 50 | ## 如何验证我的贡献 ? 51 | 52 | 在所有参与者完成迭代后,我们把最终的`params`发布于aws上,永久存储。可以通过以下方式验证: 53 | ``` 54 | # cd mpc 55 | # wget https://mpcfilepub.s3.amazonaws.com/mpc/params 56 | # wget https://mpcfilepub.s3.amazonaws.com/powersoftau/powersoftau_phase1_files.tar 57 | # tar xvf powersoftau_phase1_files.tar && cp powersoftau_phase1_files/* . 58 | # cargo run --release --features="verification" --bin verify 59 | ``` 60 | 验证过程大约耗时一小时,输出所有参与者的hash值。查询自己保存的hash值是否在输出的hash列表中。 61 | 62 | ## License 63 | 64 | Licensed under either of 65 | 66 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 67 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 68 | 69 | at your option. 70 | 71 | ### Contribution 72 | 73 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. 74 | -------------------------------------------------------------------------------- /compute.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # install rust 4 | if [[ `rustc -V | grep '('` = '' ]] 5 | then 6 | curl https://sh.rustup.rs -sSf | sh 7 | source $HOME/.cargo/env 8 | fi 9 | 10 | # download params file 11 | echo "download params: "$1 12 | wget --no-check-certificate $1 -O params 13 | 14 | # execute mpc 15 | cargo run --release --bin compute -------------------------------------------------------------------------------- /participants.md: -------------------------------------------------------------------------------- 1 | ## Completed participants 2 | 3 | Index | Name | Email | Completed date 4 | ------------ |------------ | ------------- | ------------- 5 | 001 | Marco - TRON Family | info@tron-family.de | 2020-01-06 6 | 002 | Crypto Guy | cryptoguyinza@gmail.com | 2020-01-06 7 | 003 | Jason Neely | bondibox@gmail.com | 2020-01-07 8 | 004 | Dirk Frank | dirk.frank@tron-europe.org | 2020-01-07 9 | 005 | Dimitris Apostolou | dimitris.apostolou@icloud.com | 2020-01-08 10 | 006 | Fbsobreira| cryptochainbrazil@gmail.com | 2020-01-09 11 | 007 | Carsten Stöcker| carsten.stoecker@spherity.com | 2020-01-10 12 | 008 | Bruno Campos | baiano@tronwallet.me | 2020-01-11 13 | 009 | Justin Sun | sunyu******@gmail.com | 2020-01-12 14 | 010 | Matt | mbranton@gmail.com | 2020-01-20 15 | 011 | sun | shydesky@gmail.com | 2020-01-22 16 | 012 | Aaron Musk| aaronmusk1989@gmail.com | 2020-01-23 17 | 013 | Edward | blake2s@protonmail.com | 2020-01-23 18 | 014 | Miffy Tang | timothychungkitwai@gmail.com | 2020-01-31 19 | 015 | Alberto Zhang | alberto.zhangbo@gmail.com | 2020-02-01 20 | 016 | Abner Frank | abner725@aol.com | 2020-02-01 21 | 017 | Martin | martin012020@aol.com | 2020-02-02 22 | 018 | Holt Hou | holy.holt@aol.com | 2020-02-02 23 | 019 | Hong Guo | tsabo_gh@163.com | 2020-02-02 24 | 020 | Cathy Tan | lotusLeaffy@protonmail.com | 2020-02-02 25 | 021 | Ben Peng | ben.peng18@gmail.com | 2020-02-03 26 | 022 | Elvis Zhang | zhangheng1536@gmail.com | 2020-02-03 27 | 023 | Miraculous Wong | wm18840987261@163.com | 2020-02-03 28 | 024 | Stan Lee | stanlee8080@outlook.com | 2020-02-04 29 | 025 | Ray Wu | wgq.quan@gmail.com | 2020-02-04 30 | 026 | Joe Kim | ksl2945@icloud.com | 2020-02-04 31 | 027 | Rani | greatcanaka123@protonmail.com | 2020-02-04 32 | 028 | Xing | xingyuan15@gmail.com | 2020-02-05 33 | 029 | Matthew To | mattopolitan@gmail.com | 2020-02-05 34 | 030 | Taihao Fu | taihao.fu@gmail.com | 2020-02-05 35 | 031 | Wayne Zhang | shiziwen@gmail.com | 2020-02-05 36 | 032 | LEUNG Cheung | fledna@ymail.com | 2020-02-06 37 | 033 | Oleksandr Zolotarov | xgakamusic@gmail.com | 2020-02-06 38 | 034 | Sakary Jia | starsakary@gmail.com| 2020-02-06 39 | 035 | Maik (TRON-Family) | schierholz@eulibi.de | 2020-02-06 40 | 036 | Jeancky Jiang | jeancky.jiang@outlook.com | 2020-02-07 41 | 037 | Adi Lee | nwolvip@outlook.com | 2020-02-07 42 | 038 | Alex Huang | oday0311@hotmail.com | 2020-02-08 43 | 039 | Olivier Zhang | olenheim@hotmail.com | 2020-02-08 44 | 040 | dzhcrypto  | dzhcrypto@gmail.com | 2020-02-08 45 | 041 | Harry Xu | myfocus3722@gmail.com | 2020-02-08 46 | 042 | Mangumpit Leo | mangumpitnorca@outlook.com | 2020-02-09 47 | 043 | Leon Ji | leon.ji4965@gmail.com | 2020-02-09 48 | 044 | Nile | freundjackie1982@gmail.com | 2020-02-09 49 | 045 | Cris Wang | wangzihecisco@gmail.com | 2020-02-09 50 | 046 | Imart Kang | imart.kang@gmail.com | 2020-02-10 51 | 047 | Dorian Wu | yit323487@163.com | 2020-02-10 52 | 048 | Allen Cheng | ctx157194515@126.com | 2020-02-10 | 53 | 049 | Dzyk | yes@dzyk.ru | 2020-02-11 | 54 | 050 | Allen Lee | al6303076@gmail.com | 2020-02-11 55 | 051 | Rick Zhu | zkkzkk@icloud.com | 2020-02-11 56 | 052 | Charis Wang | hccyqw@163.com | 2020-02-11 57 | 053 | Zhang Yu | 971071009@qq.com | 2020-02-12 58 | 054 | Matt Yue | yrp1990@gmail.com | 2020-02-12 59 | 055 | Daryl Morey | just4onetime01@gmail.com | 2020-02-12 60 | 056 | Adam Silver | adam.silver1024@gmail.com | 2020-02-13 61 | 057 | Bruce | 001mawork@gmail.com | 2020-02-13 62 | 058 | Yuki Xue | xueyuanying123@gmail.com | 2020-02-13 63 | 059 | Boyan Shen | shenboyan0325@gmail.com | 2020-02-13 64 | 060 | Slogan.Wang | wangxuguo@gmail.com | 2020-02-14 65 | 061 | David Stern | loktarogar1@163.com | 2020-02-14 66 | 062 | James | codewellliu@gmail.com | 2020-02-14 67 | 063 | Holly Jiang | jianghong5215@gmail.com | 2020-02-15 68 | 064 | Andrew Shulgin | shultz.andrey@gmail.com | 2020-02-17 69 | 065 | Teslenko Andrey | tinkoya3@gmail.com | 2020-02-17 70 | 066 | Kane Sun | kanesun0626@gmail.com | 2020-02-18 71 | 067 | Maxim Sergeev | allugra@mail.ru | 2020-02-18 72 | 068 | JK | houjingkuan1024@outlook.com | 2020-02-18 73 | 069 | Victoria Green | mongogo2010@outlook.com | 2020-02-19 74 | 070 | Valery Dzyk | dzykland@gmail.com | 2020-02-19 75 | 071 | KrazyKewl Bruce | krazykewlgameztoken@gmail.com | 2020-02-20 76 | 072 | Steven Cabrera Londoño | sevenupsoyo12@gmail.com | 2020-02-20 77 | 073 | Captain Liu | workuseliubin@gmail.com | 2020-02-20 78 | 074 | Kuntanury | kuntanury@gmail.com | 2020-02-20 79 | 075 | Jacky | limaolei.jacky@gmail.com | 2020-02-21 80 | 076 | Denis Pitcher | mail@denispitcher.com | 2020-02-22 81 | 077 | Eric He | adhcname@gmail.com | 2020-02-24 82 | 078 | Ekaterina Bukina | misssixty@mail.ru | 2020-02-24 83 | 079 | Alan | ppb772074568@gmail.com | 2020-02-25 84 | 080 | Moon Liu | june.jk9999@gmail.com | 2020-02-25 85 | 081 | Jimmy | himalayan.8848.asia@gmail.com | 2020-02-26 86 | 082 | Josie Wang | josie.wang66@gmail.com | 2020-02-27 87 | 083 | Tiffani Yang | yangting950803@gmail.com | 2020-02-28 88 | 084 | Mustafa khater | khatermustafa5@gmail.com | 2020-02-28 89 | 085 | Bella Zhao | zling041@gmail.com | 2020-03-02 90 | 086 | Hang Li | li1360214027@gmail.com | 2020-03-02 91 | 087 | Yana | yana552200@gmail.com | 2020-03-04 92 | 088 | shadow Q | qq07shadow@gmail.com | 2020-03-05 93 | 089 | Elon Xu | xuchina67@gmail.com | 2020-03-06 94 | 090 | Aldo Urem | aldo.urem@gmail.com | 2020-03-07 95 | 091 | Zhiqiang Yu | zhiqiangyu.pku@gmail.com | 2020-03-09 96 | 092 | Davi Nunes | davi@edu.unifor.br | 2020-03-11 97 | 093 | Red An | hongan2020@outlook.com | 2020-03-12 98 | 094 | Slash Wang | corechords@gmail.com | 2020-03-12 99 | 095 | Roney Charles | roneycharles@edu.unifor.br | 2020-03-13 100 | 096 | Nico Yang | luoyang103206@gmail.com | 2020-03-16 101 | 097 | Charlie | charlie.liu77@gmail.com | 2020-03-18 102 | 098 | Daimeng Zhang | daimengzhang0330@gmail.com | 2020-03-19 103 | 099 | Iryna Sychuk | mimi.krich@gmail.com | 2020-03-20 104 | 100 | TronLive | admin@tron.live | 2020-03-24 105 | Random Beacon| - | - | 2020-06-09 106 | 107 | -------------------------------------------------------------------------------- /src/bin/beacon.rs: -------------------------------------------------------------------------------- 1 | extern crate phase2; 2 | extern crate pairing; 3 | extern crate rand; 4 | extern crate blake2_rfc; 5 | extern crate byteorder; 6 | 7 | #[macro_use] 8 | extern crate hex_literal; 9 | 10 | extern crate crypto; 11 | 12 | use std::fs::File; 13 | use std::io::{BufWriter, BufReader}; 14 | use blake2_rfc::blake2b::Blake2b; 15 | 16 | fn main() { 17 | let current_params = File::open("params").expect("couldn't open `./params`"); 18 | let mut current_params = BufReader::with_capacity(1024*1024, current_params); 19 | 20 | let new_params = File::create("new_params").expect("couldn't create `./new_params`"); 21 | let mut new_params = BufWriter::with_capacity(1024*1024, new_params); 22 | 23 | let mut sapling_spend = phase2::MPCParameters::read(&mut current_params, false) 24 | .expect("couldn't deserialize Sapling Spend params"); 25 | 26 | let mut sapling_output = phase2::MPCParameters::read(&mut current_params, false) 27 | .expect("couldn't deserialize Sapling Output params"); 28 | 29 | let mut sprout_joinsplit = phase2::MPCParameters::read(&mut current_params, false) 30 | .expect("couldn't deserialize Sprout JoinSplit params"); 31 | 32 | // Create an RNG based on the outcome of the random beacon 33 | let rng = &mut { 34 | use byteorder::{ReadBytesExt, BigEndian}; 35 | use rand::{SeedableRng}; 36 | use rand::chacha::ChaChaRng; 37 | use crypto::sha2::Sha256; 38 | use crypto::digest::Digest; 39 | 40 | // Place block hash here (block number #632800) 41 | let mut beacon_value: [u8; 32] = hex!("00000000000000000002b7b77db5165aa09d80009c6688bf98746615d9c7ceb2"); 42 | 43 | // Performs 2^n hash iterations over it 44 | const N: usize = 40; 45 | 46 | for i in 0..(1u64<().expect("digest is large enough for this to work"); 74 | } 75 | 76 | ChaChaRng::from_seed(&seed) 77 | }; 78 | 79 | let h1 = sapling_spend.contribute(rng); 80 | let h2 = sapling_output.contribute(rng); 81 | let h3 = sprout_joinsplit.contribute(rng); 82 | 83 | sapling_spend.write(&mut new_params).expect("couldn't write new Sapling Spend params"); 84 | sapling_output.write(&mut new_params).expect("couldn't write new Sapling Spend params"); 85 | sprout_joinsplit.write(&mut new_params).expect("couldn't write new Sapling Spend params"); 86 | 87 | let mut h = Blake2b::new(64); 88 | h.update(&h1); 89 | h.update(&h2); 90 | h.update(&h3); 91 | let h = h.finalize(); 92 | 93 | print!("Done!\n\n\ 94 | Your contribution has been written to `./new_params`\n\n\ 95 | The contribution you made is bound to the following hash:\n"); 96 | 97 | for line in h.as_ref().chunks(16) { 98 | print!("\t"); 99 | for section in line.chunks(4) { 100 | for b in section { 101 | print!("{:02x}", b); 102 | } 103 | print!(" "); 104 | } 105 | println!(""); 106 | } 107 | 108 | println!("\n"); 109 | } 110 | -------------------------------------------------------------------------------- /src/bin/compute.rs: -------------------------------------------------------------------------------- 1 | extern crate phase2; 2 | extern crate pairing; 3 | extern crate rand; 4 | extern crate blake2_rfc; 5 | 6 | use std::fs::File; 7 | use std::io::{BufWriter, BufReader}; 8 | use blake2_rfc::blake2b::Blake2b; 9 | 10 | fn main() { 11 | let current_params = File::open("params").expect("couldn't open `./params`"); 12 | let mut current_params = BufReader::with_capacity(1024*1024, current_params); 13 | 14 | let new_params = File::create("new_params").expect("couldn't create `./new_params`"); 15 | let mut new_params = BufWriter::with_capacity(1024*1024, new_params); 16 | 17 | let mut sapling_spend = phase2::MPCParameters::read(&mut current_params, false) 18 | .expect("couldn't deserialize Sapling Spend params"); 19 | 20 | let mut sapling_output = phase2::MPCParameters::read(&mut current_params, false) 21 | .expect("couldn't deserialize Sapling Output params"); 22 | 23 | let mut sprout_joinsplit = phase2::MPCParameters::read(&mut current_params, false) 24 | .expect("couldn't deserialize Sprout JoinSplit params"); 25 | 26 | let rng = &mut rand::OsRng::new().expect("couldn't create RNG"); 27 | 28 | let h1 = sapling_spend.contribute(rng); 29 | let h2 = sapling_output.contribute(rng); 30 | let h3 = sprout_joinsplit.contribute(rng); 31 | 32 | sapling_spend.write(&mut new_params).expect("couldn't write new Sapling Spend params"); 33 | sapling_output.write(&mut new_params).expect("couldn't write new Sapling Spend params"); 34 | sprout_joinsplit.write(&mut new_params).expect("couldn't write new Sapling Spend params"); 35 | 36 | let mut h = Blake2b::new(64); 37 | h.update(&h1); 38 | h.update(&h2); 39 | h.update(&h3); 40 | let h = h.finalize(); 41 | 42 | print!("Done!\n\n\ 43 | Your contribution has been written to `./new_params`\n\n\ 44 | The contribution you made is bound to the following hash:\n"); 45 | 46 | for line in h.as_ref().chunks(16) { 47 | print!("\t"); 48 | for section in line.chunks(4) { 49 | for b in section { 50 | print!("{:02x}", b); 51 | } 52 | print!(" "); 53 | } 54 | println!(""); 55 | } 56 | 57 | println!("\n"); 58 | } 59 | -------------------------------------------------------------------------------- /src/bin/new.rs: -------------------------------------------------------------------------------- 1 | extern crate phase2; 2 | extern crate sapling_crypto; 3 | extern crate pairing; 4 | 5 | use std::fs::File; 6 | use std::io::BufWriter; 7 | 8 | fn main() { 9 | let jubjub_params = sapling_crypto::jubjub::JubjubBls12::new(); 10 | 11 | let params = File::create("params").unwrap(); 12 | let mut params = BufWriter::with_capacity(1024 * 1024, params); 13 | 14 | // Sapling spend circuit 15 | phase2::MPCParameters::new(sapling_crypto::circuit::sapling::Spend { 16 | params: &jubjub_params, 17 | value_commitment: None, 18 | proof_generation_key: None, 19 | payment_address: None, 20 | commitment_randomness: None, 21 | ar: None, 22 | auth_path: vec![None; 32], // Tree depth is 32 for sapling 23 | anchor: None 24 | }).unwrap().write(&mut params).unwrap(); 25 | 26 | // Sapling output circuit 27 | phase2::MPCParameters::new(sapling_crypto::circuit::sapling::Output { 28 | params: &jubjub_params, 29 | value_commitment: None, 30 | payment_address: None, 31 | commitment_randomness: None, 32 | esk: None 33 | }).unwrap().write(&mut params).unwrap(); 34 | 35 | // Sprout joinsplit circuit 36 | phase2::MPCParameters::new(sapling_crypto::circuit::sprout::JoinSplit { 37 | vpub_old: None, 38 | vpub_new: None, 39 | h_sig: None, 40 | phi: None, 41 | inputs: vec![sapling_crypto::circuit::sprout::JSInput { 42 | value: None, 43 | a_sk: None, 44 | rho: None, 45 | r: None, 46 | auth_path: [None; 29] // Depth is 29 for Sprout 47 | }, sapling_crypto::circuit::sprout::JSInput { 48 | value: None, 49 | a_sk: None, 50 | rho: None, 51 | r: None, 52 | auth_path: [None; 29] // Depth is 29 for Sprout 53 | }], 54 | outputs: vec![sapling_crypto::circuit::sprout::JSOutput { 55 | value: None, 56 | a_pk: None, 57 | r: None 58 | }, sapling_crypto::circuit::sprout::JSOutput { 59 | value: None, 60 | a_pk: None, 61 | r: None 62 | }], 63 | rt: None, 64 | }).unwrap().write(&mut params).unwrap(); 65 | } 66 | -------------------------------------------------------------------------------- /src/bin/split_params.rs: -------------------------------------------------------------------------------- 1 | //! This binary just splits the parameters up into separate files. 2 | 3 | extern crate phase2; 4 | extern crate pairing; 5 | extern crate rand; 6 | extern crate blake2_rfc; 7 | 8 | use std::fs::File; 9 | use std::io::{BufWriter, BufReader}; 10 | 11 | fn main() { 12 | let current_params = File::open("params").expect("couldn't open `./params`"); 13 | let mut current_params = BufReader::with_capacity(1024*1024, current_params); 14 | 15 | let sapling_spend = phase2::MPCParameters::read(&mut current_params, false) 16 | .expect("couldn't deserialize Sapling Spend params"); 17 | 18 | let sapling_output = phase2::MPCParameters::read(&mut current_params, false) 19 | .expect("couldn't deserialize Sapling Output params"); 20 | 21 | let sprout_joinsplit = phase2::MPCParameters::read(&mut current_params, false) 22 | .expect("couldn't deserialize Sprout JoinSplit params"); 23 | 24 | { 25 | let f = File::create("sapling-spend.params").expect("couldn't create `./sapling-spend.params`"); 26 | let mut f = BufWriter::with_capacity(1024*1024, f); 27 | sapling_spend.write(&mut f) 28 | .expect("couldn't write new Sapling Spend params"); 29 | } 30 | 31 | { 32 | let f = File::create("sapling-output.params").expect("couldn't create `./sapling-output.params`"); 33 | let mut f = BufWriter::with_capacity(1024*1024, f); 34 | sapling_output.write(&mut f) 35 | .expect("couldn't write new Sapling Output params"); 36 | } 37 | 38 | { 39 | let f = File::create("sprout-groth16.params").expect("couldn't create `./sapling-groth16.params`"); 40 | let mut f = BufWriter::with_capacity(1024*1024, f); 41 | sprout_joinsplit.write(&mut f) 42 | .expect("couldn't write new Sprout JoinSplit params"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/bin/verify.rs: -------------------------------------------------------------------------------- 1 | extern crate phase2; 2 | extern crate sapling_crypto; 3 | extern crate pairing; 4 | extern crate blake2_rfc; 5 | 6 | use std::fs::File; 7 | use std::io::BufReader; 8 | use blake2_rfc::blake2b::Blake2b; 9 | 10 | fn main() { 11 | let jubjub_params = sapling_crypto::jubjub::JubjubBls12::new(); 12 | 13 | let params = File::open("params").unwrap(); 14 | let mut params = BufReader::with_capacity(1024 * 1024, params); 15 | 16 | let sapling_spend = phase2::MPCParameters::read(&mut params, true) 17 | .expect("couldn't deserialize Sapling Spend params"); 18 | 19 | let sapling_output = phase2::MPCParameters::read(&mut params, true) 20 | .expect("couldn't deserialize Sapling Output params"); 21 | 22 | let sprout_joinsplit = phase2::MPCParameters::read(&mut params, true) 23 | .expect("couldn't deserialize Sprout JoinSplit params"); 24 | 25 | let sapling_spend_contributions = sapling_spend.verify(sapling_crypto::circuit::sapling::Spend { 26 | params: &jubjub_params, 27 | value_commitment: None, 28 | proof_generation_key: None, 29 | payment_address: None, 30 | commitment_randomness: None, 31 | ar: None, 32 | auth_path: vec![None; 32], // Tree depth is 32 for sapling 33 | anchor: None 34 | }).expect("parameters are invalid"); 35 | 36 | let sapling_output_contributions = sapling_output.verify(sapling_crypto::circuit::sapling::Output { 37 | params: &jubjub_params, 38 | value_commitment: None, 39 | payment_address: None, 40 | commitment_randomness: None, 41 | esk: None 42 | }).expect("parameters are invalid"); 43 | 44 | let sprout_joinsplit_contributions = sprout_joinsplit.verify(sapling_crypto::circuit::sprout::JoinSplit { 45 | vpub_old: None, 46 | vpub_new: None, 47 | h_sig: None, 48 | phi: None, 49 | inputs: vec![sapling_crypto::circuit::sprout::JSInput { 50 | value: None, 51 | a_sk: None, 52 | rho: None, 53 | r: None, 54 | auth_path: [None; 29] // Depth is 29 for Sprout 55 | }, sapling_crypto::circuit::sprout::JSInput { 56 | value: None, 57 | a_sk: None, 58 | rho: None, 59 | r: None, 60 | auth_path: [None; 29] // Depth is 29 for Sprout 61 | }], 62 | outputs: vec![sapling_crypto::circuit::sprout::JSOutput { 63 | value: None, 64 | a_pk: None, 65 | r: None 66 | }, sapling_crypto::circuit::sprout::JSOutput { 67 | value: None, 68 | a_pk: None, 69 | r: None 70 | }], 71 | rt: None, 72 | }).expect("parameters are invalid"); 73 | 74 | for ((a, b), c) in sapling_spend_contributions.into_iter() 75 | .zip(sapling_output_contributions.into_iter()) 76 | .zip(sprout_joinsplit_contributions) 77 | { 78 | let mut h = Blake2b::new(64); 79 | h.update(&a); 80 | h.update(&b); 81 | h.update(&c); 82 | let h = h.finalize(); 83 | 84 | println!("{}", into_hex(h.as_ref())); 85 | } 86 | } 87 | 88 | fn into_hex(h: &[u8]) -> String { 89 | let mut f = String::new(); 90 | 91 | for byte in &h[..] { 92 | f += &format!("{:02x}", byte); 93 | } 94 | 95 | f 96 | } 97 | -------------------------------------------------------------------------------- /src/bin/verify_transform.rs: -------------------------------------------------------------------------------- 1 | extern crate phase2; 2 | extern crate pairing; 3 | extern crate blake2_rfc; 4 | 5 | use std::fs::File; 6 | use std::io::BufReader; 7 | use blake2_rfc::blake2b::Blake2b; 8 | 9 | fn main() { 10 | let params = File::open("params").unwrap(); 11 | let mut params = BufReader::with_capacity(1024 * 1024, params); 12 | 13 | let new_params = File::open("new_params").unwrap(); 14 | let mut new_params = BufReader::with_capacity(1024 * 1024, new_params); 15 | 16 | let sapling_spend = phase2::MPCParameters::read(&mut params, false) 17 | .expect("couldn't deserialize Sapling Spend params"); 18 | 19 | let sapling_output = phase2::MPCParameters::read(&mut params, false) 20 | .expect("couldn't deserialize Sapling Output params"); 21 | 22 | let sprout_joinsplit = phase2::MPCParameters::read(&mut params, false) 23 | .expect("couldn't deserialize Sprout JoinSplit params"); 24 | 25 | let new_sapling_spend = phase2::MPCParameters::read(&mut new_params, true) 26 | .expect("couldn't deserialize Sapling Spend new_params"); 27 | 28 | let new_sapling_output = phase2::MPCParameters::read(&mut new_params, true) 29 | .expect("couldn't deserialize Sapling Output new_params"); 30 | 31 | let new_sprout_joinsplit = phase2::MPCParameters::read(&mut new_params, true) 32 | .expect("couldn't deserialize Sprout JoinSplit new_params"); 33 | 34 | let h1 = match phase2::verify_contribution(&sapling_spend, &new_sapling_spend) { 35 | Ok(hash) => hash, 36 | Err(_) => panic!("invalid transformation!") 37 | }; 38 | 39 | let h2 = match phase2::verify_contribution(&sapling_output, &new_sapling_output) { 40 | Ok(hash) => hash, 41 | Err(_) => panic!("invalid transformation!") 42 | }; 43 | 44 | let h3 = match phase2::verify_contribution(&sprout_joinsplit, &new_sprout_joinsplit) { 45 | Ok(hash) => hash, 46 | Err(_) => panic!("invalid transformation!") 47 | }; 48 | 49 | let mut h = Blake2b::new(64); 50 | h.update(&h1); 51 | h.update(&h2); 52 | h.update(&h3); 53 | let h = h.finalize(); 54 | 55 | println!("{}", into_hex(h.as_ref())); 56 | } 57 | 58 | fn into_hex(h: &[u8]) -> String { 59 | let mut f = String::new(); 60 | 61 | for byte in &h[..] { 62 | f += &format!("{:02x}", byte); 63 | } 64 | 65 | f 66 | } 67 | --------------------------------------------------------------------------------