From 085bb763dba1450cab46d6198bb6b448dce36002 Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Mon, 5 Apr 2021 11:51:14 +0200 Subject: [PATCH 01/69] Update aead and aes-gcm-siv --- Cargo.lock | 120 ++++++++++++++++++---------- rust/Cargo.toml | 4 +- rust/src/api/groups/group_params.rs | 4 +- 3 files changed, 80 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75c98bb..6711902 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,52 +2,52 @@ # It is not intended for manual editing. [[package]] name = "aead" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aes" -version = "0.3.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aes-soft 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "aesni 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aes-gcm-siv" -version = "0.4.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aead 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "polyval 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aead 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aes 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ctr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "polyval 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aes-soft" -version = "0.3.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aesni" -version = "0.6.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -95,14 +95,6 @@ dependencies = [ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "block-cipher-trait" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "block-padding" version = "0.1.5" @@ -155,6 +147,14 @@ name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" version = "2.33.0" @@ -177,6 +177,11 @@ dependencies = [ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cpuid-bool" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "criterion" version = "0.3.1" @@ -282,6 +287,14 @@ dependencies = [ "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ctr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "curve25519-dalek" version = "2.0.0" @@ -327,7 +340,16 @@ name = "generic-array" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -464,6 +486,11 @@ name = "opaque-debug" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "packed_simd" version = "0.3.3" @@ -495,11 +522,12 @@ dependencies = [ [[package]] name = "polyval" -version = "0.3.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "universal-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cpuid-bool 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "universal-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -686,7 +714,7 @@ dependencies = [ [[package]] name = "typenum" -version = "1.11.2" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -701,10 +729,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "universal-hash" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -835,8 +863,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "zkgroup" version = "0.7.2" dependencies = [ - "aead 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "aes-gcm-siv 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aead 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aes-gcm-siv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)", @@ -848,18 +876,17 @@ dependencies = [ ] [metadata] -"checksum aead 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4cf01b9b56e767bb57b94ebf91a58b338002963785cdd7013e21c0d4679471e4" -"checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" -"checksum aes-gcm-siv 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8c21a21a0afb20aeb41328e980939e99fa02f136ae7317665e892d2760912a" -"checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" -"checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +"checksum aead 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +"checksum aes 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" +"checksum aes-gcm-siv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "202a43562bc3e159554b7590f5fd1f432d9e8de0cc2c2ce4bb8d194a34b3b0f3" +"checksum aes-soft 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +"checksum aesni 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" "checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -"checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" "checksum bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" @@ -868,8 +895,10 @@ dependencies = [ "checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +"checksum cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +"checksum cpuid-bool 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" "checksum criterion 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1" "checksum criterion-plot 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545" "checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" @@ -879,12 +908,14 @@ dependencies = [ "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" "checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +"checksum ctr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" "checksum curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)" = "" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" "checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" "checksum hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" "checksum hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" @@ -904,10 +935,11 @@ dependencies = [ "checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" "checksum oorandom 11.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +"checksum opaque-debug 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" "checksum packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a85ea9fc0d4ac0deb6fe7911d38786b32fc11119afd9e9d38b84ff691ce64220" "checksum plotters 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb" "checksum poksho 0.7.0 (git+https://github.com/signalapp/poksho.git?tag=v0.7.0)" = "" -"checksum polyval 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec3341498978de3bfd12d1b22f1af1de22818f5473a11e8a6ef997989e3a212" +"checksum polyval 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" "checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" "checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" @@ -931,10 +963,10 @@ dependencies = [ "checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" -"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum universal-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" +"checksum universal-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index efd49c4..96d1945 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -23,8 +23,8 @@ serde = { version = "1.0.106", features = ["derive"] } sha2 = "0.8.0" jni = { version = "0.16.0", default-features = false } hex = "0.4.0" -aead = "0.2.0" -aes-gcm-siv = "0.4.1" +aead = "0.3.0" +aes-gcm-siv = "0.9.0" [dependencies.curve25519-dalek] features = ["std", "serde", "alloc"] diff --git a/rust/src/api/groups/group_params.rs b/rust/src/api/groups/group_params.rs index 193742b..5eb56d8 100644 --- a/rust/src/api/groups/group_params.rs +++ b/rust/src/api/groups/group_params.rs @@ -196,7 +196,7 @@ impl GroupSecretParams { plaintext: &[u8], ) -> Result, ZkGroupError> { let key = GenericArray::from_slice(key); - let aead_cipher = Aes256GcmSiv::new(*key); + let aead_cipher = Aes256GcmSiv::new(&*key); let nonce = GenericArray::from_slice(nonce); match aead_cipher.encrypt(nonce, plaintext) { Ok(ciphertext_vec) => Ok(ciphertext_vec), @@ -215,7 +215,7 @@ impl GroupSecretParams { return Err(ZkGroupError::DecryptionFailure); } let key = GenericArray::from_slice(key); - let aead_cipher = Aes256GcmSiv::new(*key); + let aead_cipher = Aes256GcmSiv::new(&*key); let nonce = GenericArray::from_slice(nonce); match aead_cipher.decrypt(nonce, ciphertext) { Ok(plaintext_vec) => Ok(plaintext_vec), From 9f29bccdcc6d9f78221f21f1e46aff9b257a5d44 Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Mon, 5 Apr 2021 11:51:30 +0200 Subject: [PATCH 02/69] Minor version bump --- Cargo.lock | 527 +++++++++++++++++++++++++++++------------------------ 1 file changed, 284 insertions(+), 243 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6711902..5d2f08a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,8 +28,8 @@ dependencies = [ "cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "ctr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "polyval 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -60,23 +60,23 @@ name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.92 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bincode" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -92,7 +92,7 @@ dependencies = [ "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -105,18 +105,18 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bumpalo" -version = "3.2.1" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -147,6 +147,11 @@ name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cipher" version = "0.2.5" @@ -157,12 +162,12 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.0" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -172,8 +177,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -184,77 +189,76 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "criterion" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion-plot 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion-plot 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "oorandom 11.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "plotters 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", - "tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "plotters 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_cbor 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", + "tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "criterion-plot" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "crossbeam-deque" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "crossbeam-queue" -version = "0.2.1" +name = "crossbeam-epoch" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -263,20 +267,20 @@ name = "crypto-mac" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "csv" -version = "1.1.3" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -284,7 +288,7 @@ name = "csv-core" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -304,9 +308,9 @@ dependencies = [ "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -314,20 +318,20 @@ name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "either" -version = "1.5.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "error-chain" -version = "0.12.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -337,7 +341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -349,30 +353,35 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.92 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "half" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "hermit-abi" -version = "0.1.10" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -386,15 +395,23 @@ dependencies = [ [[package]] name = "itertools" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "itertools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -404,10 +421,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "error-chain 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -417,10 +434,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" -version = "0.3.37" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -430,55 +447,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.67" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.8" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "memchr" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memoffset" -version = "0.5.4" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num_cpus" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "oorandom" -version = "11.1.0" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -501,13 +513,27 @@ dependencies = [ [[package]] name = "plotters" -version = "0.2.12" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "plotters-backend 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "plotters-svg 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "plotters-svg" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", + "plotters-backend 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -517,7 +543,7 @@ source = "git+https://github.com/signalapp/poksho.git?tag=v0.7.0#8bb8c61c18e7bbe dependencies = [ "curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)", "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -532,18 +558,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.9" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" -version = "1.0.3" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -551,37 +577,38 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon-core" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.3.6" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -594,7 +621,7 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.17" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -607,7 +634,7 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -615,7 +642,7 @@ name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -638,35 +665,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.106" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_cbor" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.106" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.51" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "sha2" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -682,17 +718,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.2.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "1.0.16" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -700,16 +736,16 @@ name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tinytemplate" -version = "1.0.3" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -719,12 +755,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -733,7 +769,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -746,7 +782,7 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -756,12 +792,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "walkdir" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -771,65 +807,65 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.60" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.60" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.60" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.60" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.60" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "web-sys" -version = "0.3.37" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.50 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -843,10 +879,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -856,7 +892,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "zeroize" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -865,14 +901,14 @@ version = "0.7.2" dependencies = [ "aead 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "aes-gcm-siv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bincode 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)", - "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "jni 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "poksho 0.7.0 (git+https://github.com/signalapp/poksho.git?tag=v0.7.0)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] @@ -883,103 +919,108 @@ dependencies = [ "checksum aesni 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" "checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" +"checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +"checksum bincode 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -"checksum bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" -"checksum bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" +"checksum bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +"checksum bumpalo 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" "checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +"checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" "checksum cipher 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)" = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" "checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" "checksum cpuid-bool 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" -"checksum criterion 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1" -"checksum criterion-plot 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545" -"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -"checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" -"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +"checksum criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" +"checksum criterion-plot 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" +"checksum crossbeam-channel 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +"checksum crossbeam-deque 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +"checksum crossbeam-epoch 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +"checksum crossbeam-utils 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -"checksum csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" +"checksum csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" "checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" "checksum ctr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" "checksum curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)" = "" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" +"checksum either 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +"checksum error-chain 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" "checksum generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -"checksum hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" -"checksum hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +"checksum getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +"checksum half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" +"checksum hermit-abi 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +"checksum hex 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -"checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" -"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +"checksum itertools 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" +"checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +"checksum itoa 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" "checksum jni 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22bbdc25b49340bc4fc3d9c96dd84d878c4beeca35e3651efa53db51a68d7d4d" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -"checksum js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" +"checksum js-sys 0.3.50 (registry+https://github.com/rust-lang/crates.io-index)" = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -"checksum memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" -"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" -"checksum oorandom 11.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405" +"checksum libc 0.2.92 (registry+https://github.com/rust-lang/crates.io-index)" = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" +"checksum log 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +"checksum memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +"checksum memoffset 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +"checksum num-traits 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +"checksum oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum opaque-debug 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" "checksum packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a85ea9fc0d4ac0deb6fe7911d38786b32fc11119afd9e9d38b84ff691ce64220" -"checksum plotters 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb" +"checksum plotters 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" +"checksum plotters-backend 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" +"checksum plotters-svg 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" "checksum poksho 0.7.0 (git+https://github.com/signalapp/poksho.git?tag=v0.7.0)" = "" "checksum polyval 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" -"checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" -"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +"checksum proc-macro2 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +"checksum quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" -"checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" -"checksum regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" +"checksum rayon 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +"checksum rayon-core 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +"checksum regex 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" "checksum regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -"checksum regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" +"checksum regex-syntax 0.6.23 (registry+https://github.com/rust-lang/crates.io-index)" = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" +"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" -"checksum serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" -"checksum serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)" = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" -"checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +"checksum serde 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)" = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +"checksum serde_cbor 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +"checksum serde_derive 1.0.125 (registry+https://github.com/rust-lang/crates.io-index)" = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +"checksum serde_json 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)" = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +"checksum sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" -"checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" +"checksum subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +"checksum syn 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)" = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" +"checksum tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" "checksum typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" -"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" "checksum universal-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +"checksum version_check 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +"checksum walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" "checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -"checksum wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" -"checksum wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" -"checksum wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" -"checksum wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" -"checksum wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" -"checksum web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum wasm-bindgen 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +"checksum wasm-bindgen-backend 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +"checksum wasm-bindgen-macro 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +"checksum wasm-bindgen-macro-support 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +"checksum wasm-bindgen-shared 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" +"checksum web-sys 0.3.50 (registry+https://github.com/rust-lang/crates.io-index)" = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" +"checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +"checksum zeroize 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" From 873af13879ca914f3f38b6d2893a9168a0a8bb44 Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Mon, 5 Apr 2021 14:21:18 +0200 Subject: [PATCH 03/69] Comment crate-type, we don't need this. --- rust/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 96d1945..5303630 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -15,7 +15,7 @@ license = "GPL-3.0-only" [lib] name = "zkgroup" -crate-type = [ "staticlib", "cdylib", "rlib"] +#crate-type = [ "staticlib", "cdylib", "rlib"] [dependencies] bincode = "1.2.1" From 932aed554f307133694f6a6273a728343ba702e9 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Mon, 7 Jun 2021 11:29:39 -0700 Subject: [PATCH 04/69] Java: switch to Debian for Docker builds instead of Ubuntu Debian has a more stable retention period for pinned dependencies (the version of OpenJDK 8 we were using for Ubuntu is gone already!), and it matches what the Signal-Android repository is doing. --- Dockerfile | 16 +++++++--------- docker/apt.conf | 6 ++++++ docker/dependencies.txt | 1 + docker/print-versions.sh | 7 +++++++ docker/sources.list | 2 ++ 5 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 docker/apt.conf create mode 100644 docker/dependencies.txt create mode 100755 docker/print-versions.sh create mode 100644 docker/sources.list diff --git a/Dockerfile b/Dockerfile index 0e28a94..b1eb062 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM ubuntu:18.04 +FROM debian:stretch + +COPY docker/ docker/ +COPY docker/apt.conf docker/sources.list /etc/apt/ RUN dpkg --add-architecture i386 @@ -17,14 +20,9 @@ RUN apt-get update \ openssh-client \ unzip -RUN apt-get install -y --no-install-recommends \ - libc6:i386=2.27-3ubuntu1 \ - libncurses5:i386=6.1-1ubuntu1.18.04 \ - libstdc++6:i386=8.4.0-1ubuntu1~18.04 \ - lib32z1=1:1.2.11.dfsg-0ubuntu2 - -RUN apt-get install -y --no-install-recommends \ - openjdk-8-jdk=8u242-b08-0ubuntu3~18.04 +# Install pinned dependencies +RUN apt-get install -y $(cat docker/dependencies.txt) +RUN docker/print-versions.sh docker/dependencies.txt RUN rm -rf /var/lib/apt/lists/* && \ apt-get autoremove -y && \ diff --git a/docker/apt.conf b/docker/apt.conf new file mode 100644 index 0000000..cda34c6 --- /dev/null +++ b/docker/apt.conf @@ -0,0 +1,6 @@ +Acquire::Check-Valid-Until "false"; +Acquire::Languages "none"; +Binary::apt-get::Acquire::AllowInsecureRepositories "false"; + +APT::Install-Recommends "false"; +APT::Immediate-Configure "false"; diff --git a/docker/dependencies.txt b/docker/dependencies.txt new file mode 100644 index 0000000..d4423ec --- /dev/null +++ b/docker/dependencies.txt @@ -0,0 +1 @@ +openjdk-8-jdk=8u252-b09-1 diff --git a/docker/print-versions.sh b/docker/print-versions.sh new file mode 100755 index 0000000..954a69e --- /dev/null +++ b/docker/print-versions.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +while read dep; do + dep_name=$(echo $dep | cut -f1 -d '=') + version=$(dpkg -s $dep_name | grep 'Version: ' | cut -f2 -d ' ') + echo "$dep_name=$version" +done < $1 diff --git a/docker/sources.list b/docker/sources.list new file mode 100644 index 0000000..620a680 --- /dev/null +++ b/docker/sources.list @@ -0,0 +1,2 @@ +deb http://snapshot.debian.org/archive/debian-security/20200731T201723Z stretch/updates main +deb http://snapshot.debian.org/archive/debian/20200731T211026Z/ unstable main From 8bfcfb3d600c7cd1c96e014ff61ed2b56dd713ee Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Mon, 14 Jun 2021 11:57:29 -0700 Subject: [PATCH 05/69] Docker: use the rust-toolchain file instead of hardcoding a version --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b1eb062..fdef1fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ ENV SHELL /bin/bash WORKDIR /home/zkgroup # Rust setup... -ARG RUST_TOOLCHAIN=1.41.1 +COPY rust-toolchain rust-toolchain ARG RUST_TOOLCHAIN_SHA=ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b ARG CARGO_NDK_VERSION=1.0.0 ENV PATH="/home/zkgroup/.cargo/bin:${PATH}" @@ -51,7 +51,7 @@ ENV PATH="/home/zkgroup/.cargo/bin:${PATH}" RUN curl -f https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-unknown-linux-gnu/rustup-init -o /tmp/rustup-init \ && echo "${RUST_TOOLCHAIN_SHA} /tmp/rustup-init" | sha256sum -c - \ && chmod a+x /tmp/rustup-init \ - && /tmp/rustup-init -y --profile minimal --default-toolchain "${RUST_TOOLCHAIN}" \ + && /tmp/rustup-init -y --profile minimal --default-toolchain "$(cat rust-toolchain)" \ && rm -rf /tmp/rustup-init \ && rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android \ && cargo install --version ${CARGO_NDK_VERSION} cargo-ndk From e4aaf13244cda87007c7c642430ff8b5d89ee208 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Mon, 14 Jun 2021 11:59:15 -0700 Subject: [PATCH 06/69] Java: allow testing on macOS by looking for .dylib as well as .so --- ffi/java/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffi/java/Makefile b/ffi/java/Makefile index 90cee15..84fe053 100644 --- a/ffi/java/Makefile +++ b/ffi/java/Makefile @@ -1,12 +1,12 @@ -.PHONY: so +.PHONY: native_library .PHONY: jar .PHONY: test -so: +native_library: cargo build --release - cp ../../target/release/libzkgroup.so \ - src/main/resources/ + cp ../../target/release/libzkgroup.so src/main/resources/ 2>/dev/null || \ + cp ../../target/release/libzkgroup.dylib src/main/resources/ jar: mvn package From d5f191e341b9e522f2180186c2dd7556b3a4e3cc Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 10 Jun 2021 16:42:11 -0700 Subject: [PATCH 07/69] Update toolchain to nightly-2021-06-08 --- rust-toolchain | 2 +- rust/benches/zkgroup_benchmarks.rs | 10 +-- rust/src/api/groups/group_params.rs | 8 +-- rust/src/common/simple_types.rs | 2 +- rust/src/crypto/credentials.rs | 2 +- rust/src/crypto/profile_key_encryption.rs | 2 +- rust/src/crypto/proofs.rs | 4 +- rust/src/crypto/signature.rs | 4 +- rust/src/crypto/uid_encryption.rs | 2 +- rust/src/ffi/ffiapi.rs | 82 +++++++++++------------ rust/tests/integration_tests.rs | 4 +- 11 files changed, 58 insertions(+), 64 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 11c831f..994890c 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.41.1 \ No newline at end of file +nightly-2021-06-08 \ No newline at end of file diff --git a/rust/benches/zkgroup_benchmarks.rs b/rust/benches/zkgroup_benchmarks.rs index cea08b4..26c7de6 100644 --- a/rust/benches/zkgroup_benchmarks.rs +++ b/rust/benches/zkgroup_benchmarks.rs @@ -1,13 +1,7 @@ -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{criterion_group, criterion_main, Criterion}; extern crate zkgroup; -use zkgroup::common::simple_types::*; -use zkgroup::crypto; - -use curve25519_dalek::ristretto::RistrettoPoint; -use sha2::Sha256; - fn benchmark_integration_auth(c: &mut Criterion) { let server_secret_params = zkgroup::ServerSecretParams::generate(zkgroup::TEST_ARRAY_32); let server_public_params = server_secret_params.get_public_params(); @@ -68,7 +62,7 @@ fn benchmark_integration_auth(c: &mut Criterion) { }) }); - let presentation_bytes = &bincode::serialize(&presentation).unwrap(); + let _presentation_bytes = &bincode::serialize(&presentation).unwrap(); //for b in presentation_bytes.iter() { // print!("0x{:02x}, ", b); diff --git a/rust/src/api/groups/group_params.rs b/rust/src/api/groups/group_params.rs index 193742b..afd421b 100644 --- a/rust/src/api/groups/group_params.rs +++ b/rust/src/api/groups/group_params.rs @@ -267,12 +267,12 @@ mod tests { .encrypt_blob_aesgcmsiv(&key_vec, &nonce_vec, &plaintext_vec) .unwrap(); - assert!(&calc_ciphertext[..ciphertext_vec.len()] == &ciphertext_vec[..]); + assert!(calc_ciphertext[..ciphertext_vec.len()] == ciphertext_vec[..]); let calc_plaintext = group_secret_params .decrypt_blob_aesgcmsiv(&key_vec, &nonce_vec, &calc_ciphertext) .unwrap(); - assert!(&calc_plaintext[..] == &plaintext_vec[..]); + assert!(calc_plaintext[..] == plaintext_vec[..]); } #[test] @@ -308,11 +308,11 @@ mod tests { .encrypt_blob_aesgcmsiv(&key_vec, &nonce_vec, &plaintext_vec) .unwrap(); - assert!(&calc_ciphertext[..ciphertext_vec.len()] == &ciphertext_vec[..]); + assert!(calc_ciphertext[..ciphertext_vec.len()] == ciphertext_vec[..]); let calc_plaintext = group_secret_params .decrypt_blob_aesgcmsiv(&key_vec, &nonce_vec, &calc_ciphertext) .unwrap(); - assert!(&calc_plaintext[..] == &plaintext_vec[..]); + assert!(calc_plaintext[..] == plaintext_vec[..]); } } diff --git a/rust/src/common/simple_types.rs b/rust/src/common/simple_types.rs index b9d6c4b..a2af34d 100644 --- a/rust/src/common/simple_types.rs +++ b/rust/src/common/simple_types.rs @@ -32,6 +32,6 @@ fn test_encode_scalar() { let s_bytes = [0xFF; 32]; match bincode::deserialize::(&s_bytes) { Err(_) => (), - Ok(_) => assert!(false), + Ok(_) => unreachable!(), } } diff --git a/rust/src/crypto/credentials.rs b/rust/src/crypto/credentials.rs index d079ae0..0469c9b 100644 --- a/rust/src/crypto/credentials.rs +++ b/rust/src/crypto/credentials.rs @@ -181,7 +181,7 @@ impl SystemParams { impl KeyPair { pub fn generate(sho: &mut Sho, num_attributes: usize) -> Self { - if num_attributes > 4 || num_attributes < 3 { + if !(3..=4).contains(&num_attributes) { panic!(); } diff --git a/rust/src/crypto/profile_key_encryption.rs b/rust/src/crypto/profile_key_encryption.rs index 8aaddaf..d1f6f9a 100644 --- a/rust/src/crypto/profile_key_encryption.rs +++ b/rust/src/crypto/profile_key_encryption.rs @@ -161,7 +161,7 @@ mod tests { let key_pair_bytes = bincode::serialize(&key_pair).unwrap(); match bincode::deserialize::(&key_pair_bytes[0..key_pair_bytes.len() - 1]) { Err(_) => (), - _ => assert!(false), + _ => unreachable!(), }; let key_pair2: KeyPair = bincode::deserialize(&key_pair_bytes).unwrap(); assert!(key_pair == key_pair2); diff --git a/rust/src/crypto/proofs.rs b/rust/src/crypto/proofs.rs index 5214f4e..2a9ba6f 100644 --- a/rust/src/crypto/proofs.rs +++ b/rust/src/crypto/proofs.rs @@ -521,7 +521,7 @@ impl AuthCredentialPresentationProof { point_args.add("C_y3", C_y3); point_args.add("G_y3", credentials_system.G_y3); - match Self::get_poksho_statement().verify_proof(&poksho_proof, &point_args, &[]) { + match Self::get_poksho_statement().verify_proof(poksho_proof, &point_args, &[]) { Err(_) => Err(ZkGroupError::ProofVerificationFailure), Ok(_) => Ok(()), } @@ -723,7 +723,7 @@ impl ProfileKeyCredentialPresentationProof { point_args.add("C_y3", C_y3); point_args.add("G_y3", credentials_system.G_y3); - match Self::get_poksho_statement().verify_proof(&poksho_proof, &point_args, &[]) { + match Self::get_poksho_statement().verify_proof(poksho_proof, &point_args, &[]) { Err(_) => Err(ZkGroupError::ProofVerificationFailure), Ok(_) => Ok(()), } diff --git a/rust/src/crypto/signature.rs b/rust/src/crypto/signature.rs index b85a59f..fb635eb 100644 --- a/rust/src/crypto/signature.rs +++ b/rust/src/crypto/signature.rs @@ -103,7 +103,7 @@ mod tests { message[0] ^= 1; match key_pair2.get_public_key().verify(&message, signature) { Err(SignatureVerificationFailure) => (), - _ => assert!(false), + _ => unreachable!(), } println!("signature = {:#x?}", &signature[..]); @@ -115,6 +115,6 @@ mod tests { 0xe1, 0x10, 0xee, 0xb7, 0x72, 0xb, 0x6, ]; - assert!(&signature[..] == &signature_result[..]); + assert!(signature[..] == signature_result[..]); } } diff --git a/rust/src/crypto/uid_encryption.rs b/rust/src/crypto/uid_encryption.rs index 7a88376..6463644 100644 --- a/rust/src/crypto/uid_encryption.rs +++ b/rust/src/crypto/uid_encryption.rs @@ -128,7 +128,7 @@ mod tests { let key_pair_bytes = bincode::serialize(&key_pair).unwrap(); match bincode::deserialize::(&key_pair_bytes[0..key_pair_bytes.len() - 1]) { Err(_) => (), - _ => assert!(false), + _ => unreachable!(), }; let key_pair2: KeyPair = bincode::deserialize(&key_pair_bytes).unwrap(); assert!(key_pair == key_pair2); diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index 23e0bdd..810afe3 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -30,7 +30,7 @@ pub extern "C" fn FFI_ProfileKey_getCommitment( slice::from_raw_parts_mut(profileKeyCommitmentOut, profileKeyCommitmentLen as usize) }; - simpleapi::ProfileKey_getCommitment(profile_key, &uuid, profile_key_commitment) + simpleapi::ProfileKey_getCommitment(profile_key, uuid, profile_key_commitment) }); match result { @@ -56,7 +56,7 @@ pub extern "C" fn FFI_ProfileKey_getProfileKeyVersion( slice::from_raw_parts_mut(profileKeyVersionOut, profileKeyVersionLen as usize) }; - simpleapi::ProfileKey_getProfileKeyVersion(profile_key, &uuid, profile_key_version) + simpleapi::ProfileKey_getProfileKeyVersion(profile_key, uuid, profile_key_version) }); match result { @@ -98,7 +98,7 @@ pub extern "C" fn FFI_GroupSecretParams_generateDeterministic( slice::from_raw_parts_mut(groupSecretParamsOut, groupSecretParamsLen as usize) }; - simpleapi::GroupSecretParams_generateDeterministic(&randomness, group_secret_params) + simpleapi::GroupSecretParams_generateDeterministic(randomness, group_secret_params) }); match result { @@ -121,7 +121,7 @@ pub extern "C" fn FFI_GroupSecretParams_deriveFromMasterKey( slice::from_raw_parts_mut(groupSecretParamsOut, groupSecretParamsLen as usize) }; - simpleapi::GroupSecretParams_deriveFromMasterKey(&group_master_key, group_secret_params) + simpleapi::GroupSecretParams_deriveFromMasterKey(group_master_key, group_secret_params) }); match result { @@ -209,7 +209,7 @@ pub extern "C" fn FFI_GroupSecretParams_encryptUuid( let uuid_ciphertext: &mut [u8] = unsafe { slice::from_raw_parts_mut(uuidCiphertextOut, uuidCiphertextLen as usize) }; - simpleapi::GroupSecretParams_encryptUuid(group_secret_params, &uuid, uuid_ciphertext) + simpleapi::GroupSecretParams_encryptUuid(group_secret_params, uuid, uuid_ciphertext) }); match result { @@ -234,7 +234,7 @@ pub extern "C" fn FFI_GroupSecretParams_decryptUuid( unsafe { slice::from_raw_parts(uuidCiphertext, uuidCiphertextLen as usize) }; let uuid: &mut [u8] = unsafe { slice::from_raw_parts_mut(uuidOut, uuidLen as usize) }; - simpleapi::GroupSecretParams_decryptUuid(group_secret_params, &uuid_ciphertext, uuid) + simpleapi::GroupSecretParams_decryptUuid(group_secret_params, uuid_ciphertext, uuid) }); match result { @@ -266,8 +266,8 @@ pub extern "C" fn FFI_GroupSecretParams_encryptProfileKey( simpleapi::GroupSecretParams_encryptProfileKey( group_secret_params, - &profile_key, - &uuid, + profile_key, + uuid, profile_key_ciphertext, ) }); @@ -301,8 +301,8 @@ pub extern "C" fn FFI_GroupSecretParams_decryptProfileKey( simpleapi::GroupSecretParams_decryptProfileKey( group_secret_params, - &profile_key_ciphertext, - &uuid, + profile_key_ciphertext, + uuid, profile_key, ) }); @@ -335,8 +335,8 @@ pub extern "C" fn FFI_GroupSecretParams_encryptBlobDeterministic( simpleapi::GroupSecretParams_encryptBlobDeterministic( group_secret_params, - &randomness, - &plaintext, + randomness, + plaintext, blob_ciphertext, ) }); @@ -364,7 +364,7 @@ pub extern "C" fn FFI_GroupSecretParams_decryptBlob( let plaintext: &mut [u8] = unsafe { slice::from_raw_parts_mut(plaintextOut, plaintextLen as usize) }; - simpleapi::GroupSecretParams_decryptBlob(group_secret_params, &blob_ciphertext, plaintext) + simpleapi::GroupSecretParams_decryptBlob(group_secret_params, blob_ciphertext, plaintext) }); match result { @@ -387,7 +387,7 @@ pub extern "C" fn FFI_ServerSecretParams_generateDeterministic( slice::from_raw_parts_mut(serverSecretParamsOut, serverSecretParamsLen as usize) }; - simpleapi::ServerSecretParams_generateDeterministic(&randomness, server_secret_params) + simpleapi::ServerSecretParams_generateDeterministic(randomness, server_secret_params) }); match result { @@ -459,8 +459,8 @@ pub extern "C" fn FFI_ServerSecretParams_signDeterministic( simpleapi::ServerSecretParams_signDeterministic( server_secret_params, - &randomness, - &message, + randomness, + message, notary_signature, ) }); @@ -496,9 +496,9 @@ pub extern "C" fn FFI_ServerPublicParams_receiveAuthCredential( simpleapi::ServerPublicParams_receiveAuthCredential( server_public_params, - &uuid, + uuid, redemption_time, - &auth_credential_response, + auth_credential_response, auth_credential, ) }); @@ -540,9 +540,9 @@ pub extern "C" fn FFI_ServerPublicParams_createAuthCredentialPresentationDetermi simpleapi::ServerPublicParams_createAuthCredentialPresentationDeterministic( server_public_params, - &randomness, - &group_secret_params, - &auth_credential, + randomness, + group_secret_params, + auth_credential, auth_credential_presentation, ) }); @@ -583,9 +583,9 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialRequestContex simpleapi::ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic( server_public_params, - &randomness, - &uuid, - &profile_key, + randomness, + uuid, + profile_key, profile_key_credential_request_context, ) }); @@ -628,8 +628,8 @@ pub extern "C" fn FFI_ServerPublicParams_receiveProfileKeyCredential( simpleapi::ServerPublicParams_receiveProfileKeyCredential( server_public_params, - &profile_key_credential_request_context, - &profile_key_credential_response, + profile_key_credential_request_context, + profile_key_credential_response, profile_key_credential, ) }); @@ -672,9 +672,9 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialPresentationD simpleapi::ServerPublicParams_createProfileKeyCredentialPresentationDeterministic( server_public_params, - &randomness, - &group_secret_params, - &profile_key_credential, + randomness, + group_secret_params, + profile_key_credential, profile_key_credential_presentation, ) }); @@ -713,8 +713,8 @@ pub extern "C" fn FFI_ServerSecretParams_issueAuthCredentialDeterministic( simpleapi::ServerSecretParams_issueAuthCredentialDeterministic( server_secret_params, - &randomness, - &uuid, + randomness, + uuid, redemption_time, auth_credential_response, ) @@ -749,8 +749,8 @@ pub extern "C" fn FFI_ServerSecretParams_verifyAuthCredentialPresentation( simpleapi::ServerSecretParams_verifyAuthCredentialPresentation( server_secret_params, - &group_public_params, - &auth_credential_presentation, + group_public_params, + auth_credential_presentation, ) }); @@ -799,10 +799,10 @@ pub extern "C" fn FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic( simpleapi::ServerSecretParams_issueProfileKeyCredentialDeterministic( server_secret_params, - &randomness, - &profile_key_credential_request, - &uuid, - &profile_key_commitment, + randomness, + profile_key_credential_request, + uuid, + profile_key_commitment, profile_key_credential_response, ) }); @@ -836,8 +836,8 @@ pub extern "C" fn FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation( simpleapi::ServerSecretParams_verifyProfileKeyCredentialPresentation( server_secret_params, - &group_public_params, - &profile_key_credential_presentation, + group_public_params, + profile_key_credential_presentation, ) }); @@ -923,8 +923,8 @@ pub extern "C" fn FFI_ServerPublicParams_verifySignature( simpleapi::ServerPublicParams_verifySignature( server_public_params, - &message, - ¬ary_signature, + message, + notary_signature, ) }); diff --git a/rust/tests/integration_tests.rs b/rust/tests/integration_tests.rs index 8587011..c8632b9 100644 --- a/rust/tests/integration_tests.rs +++ b/rust/tests/integration_tests.rs @@ -300,8 +300,8 @@ fn test_server_sigs() { print!("0x{:02x}, ", b); } assert!( - &signature[..] - == &[ + signature[..] + == [ 0x87, 0xd3, 0x54, 0x56, 0x4d, 0x35, 0xef, 0x91, 0xed, 0xba, 0x85, 0x1e, 0x08, 0x15, 0x61, 0x2e, 0x86, 0x4c, 0x22, 0x7a, 0x04, 0x71, 0xd5, 0x0c, 0x27, 0x06, 0x98, 0x60, 0x44, 0x06, 0xd0, 0x03, 0xa5, 0x54, 0x73, 0xf5, 0x76, 0xcf, 0x24, 0x1f, 0xc6, 0xb4, From b8dc2b741b86665c91c900ae482a5a577ed8ce69 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Thu, 10 Jun 2021 18:00:25 -0700 Subject: [PATCH 08/69] Add support for M1 and Catalyst architectures via cocoapods --- .github/workflows/tests.yml | 34 +- ZKGroup.podspec | 82 +++ bin/build_helpers.sh | 58 ++ ffi/swift/BUILDING.md | 50 -- ffi/swift/Makefile | 21 - ffi/swift/README.md | 35 +- ffi/swift/Scripts/copy_repo.sh | 24 - ffi/swift/Scripts/git_hooks/README.md | 1 - ffi/swift/Scripts/git_hooks/post-commit | 3 - ffi/swift/Scripts/git_hooks/pre-commit | 3 - ffi/swift/Scripts/precommit.py | 475 ------------- .../ZKGroup/AuthCredential.swift | 0 .../ZKGroup/AuthCredentialPresentation.swift | 0 .../ZKGroup/AuthCredentialResponse.swift | 0 .../{ => Sources}/ZKGroup/ByteArray.swift | 0 .../ZKGroup/ClientZkAuthOperations.swift | 0 .../ZKGroup/ClientZkGroupCipher.swift | 0 .../ZKGroup/ClientZkProfileOperations.swift | 0 ffi/swift/{ => Sources}/ZKGroup/Errors.swift | 0 .../ZKGroup/GroupIdentifier.swift | 0 .../ZKGroup/GroupMasterKey.swift | 0 .../ZKGroup/GroupPublicParams.swift | 0 .../ZKGroup/GroupSecretParams.swift | 0 ffi/swift/{ => Sources}/ZKGroup/Native.swift | 0 .../ZKGroup/NotarySignature.swift | 0 .../{ => Sources}/ZKGroup/ProfileKey.swift | 0 .../ZKGroup/ProfileKeyCiphertext.swift | 0 .../ZKGroup/ProfileKeyCommitment.swift | 0 .../ZKGroup/ProfileKeyCredential.swift | 0 .../ProfileKeyCredentialPresentation.swift | 0 .../ZKGroup/ProfileKeyCredentialRequest.swift | 0 .../ProfileKeyCredentialRequestContext.swift | 0 .../ProfileKeyCredentialResponse.swift | 0 .../ZKGroup/ProfileKeyVersion.swift | 0 .../ZKGroup/ServerPublicParams.swift | 0 .../ZKGroup/ServerSecretParams.swift | 0 .../ZKGroup/ServerZkAuthOperations.swift | 0 .../ZKGroup/ServerZkProfileOperations.swift | 0 ffi/swift/{ => Sources}/ZKGroup/Uuid.swift | 0 .../ZKGroup/UuidCiphertext.swift | 0 ffi/swift/Sources/libzkgroup/module.modulemap | 8 + ffi/swift/Sources/libzkgroup/zkgroup.h | 344 ++++++++++ .../ZKGroupTests.swift | 0 ffi/swift/ZKGroup.podspec | 34 - ffi/swift/ZKGroup.xcodeproj/project.pbxproj | 622 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../xcshareddata/xcschemes/ZKGroup.xcscheme | 78 --- ffi/swift/ZKGroup/Info.plist | 22 - ffi/swift/ZKGroup/ZKGroup.h | 15 - ffi/swift/ZKGroup/libzkgroup/module.modulemap | 4 - ffi/swift/ZKGroupTests/Info.plist | 22 - ffi/swift/build_ffi.sh | 115 ++++ 53 files changed, 646 insertions(+), 1419 deletions(-) create mode 100644 ZKGroup.podspec create mode 100755 bin/build_helpers.sh delete mode 100644 ffi/swift/BUILDING.md delete mode 100644 ffi/swift/Makefile delete mode 100755 ffi/swift/Scripts/copy_repo.sh delete mode 100644 ffi/swift/Scripts/git_hooks/README.md delete mode 100755 ffi/swift/Scripts/git_hooks/post-commit delete mode 100755 ffi/swift/Scripts/git_hooks/pre-commit delete mode 100755 ffi/swift/Scripts/precommit.py rename ffi/swift/{ => Sources}/ZKGroup/AuthCredential.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/AuthCredentialPresentation.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/AuthCredentialResponse.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ByteArray.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ClientZkAuthOperations.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ClientZkGroupCipher.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ClientZkProfileOperations.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/Errors.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/GroupIdentifier.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/GroupMasterKey.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/GroupPublicParams.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/GroupSecretParams.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/Native.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/NotarySignature.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKey.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyCiphertext.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyCommitment.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyCredential.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyCredentialPresentation.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyCredentialRequest.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyCredentialRequestContext.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyCredentialResponse.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ProfileKeyVersion.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ServerPublicParams.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ServerSecretParams.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ServerZkAuthOperations.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/ServerZkProfileOperations.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/Uuid.swift (100%) rename ffi/swift/{ => Sources}/ZKGroup/UuidCiphertext.swift (100%) create mode 100644 ffi/swift/Sources/libzkgroup/module.modulemap create mode 100644 ffi/swift/Sources/libzkgroup/zkgroup.h rename ffi/swift/{ZKGroupTests => Tests}/ZKGroupTests.swift (100%) delete mode 100644 ffi/swift/ZKGroup.podspec delete mode 100644 ffi/swift/ZKGroup.xcodeproj/project.pbxproj delete mode 100644 ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 ffi/swift/ZKGroup.xcodeproj/xcshareddata/xcschemes/ZKGroup.xcscheme delete mode 100644 ffi/swift/ZKGroup/Info.plist delete mode 100644 ffi/swift/ZKGroup/ZKGroup.h delete mode 100644 ffi/swift/ZKGroup/libzkgroup/module.modulemap delete mode 100644 ffi/swift/ZKGroupTests/Info.plist create mode 100755 ffi/swift/build_ffi.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d09b42c..785b54b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -71,32 +71,24 @@ jobs: runs-on: macOS-latest steps: - uses: actions/checkout@v2 - - name: Configure git to use HTTPS - run: git config --global url."https://${{ secrets.REPO_ACCESS_TOKEN }}:x-oauth-basic@github.com".insteadOf ssh://git@github.com - - name: Cache cargo registry - uses: actions/cache@v1 + - name: Install Rust + uses: actions-rs/toolchain@v1 with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - - name: Cache cargo index - uses: actions/cache@v1 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + profile: minimal + + - name: Add iOS targets + run: rustup target add aarch64-apple-ios x86_64-apple-ios + + - name: Add rust-src component + run: rustup component add rust-src + - name: Cache cargo build uses: actions/cache@v1 with: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - - name: Install iOS Rust targets - run: rustup target add aarch64-apple-ios x86_64-apple-ios armv7-apple-ios armv7s-apple-ios - - name: Build zkgroup library - working-directory: ffi/swift - run: | - make install_build_dependencies - make default - - name: Test XCode project - working-directory: ffi/swift - run: xcodebuild test -project ZKGroup.xcodeproj -scheme ZKGroup -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' + - name: Run pod lint + # No import validation because it tries to build unsupported platforms (like 32-bit iOS). + run: pod lib lint --verbose --platforms=ios --skip-import-validation --allow-warnings diff --git a/ZKGroup.podspec b/ZKGroup.podspec new file mode 100644 index 0000000..d1bc42d --- /dev/null +++ b/ZKGroup.podspec @@ -0,0 +1,82 @@ +# +# Be sure to run `pod spec lint credential.podspec' to ensure this is a +# valid spec and to remove all comments including this before submitting the spec. +# +# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + +Pod::Spec.new do |s| + s.name = "ZKGroup" + s.version = "0.7.2" + s.summary = "Swift API for the Rust zkgroup crate." + s.homepage = "https://signal.org/" + s.license = { :type => "GPLv3", :file => "LICENSE" } + s.authors = { "Signal iOS" => "ios@signal.org" } + s.source = { :git => "https://github.com/signalapp/zkgroup.git", :tag => "#{s.version}" } + + s.swift_version = '5' + s.platform = :ios, '10' + + s.source_files = 'ffi/swift/Sources/**/*.{m,swift}' + s.preserve_paths = [ + 'target/*/release/libzkgroup.a', + 'ffi/swift/Sources/libzkgroup', + ] + + s.pod_target_xcconfig = { + 'HEADER_SEARCH_PATHS' => '$(PODS_TARGET_SRCROOT)/ffi/swift/Sources/libzkgroup', + # Duplicate this here to make sure the search path is passed on to Swift dependencies. + 'SWIFT_INCLUDE_PATHS' => '$(HEADER_SEARCH_PATHS)', + + # Make sure we link the static library, not a dynamic one. + # Use an extra level of indirection because CocoaPods messes with OTHER_LDFLAGS too. + 'LIBZKGROUP_FFI_LIB_IF_NEEDED' => '$(PODS_TARGET_SRCROOT)/target/$(CARGO_BUILD_TARGET)/release/libzkgroup.a', + 'OTHER_LDFLAGS' => '$(LIBZKGROUP_FFI_LIB_IF_NEEDED)', + + 'CARGO_BUILD_TARGET[sdk=iphonesimulator*][arch=arm64]' => 'aarch64-apple-ios-sim', + 'CARGO_BUILD_TARGET[sdk=iphonesimulator*][arch=*]' => 'x86_64-apple-ios', + 'CARGO_BUILD_TARGET[sdk=iphoneos*]' => 'aarch64-apple-ios', + # Presently, there's no special SDK or arch for maccatalyst, + # so we need to hackily use the "IS_MACCATALYST" build flag + # to set the appropriate cargo target + 'CARGO_BUILD_TARGET_MAC_CATALYST_ARM_' => 'aarch64-apple-darwin', + 'CARGO_BUILD_TARGET_MAC_CATALYST_ARM_YES' => 'aarch64-apple-ios-macabi', + 'CARGO_BUILD_TARGET[sdk=macosx*][arch=arm64]' => '$(CARGO_BUILD_TARGET_MAC_CATALYST_ARM_$(IS_MACCATALYST))', + 'CARGO_BUILD_TARGET_MAC_CATALYST_X86_' => 'x86_64-apple-darwin', + 'CARGO_BUILD_TARGET_MAC_CATALYST_X86_YES' => 'x86_64-apple-ios-macabi', + 'CARGO_BUILD_TARGET[sdk=macosx*][arch=*]' => '$(CARGO_BUILD_TARGET_MAC_CATALYST_X86_$(IS_MACCATALYST))', + + 'ARCHS[sdk=iphonesimulator*]' => 'x86_64 arm64', + 'ARCHS[sdk=iphoneos*]' => 'arm64', + } + + s.script_phases = [ + { :name => 'Check libzkgroup', + :execution_position => :before_compile, + :script => %q( + test -e "${LIBZKGROUP_FFI_LIB_IF_NEEDED}" && exit 0 + if test -e "${PODS_TARGET_SRCROOT}/ffi/swift/build_ffi.sh"; then + echo 'error: libzkgroup.a not built; run the following to build it:' >&2 + echo "CARGO_BUILD_TARGET=${CARGO_BUILD_TARGET} \"${PODS_TARGET_SRCROOT}/ffi/swift/build_ffi.sh\" --release" >&2 + else + echo 'error: libzkgroup.a not built; try re-running `pod install`' >&2 + fi + false + ), + } + ] + + s.prepare_command = %q( + set -euo pipefail + CARGO_BUILD_TARGET=aarch64-apple-ios ffi/swift/build_ffi.sh --release + CARGO_BUILD_TARGET=x86_64-apple-ios ffi/swift/build_ffi.sh --release + CARGO_BUILD_TARGET=aarch64-apple-ios-sim ffi/swift/build_ffi.sh --release --build-std + CARGO_BUILD_TARGET=x86_64-apple-ios-macabi ffi/swift/build_ffi.sh --release --build-std + CARGO_BUILD_TARGET=aarch64-apple-ios-macabi ffi/swift/build_ffi.sh --release --build-std + ) + + s.test_spec 'Tests' do |test_spec| + test_spec.source_files = 'ffi/swift/Tests/**/*.{m,swift}' + end +end diff --git a/bin/build_helpers.sh b/bin/build_helpers.sh new file mode 100755 index 0000000..db125cb --- /dev/null +++ b/bin/build_helpers.sh @@ -0,0 +1,58 @@ +# +# Copyright 2020 Signal Messenger, LLC. +# SPDX-License-Identifier: AGPL-3.0-only +# + +# shellcheck shell=bash + +check_rust() { + if ! command -v rustup > /dev/null && [[ -d ~/.cargo/bin ]]; then + # Try to find rustup in its default per-user install location. + # This will be important when running from inside Xcode, + # which does not run in a login shell context. + PATH=~/.cargo/bin:$PATH + fi + + if ! command -v rustup > /dev/null; then + if ! command -v cargo > /dev/null; then + echo 'error: cargo not found in PATH; do you have Rust installed?' >&2 + echo 'note: we recommend installing Rust via rustup from https://rustup.rs/' >&2 + exit 1 + fi + + echo 'warning: rustup not found in PATH; using cargo at' "$(command -v cargo)" >&2 + echo 'note: this project uses Rust toolchain' "'$(cat ./rust-toolchain)'" >&2 + return + fi + + if [[ -n "${CARGO_BUILD_TARGET:-}" ]] && ! (rustup target list --installed | grep -q "${CARGO_BUILD_TARGET:-}"); then + # TODO: We could remove this once M1 and catalyst support are promoted to tier 2 + if [[ -n "${BUILD_STD:-}" ]]; then + echo "warning: Building std from source to support tier 3 target ${CARGO_BUILD_TARGET}." >&2 + else + echo "error: Rust target ${CARGO_BUILD_TARGET} not installed" >&2 + echo 'note: get it by running' >&2 + printf "\n\t%s\n\n" "rustup +${RUSTUP_TOOLCHAIN:-$(cat ./rust-toolchain)} target add ${CARGO_BUILD_TARGET}" >&2 + exit 1 + fi + fi +} + +# usage: copy_built_library target/release signal_node out_dir/libsignal_node.node +# copy_built_library target/release signal_jni out_dir/ +copy_built_library() { + for possible_library_name in "lib$2.dylib" "lib$2.so" "$2.dll"; do + possible_library_path="$1/${possible_library_name}" + if [ -e "${possible_library_path}" ]; then + out_dir=$(dirname "$3"x) # trailing x to distinguish directories from files + echo_then_run mkdir -p "${out_dir}" + echo_then_run cp "${possible_library_path}" "$3" + break + fi + done +} + +echo_then_run() { + echo "$@" + "$@" +} diff --git a/ffi/swift/BUILDING.md b/ffi/swift/BUILDING.md deleted file mode 100644 index f81f157..0000000 --- a/ffi/swift/BUILDING.md +++ /dev/null @@ -1,50 +0,0 @@ -# Building zkgroup for Swift / iOS -This document describes how to build and package zkgroup for Swift. We assume the repository is already available (i.e. cloned with git). - -## tl;dr -``` -$ make -``` - -Always test: -- Open the ZKGroup.xcodeproj -- Choose the Test scheme to run tests - -## From Zero - -### Mac -Ensure that Xcode and Rust are installed. - -- Install Rust from: https://www.rust-lang.org/tools/install -- Install the cargo-lipo and cbindgen utilities -- Install all the required toolchains - -Example: -``` -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -cargo install cbindgen -cargo install cargo-lipo - -rustup target add aarch64-apple-ios x86_64-apple-ios armv7-apple-ios armv7s-apple-ios -``` - -`rustup show` should indicate that the `x86_64-apple-darwin` is the host and stable, as well as having all the targets above listed. - -## Building -Only build using a Mac. From this directory, run make: -``` -make -``` -This will result in a universal library containing all the targets and header file which are copied to the ZKGroup/libzkgroup directory. - -To ensure proper operation, it is suggested to open the ZKGroup.xcodeproj and run tests from there. - -## Packaging -When either the source code or binaries have been updated, the entire swift directory and associated binary artifacts can be used to create a new artifact repository branch. - -There is a script that can help with the copying bit. For example, to copy to the `signal-zkgroup-swift` repository that is at the same directory level as `zkgroup`: -``` -Scripts/copy_repo.sh . ../../../signal-zkgroup-swift -``` - -Now a branch can be created in signal-zkgroup-swift and pushed to the upstream remote to serve as the formal release. diff --git a/ffi/swift/Makefile b/ffi/swift/Makefile deleted file mode 100644 index 86d67e5..0000000 --- a/ffi/swift/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -ZKGROUP_RUST_DIR=../../rust -ZKGROUP_TARGET_DIR=../../target - -default: zkgroup.h libzkgroup_ios.a - -clean: - rm ZKGroup/libzkgroup/zkgroup.h ZKGroup/libzkgroup/libzkgroup_ios.a - -zkgroup.h: FORCE - cbindgen --lang c $(ZKGROUP_RUST_DIR) -o ZKGroup/libzkgroup/zkgroup.h - -libzkgroup_ios.a: FORCE - cargo lipo --manifest-path=$(ZKGROUP_RUST_DIR)/Cargo.toml --release --targets=aarch64-apple-ios,x86_64-apple-ios,armv7-apple-ios,armv7s-apple-ios - mv $(ZKGROUP_TARGET_DIR)/universal/release/libzkgroup.a ZKGroup/libzkgroup/libzkgroup_ios.a - -install_build_dependencies: - cargo install --version 0.9.0 cbindgen - # FIXME: We're only using stable because one of cargo-lipo's dependencies doesn't support our pinned toolchain. When we update our pinned toolchain, we can undo this. - cargo +stable install --version 3.0.1 cargo-lipo - -FORCE: diff --git a/ffi/swift/README.md b/ffi/swift/README.md index eaee477..7a11421 100644 --- a/ffi/swift/README.md +++ b/ffi/swift/README.md @@ -1,12 +1,29 @@ -# ZKGroups for iOS +# Overview -Swift wrapper for the zkgroup rust crate. +This is a binding to the ZKGroup code in rust/, implemented on top of the C FFI produced by cbindgen. It's set up as a CocoaPod for integration into the Signal iOS client and as a Swift Package for local development. -## Rebuild the libzkgroup framework -Build the static library and header file. -``` -make -``` +# Use as CocoaPod -## Test -Open the ZKGroup.xcodeproj. Run the ZKGroupTests. +1. Make sure you are using `use_frameworks!` in your Podfile. ZKGroup is a Swift pod and as such cannot be compiled as a plain library. + +2. Add 'ZKGroup' as a dependency in your Podfile: + + pod 'ZKGroup', git: 'https://github.com/signalapp/zkgroup.git' + +3. Use `pod install` or `pod update` to build the Rust library for both iOS simulator and iOS device + +4. Build as usual. The Rust library will automatically be linked into the built ZKGroup.framework. + + +## Development as a CocoaPod + +Instead of a git-based dependency, use a path-based dependency to treat ZKGroup as a development pod. Since [`prepare_command`s][pc] are not run for path-based dependencies, you will need to build the Rust library yourself. (Xcode should prompt you to do this if you forget.) + + CARGO_BUILD_TARGET=x86_64-apple-ios ffi/swift/build_ffi.sh --release + +The CocoaPod is configured to use the release build of the Rust library. + +When exposing new APIs to Swift, you will need to add the `--generate-ffi` flag to your +`build_ffi.sh` invocation. + +[pc]: https://guides.cocoapods.org/syntax/podspec.html#prepare_command diff --git a/ffi/swift/Scripts/copy_repo.sh b/ffi/swift/Scripts/copy_repo.sh deleted file mode 100755 index 2e9f5ec..0000000 --- a/ffi/swift/Scripts/copy_repo.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# -# copy_repo.sh -# -# Copy the given swift directory to the artifact repository. -# -# Example: -# zkgroup/ffi/swift$ Scripts/copy_repo.sh . ../../../signal-zkgroup-swift -# - -rsync -avrq \ - --exclude='Scripts' \ - --exclude='.gitignore' \ - --exclude='Makefile' \ - --exclude='BUILDING.md' \ - --exclude='README.md' \ - $1 $2 - -# Ensure that the LICENSE file is up to date. -cp -f $1/../../LICENSE $2 - -# Ensure that the README.md file is up to date. -cp -f $1/../../README.md $2 diff --git a/ffi/swift/Scripts/git_hooks/README.md b/ffi/swift/Scripts/git_hooks/README.md deleted file mode 100644 index 146c2df..0000000 --- a/ffi/swift/Scripts/git_hooks/README.md +++ /dev/null @@ -1 +0,0 @@ -Copy these git hooks into .git/hooks diff --git a/ffi/swift/Scripts/git_hooks/post-commit b/ffi/swift/Scripts/git_hooks/post-commit deleted file mode 100755 index ed392f1..0000000 --- a/ffi/swift/Scripts/git_hooks/post-commit +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -Scripts/reverse_integration_check.py diff --git a/ffi/swift/Scripts/git_hooks/pre-commit b/ffi/swift/Scripts/git_hooks/pre-commit deleted file mode 100755 index 89a3163..0000000 --- a/ffi/swift/Scripts/git_hooks/pre-commit +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -Scripts/precommit.py diff --git a/ffi/swift/Scripts/precommit.py b/ffi/swift/Scripts/precommit.py deleted file mode 100755 index d8d9191..0000000 --- a/ffi/swift/Scripts/precommit.py +++ /dev/null @@ -1,475 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys -import subprocess -import datetime -import argparse -import commands - - -git_repo_path = os.path.abspath(subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).strip()) - - - -class include: - def __init__(self, isInclude, isQuote, body, comment): - self.isInclude = isInclude - self.isQuote = isQuote - self.body = body - self.comment = comment - - def format(self): - result = '%s %s%s%s' % ( - ('#include' if self.isInclude else '#import'), - ('"' if self.isQuote else '<'), - self.body.strip(), - ('"' if self.isQuote else '>'), - ) - if self.comment.strip(): - result += ' ' + self.comment.strip() - return result - - -def is_include_or_import(line): - line = line.strip() - if line.startswith('#include '): - return True - elif line.startswith('#import '): - return True - else: - return False - - -def parse_include(line): - remainder = line.strip() - - if remainder.startswith('#include '): - isInclude = True - remainder = remainder[len('#include '):] - elif remainder.startswith('#import '): - isInclude = False - remainder = remainder[len('#import '):] - elif remainder == '//': - return None - elif not remainder: - return None - else: - print ('Unexpected import or include: '+ line) - sys.exit(1) - - comment = None - if remainder.startswith('"'): - isQuote = True - endIndex = remainder.find('"', 1) - if endIndex < 0: - print ('Unexpected import or include: '+ line) - sys.exit(1) - body = remainder[1:endIndex] - comment = remainder[endIndex+1:] - elif remainder.startswith('<'): - isQuote = False - endIndex = remainder.find('>', 1) - if endIndex < 0: - print ('Unexpected import or include: '+ line) - sys.exit(1) - body = remainder[1:endIndex] - comment = remainder[endIndex+1:] - else: - print ('Unexpected import or include: '+ remainder) - sys.exit(1) - - return include(isInclude, isQuote, body, comment) - - -def parse_includes(text): - lines = text.split('\n') - - includes = [] - for line in lines: - include = parse_include(line) - if include: - includes.append(include) - - return includes - - -def sort_include_block(text, filepath, filename, file_extension): - lines = text.split('\n') - - includes = parse_includes(text) - - blocks = [] - - file_extension = file_extension.lower() - - for include in includes: - include.isInclude = False - - if file_extension in ('c', 'cpp', 'hpp'): - for include in includes: - include.isInclude = True - elif file_extension in ('m'): - for include in includes: - include.isInclude = False - - # Make sure matching header is first. - matching_header_includes = [] - other_includes = [] - def is_matching_header(include): - filename_wo_ext = os.path.splitext(filename)[0] - include_filename_wo_ext = os.path.splitext(os.path.basename(include.body))[0] - return filename_wo_ext == include_filename_wo_ext - for include in includes: - if is_matching_header(include): - matching_header_includes.append(include) - else: - other_includes.append(include) - includes = other_includes - - def formatBlock(includes): - lines = [include.format() for include in includes] - lines = list(set(lines)) - def include_sorter(a, b): - # return cmp(a.lower(), b.lower()) - return cmp(a, b) - # print 'before' - # for line in lines: - # print '\t', line - # print - lines.sort(include_sorter) - # print 'after' - # for line in lines: - # print '\t', line - # print - # print - # print 'filepath' - # for line in lines: - # print '\t', line - # print - return '\n'.join(lines) - - includeAngles = [include for include in includes if include.isInclude and not include.isQuote] - includeQuotes = [include for include in includes if include.isInclude and include.isQuote] - importAngles = [include for include in includes if (not include.isInclude) and not include.isQuote] - importQuotes = [include for include in includes if (not include.isInclude) and include.isQuote] - if matching_header_includes: - blocks.append(formatBlock(matching_header_includes)) - if includeQuotes: - blocks.append(formatBlock(includeQuotes)) - if includeAngles: - blocks.append(formatBlock(includeAngles)) - if importQuotes: - blocks.append(formatBlock(importQuotes)) - if importAngles: - blocks.append(formatBlock(importAngles)) - - return '\n'.join(blocks) + '\n' - - -def sort_class_statement_block(text, filepath, filename, file_extension): - lines = text.split('\n') - lines = [line.strip() for line in lines if line.strip()] - lines = list(set(lines)) - lines.sort() - return '\n' + '\n'.join(lines) + '\n' - - -def find_matching_section(text, match_test): - lines = text.split('\n') - first_matching_line_index = None - for index, line in enumerate(lines): - if match_test(line): - first_matching_line_index = index - break - - if first_matching_line_index is None: - return None - - # Absorb any leading empty lines. - while first_matching_line_index > 0: - prev_line = lines[first_matching_line_index - 1] - if prev_line.strip(): - break - first_matching_line_index = first_matching_line_index - 1 - - first_non_matching_line_index = None - for index, line in enumerate(lines[first_matching_line_index:]): - if not line.strip(): - # Absorb any trailing empty lines. - continue - if not match_test(line): - first_non_matching_line_index = index + first_matching_line_index - break - - text0 = '\n'.join(lines[:first_matching_line_index]) - if first_non_matching_line_index is None: - text1 = '\n'.join(lines[first_matching_line_index:]) - text2 = None - else: - text1 = '\n'.join(lines[first_matching_line_index:first_non_matching_line_index]) - text2 = '\n'.join(lines[first_non_matching_line_index:]) - - return text0, text1, text2 - - -def sort_matching_blocks(sort_name, filepath, filename, file_extension, text, match_func, sort_func): - unprocessed = text - processed = None - while True: - section = find_matching_section(unprocessed, match_func) - # print '\t', 'sort_matching_blocks', section - if not section: - if processed: - processed = '\n'.join((processed, unprocessed,)) - else: - processed = unprocessed - break - - text0, text1, text2 = section - - if processed: - processed = '\n'.join((processed, text0,)) - else: - processed = text0 - - # print 'before:' - # temp_lines = text1.split('\n') - # for index, line in enumerate(temp_lines): - # if index < 3 or index + 3 >= len(temp_lines): - # print '\t', index, line - # # print text1 - # print - text1 = sort_func(text1, filepath, filename, file_extension) - # print 'after:' - # # print text1 - # temp_lines = text1.split('\n') - # for index, line in enumerate(temp_lines): - # if index < 3 or index + 3 >= len(temp_lines): - # print '\t', index, line - # print - processed = '\n'.join((processed, text1,)) - if text2: - unprocessed = text2 - else: - break - - if text != processed: - print sort_name, filepath - return processed - - -def find_class_statement_section(text): - def is_class_statement(line): - return line.strip().startswith('@class ') - - return find_matching_section(text, is_class_statement) - - -def find_include_section(text): - def is_include_line(line): - return is_include_or_import(line) - # return is_include_or_import_or_empty(line) - - return find_matching_section(text, is_include_line) - - -def sort_includes(filepath, filename, file_extension, text): - # print 'sort_includes', filepath - if file_extension not in ('.h', '.m', '.mm'): - return text - return sort_matching_blocks('sort_includes', filepath, filename, file_extension, text, find_include_section, sort_include_block) - - -def sort_class_statements(filepath, filename, file_extension, text): - # print 'sort_class_statements', filepath - if file_extension not in ('.h', '.m', '.mm'): - return text - return sort_matching_blocks('sort_class_statements', filepath, filename, file_extension, text, find_class_statement_section, sort_class_statement_block) - - -def splitall(path): - allparts = [] - while 1: - parts = os.path.split(path) - if parts[0] == path: # sentinel for absolute paths - allparts.insert(0, parts[0]) - break - elif parts[1] == path: # sentinel for relative paths - allparts.insert(0, parts[1]) - break - else: - path = parts[0] - allparts.insert(0, parts[1]) - return allparts - - -def process(filepath): - - short_filepath = filepath[len(git_repo_path):] - if short_filepath.startswith(os.sep): - short_filepath = short_filepath[len(os.sep):] - - filename = os.path.basename(filepath) - if filename.startswith('.'): - raise "shouldn't call process with dotfile" - file_ext = os.path.splitext(filename)[1] - if file_ext in ('.swift'): - env_copy = os.environ.copy() - env_copy["SCRIPT_INPUT_FILE_COUNT"] = "1" - env_copy["SCRIPT_INPUT_FILE_0"] = '%s' % ( short_filepath, ) - lint_output = subprocess.check_output(['swiftlint', 'autocorrect', '--use-script-input-files'], env=env_copy) - print lint_output - try: - lint_output = subprocess.check_output(['swiftlint', 'lint', '--use-script-input-files'], env=env_copy) - except subprocess.CalledProcessError, e: - lint_output = e.output - print lint_output - - with open(filepath, 'rt') as f: - text = f.read() - - original_text = text - - text = sort_includes(filepath, filename, file_ext, text) - text = sort_class_statements(filepath, filename, file_ext, text) - - lines = text.split('\n') - while lines and lines[0].startswith('//'): - lines = lines[1:] - text = '\n'.join(lines) - text = text.strip() - - header = '''// -// Copyright (c) %s Open Whisper Systems. All rights reserved. -// - -''' % ( - datetime.datetime.now().year, - ) - text = header + text + '\n' - - if original_text == text: - return - - print 'Updating:', short_filepath - - with open(filepath, 'wt') as f: - f.write(text) - - -def should_ignore_path(path): - ignore_paths = [ - os.path.join(git_repo_path, '.git') - ] - for ignore_path in ignore_paths: - if path.startswith(ignore_path): - return True - for component in splitall(path): - if component.startswith('.'): - return True - if component.endswith('.framework'): - return True - if component in ('Pods', 'ThirdParty', 'Carthage',): - return True - - return False - - -def process_if_appropriate(filepath): - filename = os.path.basename(filepath) - if filename.startswith('.'): - return - file_ext = os.path.splitext(filename)[1] - if file_ext not in ('.h', '.hpp', '.cpp', '.m', '.mm', '.pch', '.swift'): - return - if should_ignore_path(filepath): - return - process(filepath) - - -def check_diff_for_keywords(): - objc_keywords = [ - "OWSAbstractMethod\(" - "OWSAssert\(", - "OWSCAssert\(", - "OWSFail\(", - "OWSCFail\(", - "ows_add_overflow\(", - "ows_sub_overflow\(", - ] - - swift_keywords = [ - "owsFail\(", - "precondition\(", - "fatalError\(", - "dispatchPrecondition\(", - "preconditionFailure\(", - "notImplemented\(" - ] - - keywords = objc_keywords + swift_keywords - - matching_expression = "|".join(keywords) - command_line = 'git diff --staged | grep --color=always -C 3 -E "%s"' % matching_expression - try: - output = subprocess.check_output(command_line, shell=True) - except subprocess.CalledProcessError, e: - # > man grep - # EXIT STATUS - # The grep utility exits with one of the following values: - # 0 One or more lines were selected. - # 1 No lines were selected. - # >1 An error occurred. - if e.returncode == 1: - # no keywords in diff output - return - else: - # some other error - bad grep expression? - raise e - - if len(output) > 0: - print("⚠️ keywords detected in diff:") - print(output) - - -if __name__ == "__main__": - - parser = argparse.ArgumentParser(description='Precommit script.') - parser.add_argument('--all', action='store_true', help='process all files in or below current dir') - parser.add_argument('--path', help='used to specify a path to process.') - args = parser.parse_args() - - if args.all: - for rootdir, dirnames, filenames in os.walk(git_repo_path): - for filename in filenames: - file_path = os.path.abspath(os.path.join(rootdir, filename)) - process_if_appropriate(file_path) - elif args.path: - for rootdir, dirnames, filenames in os.walk(args.path): - for filename in filenames: - file_path = os.path.abspath(os.path.join(rootdir, filename)) - process_if_appropriate(file_path) - else: - filepaths = [] - - # Staging - output = commands.getoutput('git diff --cached --name-only --diff-filter=ACMR') - filepaths.extend([line.strip() for line in output.split('\n')]) - - # Working - output = commands.getoutput('git diff --name-only --diff-filter=ACMR') - filepaths.extend([line.strip() for line in output.split('\n')]) - - # Only process each path once. - filepaths = sorted(set(filepaths)) - - for filepath in filepaths: - filepath = os.path.abspath(os.path.join(git_repo_path, filepath)) - process_if_appropriate(filepath) - - print 'git clang-format...' - print commands.getoutput('git clang-format') - - check_diff_for_keywords() diff --git a/ffi/swift/ZKGroup/AuthCredential.swift b/ffi/swift/Sources/ZKGroup/AuthCredential.swift similarity index 100% rename from ffi/swift/ZKGroup/AuthCredential.swift rename to ffi/swift/Sources/ZKGroup/AuthCredential.swift diff --git a/ffi/swift/ZKGroup/AuthCredentialPresentation.swift b/ffi/swift/Sources/ZKGroup/AuthCredentialPresentation.swift similarity index 100% rename from ffi/swift/ZKGroup/AuthCredentialPresentation.swift rename to ffi/swift/Sources/ZKGroup/AuthCredentialPresentation.swift diff --git a/ffi/swift/ZKGroup/AuthCredentialResponse.swift b/ffi/swift/Sources/ZKGroup/AuthCredentialResponse.swift similarity index 100% rename from ffi/swift/ZKGroup/AuthCredentialResponse.swift rename to ffi/swift/Sources/ZKGroup/AuthCredentialResponse.swift diff --git a/ffi/swift/ZKGroup/ByteArray.swift b/ffi/swift/Sources/ZKGroup/ByteArray.swift similarity index 100% rename from ffi/swift/ZKGroup/ByteArray.swift rename to ffi/swift/Sources/ZKGroup/ByteArray.swift diff --git a/ffi/swift/ZKGroup/ClientZkAuthOperations.swift b/ffi/swift/Sources/ZKGroup/ClientZkAuthOperations.swift similarity index 100% rename from ffi/swift/ZKGroup/ClientZkAuthOperations.swift rename to ffi/swift/Sources/ZKGroup/ClientZkAuthOperations.swift diff --git a/ffi/swift/ZKGroup/ClientZkGroupCipher.swift b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift similarity index 100% rename from ffi/swift/ZKGroup/ClientZkGroupCipher.swift rename to ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift diff --git a/ffi/swift/ZKGroup/ClientZkProfileOperations.swift b/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift similarity index 100% rename from ffi/swift/ZKGroup/ClientZkProfileOperations.swift rename to ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift diff --git a/ffi/swift/ZKGroup/Errors.swift b/ffi/swift/Sources/ZKGroup/Errors.swift similarity index 100% rename from ffi/swift/ZKGroup/Errors.swift rename to ffi/swift/Sources/ZKGroup/Errors.swift diff --git a/ffi/swift/ZKGroup/GroupIdentifier.swift b/ffi/swift/Sources/ZKGroup/GroupIdentifier.swift similarity index 100% rename from ffi/swift/ZKGroup/GroupIdentifier.swift rename to ffi/swift/Sources/ZKGroup/GroupIdentifier.swift diff --git a/ffi/swift/ZKGroup/GroupMasterKey.swift b/ffi/swift/Sources/ZKGroup/GroupMasterKey.swift similarity index 100% rename from ffi/swift/ZKGroup/GroupMasterKey.swift rename to ffi/swift/Sources/ZKGroup/GroupMasterKey.swift diff --git a/ffi/swift/ZKGroup/GroupPublicParams.swift b/ffi/swift/Sources/ZKGroup/GroupPublicParams.swift similarity index 100% rename from ffi/swift/ZKGroup/GroupPublicParams.swift rename to ffi/swift/Sources/ZKGroup/GroupPublicParams.swift diff --git a/ffi/swift/ZKGroup/GroupSecretParams.swift b/ffi/swift/Sources/ZKGroup/GroupSecretParams.swift similarity index 100% rename from ffi/swift/ZKGroup/GroupSecretParams.swift rename to ffi/swift/Sources/ZKGroup/GroupSecretParams.swift diff --git a/ffi/swift/ZKGroup/Native.swift b/ffi/swift/Sources/ZKGroup/Native.swift similarity index 100% rename from ffi/swift/ZKGroup/Native.swift rename to ffi/swift/Sources/ZKGroup/Native.swift diff --git a/ffi/swift/ZKGroup/NotarySignature.swift b/ffi/swift/Sources/ZKGroup/NotarySignature.swift similarity index 100% rename from ffi/swift/ZKGroup/NotarySignature.swift rename to ffi/swift/Sources/ZKGroup/NotarySignature.swift diff --git a/ffi/swift/ZKGroup/ProfileKey.swift b/ffi/swift/Sources/ZKGroup/ProfileKey.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKey.swift rename to ffi/swift/Sources/ZKGroup/ProfileKey.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyCiphertext.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyCiphertext.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyCiphertext.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyCiphertext.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyCommitment.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyCommitment.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyCommitment.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyCommitment.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyCredential.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyCredential.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyCredential.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyCredential.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyCredentialPresentation.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyCredentialPresentation.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyCredentialPresentation.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyCredentialPresentation.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyCredentialRequest.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyCredentialRequest.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyCredentialRequest.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyCredentialRequest.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyCredentialRequestContext.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyCredentialRequestContext.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyCredentialRequestContext.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyCredentialRequestContext.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyCredentialResponse.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyCredentialResponse.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyCredentialResponse.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyCredentialResponse.swift diff --git a/ffi/swift/ZKGroup/ProfileKeyVersion.swift b/ffi/swift/Sources/ZKGroup/ProfileKeyVersion.swift similarity index 100% rename from ffi/swift/ZKGroup/ProfileKeyVersion.swift rename to ffi/swift/Sources/ZKGroup/ProfileKeyVersion.swift diff --git a/ffi/swift/ZKGroup/ServerPublicParams.swift b/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift similarity index 100% rename from ffi/swift/ZKGroup/ServerPublicParams.swift rename to ffi/swift/Sources/ZKGroup/ServerPublicParams.swift diff --git a/ffi/swift/ZKGroup/ServerSecretParams.swift b/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift similarity index 100% rename from ffi/swift/ZKGroup/ServerSecretParams.swift rename to ffi/swift/Sources/ZKGroup/ServerSecretParams.swift diff --git a/ffi/swift/ZKGroup/ServerZkAuthOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkAuthOperations.swift similarity index 100% rename from ffi/swift/ZKGroup/ServerZkAuthOperations.swift rename to ffi/swift/Sources/ZKGroup/ServerZkAuthOperations.swift diff --git a/ffi/swift/ZKGroup/ServerZkProfileOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift similarity index 100% rename from ffi/swift/ZKGroup/ServerZkProfileOperations.swift rename to ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift diff --git a/ffi/swift/ZKGroup/Uuid.swift b/ffi/swift/Sources/ZKGroup/Uuid.swift similarity index 100% rename from ffi/swift/ZKGroup/Uuid.swift rename to ffi/swift/Sources/ZKGroup/Uuid.swift diff --git a/ffi/swift/ZKGroup/UuidCiphertext.swift b/ffi/swift/Sources/ZKGroup/UuidCiphertext.swift similarity index 100% rename from ffi/swift/ZKGroup/UuidCiphertext.swift rename to ffi/swift/Sources/ZKGroup/UuidCiphertext.swift diff --git a/ffi/swift/Sources/libzkgroup/module.modulemap b/ffi/swift/Sources/libzkgroup/module.modulemap new file mode 100644 index 0000000..19171b5 --- /dev/null +++ b/ffi/swift/Sources/libzkgroup/module.modulemap @@ -0,0 +1,8 @@ +// +// Copyright 2020-2021 Signal Messenger, LLC. +// SPDX-License-Identifier: AGPL-3.0-only +// +module libzkgroup { + header "zkgroup.h" + link "zkgroup" +} diff --git a/ffi/swift/Sources/libzkgroup/zkgroup.h b/ffi/swift/Sources/libzkgroup/zkgroup.h new file mode 100644 index 0000000..6587518 --- /dev/null +++ b/ffi/swift/Sources/libzkgroup/zkgroup.h @@ -0,0 +1,344 @@ +#include +#include +#include +#include + +#define NUM_AUTH_CRED_ATTRIBUTES 3 + +#define NUM_PROFILE_KEY_CRED_ATTRIBUTES 4 + +#define AES_KEY_LEN 32 + +#define AESGCM_NONCE_LEN 12 + +#define AESGCM_TAG_LEN 16 + +#define GROUP_MASTER_KEY_LEN 32 + +#define GROUP_SECRET_PARAMS_LEN 289 + +#define GROUP_PUBLIC_PARAMS_LEN 97 + +#define GROUP_IDENTIFIER_LEN 32 + +#define AUTH_CREDENTIAL_LEN 342 + +#define AUTH_CREDENTIAL_PRESENTATION_LEN 493 + +#define AUTH_CREDENTIAL_RESPONSE_LEN 361 + +#define PROFILE_KEY_LEN 32 + +#define PROFILE_KEY_CIPHERTEXT_LEN 65 + +#define PROFILE_KEY_COMMITMENT_LEN 97 + +#define PROFILE_KEY_CREDENTIAL_LEN 145 + +#define PROFILE_KEY_CREDENTIAL_PRESENTATION_LEN 713 + +#define PROFILE_KEY_CREDENTIAL_REQUEST_LEN 329 + +#define PROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN 473 + +#define PROFILE_KEY_CREDENTIAL_RESPONSE_LEN 457 + +#define PROFILE_KEY_VERSION_LEN 32 + +#define PROFILE_KEY_VERSION_ENCODED_LEN 64 + +#define RESERVED_LEN 1 + +#define SERVER_SECRET_PARAMS_LEN 769 + +#define SERVER_PUBLIC_PARAMS_LEN 161 + +#define UUID_CIPHERTEXT_LEN 65 + +#define RANDOMNESS_LEN 32 + +#define SIGNATURE_LEN 64 + +#define UUID_LEN 16 + +#define FFI_RETURN_OK 0 + +#define FFI_RETURN_INTERNAL_ERROR 1 + +#define FFI_RETURN_INPUT_ERROR 2 + +int32_t FFI_ProfileKey_getCommitment(const uint8_t *profileKey, + uint32_t profileKeyLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyCommitmentOut, + uint32_t profileKeyCommitmentLen); + +int32_t FFI_ProfileKey_getProfileKeyVersion(const uint8_t *profileKey, + uint32_t profileKeyLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyVersionOut, + uint32_t profileKeyVersionLen); + +int32_t FFI_ProfileKeyCommitment_checkValidContents(const uint8_t *profileKeyCommitment, + uint32_t profileKeyCommitmentLen); + +int32_t FFI_GroupSecretParams_generateDeterministic(const uint8_t *randomness, + uint32_t randomnessLen, + uint8_t *groupSecretParamsOut, + uint32_t groupSecretParamsLen); + +int32_t FFI_GroupSecretParams_deriveFromMasterKey(const uint8_t *groupMasterKey, + uint32_t groupMasterKeyLen, + uint8_t *groupSecretParamsOut, + uint32_t groupSecretParamsLen); + +int32_t FFI_GroupSecretParams_checkValidContents(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen); + +int32_t FFI_GroupSecretParams_getMasterKey(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + uint8_t *groupMasterKeyOut, + uint32_t groupMasterKeyLen); + +int32_t FFI_GroupSecretParams_getPublicParams(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + uint8_t *groupPublicParamsOut, + uint32_t groupPublicParamsLen); + +int32_t FFI_GroupSecretParams_encryptUuid(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_GroupSecretParams_decryptUuid(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *uuidCiphertext, + uint32_t uuidCiphertextLen, + uint8_t *uuidOut, + uint32_t uuidLen); + +int32_t FFI_GroupSecretParams_encryptProfileKey(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *profileKey, + uint32_t profileKeyLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyCiphertextOut, + uint32_t profileKeyCiphertextLen); + +int32_t FFI_GroupSecretParams_decryptProfileKey(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *profileKeyCiphertext, + uint32_t profileKeyCiphertextLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyOut, + uint32_t profileKeyLen); + +int32_t FFI_GroupSecretParams_encryptBlobDeterministic(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *plaintext, + uint32_t plaintextLen, + uint8_t *blobCiphertextOut, + uint32_t blobCiphertextLen); + +int32_t FFI_GroupSecretParams_decryptBlob(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *blobCiphertext, + uint32_t blobCiphertextLen, + uint8_t *plaintextOut, + uint32_t plaintextLen); + +int32_t FFI_ServerSecretParams_generateDeterministic(const uint8_t *randomness, + uint32_t randomnessLen, + uint8_t *serverSecretParamsOut, + uint32_t serverSecretParamsLen); + +int32_t FFI_ServerSecretParams_checkValidContents(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen); + +int32_t FFI_ServerSecretParams_getPublicParams(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + uint8_t *serverPublicParamsOut, + uint32_t serverPublicParamsLen); + +int32_t FFI_ServerSecretParams_signDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *message, + uint32_t messageLen, + uint8_t *notarySignatureOut, + uint32_t notarySignatureLen); + +int32_t FFI_ServerPublicParams_receiveAuthCredential(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint32_t redemptionTime, + const uint8_t *authCredentialResponse, + uint32_t authCredentialResponseLen, + uint8_t *authCredentialOut, + uint32_t authCredentialLen); + +int32_t FFI_ServerPublicParams_createAuthCredentialPresentationDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *authCredential, + uint32_t authCredentialLen, + uint8_t *authCredentialPresentationOut, + uint32_t authCredentialPresentationLen); + +int32_t FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *uuid, + uint32_t uuidLen, + const uint8_t *profileKey, + uint32_t profileKeyLen, + uint8_t *profileKeyCredentialRequestContextOut, + uint32_t profileKeyCredentialRequestContextLen); + +int32_t FFI_ServerPublicParams_receiveProfileKeyCredential(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *profileKeyCredentialRequestContext, + uint32_t profileKeyCredentialRequestContextLen, + const uint8_t *profileKeyCredentialResponse, + uint32_t profileKeyCredentialResponseLen, + uint8_t *profileKeyCredentialOut, + uint32_t profileKeyCredentialLen); + +int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *profileKeyCredential, + uint32_t profileKeyCredentialLen, + uint8_t *profileKeyCredentialPresentationOut, + uint32_t profileKeyCredentialPresentationLen); + +int32_t FFI_ServerSecretParams_issueAuthCredentialDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint32_t redemptionTime, + uint8_t *authCredentialResponseOut, + uint32_t authCredentialResponseLen); + +int32_t FFI_ServerSecretParams_verifyAuthCredentialPresentation(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen, + const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen); + +int32_t FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *profileKeyCredentialRequest, + uint32_t profileKeyCredentialRequestLen, + const uint8_t *uuid, + uint32_t uuidLen, + const uint8_t *profileKeyCommitment, + uint32_t profileKeyCommitmentLen, + uint8_t *profileKeyCredentialResponseOut, + uint32_t profileKeyCredentialResponseLen); + +int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen, + const uint8_t *profileKeyCredentialPresentation, + uint32_t profileKeyCredentialPresentationLen); + +int32_t FFI_GroupPublicParams_checkValidContents(const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen); + +int32_t FFI_GroupPublicParams_getGroupIdentifier(const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen, + uint8_t *groupIdentifierOut, + uint32_t groupIdentifierLen); + +int32_t FFI_ServerPublicParams_checkValidContents(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen); + +int32_t FFI_ServerPublicParams_verifySignature(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *message, + uint32_t messageLen, + const uint8_t *notarySignature, + uint32_t notarySignatureLen); + +int32_t FFI_AuthCredentialResponse_checkValidContents(const uint8_t *authCredentialResponse, + uint32_t authCredentialResponseLen); + +int32_t FFI_AuthCredential_checkValidContents(const uint8_t *authCredential, + uint32_t authCredentialLen); + +int32_t FFI_AuthCredentialPresentation_checkValidContents(const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen); + +int32_t FFI_AuthCredentialPresentation_getUuidCiphertext(const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_AuthCredentialPresentation_getRedemptionTime(const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen, + uint8_t *redemptionTimeOut, + uint32_t redemptionTimeLen); + +int32_t FFI_ProfileKeyCredentialRequestContext_checkValidContents(const uint8_t *profileKeyCredentialRequestContext, + uint32_t profileKeyCredentialRequestContextLen); + +int32_t FFI_ProfileKeyCredentialRequestContext_getRequest(const uint8_t *profileKeyCredentialRequestContext, + uint32_t profileKeyCredentialRequestContextLen, + uint8_t *profileKeyCredentialRequestOut, + uint32_t profileKeyCredentialRequestLen); + +int32_t FFI_ProfileKeyCredentialRequest_checkValidContents(const uint8_t *profileKeyCredentialRequest, + uint32_t profileKeyCredentialRequestLen); + +int32_t FFI_ProfileKeyCredentialResponse_checkValidContents(const uint8_t *profileKeyCredentialResponse, + uint32_t profileKeyCredentialResponseLen); + +int32_t FFI_ProfileKeyCredential_checkValidContents(const uint8_t *profileKeyCredential, + uint32_t profileKeyCredentialLen); + +int32_t FFI_ProfileKeyCredentialPresentation_checkValidContents(const uint8_t *profileKeyCredentialPresentation, + uint32_t profileKeyCredentialPresentationLen); + +int32_t FFI_ProfileKeyCredentialPresentation_getUuidCiphertext(const uint8_t *profileKeyCredentialPresentation, + uint32_t profileKeyCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext(const uint8_t *profileKeyCredentialPresentation, + uint32_t profileKeyCredentialPresentationLen, + uint8_t *profileKeyCiphertextOut, + uint32_t profileKeyCiphertextLen); + +int32_t FFI_UuidCiphertext_checkValidContents(const uint8_t *uuidCiphertext, + uint32_t uuidCiphertextLen); + +int32_t FFI_ProfileKeyCiphertext_checkValidContents(const uint8_t *profileKeyCiphertext, + uint32_t profileKeyCiphertextLen); + +int32_t FFI_Randomness_checkValidContents(const uint8_t *randomness, uint32_t randomnessLen); + +int32_t FFI_Uuid_checkValidContents(const uint8_t *uuid, uint32_t uuidLen); diff --git a/ffi/swift/ZKGroupTests/ZKGroupTests.swift b/ffi/swift/Tests/ZKGroupTests.swift similarity index 100% rename from ffi/swift/ZKGroupTests/ZKGroupTests.swift rename to ffi/swift/Tests/ZKGroupTests.swift diff --git a/ffi/swift/ZKGroup.podspec b/ffi/swift/ZKGroup.podspec deleted file mode 100644 index 2c0e052..0000000 --- a/ffi/swift/ZKGroup.podspec +++ /dev/null @@ -1,34 +0,0 @@ -# -# Be sure to run `pod spec lint credential.podspec' to ensure this is a -# valid spec and to remove all comments including this before submitting the spec. -# -# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html -# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ -# - -Pod::Spec.new do |s| - s.name = "ZKGroup" - s.version = "0.7.2" - s.summary = "Swift API for the Rust zkgroup crate." - s.homepage = "https://signal.org/" - s.license = { :type => "GPLv3", :file => "LICENSE" } - s.authors = { "Signal iOS" => "ios@signal.org" } - s.source = { :git => "https://github.com/signalapp/signal-groupzk-swift.git", :tag => "#{s.version}" } - - s.ios.deployment_target = "10.0" - - s.ios.vendored_library = "ZKGroup/libzkgroup/libzkgroup_ios.a" - - s.source_files = "ZKGroup/**/*.{h,swift}" - - s.preserve_paths = 'ZKGroup/libzkgroup/module.modulemap' - s.pod_target_xcconfig = { - 'SWIFT_INCLUDE_PATHS' => '$(PODS_TARGET_SRCROOT)/ZKGroup/libzkgroup', - } - - s.requires_arc = true - - s.test_spec 'Tests' do |test_spec| - test_spec.source_files = 'ZKGroupTests/*.{h,m,swift}' - end -end diff --git a/ffi/swift/ZKGroup.xcodeproj/project.pbxproj b/ffi/swift/ZKGroup.xcodeproj/project.pbxproj deleted file mode 100644 index 6f4fc42..0000000 --- a/ffi/swift/ZKGroup.xcodeproj/project.pbxproj +++ /dev/null @@ -1,622 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - 20118BA0237101A6004584B6 /* GroupSecretParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20118B9D237101A6004584B6 /* GroupSecretParams.swift */; }; - 20118BA1237101A6004584B6 /* ByteArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20118B9E237101A6004584B6 /* ByteArray.swift */; }; - 20118BA2237101A6004584B6 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20118B9F237101A6004584B6 /* Errors.swift */; }; - 20A67AB32374813600CB56A1 /* AuthCredential.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AB02374813600CB56A1 /* AuthCredential.swift */; }; - 20A67AB42374813600CB56A1 /* AuthCredentialResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AB12374813600CB56A1 /* AuthCredentialResponse.swift */; }; - 20A67AB52374813600CB56A1 /* AuthCredentialPresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AB22374813600CB56A1 /* AuthCredentialPresentation.swift */; }; - 20A67ABA2374814A00CB56A1 /* ClientZkProfileOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AB62374814A00CB56A1 /* ClientZkProfileOperations.swift */; }; - 20A67ABC2374814A00CB56A1 /* ClientZkGroupCipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AB82374814A00CB56A1 /* ClientZkGroupCipher.swift */; }; - 20A67ABD2374814A00CB56A1 /* ClientZkAuthOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AB92374814A00CB56A1 /* ClientZkAuthOperations.swift */; }; - 20A67AC12374819000CB56A1 /* GroupMasterKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ABE2374819000CB56A1 /* GroupMasterKey.swift */; }; - 20A67AC22374819000CB56A1 /* GroupIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ABF2374819000CB56A1 /* GroupIdentifier.swift */; }; - 20A67AC32374819000CB56A1 /* GroupPublicParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AC02374819000CB56A1 /* GroupPublicParams.swift */; }; - 20A67AD5237481AD00CB56A1 /* ServerZkProfileOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AC4237481AC00CB56A1 /* ServerZkProfileOperations.swift */; }; - 20A67AD6237481AD00CB56A1 /* Native.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AC5237481AC00CB56A1 /* Native.swift */; }; - 20A67AD7237481AD00CB56A1 /* UuidCiphertext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AC6237481AC00CB56A1 /* UuidCiphertext.swift */; }; - 20A67AD8237481AD00CB56A1 /* ProfileKeyCredentialRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AC7237481AC00CB56A1 /* ProfileKeyCredentialRequest.swift */; }; - 20A67AD9237481AD00CB56A1 /* Uuid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AC8237481AC00CB56A1 /* Uuid.swift */; }; - 20A67ADA237481AD00CB56A1 /* ServerZkAuthOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AC9237481AC00CB56A1 /* ServerZkAuthOperations.swift */; }; - 20A67ADB237481AD00CB56A1 /* ProfileKeyCredentialResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ACA237481AC00CB56A1 /* ProfileKeyCredentialResponse.swift */; }; - 20A67ADC237481AD00CB56A1 /* ServerPublicParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ACB237481AC00CB56A1 /* ServerPublicParams.swift */; }; - 20A67ADD237481AD00CB56A1 /* ServerSecretParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ACC237481AC00CB56A1 /* ServerSecretParams.swift */; }; - 20A67ADE237481AD00CB56A1 /* ProfileKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ACD237481AC00CB56A1 /* ProfileKey.swift */; }; - 20A67ADF237481AD00CB56A1 /* ProfileKeyCommitment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ACE237481AC00CB56A1 /* ProfileKeyCommitment.swift */; }; - 20A67AE0237481AD00CB56A1 /* ProfileKeyCredential.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67ACF237481AC00CB56A1 /* ProfileKeyCredential.swift */; }; - 20A67AE1237481AD00CB56A1 /* ProfileKeyCiphertext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AD0237481AC00CB56A1 /* ProfileKeyCiphertext.swift */; }; - 20A67AE2237481AD00CB56A1 /* NotarySignature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AD1237481AC00CB56A1 /* NotarySignature.swift */; }; - 20A67AE3237481AD00CB56A1 /* ProfileKeyCredentialPresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AD2237481AC00CB56A1 /* ProfileKeyCredentialPresentation.swift */; }; - 20A67AE4237481AD00CB56A1 /* ProfileKeyVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AD3237481AC00CB56A1 /* ProfileKeyVersion.swift */; }; - 20A67AE5237481AD00CB56A1 /* ProfileKeyCredentialRequestContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A67AD4237481AD00CB56A1 /* ProfileKeyCredentialRequestContext.swift */; }; - 4C6814EA229EFF00006FC282 /* ZKGroup.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C6814E0229EFF00006FC282 /* ZKGroup.framework */; }; - 4C6814EF229EFF00006FC282 /* ZKGroupTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C6814EE229EFF00006FC282 /* ZKGroupTests.swift */; }; - 4C6814F1229EFF00006FC282 /* ZKGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C6814E3229EFF00006FC282 /* ZKGroup.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4CD24E7F229F122800BF655D /* libzkgroup_ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CD24E79229F0D3B00BF655D /* libzkgroup_ios.a */; }; - 4CD24E80229F122F00BF655D /* zkgroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CD24E78229F0D3B00BF655D /* zkgroup.h */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 4C6814EB229EFF00006FC282 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4C6814D7229EFF00006FC282 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4C6814DF229EFF00006FC282; - remoteInfo = ZKGroup; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 20118B9D237101A6004584B6 /* GroupSecretParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupSecretParams.swift; sourceTree = ""; }; - 20118B9E237101A6004584B6 /* ByteArray.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ByteArray.swift; sourceTree = ""; }; - 20118B9F237101A6004584B6 /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = ""; }; - 20A67AB02374813600CB56A1 /* AuthCredential.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthCredential.swift; sourceTree = ""; }; - 20A67AB12374813600CB56A1 /* AuthCredentialResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthCredentialResponse.swift; sourceTree = ""; }; - 20A67AB22374813600CB56A1 /* AuthCredentialPresentation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthCredentialPresentation.swift; sourceTree = ""; }; - 20A67AB62374814A00CB56A1 /* ClientZkProfileOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClientZkProfileOperations.swift; sourceTree = ""; }; - 20A67AB82374814A00CB56A1 /* ClientZkGroupCipher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClientZkGroupCipher.swift; sourceTree = ""; }; - 20A67AB92374814A00CB56A1 /* ClientZkAuthOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClientZkAuthOperations.swift; sourceTree = ""; }; - 20A67ABE2374819000CB56A1 /* GroupMasterKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupMasterKey.swift; sourceTree = ""; }; - 20A67ABF2374819000CB56A1 /* GroupIdentifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupIdentifier.swift; sourceTree = ""; }; - 20A67AC02374819000CB56A1 /* GroupPublicParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupPublicParams.swift; sourceTree = ""; }; - 20A67AC4237481AC00CB56A1 /* ServerZkProfileOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServerZkProfileOperations.swift; sourceTree = ""; }; - 20A67AC5237481AC00CB56A1 /* Native.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Native.swift; sourceTree = ""; }; - 20A67AC6237481AC00CB56A1 /* UuidCiphertext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UuidCiphertext.swift; sourceTree = ""; }; - 20A67AC7237481AC00CB56A1 /* ProfileKeyCredentialRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyCredentialRequest.swift; sourceTree = ""; }; - 20A67AC8237481AC00CB56A1 /* Uuid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Uuid.swift; sourceTree = ""; }; - 20A67AC9237481AC00CB56A1 /* ServerZkAuthOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServerZkAuthOperations.swift; sourceTree = ""; }; - 20A67ACA237481AC00CB56A1 /* ProfileKeyCredentialResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyCredentialResponse.swift; sourceTree = ""; }; - 20A67ACB237481AC00CB56A1 /* ServerPublicParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServerPublicParams.swift; sourceTree = ""; }; - 20A67ACC237481AC00CB56A1 /* ServerSecretParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServerSecretParams.swift; sourceTree = ""; }; - 20A67ACD237481AC00CB56A1 /* ProfileKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKey.swift; sourceTree = ""; }; - 20A67ACE237481AC00CB56A1 /* ProfileKeyCommitment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyCommitment.swift; sourceTree = ""; }; - 20A67ACF237481AC00CB56A1 /* ProfileKeyCredential.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyCredential.swift; sourceTree = ""; }; - 20A67AD0237481AC00CB56A1 /* ProfileKeyCiphertext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyCiphertext.swift; sourceTree = ""; }; - 20A67AD1237481AC00CB56A1 /* NotarySignature.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotarySignature.swift; sourceTree = ""; }; - 20A67AD2237481AC00CB56A1 /* ProfileKeyCredentialPresentation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyCredentialPresentation.swift; sourceTree = ""; }; - 20A67AD3237481AC00CB56A1 /* ProfileKeyVersion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyVersion.swift; sourceTree = ""; }; - 20A67AD4237481AD00CB56A1 /* ProfileKeyCredentialRequestContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileKeyCredentialRequestContext.swift; sourceTree = ""; }; - 4C6814E0229EFF00006FC282 /* ZKGroup.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZKGroup.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C6814E3229EFF00006FC282 /* ZKGroup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZKGroup.h; sourceTree = ""; }; - 4C6814E4229EFF00006FC282 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 4C6814E9229EFF00006FC282 /* ZKGroupTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ZKGroupTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C6814EE229EFF00006FC282 /* ZKGroupTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZKGroupTests.swift; sourceTree = ""; }; - 4C6814F0229EFF00006FC282 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 4CD24E77229F0D3B00BF655D /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; - 4CD24E78229F0D3B00BF655D /* zkgroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zkgroup.h; sourceTree = ""; }; - 4CD24E79229F0D3B00BF655D /* libzkgroup_ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libzkgroup_ios.a; sourceTree = ""; }; - 4CD24E7A229F0D3B00BF655D /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 4C6814DD229EFF00006FC282 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4CD24E7F229F122800BF655D /* libzkgroup_ios.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C6814E6229EFF00006FC282 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C6814EA229EFF00006FC282 /* ZKGroup.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 4C6814D6229EFF00006FC282 = { - isa = PBXGroup; - children = ( - 4C6814E2229EFF00006FC282 /* ZKGroup */, - 4C6814ED229EFF00006FC282 /* ZKGroupTests */, - 4C6814E1229EFF00006FC282 /* Products */, - 4CD24E7E229F122800BF655D /* Frameworks */, - ); - sourceTree = ""; - }; - 4C6814E1229EFF00006FC282 /* Products */ = { - isa = PBXGroup; - children = ( - 4C6814E0229EFF00006FC282 /* ZKGroup.framework */, - 4C6814E9229EFF00006FC282 /* ZKGroupTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 4C6814E2229EFF00006FC282 /* ZKGroup */ = { - isa = PBXGroup; - children = ( - 20A67AC5237481AC00CB56A1 /* Native.swift */, - 20A67AD1237481AC00CB56A1 /* NotarySignature.swift */, - 20A67ACD237481AC00CB56A1 /* ProfileKey.swift */, - 20A67AD0237481AC00CB56A1 /* ProfileKeyCiphertext.swift */, - 20A67ACE237481AC00CB56A1 /* ProfileKeyCommitment.swift */, - 20A67ACF237481AC00CB56A1 /* ProfileKeyCredential.swift */, - 20A67AD2237481AC00CB56A1 /* ProfileKeyCredentialPresentation.swift */, - 20A67AC7237481AC00CB56A1 /* ProfileKeyCredentialRequest.swift */, - 20A67AD4237481AD00CB56A1 /* ProfileKeyCredentialRequestContext.swift */, - 20A67ACA237481AC00CB56A1 /* ProfileKeyCredentialResponse.swift */, - 20A67AD3237481AC00CB56A1 /* ProfileKeyVersion.swift */, - 20A67ACB237481AC00CB56A1 /* ServerPublicParams.swift */, - 20A67ACC237481AC00CB56A1 /* ServerSecretParams.swift */, - 20A67AC9237481AC00CB56A1 /* ServerZkAuthOperations.swift */, - 20A67AC4237481AC00CB56A1 /* ServerZkProfileOperations.swift */, - 20A67AC8237481AC00CB56A1 /* Uuid.swift */, - 20A67AC6237481AC00CB56A1 /* UuidCiphertext.swift */, - 20A67ABF2374819000CB56A1 /* GroupIdentifier.swift */, - 20A67ABE2374819000CB56A1 /* GroupMasterKey.swift */, - 20A67AC02374819000CB56A1 /* GroupPublicParams.swift */, - 20A67AB92374814A00CB56A1 /* ClientZkAuthOperations.swift */, - 20A67AB82374814A00CB56A1 /* ClientZkGroupCipher.swift */, - 20A67AB62374814A00CB56A1 /* ClientZkProfileOperations.swift */, - 20A67AB02374813600CB56A1 /* AuthCredential.swift */, - 20A67AB22374813600CB56A1 /* AuthCredentialPresentation.swift */, - 20A67AB12374813600CB56A1 /* AuthCredentialResponse.swift */, - 20118B9E237101A6004584B6 /* ByteArray.swift */, - 20118B9F237101A6004584B6 /* Errors.swift */, - 20118B9D237101A6004584B6 /* GroupSecretParams.swift */, - 4CD24E76229F0D3B00BF655D /* libzkgroup */, - 4C6814E3229EFF00006FC282 /* ZKGroup.h */, - 4C6814E4229EFF00006FC282 /* Info.plist */, - ); - path = ZKGroup; - sourceTree = ""; - }; - 4C6814ED229EFF00006FC282 /* ZKGroupTests */ = { - isa = PBXGroup; - children = ( - 4C6814EE229EFF00006FC282 /* ZKGroupTests.swift */, - 4C6814F0229EFF00006FC282 /* Info.plist */, - ); - path = ZKGroupTests; - sourceTree = ""; - }; - 4CD24E76229F0D3B00BF655D /* libzkgroup */ = { - isa = PBXGroup; - children = ( - 4CD24E77229F0D3B00BF655D /* Makefile */, - 4CD24E78229F0D3B00BF655D /* zkgroup.h */, - 4CD24E79229F0D3B00BF655D /* libzkgroup_ios.a */, - 4CD24E7A229F0D3B00BF655D /* module.modulemap */, - ); - path = libzkgroup; - sourceTree = ""; - }; - 4CD24E7E229F122800BF655D /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 4C6814DB229EFF00006FC282 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C6814F1229EFF00006FC282 /* ZKGroup.h in Headers */, - 4CD24E80229F122F00BF655D /* zkgroup.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 4C6814DF229EFF00006FC282 /* ZKGroup */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4C6814F4229EFF00006FC282 /* Build configuration list for PBXNativeTarget "ZKGroup" */; - buildPhases = ( - 4C6814DB229EFF00006FC282 /* Headers */, - 4C6814DC229EFF00006FC282 /* Sources */, - 4C6814DD229EFF00006FC282 /* Frameworks */, - 4C6814DE229EFF00006FC282 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ZKGroup; - productName = ZKGroup; - productReference = 4C6814E0229EFF00006FC282 /* ZKGroup.framework */; - productType = "com.apple.product-type.framework"; - }; - 4C6814E8229EFF00006FC282 /* ZKGroupTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4C6814F7229EFF00006FC282 /* Build configuration list for PBXNativeTarget "ZKGroupTests" */; - buildPhases = ( - 4C6814E5229EFF00006FC282 /* Sources */, - 4C6814E6229EFF00006FC282 /* Frameworks */, - 4C6814E7229EFF00006FC282 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 4C6814EC229EFF00006FC282 /* PBXTargetDependency */, - ); - name = ZKGroupTests; - productName = ZKGroupTests; - productReference = 4C6814E9229EFF00006FC282 /* ZKGroupTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 4C6814D7229EFF00006FC282 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1020; - LastUpgradeCheck = 1020; - ORGANIZATIONNAME = "Signal Messenger"; - TargetAttributes = { - 4C6814DF229EFF00006FC282 = { - CreatedOnToolsVersion = 10.2; - LastSwiftMigration = 1020; - }; - 4C6814E8229EFF00006FC282 = { - CreatedOnToolsVersion = 10.2; - }; - }; - }; - buildConfigurationList = 4C6814DA229EFF00006FC282 /* Build configuration list for PBXProject "ZKGroup" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 4C6814D6229EFF00006FC282; - productRefGroup = 4C6814E1229EFF00006FC282 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 4C6814DF229EFF00006FC282 /* ZKGroup */, - 4C6814E8229EFF00006FC282 /* ZKGroupTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 4C6814DE229EFF00006FC282 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C6814E7229EFF00006FC282 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 4C6814DC229EFF00006FC282 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 20A67ADE237481AD00CB56A1 /* ProfileKey.swift in Sources */, - 20A67AD6237481AD00CB56A1 /* Native.swift in Sources */, - 20A67AE5237481AD00CB56A1 /* ProfileKeyCredentialRequestContext.swift in Sources */, - 20A67ADC237481AD00CB56A1 /* ServerPublicParams.swift in Sources */, - 20A67AB32374813600CB56A1 /* AuthCredential.swift in Sources */, - 20A67ABA2374814A00CB56A1 /* ClientZkProfileOperations.swift in Sources */, - 20A67AD5237481AD00CB56A1 /* ServerZkProfileOperations.swift in Sources */, - 20118BA2237101A6004584B6 /* Errors.swift in Sources */, - 20A67AD7237481AD00CB56A1 /* UuidCiphertext.swift in Sources */, - 20A67AC22374819000CB56A1 /* GroupIdentifier.swift in Sources */, - 20A67AD9237481AD00CB56A1 /* Uuid.swift in Sources */, - 20A67AC12374819000CB56A1 /* GroupMasterKey.swift in Sources */, - 20A67AB52374813600CB56A1 /* AuthCredentialPresentation.swift in Sources */, - 20A67AE0237481AD00CB56A1 /* ProfileKeyCredential.swift in Sources */, - 20A67AE3237481AD00CB56A1 /* ProfileKeyCredentialPresentation.swift in Sources */, - 20A67ABD2374814A00CB56A1 /* ClientZkAuthOperations.swift in Sources */, - 20A67AE2237481AD00CB56A1 /* NotarySignature.swift in Sources */, - 20A67AB42374813600CB56A1 /* AuthCredentialResponse.swift in Sources */, - 20A67ADB237481AD00CB56A1 /* ProfileKeyCredentialResponse.swift in Sources */, - 20118BA0237101A6004584B6 /* GroupSecretParams.swift in Sources */, - 20A67ADD237481AD00CB56A1 /* ServerSecretParams.swift in Sources */, - 20A67ADA237481AD00CB56A1 /* ServerZkAuthOperations.swift in Sources */, - 20A67AE4237481AD00CB56A1 /* ProfileKeyVersion.swift in Sources */, - 20A67ABC2374814A00CB56A1 /* ClientZkGroupCipher.swift in Sources */, - 20A67AE1237481AD00CB56A1 /* ProfileKeyCiphertext.swift in Sources */, - 20A67ADF237481AD00CB56A1 /* ProfileKeyCommitment.swift in Sources */, - 20A67AC32374819000CB56A1 /* GroupPublicParams.swift in Sources */, - 20118BA1237101A6004584B6 /* ByteArray.swift in Sources */, - 20A67AD8237481AD00CB56A1 /* ProfileKeyCredentialRequest.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 4C6814E5229EFF00006FC282 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4C6814EF229EFF00006FC282 /* ZKGroupTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 4C6814EC229EFF00006FC282 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4C6814DF229EFF00006FC282 /* ZKGroup */; - targetProxy = 4C6814EB229EFF00006FC282 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 4C6814F2229EFF00006FC282 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_BITCODE = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 4C6814F3229EFF00006FC282 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_BITCODE = NO; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 4C6814F5229EFF00006FC282 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = U68MSDN6DR; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = ZKGroup/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/ZKGroup/libzkgroup", - ); - PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.ZKGroup; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/ZKGroup/libzkgroup"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 4C6814F6229EFF00006FC282 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Automatic; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = U68MSDN6DR; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = ZKGroup/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/ZKGroup/libzkgroup", - ); - PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.ZKGroup; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/ZKGroup/libzkgroup"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 4C6814F8229EFF00006FC282 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = U68MSDN6DR; - INFOPLIST_FILE = ZKGroupTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.ZKGroupTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 4C6814F9229EFF00006FC282 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = U68MSDN6DR; - INFOPLIST_FILE = ZKGroupTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = org.whispersystems.ZKGroupTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4C6814DA229EFF00006FC282 /* Build configuration list for PBXProject "ZKGroup" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C6814F2229EFF00006FC282 /* Debug */, - 4C6814F3229EFF00006FC282 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C6814F4229EFF00006FC282 /* Build configuration list for PBXNativeTarget "ZKGroup" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C6814F5229EFF00006FC282 /* Debug */, - 4C6814F6229EFF00006FC282 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4C6814F7229EFF00006FC282 /* Build configuration list for PBXNativeTarget "ZKGroupTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4C6814F8229EFF00006FC282 /* Debug */, - 4C6814F9229EFF00006FC282 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 4C6814D7229EFF00006FC282 /* Project object */; -} diff --git a/ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index e55426b..0000000 --- a/ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/ffi/swift/ZKGroup.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/ffi/swift/ZKGroup.xcodeproj/xcshareddata/xcschemes/ZKGroup.xcscheme b/ffi/swift/ZKGroup.xcodeproj/xcshareddata/xcschemes/ZKGroup.xcscheme deleted file mode 100644 index ae14a0a..0000000 --- a/ffi/swift/ZKGroup.xcodeproj/xcshareddata/xcschemes/ZKGroup.xcscheme +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ffi/swift/ZKGroup/Info.plist b/ffi/swift/ZKGroup/Info.plist deleted file mode 100644 index e1fe4cf..0000000 --- a/ffi/swift/ZKGroup/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - - diff --git a/ffi/swift/ZKGroup/ZKGroup.h b/ffi/swift/ZKGroup/ZKGroup.h deleted file mode 100644 index a7cb484..0000000 --- a/ffi/swift/ZKGroup/ZKGroup.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. -// - -#import - -//! Project version number for ZKGroup. -FOUNDATION_EXPORT double ZKGroupVersionNumber; - -//! Project version string for ZKGroup. -FOUNDATION_EXPORT const unsigned char ZKGroupVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - - diff --git a/ffi/swift/ZKGroup/libzkgroup/module.modulemap b/ffi/swift/ZKGroup/libzkgroup/module.modulemap deleted file mode 100644 index 2e36ce4..0000000 --- a/ffi/swift/ZKGroup/libzkgroup/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module libzkgroup { - header "zkgroup.h" - export * -} diff --git a/ffi/swift/ZKGroupTests/Info.plist b/ffi/swift/ZKGroupTests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/ffi/swift/ZKGroupTests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/ffi/swift/build_ffi.sh b/ffi/swift/build_ffi.sh new file mode 100755 index 0000000..1bbcb69 --- /dev/null +++ b/ffi/swift/build_ffi.sh @@ -0,0 +1,115 @@ +#!/bin/bash + +# +# Copyright 2020-2021 Signal Messenger, LLC. +# SPDX-License-Identifier: AGPL-3.0-only +# + +set -euo pipefail + +SCRIPT_DIR=$(dirname "$0") +cd "${SCRIPT_DIR}"/../.. +. bin/build_helpers.sh + +export CARGO_PROFILE_RELEASE_DEBUG=1 # enable line tables +export CARGO_PROFILE_RELEASE_LTO=fat # use fat LTO to reduce binary size + +usage() { + cat >&2 < /dev/null; then + echo 'error: cbindgen not found in PATH' >&2 + if command -v cargo > /dev/null; then + echo 'note: get it by running' >&2 + printf "\n\t%s\n\n" "cargo install cbindgen --vers '^0.16'" >&2 + fi + exit 1 + fi +} + + +RELEASE_BUILD= +VERBOSE= +SHOULD_CBINDGEN= +CBINDGEN_VERIFY= +BUILD_STD= + +while [ "${1:-}" != "" ]; do + case $1 in + -d | --debug ) + RELEASE_BUILD= + ;; + -r | --release ) + RELEASE_BUILD=1 + ;; + -v | --verbose ) + VERBOSE=1 + ;; + --generate-ffi ) + SHOULD_CBINDGEN=1 + ;; + --verify-ffi ) + SHOULD_CBINDGEN=1 + CBINDGEN_VERIFY=1 + ;; + --build-std) + BUILD_STD=1 + ;; + -h | --help ) + usage + exit + ;; + * ) + usage + exit 2 + esac + shift +done + +check_rust + +if [[ -n "${DEVELOPER_SDK_DIR:-}" ]]; then + # Assume we're in Xcode, which means we're probably cross-compiling. + # In this case, we need to add an extra library search path for build scripts and proc-macros, + # which run on the host instead of the target. + # (macOS Big Sur does not have linkable libraries in /usr/lib/.) + export LIBRARY_PATH="${DEVELOPER_SDK_DIR}/MacOSX.sdk/usr/lib:${LIBRARY_PATH:-}" +fi + +echo_then_run cargo ${BUILD_STD:+-Zbuild-std} build -p zkgroup ${RELEASE_BUILD:+--release} ${VERBOSE:+--verbose} ${CARGO_BUILD_TARGET:+--target $CARGO_BUILD_TARGET} + +FFI_HEADER_PATH=ffi/swift/Sources/libzkgroup/zkgroup.h + +if [[ -n "${SHOULD_CBINDGEN}" ]]; then + check_cbindgen + if [[ -n "${CBINDGEN_VERIFY}" ]]; then + echo diff -u "${FFI_HEADER_PATH}" "<(cbindgen -q ${RELEASE_BUILD:+--profile release} --lang c rust)" + if ! diff -u "${FFI_HEADER_PATH}" <(cbindgen -q ${RELEASE_BUILD:+--profile release} --lang c rust); then + echo + echo 'error: signal_ffi.h not up to date; run' "$0" '--generate-ffi' >&2 + exit 1 + fi + else + echo cbindgen ${RELEASE_BUILD:+--profile release} --lang c -o "${FFI_HEADER_PATH}" rust + # Use sed to ignore irrelevant cbindgen warnings. + # ...and then disable the shellcheck warning about literal backticks in single-quotes + # shellcheck disable=SC2016 + cbindgen ${RELEASE_BUILD:+--profile release} --lang c -o "${FFI_HEADER_PATH}" rust 2>&1 | + sed '/WARN: Missing `\[defines\]` entry for `feature = "ffi"` in cbindgen config\./ d' >&2 + fi +fi From 2dc537e90ea540fe6f35bed8593d9ba480d11f2c Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Sun, 2 May 2021 01:04:39 +0200 Subject: [PATCH 09/69] Add Node cross-compilation support --- .github/workflows/artifacts.yml | 14 +++++++------- ffi/node/Makefile | 10 ++++++---- ffi/node/package.json | 6 +++--- ffi/node/zkgroup/internal/Native.ts | 3 ++- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 547bbae..4ef411b 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -61,8 +61,8 @@ jobs: uses: svenstaro/upload-release-action@v1-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ffi/node/libzkgroup.so - asset_name: libzkgroup.so + file: ffi/node/libzkgroup-x64.so + asset_name: libzkgroup-x64.so tag: ${{ github.ref }} overwrite: true @@ -96,8 +96,8 @@ jobs: uses: svenstaro/upload-release-action@v1-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ffi/node/libzkgroup.dll - asset_name: libzkgroup.dll + file: ffi/node/libzkgroup-x64.dll + asset_name: libzkgroup-x64.dll tag: ${{ github.ref }} overwrite: true @@ -112,7 +112,7 @@ jobs: - name: Install pre-requisites run: | - rustup target add aarch64-apple-ios x86_64-apple-ios armv7-apple-ios armv7s-apple-ios + rustup target add aarch64-apple-ios x86_64-apple-ios cd ffi/swift make install_build_dependencies @@ -141,8 +141,8 @@ jobs: uses: svenstaro/upload-release-action@v1-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ffi/node/libzkgroup.dylib - asset_name: libzkgroup.dylib + file: ffi/node/libzkgroup-x64.dylib + asset_name: libzkgroup-x64.dylib tag: ${{ github.ref }} overwrite: true diff --git a/ffi/node/Makefile b/ffi/node/Makefile index cb87774..be72fa3 100644 --- a/ffi/node/Makefile +++ b/ffi/node/Makefile @@ -1,6 +1,8 @@ ZKGROUP_RUST_DIR=../../rust ZKGROUP_TARGET_DIR=../../target +NODE_ARCH := $(shell node -p "process.arch" || echo x64) + ifeq ($(OS),Windows_NT) DETECTED_OS := Windows else @@ -9,17 +11,17 @@ endif ifeq ($(DETECTED_OS),Windows) SOURCE_LIB = zkgroup.dll - TARGET_LIB = libzkgroup.dll + TARGET_LIB = libzkgroup-$(NODE_ARCH).dll RUSTFLAGS = '-C link-arg=-s -C target-feature=+crt-static' endif ifeq ($(DETECTED_OS),Linux) SOURCE_LIB = libzkgroup.so - TARGET_LIB = libzkgroup.so + TARGET_LIB = libzkgroup-$(NODE_ARCH).so RUSTFLAGS='-C link-arg=-s' endif ifeq ($(DETECTED_OS),Darwin) SOURCE_LIB = libzkgroup.dylib - TARGET_LIB = libzkgroup.dylib + TARGET_LIB = libzkgroup-$(NODE_ARCH).dylib RUSTFLAGS='-C link-arg=-s' endif @@ -32,7 +34,7 @@ clean: libzkgroup: FORCE RUSTFLAGS=$(RUSTFLAGS) cargo build --manifest-path=$(ZKGROUP_RUST_DIR)/Cargo.toml --release rm -f $(TARGET_LIB) - mv $(ZKGROUP_TARGET_DIR)/release/$(SOURCE_LIB) $(TARGET_LIB) + mv $(ZKGROUP_TARGET_DIR)/${CARGO_BUILD_TARGET}/release/$(SOURCE_LIB) $(TARGET_LIB) test: FORCE npm install diff --git a/ffi/node/package.json b/ffi/node/package.json index 888aaa8..3fe586d 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -8,9 +8,9 @@ "dist/zkgroup", "dist/index.d.ts", "zkgroup/modules", - "libzkgroup.dylib", - "libzkgroup.dll", - "libzkgroup.so" + "libzkgroup-*.dylib", + "libzkgroup-*.dll", + "libzkgroup-*.so" ], "scripts": { "build": "tsc", diff --git a/ffi/node/zkgroup/internal/Native.ts b/ffi/node/zkgroup/internal/Native.ts index a287f40..5c75045 100644 --- a/ffi/node/zkgroup/internal/Native.ts +++ b/ffi/node/zkgroup/internal/Native.ts @@ -1,6 +1,7 @@ import { join, resolve } from 'path'; import { Library } from 'ffi-napi'; import FFICompatArray, { FFICompatArrayType } from './FFICompatArray'; +import * as process from 'process'; type IntType = number; type UInt32Type = number; @@ -15,7 +16,7 @@ export const RANDOM_LENGTH = 32; const rootPath = resolve(`${__dirname}/../../../`); // We need to do things differently if we are in an app.asar, common in the Electron world -const libraryPath = join(rootPath.replace('app.asar', 'app.asar.unpacked'), 'libzkgroup'); +const libraryPath = join(rootPath.replace('app.asar', 'app.asar.unpacked'), 'libzkgroup-' + process.arch); interface NativeCalls { From 427b2122dc8c51000d30b1e1f09fa1f91669de50 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Sun, 30 May 2021 15:25:45 +0200 Subject: [PATCH 10/69] Bump deps to get node-addon-api to v3 --- ffi/node/package-lock.json | 133 +++++++++---------------------------- ffi/node/package.json | 4 +- 2 files changed, 33 insertions(+), 104 deletions(-) diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 17a457d..0e1bf16 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -10,8 +10,8 @@ "license": "ISC", "dependencies": { "ffi-napi": "4.0.3", - "ref-array-napi": "1.2.1", - "ref-napi": "3.0.2" + "ref-array-napi": "1.2.2", + "ref-napi": "3.0.3" }, "devDependencies": { "@types/chai": "4.2.7", @@ -480,9 +480,9 @@ } }, "node_modules/ext/node_modules/type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", - "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.5.0.tgz", + "integrity": "sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw==" }, "node_modules/ffi-napi": { "version": "4.0.3", @@ -1107,13 +1107,14 @@ } }, "node_modules/ref-array-napi": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ref-array-napi/-/ref-array-napi-1.2.1.tgz", - "integrity": "sha512-jQp2WWSucmxkqVfoNfm7yDlDeGu3liAbzqfwjNybL80ooLOCnCZpAK2woDInY+lxNOK/VlIVSqeDEYb4gVPuNQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/ref-array-napi/-/ref-array-napi-1.2.2.tgz", + "integrity": "sha512-EGQzUQpyqD/hN9eIn3uF68UPBmwJXdWkumHCmvK3ncjw128bkjd8TbJ51ur+2PZ4UrfCOQCcPQkuWZ6mNHch9A==", + "license": "MIT", "dependencies": { "array-index": "1", "debug": "2", - "ref-napi": "^1.4.2" + "ref-napi": "^3.0.1" } }, "node_modules/ref-array-napi/node_modules/debug": { @@ -1129,47 +1130,15 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "node_modules/ref-array-napi/node_modules/node-addon-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" - }, - "node_modules/ref-array-napi/node_modules/ref-napi": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-1.5.2.tgz", - "integrity": "sha512-hwyNmWpUkt1bDWDW4aiwCoC+SJfJO69UIdjqssNqdaS0sYJpgqzosGg/rLtk69UoQ8drZdI9yyQefM7eEMM3Gw==", - "hasInstallScript": true, - "dependencies": { - "debug": "^3.1.0", - "node-addon-api": "^2.0.0", - "node-gyp-build": "^4.2.1" - }, - "engines": { - "node": ">= 6.0" - } - }, - "node_modules/ref-array-napi/node_modules/ref-napi/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, - "node_modules/ref-array-napi/node_modules/ref-napi/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, "node_modules/ref-napi": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.2.tgz", - "integrity": "sha512-5YE0XrvWteoTr5DR2sEqxefL06aml7c6qS7hGv3u27do4HlGQphwvB+zD1NYep9utMKScvwOZsSs9EPYdGBVsg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.3.tgz", + "integrity": "sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA==", "hasInstallScript": true, "dependencies": { "debug": "^4.1.1", "get-symbol-from-current-process-h": "^1.0.2", - "node-addon-api": "^2.0.0", + "node-addon-api": "^3.0.0", "node-gyp-build": "^4.2.1" }, "engines": { @@ -1192,15 +1161,10 @@ } } }, - "node_modules/ref-napi/node_modules/node-addon-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" - }, "node_modules/ref-struct-di": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.0.tgz", - "integrity": "sha512-gghZITj/iQwdwFDduZ6T8kL2B2ogInlOz7AOB0ggFoEc7akAKMcDrbzh3OIPk13Kxy8U2bHPvN6nejcBh4jN7A==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz", + "integrity": "sha512-2Xyn/0Qgz89VT+++WP0sTosdm9oeowLP23wRJYhG4BFdMUrLj3jhwHZNEytYNYgtPKLNTP3KJX4HEgBvM1/Y2g==", "dependencies": { "debug": "^3.1.0" } @@ -1913,9 +1877,9 @@ }, "dependencies": { "type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", - "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.5.0.tgz", + "integrity": "sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw==" } } }, @@ -2399,13 +2363,13 @@ } }, "ref-array-napi": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ref-array-napi/-/ref-array-napi-1.2.1.tgz", - "integrity": "sha512-jQp2WWSucmxkqVfoNfm7yDlDeGu3liAbzqfwjNybL80ooLOCnCZpAK2woDInY+lxNOK/VlIVSqeDEYb4gVPuNQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/ref-array-napi/-/ref-array-napi-1.2.2.tgz", + "integrity": "sha512-EGQzUQpyqD/hN9eIn3uF68UPBmwJXdWkumHCmvK3ncjw128bkjd8TbJ51ur+2PZ4UrfCOQCcPQkuWZ6mNHch9A==", "requires": { "array-index": "1", "debug": "2", - "ref-napi": "^1.4.2" + "ref-napi": "^3.0.1" }, "dependencies": { "debug": { @@ -2420,47 +2384,17 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "node-addon-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" - }, - "ref-napi": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-1.5.2.tgz", - "integrity": "sha512-hwyNmWpUkt1bDWDW4aiwCoC+SJfJO69UIdjqssNqdaS0sYJpgqzosGg/rLtk69UoQ8drZdI9yyQefM7eEMM3Gw==", - "requires": { - "debug": "^3.1.0", - "node-addon-api": "^2.0.0", - "node-gyp-build": "^4.2.1" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - } - } } } }, "ref-napi": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.2.tgz", - "integrity": "sha512-5YE0XrvWteoTr5DR2sEqxefL06aml7c6qS7hGv3u27do4HlGQphwvB+zD1NYep9utMKScvwOZsSs9EPYdGBVsg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.3.tgz", + "integrity": "sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA==", "requires": { "debug": "^4.1.1", "get-symbol-from-current-process-h": "^1.0.2", - "node-addon-api": "^2.0.0", + "node-addon-api": "^3.0.0", "node-gyp-build": "^4.2.1" }, "dependencies": { @@ -2471,18 +2405,13 @@ "requires": { "ms": "2.1.2" } - }, - "node-addon-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" } } }, "ref-struct-di": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.0.tgz", - "integrity": "sha512-gghZITj/iQwdwFDduZ6T8kL2B2ogInlOz7AOB0ggFoEc7akAKMcDrbzh3OIPk13Kxy8U2bHPvN6nejcBh4jN7A==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz", + "integrity": "sha512-2Xyn/0Qgz89VT+++WP0sTosdm9oeowLP23wRJYhG4BFdMUrLj3jhwHZNEytYNYgtPKLNTP3KJX4HEgBvM1/Y2g==", "requires": { "debug": "^3.1.0" } diff --git a/ffi/node/package.json b/ffi/node/package.json index 3fe586d..5c6cc0c 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -21,8 +21,8 @@ "license": "ISC", "dependencies": { "ffi-napi": "4.0.3", - "ref-array-napi": "1.2.1", - "ref-napi": "3.0.2" + "ref-array-napi": "1.2.2", + "ref-napi": "3.0.3" }, "devDependencies": { "@types/chai": "4.2.7", From 10ed36f002f6671982f38ae8b92b89481006368c Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 4 Jun 2021 16:27:57 -0700 Subject: [PATCH 11/69] Node: Remove custom .d.ts files and use the ones from NPM --- ffi/node/package-lock.json | 1518 +---------------- ffi/node/package.json | 3 +- ffi/node/zkgroup/ServerPublicParams.ts | 6 +- ffi/node/zkgroup/ServerSecretParams.ts | 2 +- ffi/node/zkgroup/internal/ByteArray.ts | 2 +- ffi/node/zkgroup/internal/FFICompatArray.ts | 7 +- ffi/node/zkgroup/modules/ffi-napi.d.ts | 192 --- ffi/node/zkgroup/modules/ref-array-napi.d.ts | 50 - ffi/node/zkgroup/modules/ref-napi.d.ts | 190 --- ffi/node/zkgroup/modules/ref-struct-napi.d.ts | 60 - 10 files changed, 36 insertions(+), 1994 deletions(-) delete mode 100644 ffi/node/zkgroup/modules/ffi-napi.d.ts delete mode 100644 ffi/node/zkgroup/modules/ref-array-napi.d.ts delete mode 100644 ffi/node/zkgroup/modules/ref-napi.d.ts delete mode 100644 ffi/node/zkgroup/modules/ref-struct-napi.d.ts diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 0e1bf16..0bbd932 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,1518 +1,52 @@ { "name": "zkgroup", "version": "0.7.2", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "name": "zkgroup", - "version": "0.7.2", - "license": "ISC", - "dependencies": { - "ffi-napi": "4.0.3", - "ref-array-napi": "1.2.2", - "ref-napi": "3.0.3" - }, - "devDependencies": { - "@types/chai": "4.2.7", - "@types/mocha": "5.2.7", - "@types/node": "13.1.8", - "chai": "4.2.0", - "mocha": "7.1.1", - "rimraf": "3.0.1", - "typescript": "3.7.4" - } - }, - "node_modules/@types/chai": { + "dependencies": { + "@types/chai": { "version": "4.2.7", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.7.tgz", "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", "dev": true }, - "node_modules/@types/mocha": { + "@types/ffi-napi": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/ffi-napi/-/ffi-napi-4.0.1.tgz", + "integrity": "sha512-UOzFWt8jCQRo07WmiPbnEeMI5gfvisokMP3M751clxG3WRQb6+0shWLR0NI8Mqq/0l1zYA1ZPwOaN7H/O2vDlQ==", + "requires": { + "@types/node": "*", + "@types/ref-napi": "*", + "@types/ref-struct-di": "*" + } + }, + "@types/mocha": { "version": "5.2.7", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz", "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==", "dev": true }, - "node_modules/@types/node": { + "@types/node": { "version": "13.1.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.8.tgz", - "integrity": "sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A==", - "dev": true - }, - "node_modules/ansi-colors": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", - "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/anymatch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", - "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/array-index": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-index/-/array-index-1.0.0.tgz", - "integrity": "sha1-7FanSe4QPk4Ix5C5w1PfFgVbl/k=", - "dependencies": { - "debug": "^2.2.0", - "es6-symbol": "^3.0.2" - }, - "engines": { - "node": "*" - } - }, - "node_modules/array-index/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/array-index/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "node_modules/binary-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", - "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/chai": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", - "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", - "dev": true, - "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.0", - "type-detect": "^4.0.5" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/chalk/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/chokidar": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", - "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", - "dev": true, - "dependencies": { - "anymatch": "~3.1.1", - "braces": "~3.0.2", - "glob-parent": "~5.1.0", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.2.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "optionalDependencies": { - "fsevents": "~2.1.1" - } - }, - "node_modules/cliui": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", - "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", - "dev": true, - "dependencies": { - "string-width": "^3.1.0", - "strip-ansi": "^5.2.0", - "wrap-ansi": "^5.1.0" - } - }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/cliui/node_modules/string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "dependencies": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "dependencies": { - "ansi-regex": "^4.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "node_modules/d": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "dependencies": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - } - }, - "node_modules/debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dependencies": { - "ms": "^2.1.1" - } + "integrity": "sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A==" }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/deep-eql": { + "@types/ref-napi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, - "engines": { - "node": ">=0.12" + "resolved": "https://registry.npmjs.org/@types/ref-napi/-/ref-napi-3.0.1.tgz", + "integrity": "sha512-tBRp8JLW0IoXiqP8bRoArlfXB84JSKkLvVfCNdQGSgBPOAKvhmgW7mjVCDyxypiUMR0RXwHsu6hZlPpunKEPzg==", + "requires": { + "@types/node": "*" } }, - "node_modules/define-properties": { + "@types/ref-struct-di": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "dependencies": { - "object-keys": "^1.0.12" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true, - "engines": { - "node": ">=0.3.1" + "resolved": "https://registry.npmjs.org/@types/ref-struct-di/-/ref-struct-di-1.1.3.tgz", + "integrity": "sha512-OdsiCc10hByKZ27R8Bd+09EhiciuD6V9eAn+RjiLNx0YJum8E6CKg8zws5OmHKDtYA5Ke7kUvBJlUwITSZdvzA==", + "requires": { + "@types/ref-napi": "*" } }, - "node_modules/emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, - "node_modules/es-abstract": { - "version": "1.17.4", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", - "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", - "dev": true, - "dependencies": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.1.5", - "is-regex": "^1.0.5", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimleft": "^2.1.1", - "string.prototype.trimright": "^2.1.1" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "dependencies": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es5-ext": { - "version": "0.10.53", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", - "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", - "dependencies": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.3", - "next-tick": "~1.0.0" - } - }, - "node_modules/es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "node_modules/es6-symbol": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", - "dependencies": { - "d": "^1.0.1", - "ext": "^1.1.2" - } - }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/ext": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", - "integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==", - "dependencies": { - "type": "^2.0.0" - } - }, - "node_modules/ext/node_modules/type": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.5.0.tgz", - "integrity": "sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw==" - }, - "node_modules/ffi-napi": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/ffi-napi/-/ffi-napi-4.0.3.tgz", - "integrity": "sha512-PMdLCIvDY9mS32RxZ0XGb95sonPRal8aqRhLbeEtWKZTe2A87qRFG9HjOhvG8EX2UmQw5XNRMIOT+1MYlWmdeg==", - "hasInstallScript": true, - "dependencies": { - "debug": "^4.1.1", - "get-uv-event-loop-napi-h": "^1.0.5", - "node-addon-api": "^3.0.0", - "node-gyp-build": "^4.2.1", - "ref-napi": "^2.0.1 || ^3.0.2", - "ref-struct-di": "^1.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ffi-napi/node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "dependencies": { - "locate-path": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/flat": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", - "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", - "dev": true, - "dependencies": { - "is-buffer": "~2.0.3" - }, - "bin": { - "flat": "cli.js" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "node_modules/fsevents": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", - "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/get-symbol-from-current-process-h": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/get-symbol-from-current-process-h/-/get-symbol-from-current-process-h-1.0.2.tgz", - "integrity": "sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw==" - }, - "node_modules/get-uv-event-loop-napi-h": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/get-uv-event-loop-napi-h/-/get-uv-event-loop-napi-h-1.0.6.tgz", - "integrity": "sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==", - "dependencies": { - "get-symbol-from-current-process-h": "^1.0.1" - } - }, - "node_modules/glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/glob-parent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", - "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true, - "engines": { - "node": ">=4.x" - } - }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true, - "bin": { - "he": "bin/he" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-buffer": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", - "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/is-callable": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/is-date-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", - "dev": true, - "dependencies": { - "has": "^1.0.3" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/is-symbol": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", - "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", - "dev": true, - "dependencies": { - "has-symbols": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "node_modules/js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "dependencies": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "node_modules/log-symbols": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", - "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", - "dev": true, - "dependencies": { - "chalk": "^2.4.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "node_modules/mkdirp": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz", - "integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/mocha": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.1.tgz", - "integrity": "sha512-3qQsu3ijNS3GkWcccT5Zw0hf/rWvu1fTN9sPvEd81hlwsr30GX2GcDSSoBxo24IR8FelmrAydGC6/1J5QQP4WA==", - "dev": true, - "dependencies": { - "ansi-colors": "3.2.3", - "browser-stdout": "1.3.1", - "chokidar": "3.3.0", - "debug": "3.2.6", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "find-up": "3.0.0", - "glob": "7.1.3", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "3.13.1", - "log-symbols": "3.0.0", - "minimatch": "3.0.4", - "mkdirp": "0.5.3", - "ms": "2.1.1", - "node-environment-flags": "1.0.6", - "object.assign": "4.1.0", - "strip-json-comments": "2.0.1", - "supports-color": "6.0.0", - "which": "1.3.1", - "wide-align": "1.1.3", - "yargs": "13.3.2", - "yargs-parser": "13.1.2", - "yargs-unparser": "1.6.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha" - }, - "engines": { - "node": ">= 8.0.0" - } - }, - "node_modules/mocha/node_modules/ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" - }, - "node_modules/node-addon-api": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", - "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==" - }, - "node_modules/node-environment-flags": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz", - "integrity": "sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==", - "dev": true, - "dependencies": { - "object.getownpropertydescriptors": "^2.0.3", - "semver": "^5.7.0" - } - }, - "node_modules/node-gyp-build": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", - "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "dev": true, - "dependencies": { - "define-properties": "^1.1.2", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "object-keys": "^1.0.11" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.getownpropertydescriptors": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz", - "integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==", - "dev": true, - "dependencies": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/p-limit": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", - "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "dependencies": { - "p-limit": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/picomatch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", - "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", - "dev": true, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/readdirp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", - "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", - "dev": true, - "dependencies": { - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/ref-array-napi": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/ref-array-napi/-/ref-array-napi-1.2.2.tgz", - "integrity": "sha512-EGQzUQpyqD/hN9eIn3uF68UPBmwJXdWkumHCmvK3ncjw128bkjd8TbJ51ur+2PZ4UrfCOQCcPQkuWZ6mNHch9A==", - "license": "MIT", - "dependencies": { - "array-index": "1", - "debug": "2", - "ref-napi": "^3.0.1" - } - }, - "node_modules/ref-array-napi/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/ref-array-napi/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "node_modules/ref-napi": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.3.tgz", - "integrity": "sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA==", - "hasInstallScript": true, - "dependencies": { - "debug": "^4.1.1", - "get-symbol-from-current-process-h": "^1.0.2", - "node-addon-api": "^3.0.0", - "node-gyp-build": "^4.2.1" - }, - "engines": { - "node": ">= 10.0" - } - }, - "node_modules/ref-napi/node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/ref-struct-di": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz", - "integrity": "sha512-2Xyn/0Qgz89VT+++WP0sTosdm9oeowLP23wRJYhG4BFdMUrLj3jhwHZNEytYNYgtPKLNTP3KJX4HEgBvM1/Y2g==", - "dependencies": { - "debug": "^3.1.0" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, - "node_modules/rimraf": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.1.tgz", - "integrity": "sha512-IQ4ikL8SjBiEDZfk+DFVwqRK8md24RWMEJkdSlgNLkyyAImcjf8SWvU1qFMDOb4igBClbTQ/ugPqXcRwdFTxZw==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, - "node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "node_modules/string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "dependencies": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/string.prototype.trimleft": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", - "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", - "dev": true, - "dependencies": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/string.prototype.trimright": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", - "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", - "dev": true, - "dependencies": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "dependencies": { - "ansi-regex": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/supports-color": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", - "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/type": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" - }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/typescript": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz", - "integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" - } - }, - "node_modules/which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true - }, - "node_modules/wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, - "dependencies": { - "string-width": "^1.0.2 || 2" - } - }, - "node_modules/wrap-ansi": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", - "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.0", - "string-width": "^3.0.0", - "strip-ansi": "^5.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "dependencies": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "dependencies": { - "ansi-regex": "^4.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "node_modules/y18n": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", - "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", - "dev": true - }, - "node_modules/yargs": { - "version": "13.3.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", - "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", - "dev": true, - "dependencies": { - "cliui": "^5.0.0", - "find-up": "^3.0.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^3.0.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^13.1.2" - } - }, - "node_modules/yargs-parser": { - "version": "13.1.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", - "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", - "dev": true, - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - }, - "node_modules/yargs-unparser": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", - "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", - "dev": true, - "dependencies": { - "flat": "^4.1.0", - "lodash": "^4.17.15", - "yargs": "^13.3.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/yargs/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/yargs/node_modules/string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "dependencies": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/yargs/node_modules/strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "dependencies": { - "ansi-regex": "^4.1.0" - }, - "engines": { - "node": ">=6" - } - } - }, - "dependencies": { - "@types/chai": { - "version": "4.2.7", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.7.tgz", - "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", - "dev": true - }, - "@types/mocha": { - "version": "5.2.7", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz", - "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==", - "dev": true - }, - "@types/node": { - "version": "13.1.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.8.tgz", - "integrity": "sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A==", - "dev": true - }, "ansi-colors": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", diff --git a/ffi/node/package.json b/ffi/node/package.json index 5c6cc0c..432c65c 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -7,7 +7,6 @@ "files": [ "dist/zkgroup", "dist/index.d.ts", - "zkgroup/modules", "libzkgroup-*.dylib", "libzkgroup-*.dll", "libzkgroup-*.so" @@ -20,6 +19,8 @@ "author": "", "license": "ISC", "dependencies": { + "@types/ffi-napi": "^4.0.1", + "@types/ref-napi": "^3.0.1", "ffi-napi": "4.0.3", "ref-array-napi": "1.2.2", "ref-napi": "3.0.3" diff --git a/ffi/node/zkgroup/ServerPublicParams.ts b/ffi/node/zkgroup/ServerPublicParams.ts index 30b924f..0ee9dcc 100644 --- a/ffi/node/zkgroup/ServerPublicParams.ts +++ b/ffi/node/zkgroup/ServerPublicParams.ts @@ -7,7 +7,7 @@ import VerificationFailedException from './errors/VerificationFailedException'; import NotarySignature from './NotarySignature'; import Native, { FFI_RETURN_OK, FFI_RETURN_INPUT_ERROR } from './internal/Native'; -import { FFICompatArrayType } from './internal/FFICompatArray' +import FFICompatArray, { FFICompatArrayType } from './internal/FFICompatArray' export default class ServerPublicParams extends ByteArray { @@ -40,8 +40,8 @@ export default class ServerPublicParams extends ByteArray { } } - serialize() { - return this.contents.slice(0, this.contents.length); + serialize(): FFICompatArrayType { + return new FFICompatArray(Buffer.from(this.contents.buffer)); } } diff --git a/ffi/node/zkgroup/ServerSecretParams.ts b/ffi/node/zkgroup/ServerSecretParams.ts index f628a67..7305dcd 100644 --- a/ffi/node/zkgroup/ServerSecretParams.ts +++ b/ffi/node/zkgroup/ServerSecretParams.ts @@ -85,6 +85,6 @@ export default class ServerSecretParams extends ByteArray { } serialize(): FFICompatArrayType { - return this.contents.slice(0, this.contents.length); + return new FFICompatArray(Buffer.from(this.contents.buffer)); } } diff --git a/ffi/node/zkgroup/internal/ByteArray.ts b/ffi/node/zkgroup/internal/ByteArray.ts index 11814bc..d1c4213 100644 --- a/ffi/node/zkgroup/internal/ByteArray.ts +++ b/ffi/node/zkgroup/internal/ByteArray.ts @@ -9,7 +9,7 @@ export default class ByteArray { if (contents.length !== expectedLength) { throw new InvalidInputException(`Length of array supplied was ${contents.length} expected ${expectedLength}`); } - this.contents = contents.slice(0, expectedLength); + this.contents = new FFICompatArray(Buffer.from(contents.buffer), expectedLength); } public getContents(): FFICompatArrayType { diff --git a/ffi/node/zkgroup/internal/FFICompatArray.ts b/ffi/node/zkgroup/internal/FFICompatArray.ts index fa10d8f..e2a8216 100644 --- a/ffi/node/zkgroup/internal/FFICompatArray.ts +++ b/ffi/node/zkgroup/internal/FFICompatArray.ts @@ -1,11 +1,10 @@ import { types } from 'ref-napi'; -import * as RefArray from 'ref-array-napi'; +import ArrayType = require('ref-array-napi'); // Typescript complains that RefArray is not constructable. But it very much is -// @ts-ignore -const FFICompatArray: RefArray.ArrayType = new RefArray(types.uint8) +const FFICompatArray: ArrayType = ArrayType(types.uint8) export default FFICompatArray; -export type FFICompatArrayType = RefArray.ArrayTypeInstance; +export type FFICompatArrayType = ReturnType \ No newline at end of file diff --git a/ffi/node/zkgroup/modules/ffi-napi.d.ts b/ffi/node/zkgroup/modules/ffi-napi.d.ts deleted file mode 100644 index c768017..0000000 --- a/ffi/node/zkgroup/modules/ffi-napi.d.ts +++ /dev/null @@ -1,192 +0,0 @@ -// Type definitions for node-ffi 0.2 -// Project: https://github.com/rbranson/node-ffi, http://github.com/node-ffi/node-ffi -// Definitions by: Paul Loyd , Waiting Song -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - -/// - -declare module 'ffi-napi' { - import { Type } from 'ref-napi'; - import { StructType } from 'ref-struct-napi'; - - /** Provides a friendly API on-top of `DynamicLibrary` and `ForeignFunction`. */ - export interface Library { - /** The extension to use on libraries. */ - EXT: string; - - /** - * @param libFile name of library - * @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}] - * @param lib hash that will be extended - */ - new (libFile: string, funcs?: {[key: string]: any[]}, lib?: object): any; - - /** - * @param libFile name of library - * @param funcs hash of [retType, [...argType], opts?: {abi?, async?, varargs?}] - * @param lib hash that will be extended - */ - (libFile: string, funcs?: {[key: string]: any[]}, lib?: object): any; - } - export const Library: Library; - - /** Get value of errno. */ - export function errno(): number; - - export interface Function extends Type { - /** The type of return value. */ - retType: Type; - /** The type of arguments. */ - argTypes: Type[]; - /** Is set for node-ffi functions. */ - ffi_type: Buffer; - abi: number; - - /** Get a `Callback` pointer of this function type. */ - toPointer(fn: (...args: any[]) => any): Buffer; - /** Get a `ForeignFunction` of this function type. */ - toFunction(buf: Buffer): ForeignFunction; - } - - /** Creates and returns a type for a C function pointer. */ - export const Function: { - new (retType: Type | string, argTypes: any[], abi?: number): Function; - (retType: Type | string, argTypes: any[], abi?: number): Function; - }; - - export interface ForeignFunction { - (...args: any[]): any; - async(...args: any[]): void; - } - - /** - * Represents a foreign function in another library. Manages all of the aspects - * of function execution, including marshalling the data parameters for the - * function into native types and also unmarshalling the return from function - * execution. - */ - export const ForeignFunction: { - new (ptr: Buffer, retType: Type | string, argTypes: any[], abi?: number): ForeignFunction; - (ptr: Buffer, retType: Type | string, argTypes: any[], abi?: number): ForeignFunction; - }; - - export interface VariadicForeignFunction { - /** - * What gets returned is another function that needs to be invoked with the rest - * of the variadic types that are being invoked from the function. - */ - (...args: any[]): ForeignFunction; - - /** - * Return type as a property of the function generator to - * allow for monkey patching the return value in the very rare case where the - * return type is variadic as well - */ - returnType: any; - } - - /** - * For when you want to call to a C function with variable amount of arguments. - * i.e. `printf`. - * - * This function takes care of caching and reusing `ForeignFunction` instances that - * contain the same ffi_type argument signature. - */ - export const VariadicForeignFunction: { - new (ptr: Buffer, ret: Type | string, fixedArgs: any[], abi?: number): VariadicForeignFunction; - (ptr: Buffer, ret: Type | string, fixedArgs: any[], abi?: number): VariadicForeignFunction; - }; - - export interface DynamicLibrary { - /** Close library, returns the result of the `dlclose` system function. */ - close(): number; - /** Get a symbol from this library. */ - get(symbol: string): Buffer; - /** Get the result of the `dlerror` system function. */ - error(): string; - } - - /** - * This class loads and fetches function pointers for dynamic libraries - * (.so, .dylib, etc). After the libray's function pointer is acquired, then you - * call `get(symbol)` to retreive a pointer to an exported symbol. You need to - * call `get___` on the pointer to dereference it into its actual value, or - * turn the pointer into a callable function with `ForeignFunction`. - */ - export const DynamicLibrary: { - FLAGS: { - RTLD_LAZY: number; - RTLD_NOW: number; - RTLD_LOCAL: number; - RTLD_GLOBAL: number; - RTLD_NOLOAD: number; - RTLD_NODELETE: number; - RTLD_NEXT: Buffer; - RTLD_DEFAUL: Buffer; - } - - new (path?: string, mode?: number): DynamicLibrary; - (path?: string, mode?: number): DynamicLibrary; - }; - - /** - * Turns a JavaScript function into a C function pointer. - * The function pointer may be used in other C functions that - * accept C callback functions. - */ - export interface Callback { - new (retType: any, argTypes: any[], abi: number, fn: any): Buffer; - new (retType: any, argTypes: any[], fn: any): Buffer; - (retType: any, argTypes: any[], abi: number, fn: any): Buffer; - (retType: any, argTypes: any[], fn: any): Buffer; - } - export const Callback: Callback; - - export const ffiType: { - /** Get a `ffi_type *` Buffer appropriate for the given type. */ - (type: Type | string): Buffer - FFI_TYPE: StructType; - }; - - export function CIF(retType: any, types: any[], abi?: any): Buffer; - export function CIF_var(retType: any, types: any[], numFixedArgs: number, abi?: any): Buffer; - export const HAS_OBJC: boolean; - export const FFI_TYPES: {[key: string]: Buffer}; - export const FFI_OK: number; - export const FFI_BAD_TYPEDEF: number; - export const FFI_BAD_ABI: number; - export const FFI_DEFAULT_ABI: number; - export const FFI_FIRST_ABI: number; - export const FFI_LAST_ABI: number; - export const FFI_SYSV: number; - export const FFI_UNIX64: number; - export const FFI_WIN64: number; - export const FFI_VFP: number; - export const FFI_STDCALL: number; - export const FFI_THISCALL: number; - export const FFI_FASTCALL: number; - export const RTLD_LAZY: number; - export const RTLD_NOW: number; - export const RTLD_LOCAL: number; - export const RTLD_GLOBAL: number; - export const RTLD_NOLOAD: number; - export const RTLD_NODELETE: number; - export const RTLD_NEXT: Buffer; - export const RTLD_DEFAULT: Buffer; - export const LIB_EXT: string; - export const FFI_TYPE: StructType; - - /** Default types. */ - export const types: { - void: Type; int64: Type; ushort: Type; - int: Type; uint64: Type; float: Type; - uint: Type; long: Type; double: Type; - int8: Type; ulong: Type; Object: Type; - uint8: Type; longlong: Type; CString: Type; - int16: Type; ulonglong: Type; bool: Type; - uint16: Type; char: Type; byte: Type; - int32: Type; uchar: Type; size_t: Type; - uint32: Type; short: Type; - }; -} diff --git a/ffi/node/zkgroup/modules/ref-array-napi.d.ts b/ffi/node/zkgroup/modules/ref-array-napi.d.ts deleted file mode 100644 index a00c7fd..0000000 --- a/ffi/node/zkgroup/modules/ref-array-napi.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Type definitions for ref-array -// Project: https://github.com/TooTallNate/ref-array -// Definitions by: Paul Loyd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module 'ref-array-napi' { - import { Type } from 'ref-napi'; - - export interface ArrayTypeInstance { - [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; - inspect(): string; - buffer: Buffer; - slice: (start: number, end?: number) => ArrayTypeInstance; - ref(): Buffer; - } - - export interface ArrayType extends Type { - BYTES_PER_ELEMENT: number; - fixedLength: number; - /** The reference to the base type. */ - type: Type; - - /** - * Accepts a Buffer instance that should be an already-populated with data - * for the ArrayType. The "length" of the Array is determined by searching - * through the buffer's contents until an aligned NULL pointer is encountered. - */ - untilZeros(buffer: Buffer): ArrayTypeInstance; - - new (length?: number): ArrayTypeInstance; - new (data: number[], length?: number): ArrayTypeInstance; - new (data: Buffer, length?: number): ArrayTypeInstance; - (length?: number): ArrayTypeInstance; - (data: number[], length?: number): ArrayTypeInstance; - (data: Buffer, length?: number): ArrayTypeInstance; - } - - /** - * The array type meta-constructor. - * The returned constructor's API is highly influenced by the WebGL - * TypedArray API. - */ - export var metaConstructor: { - new (type: Type, length?: number): ArrayType; - new (type: string, length?: number): ArrayType; - (type: Type, length?: number): ArrayType; - (type: string, length?: number): ArrayType; - }; -} diff --git a/ffi/node/zkgroup/modules/ref-napi.d.ts b/ffi/node/zkgroup/modules/ref-napi.d.ts deleted file mode 100644 index ab6de98..0000000 --- a/ffi/node/zkgroup/modules/ref-napi.d.ts +++ /dev/null @@ -1,190 +0,0 @@ -// Type definitions for ref -// Project: https://github.com/TooTallNate/ref -// Definitions by: Paul Loyd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare module 'ref-napi' { - export interface Type { - /** The size in bytes required to hold this datatype. */ - size: number; - /** The current level of indirection of the buffer. */ - indirection: number; - /** To invoke when `ref.get` is invoked on a buffer of this type. */ - get(buffer: Buffer, offset: number): any; - /** To invoke when `ref.set` is invoked on a buffer of this type. */ - set(buffer: Buffer, offset: number, value: any): void; - /** The name to use during debugging for this datatype. */ - name?: string; - /** The alignment of this datatype when placed inside a struct. */ - alignment?: number; - } - - /** A Buffer that references the C NULL pointer. */ - export var NULL: Buffer; - /** A pointer-sized buffer pointing to NULL. */ - export var NULL_POINTER: Buffer; - /** Get the memory address of buffer. */ - export function address(buffer: Buffer): number; - /** Allocate the memory with the given value written to it. */ - export function alloc(type: Type, value?: any): Buffer; - /** Allocate the memory with the given value written to it. */ - export function alloc(type: string, value?: any): Buffer; - - /** - * Allocate the memory with the given string written to it with the given - * encoding (defaults to utf8). The buffer is 1 byte longer than the - * string itself, and is NULL terminated. - */ - export function allocCString(string: string, encoding?: string): Buffer; - - /** Coerce a type.*/ - export function coerceType(type: Type): Type; - /** Coerce a type. String are looked up from the ref.types object. */ - export function coerceType(type: string): Type; - - /** - * Get value after dereferencing buffer. - * That is, first it checks the indirection count of buffer's type, and - * if it's greater than 1 then it merely returns another Buffer, but with - * one level less indirection. - */ - export function deref(buffer: Buffer): any; - - /** Create clone of the type, with decremented indirection level by 1. */ - export function derefType(type: Type): Type; - /** Create clone of the type, with decremented indirection level by 1. */ - export function derefType(type: string): Type; - /** Represents the native endianness of the processor ("LE" or "BE"). */ - export var endianness: string; - /** Check the indirection level and return a dereferenced when necessary. */ - export function get(buffer: Buffer, offset?: number, type?: Type): any; - /** Check the indirection level and return a dereferenced when necessary. */ - export function get(buffer: Buffer, offset?: number, type?: string): any; - /** Get type of the buffer. Create a default type when none exists. */ - export function getType(buffer: Buffer): Type; - /** Check the NULL. */ - export function isNull(buffer: Buffer): boolean; - /** Read C string until the first NULL. */ - export function readCString(buffer: Buffer, offset?: number): string; - - /** - * Read a big-endian signed 64-bit int. - * If there is losing precision, then return a string, otherwise a number. - * @return {number|string} - */ - export function readInt64BE(buffer: Buffer, offset?: number): any; - - /** - * Read a little-endian signed 64-bit int. - * If there is losing precision, then return a string, otherwise a number. - * @return {number|string} - */ - export function readInt64LE(buffer: Buffer, offset?: number): any; - - /** Read a JS Object that has previously been written. */ - export function readObject(buffer: Buffer, offset?: number): Object; - /** Read data from the pointer. */ - export function readPointer(buffer: Buffer, offset?: number, - length?: number): Buffer; - /** - * Read a big-endian unsigned 64-bit int. - * If there is losing precision, then return a string, otherwise a number. - * @return {number|string} - */ - export function readUInt64BE(buffer: Buffer, offset?: number): any; - - /** - * Read a little-endian unsigned 64-bit int. - * If there is losing precision, then return a string, otherwise a number. - * @return {number|string} - */ - export function readUInt64LE(buffer: Buffer, offset?: number): any; - - /** Create pointer to buffer. */ - export function ref(buffer: Buffer): Buffer; - /** Create clone of the type, with incremented indirection level by 1. */ - export function refType(type: Type): Type; - /** Create clone of the type, with incremented indirection level by 1. */ - export function refType(type: string): Type; - - /** - * Create buffer with the specified size, with the same address as source. - * This function "attaches" source to the returned buffer to prevent it from - * being garbage collected. - */ - export function reinterpret(buffer: Buffer, size: number, - offset?: number): Buffer; - /** - * Scan past the boundary of the buffer's length until it finds size number - * of aligned NULL bytes. - */ - export function reinterpretUntilZeros(buffer: Buffer, size: number, - offset?: number): Buffer; - - /** Write pointer if the indirection is 1, otherwise write value. */ - export function set(buffer: Buffer, offset: number, value: any, type?: Type): void; - /** Write pointer if the indirection is 1, otherwise write value. */ - export function set(buffer: Buffer, offset: number, value: any, type?: string): void; - /** Write the string as a NULL terminated. Default encoding is utf8. */ - export function writeCString(buffer: Buffer, offset: number, - string: string, encoding?: string): void; - /** Write a big-endian signed 64-bit int. */ - export function writeInt64BE(buffer: Buffer, offset: number, input: number): void; - /** Write a big-endian signed 64-bit int. */ - export function writeInt64BE(buffer: Buffer, offset: number, input: string): void; - /** Write a little-endian signed 64-bit int. */ - export function writeInt64LE(buffer: Buffer, offset: number, input: number): void; - /** Write a little-endian signed 64-bit int. */ - export function writeInt64LE(buffer: Buffer, offset: number, input: string): void; - - /** - * Write the JS Object. This function "attaches" object to buffer to prevent - * it from being garbage collected. - */ - export function writeObject(buffer: Buffer, offset: number, object: Object): void; - - /** - * Write the memory address of pointer to buffer at the specified offset. This - * function "attaches" object to buffer to prevent it from being garbage collected. - */ - export function writePointer(buffer: Buffer, offset: number, - pointer: Buffer): void; - - /** Write a little-endian unsigned 64-bit int. */ - export function writeUInt64BE(buffer: Buffer, offset: number, input: number): void; - /** Write a little-endian unsigned 64-bit int. */ - export function writeUInt64BE(buffer: Buffer, offset: number, input: string): void; - - /** - * Attach object to buffer such. - * It prevents object from being garbage collected until buffer does. - */ - export function _attach(buffer: Buffer, object: Object): void; - - /** Same as ref.reinterpret, except that this version does not attach buffer. */ - export function _reinterpret(buffer: Buffer, size: number, - offset?: number): Buffer; - /** Same as ref.reinterpretUntilZeros, except that this version does not attach buffer. */ - export function _reinterpretUntilZeros(buffer: Buffer, size: number, - offset?: number): Buffer; - /** Same as ref.writePointer, except that this version does not attach pointer. */ - export function _writePointer(buffer: Buffer, offset: number, - pointer: Buffer): void; - /** Same as ref.writeObject, except that this version does not attach object. */ - export function _writeObject(buffer: Buffer, offset: number, object: Object): void; - - /** Default types. */ - export var types: { - void: Type; int64: Type; ushort: Type; - int: Type; uint64: Type; float: Type; - uint: Type; long: Type; double: Type; - int8: Type; ulong: Type; Object: Type; - uint8: Type; longlong: Type; CString: Type; - int16: Type; ulonglong: Type; bool: Type; - uint16: Type; char: Type; byte: Type; - int32: Type; uchar: Type; size_t: Type; - uint32: Type; short: Type; - }; -} diff --git a/ffi/node/zkgroup/modules/ref-struct-napi.d.ts b/ffi/node/zkgroup/modules/ref-struct-napi.d.ts deleted file mode 100644 index e8023f1..0000000 --- a/ffi/node/zkgroup/modules/ref-struct-napi.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -// Type definitions for ref-struct -// Project: https://github.com/TooTallNate/ref-struct -// Definitions by: Paul Loyd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - -declare module 'ref-struct-napi' { - import { Type } from 'ref-napi'; - - /** - * This is the `constructor` of the Struct type that gets returned. - * - * Invoke it with `new` to create a new Buffer instance backing the struct. - * Pass it an existing Buffer instance to use that as the backing buffer. - * Pass in an Object containing the struct fields to auto-populate the - * struct with the data. - * - * @constructor - */ - export interface StructType extends Type { - /** Pass it an existing Buffer instance to use that as the backing buffer. */ - new (arg: Buffer, data?: {}): any; - new (data?: {}): any; - /** Pass it an existing Buffer instance to use that as the backing buffer. */ - (arg: Buffer, data?: {}): any; - (data?: {}): any; - - fields: { [key: string]: { type: Type } }; - - /** - * Adds a new field to the struct instance with the given name and type. - * Note that this function will throw an Error if any instances of the struct - * type have already been created, therefore this function must be called at the - * beginning, before any instances are created. - */ - defineProperty(name: string, type: Type): void; - - /** - * Adds a new field to the struct instance with the given name and type. - * Note that this function will throw an Error if any instances of the struct - * type have already been created, therefore this function must be called at the - * beginning, before any instances are created. - */ - defineProperty(name: string, type: string): void; - - /** - * Custom for struct type instances. - * @override - */ - toString(): string; - } - - /** The struct type meta-constructor. */ - export var metaConstructor: { - new (fields?: object, opt?: object): StructType; - new (fields?: any[]): StructType; - (fields?: object, opt?: object): StructType; - (fields?: any[]): StructType; - } -} From c72cd9a9ab2e2a98c7af162431b33518437c015f Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 2 Jun 2021 17:36:37 -0700 Subject: [PATCH 12/69] Update aead and aes-gcm-siv crates --- Cargo.lock | 665 ++++++++++++++-------------- rust/Cargo.toml | 4 +- rust/src/api/groups/group_params.rs | 4 +- 3 files changed, 346 insertions(+), 327 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75c98bb..1414676 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,284 +2,320 @@ # It is not intended for manual editing. [[package]] name = "aead" -version = "0.2.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922b33332f54fc0ad13fa3e514601e8d30fb54e1f3eadc36643f6526db645621" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.14.4", ] [[package]] name = "aes" -version = "0.3.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "495ee669413bfbe9e8cace80f4d3d78e6d8c8d99579f97fb93bde351b185f2d4" dependencies = [ - "aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", + "cipher", + "cpufeatures", + "opaque-debug 0.3.0", ] [[package]] name = "aes-gcm-siv" -version = "0.4.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e28b4604398f52cd06867fe0531b62b35f0edddb561e806945cbab9af7fe6a8" dependencies = [ - "aead 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "polyval 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aes-soft" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aesni" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aead", + "aes", + "cipher", + "ctr", + "polyval", + "subtle 2.2.2", + "zeroize", ] [[package]] name = "ascii" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", + "winapi", ] [[package]] name = "autocfg" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] name = "bincode" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "serde", ] [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "block-buffer" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "block-cipher-trait" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.3", ] [[package]] name = "block-padding" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" dependencies = [ - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools", ] [[package]] name = "bstr" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", + "memchr", + "regex-automata", + "serde", ] [[package]] name = "bumpalo" version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" [[package]] name = "byte-tools" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cast" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version", ] [[package]] name = "cesu8" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.4", +] [[package]] name = "clap" version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "textwrap", + "unicode-width", ] [[package]] name = "combine" version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" dependencies = [ - "ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ascii", + "byteorder", + "either", + "memchr", + "unreachable", +] + +[[package]] +name = "cpufeatures" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" +dependencies = [ + "libc", ] [[package]] name = "criterion" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1" dependencies = [ - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion-plot 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "oorandom 11.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "plotters 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", - "tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "atty", + "cast", + "clap", + "criterion-plot", + "csv", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", ] [[package]] name = "criterion-plot" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545" dependencies = [ - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cast", + "itertools", ] [[package]] name = "crossbeam-deque" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" dependencies = [ - "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch", + "crossbeam-utils", + "maybe-uninit", ] [[package]] name = "crossbeam-epoch" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if 0.1.10", + "crossbeam-utils", + "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-queue" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10", + "crossbeam-utils", ] [[package]] name = "crossbeam-utils" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if 0.1.10", + "lazy_static", ] [[package]] name = "crypto-mac" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.3", + "subtle 1.0.0", ] [[package]] name = "csv" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" dependencies = [ - "bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", ] [[package]] name = "csv-core" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "ctr" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" dependencies = [ - "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cipher", ] [[package]] @@ -287,200 +323,242 @@ name = "curve25519-dalek" version = "2.0.0" source = "git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2#477356e017c7cc2aa168f956786b34690870768f" dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "digest", + "packed_simd", + "rand_core", + "serde", + "subtle 2.2.2", + "zeroize", ] [[package]] name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.3", ] [[package]] name = "either" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] name = "error-chain" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" dependencies = [ - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check", ] [[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "generic-array" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", + "version_check", ] [[package]] name = "getrandom" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10", + "libc", + "wasi", ] [[package]] name = "hermit-abi" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" dependencies = [ - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "hex" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" [[package]] name = "hmac" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" dependencies = [ - "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crypto-mac", + "digest", ] [[package]] name = "itertools" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" dependencies = [ - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "either", ] [[package]] name = "itoa" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" [[package]] name = "jni" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22bbdc25b49340bc4fc3d9c96dd84d878c4beeca35e3651efa53db51a68d7d4d" dependencies = [ - "cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cesu8", + "combine", + "error-chain", + "jni-sys", + "log", + "walkdir", ] [[package]] name = "jni-sys" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" dependencies = [ - "wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" version = "0.2.67" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" [[package]] name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10", ] [[package]] name = "maybe-uninit" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] name = "memoffset" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "num-traits" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "num_cpus" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" dependencies = [ - "hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", ] [[package]] name = "oorandom" version = "11.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405" [[package]] name = "opaque-debug" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "packed_simd" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a85ea9fc0d4ac0deb6fe7911d38786b32fc11119afd9e9d38b84ff691ce64220" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10", ] [[package]] name = "plotters" version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb" dependencies = [ - "js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys", + "num-traits", + "wasm-bindgen", + "web-sys", ] [[package]] @@ -488,466 +566,407 @@ name = "poksho" version = "0.7.0" source = "git+https://github.com/signalapp/poksho.git?tag=v0.7.0#8bb8c61c18e7bbe93c094ed91be52b9f96c1c5cd" dependencies = [ - "curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)", - "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek", + "hmac", + "sha2", ] [[package]] name = "polyval" -version = "0.3.3" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e597450cbf209787f0e6de80bf3795c6b2356a380ee87837b545aded8dbc1823" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "universal-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash", ] [[package]] name = "proc-macro2" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] name = "quote" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom", ] [[package]] name = "rayon" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque", + "either", + "rayon-core", ] [[package]] name = "rayon-core" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils", + "lazy_static", + "num_cpus", ] [[package]] name = "regex" version = "1.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" dependencies = [ - "regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax", ] [[package]] name = "regex-automata" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", ] [[package]] name = "regex-syntax" version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" [[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver", ] [[package]] name = "ryu" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util", ] [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser", ] [[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" dependencies = [ - "serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "serde_json" version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" dependencies = [ - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa", + "ryu", + "serde", ] [[package]] name = "sha2" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer", + "digest", + "fake-simd", + "opaque-debug 0.2.3", ] [[package]] name = "subtle" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" [[package]] name = "syn" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width", ] [[package]] name = "tinytemplate" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" dependencies = [ - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", + "serde_json", ] [[package]] name = "typenum" -version = "1.11.2" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "unicode-width" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "universal-hash" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.14.4", + "subtle 2.2.2", ] [[package]] name = "unreachable" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" dependencies = [ - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "void", ] [[package]] name = "version_check" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" [[package]] name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "walkdir" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" dependencies = [ - "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file", + "winapi", + "winapi-util", ] [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasm-bindgen" version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10", + "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" dependencies = [ - "bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" dependencies = [ - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" [[package]] name = "web-sys" version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb" dependencies = [ - "js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys", + "wasm-bindgen", ] [[package]] name = "winapi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "zeroize" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" [[package]] name = "zkgroup" version = "0.7.2" dependencies = [ - "aead 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "aes-gcm-siv 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)", - "hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jni 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "poksho 0.7.0 (git+https://github.com/signalapp/poksho.git?tag=v0.7.0)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum aead 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4cf01b9b56e767bb57b94ebf91a58b338002963785cdd7013e21c0d4679471e4" -"checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" -"checksum aes-gcm-siv 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8c21a21a0afb20aeb41328e980939e99fa02f136ae7317665e892d2760912a" -"checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" -"checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" -"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -"checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -"checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -"checksum bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" -"checksum bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" -"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" -"checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" -"checksum criterion 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1" -"checksum criterion-plot 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545" -"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -"checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" -"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -"checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -"checksum csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" -"checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" -"checksum curve25519-dalek 2.0.0 (git+https://github.com/signalapp/curve25519-dalek.git?branch=lizard2)" = "" -"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum error-chain 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" -"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -"checksum hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" -"checksum hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" -"checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -"checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" -"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" -"checksum jni 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22bbdc25b49340bc4fc3d9c96dd84d878c4beeca35e3651efa53db51a68d7d4d" -"checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -"checksum js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -"checksum memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" -"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" -"checksum oorandom 11.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405" -"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a85ea9fc0d4ac0deb6fe7911d38786b32fc11119afd9e9d38b84ff691ce64220" -"checksum plotters 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb" -"checksum poksho 0.7.0 (git+https://github.com/signalapp/poksho.git?tag=v0.7.0)" = "" -"checksum polyval 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec3341498978de3bfd12d1b22f1af1de22818f5473a11e8a6ef997989e3a212" -"checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" -"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" -"checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" -"checksum regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" -"checksum regex-automata 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -"checksum regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" -"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" -"checksum serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" -"checksum serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)" = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" -"checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" -"checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" -"checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" -"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" -"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" -"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum universal-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" -"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -"checksum wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" -"checksum wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" -"checksum wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" -"checksum wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" -"checksum wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" -"checksum web-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" + "aead", + "aes-gcm-siv", + "bincode", + "criterion", + "curve25519-dalek", + "hex", + "jni", + "poksho", + "serde", + "sha2", +] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index efd49c4..d9a25c2 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -23,8 +23,8 @@ serde = { version = "1.0.106", features = ["derive"] } sha2 = "0.8.0" jni = { version = "0.16.0", default-features = false } hex = "0.4.0" -aead = "0.2.0" -aes-gcm-siv = "0.4.1" +aead = "0.4.0" +aes-gcm-siv = "0.10.0" [dependencies.curve25519-dalek] features = ["std", "serde", "alloc"] diff --git a/rust/src/api/groups/group_params.rs b/rust/src/api/groups/group_params.rs index afd421b..c0cd2e9 100644 --- a/rust/src/api/groups/group_params.rs +++ b/rust/src/api/groups/group_params.rs @@ -196,7 +196,7 @@ impl GroupSecretParams { plaintext: &[u8], ) -> Result, ZkGroupError> { let key = GenericArray::from_slice(key); - let aead_cipher = Aes256GcmSiv::new(*key); + let aead_cipher = Aes256GcmSiv::new(&*key); let nonce = GenericArray::from_slice(nonce); match aead_cipher.encrypt(nonce, plaintext) { Ok(ciphertext_vec) => Ok(ciphertext_vec), @@ -215,7 +215,7 @@ impl GroupSecretParams { return Err(ZkGroupError::DecryptionFailure); } let key = GenericArray::from_slice(key); - let aead_cipher = Aes256GcmSiv::new(*key); + let aead_cipher = Aes256GcmSiv::new(&*key); let nonce = GenericArray::from_slice(nonce); match aead_cipher.decrypt(nonce, ciphertext) { Ok(plaintext_vec) => Ok(plaintext_vec), From c3a478ad66e6e5eb108eac46f07c12b4add752e8 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 2 Jun 2021 17:37:44 -0700 Subject: [PATCH 13/69] Update all dependencies with cargo update --- Cargo.lock | 370 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 209 insertions(+), 161 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1414676..3e90277 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,7 +32,7 @@ dependencies = [ "cipher", "ctr", "polyval", - "subtle 2.2.2", + "subtle 2.4.0", "zeroize", ] @@ -55,17 +55,16 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bincode" -version = "1.2.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "byteorder", "serde", ] @@ -84,7 +83,7 @@ dependencies = [ "block-padding", "byte-tools", "byteorder", - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] @@ -98,9 +97,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.12" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" +checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279" dependencies = [ "lazy_static", "memchr", @@ -110,9 +109,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.2.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" [[package]] name = "byte-tools" @@ -122,15 +121,15 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cast" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +checksum = "57cdfa5d50aad6cb4d44dcab6101a7f79925bd59d82ca42f38a9856a28865374" dependencies = [ "rustc_version", ] @@ -164,9 +163,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.0" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "bitflags", "textwrap", @@ -197,16 +196,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" dependencies = [ "atty", "cast", "clap", "criterion-plot", "csv", - "itertools", + "itertools 0.10.0", "lazy_static", "num-traits", "oorandom", @@ -214,6 +213,7 @@ dependencies = [ "rayon", "regex", "serde", + "serde_cbor", "serde_derive", "serde_json", "tinytemplate", @@ -222,58 +222,55 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545" +checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" dependencies = [ "cast", - "itertools", + "itertools 0.9.0", ] [[package]] -name = "crossbeam-deque" -version = "0.7.3" +name = "crossbeam-channel" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "crossbeam-epoch", + "cfg-if 1.0.0", "crossbeam-utils", - "maybe-uninit", ] [[package]] -name = "crossbeam-epoch" -version = "0.8.2" +name = "crossbeam-deque" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ - "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "crossbeam-epoch", "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", ] [[package]] -name = "crossbeam-queue" -version = "0.2.1" +name = "crossbeam-epoch" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "autocfg", - "cfg-if 0.1.10", + "cfg-if 1.0.0", "lazy_static", ] @@ -283,15 +280,15 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", "subtle 1.0.0", ] [[package]] name = "csv" -version = "1.1.3" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", @@ -328,7 +325,7 @@ dependencies = [ "packed_simd", "rand_core", "serde", - "subtle 2.2.2", + "subtle 2.4.0", "zeroize", ] @@ -338,20 +335,20 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] name = "either" -version = "1.5.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "error-chain" -version = "0.12.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" dependencies = [ "version_check", ] @@ -364,9 +361,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] @@ -383,29 +380,35 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", "wasi", ] +[[package]] +name = "half" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" + [[package]] name = "hermit-abi" -version = "0.1.10" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] [[package]] name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" @@ -419,18 +422,27 @@ dependencies = [ [[package]] name = "itertools" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jni" @@ -454,9 +466,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.37" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" +checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" dependencies = [ "wasm-bindgen", ] @@ -469,54 +481,48 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.67" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" +checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" [[package]] name = "log" -version = "0.4.8" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "memoffset" -version = "0.5.4" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] [[package]] name = "num-traits" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ "hermit-abi", "libc", @@ -524,9 +530,9 @@ dependencies = [ [[package]] name = "oorandom" -version = "11.1.0" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "opaque-debug" @@ -549,18 +555,43 @@ dependencies = [ "cfg-if 0.1.10", ] +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "plotters" -version = "0.2.12" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" dependencies = [ - "js-sys", "num-traits", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + [[package]] name = "poksho" version = "0.7.0" @@ -585,18 +616,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.9" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.3" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] @@ -612,10 +643,11 @@ dependencies = [ [[package]] name = "rayon" -version = "1.3.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ + "autocfg", "crossbeam-deque", "either", "rayon-core", @@ -623,12 +655,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.7.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ + "crossbeam-channel", "crossbeam-deque", - "crossbeam-queue", "crossbeam-utils", "lazy_static", "num_cpus", @@ -636,42 +668,39 @@ dependencies = [ [[package]] name = "regex" -version = "1.3.6" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", -] +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.17" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rustc_version" -version = "0.2.3" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ "semver", ] [[package]] name = "ryu" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "same-file" @@ -690,33 +719,46 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ "semver-parser", ] [[package]] name = "semver-parser" -version = "0.7.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] [[package]] name = "serde" -version = "1.0.106" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" dependencies = [ "serde_derive", ] +[[package]] +name = "serde_cbor" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.106" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" dependencies = [ "proc-macro2", "quote", @@ -725,9 +767,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.51" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -736,9 +778,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" dependencies = [ "block-buffer", "digest", @@ -754,15 +796,15 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.2.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.16" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ "proc-macro2", "quote", @@ -780,9 +822,9 @@ dependencies = [ [[package]] name = "tinytemplate" -version = "1.0.3" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" dependencies = [ "serde", "serde_json", @@ -794,17 +836,23 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "universal-hash" @@ -813,7 +861,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array 0.14.4", - "subtle 2.2.2", + "subtle 2.4.0", ] [[package]] @@ -827,9 +875,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "void" @@ -839,9 +887,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "walkdir" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi", @@ -856,19 +904,19 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasm-bindgen" -version = "0.2.60" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" +checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.60" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" +checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" dependencies = [ "bumpalo", "lazy_static", @@ -881,9 +929,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.60" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" +checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -891,9 +939,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.60" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" +checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" dependencies = [ "proc-macro2", "quote", @@ -904,15 +952,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.60" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" +checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" [[package]] name = "web-sys" -version = "0.3.37" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb" +checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" dependencies = [ "js-sys", "wasm-bindgen", @@ -920,9 +968,9 @@ dependencies = [ [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", @@ -936,9 +984,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] @@ -951,9 +999,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "zeroize" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" [[package]] name = "zkgroup" From 90b85f53282ad8ed6a6d55587b8835eb94e10142 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 22 Jun 2021 14:39:47 -0700 Subject: [PATCH 14/69] GitHub: now that we're on nightly, use that for formatting + clippy --- .github/workflows/formatting.yml | 7 ++----- .github/workflows/tests.yml | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index fd77201..ce3e151 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -11,8 +11,5 @@ jobs: - uses: actions/checkout@v2 - name: Run rustfmt run: | - rustup toolchain install ${{ env.NIGHTLY_VERSION }} - rustup component add rustfmt --toolchain ${{ env.NIGHTLY_VERSION }} - cargo +${{ env.NIGHTLY_VERSION }} fmt -- --check - env: - NIGHTLY_VERSION: nightly-2020-04-12 + rustup component add rustfmt + cargo fmt -- --check diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 785b54b..fae0cf0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,11 +30,8 @@ jobs: - name: Run clippy run: | - rustup toolchain install ${{ env.NIGHTLY_VERSION }} - rustup component add clippy --toolchain ${{ env.NIGHTLY_VERSION }} - cargo +${{ env.NIGHTLY_VERSION }} clippy -- -D warnings - env: - NIGHTLY_VERSION: nightly-2020-04-14 + rustup component add clippy + cargo clippy -- -D warnings - name: Test Rust run: cargo test From ff26ac3679329e182772eed3f51797d91f963c3b Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 24 Jun 2021 14:40:33 -0700 Subject: [PATCH 15/69] Bump version to 0.7.3 --- Cargo.lock | 4 +++- ZKGroup.podspec | 2 +- deploy.gradle | 2 +- ffi/node/package-lock.json | 2 +- ffi/node/package.json | 2 +- rust/Cargo.toml | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e90277..c6b8f8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aead" version = "0.4.1" @@ -1005,7 +1007,7 @@ checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" [[package]] name = "zkgroup" -version = "0.7.2" +version = "0.7.3" dependencies = [ "aead", "aes-gcm-siv", diff --git a/ZKGroup.podspec b/ZKGroup.podspec index d1bc42d..50133a2 100644 --- a/ZKGroup.podspec +++ b/ZKGroup.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "ZKGroup" - s.version = "0.7.2" + s.version = "0.7.3" s.summary = "Swift API for the Rust zkgroup crate." s.homepage = "https://signal.org/" s.license = { :type => "GPLv3", :file => "LICENSE" } diff --git a/deploy.gradle b/deploy.gradle index 47d758d..62df031 100644 --- a/deploy.gradle +++ b/deploy.gradle @@ -1,7 +1,7 @@ apply plugin: 'maven' apply plugin: 'signing' -version = '0.7.2' +version = '0.7.3' group = 'org.signal' def isReleaseBuild() { diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 0bbd932..6790e72 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.7.2", + "version": "0.7.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/ffi/node/package.json b/ffi/node/package.json index 432c65c..29f5cd7 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.7.2", + "version": "0.7.3", "description": "zero-knowledge group functionality", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d9a25c2..01f208d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "zkgroup" -version = "0.7.2" +version = "0.7.3" authors = ["Trevor Perrin "] edition = "2018" description = "A zero-knowledge group library" From 53fe59b040310f957e10978381e950a6cbc068e2 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 24 Jun 2021 14:51:05 -0700 Subject: [PATCH 16/69] GitHub: Remove build artifacts for iOS We don't prebuild these anymore; the client is expected to build themselves, installing the appropriate Rust dependencies. --- .github/workflows/artifacts.yml | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 4ef411b..3544d1e 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -101,8 +101,8 @@ jobs: tag: ${{ github.ref }} overwrite: true - build_macOS_iOS: - name: Build macOS + iOS + build_macOS: + name: Build macOS (Node) runs-on: macOS-latest steps: - uses: actions/checkout@v2 @@ -110,12 +110,6 @@ jobs: - name: Configure git to use HTTPS run: git config --global url."https://${{ secrets.REPO_ACCESS_TOKEN }}:x-oauth-basic@github.com".insteadOf ssh://git@github.com - - name: Install pre-requisites - run: | - rustup target add aarch64-apple-ios x86_64-apple-ios - cd ffi/swift - make install_build_dependencies - - name: Read .nvmrc id: node_version working-directory: ffi/node @@ -132,10 +126,6 @@ jobs: node --version cd ffi/node make libzkgroup - cd ../../ffi/swift - make - cd ZKGroup - zip -r libzkgroup-ios.zip libzkgroup - name: Upload macOS uses: svenstaro/upload-release-action@v1-release @@ -145,12 +135,3 @@ jobs: asset_name: libzkgroup-x64.dylib tag: ${{ github.ref }} overwrite: true - - - name: Upload iOS - uses: svenstaro/upload-release-action@v1-release - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ffi/swift/ZKGroup/libzkgroup-ios.zip - asset_name: libzkgroup-ios.zip - tag: ${{ github.ref }} - overwrite: true From 1e3ea018f7ca6978af01f13cabc6f9ff9a3eb89e Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 24 Jun 2021 17:17:59 -0700 Subject: [PATCH 17/69] GitHub: don't cache the Rust target/ directory for the iOS tests It's causing problems with the new-style iOS build. --- .github/workflows/tests.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fae0cf0..0e7232f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,12 +80,6 @@ jobs: - name: Add rust-src component run: rustup component add rust-src - - name: Cache cargo build - uses: actions/cache@v1 - with: - path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - - name: Run pod lint # No import validation because it tries to build unsupported platforms (like 32-bit iOS). run: pod lib lint --verbose --platforms=ios --skip-import-validation --allow-warnings From 197c382e8b7c602d6644f74348f5eb1d9d02f2d3 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 24 Jun 2021 17:05:21 -0700 Subject: [PATCH 18/69] Java: continue to use Node artifacts for the "testable" jar These names changed to allow for Node cross-compilation, but the testable jar still supports only one arch per platform. --- ffi/java/build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ffi/java/build.gradle b/ffi/java/build.gradle index cf12064..3ff1524 100644 --- a/ffi/java/build.gradle +++ b/ffi/java/build.gradle @@ -66,15 +66,15 @@ task testableJar(type: Jar) { def extraResources = ['libzkgroup.dll', 'libzkgroup.dylib'] def extraResourcesDir = 'src/otherPlatformLibraries/resources' - def urls = extraResources.collect { name -> - 'https://github.com/signalapp/zkgroup/releases/download/v' + project.version + '/' + name - } doFirst { mkdir extraResourcesDir - download { - src urls - dest extraResourcesDir + extraResources.each { name -> + def artifact = name.replace('libzkgroup', 'libzkgroup-x64') + download { + src 'https://github.com/signalapp/zkgroup/releases/download/v' + project.version + '/' + artifact + dest extraResourcesDir + '/' + name + } } } } From 72939eb66c82c6e2eafab137cedec76c26751b43 Mon Sep 17 00:00:00 2001 From: Jim Gustafson Date: Thu, 24 Jun 2021 18:15:40 -0700 Subject: [PATCH 19/69] Fix spelling of expected env var --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index db227be..ba7b954 100644 --- a/Makefile +++ b/Makefile @@ -60,11 +60,11 @@ docker_test: docker_build sh -c "cd src; ./gradlew test" -SONATYPE_USERNAME ?= -SONATYPE_PASSWORD ?= -KEYRING_FILE ?= -SIGNING_KEY ?= -SIGNING_KEY_PASSSWORD ?= +SONATYPE_USERNAME ?= +SONATYPE_PASSWORD ?= +KEYRING_FILE ?= +SIGNING_KEY ?= +SIGNING_KEY_PASSWORD ?= publish: DOCKER_EXTRA = $(shell [ -L build ] && P=$$(readlink build) && echo -v $$P/:$$P ) publish: KEYRING_VOLUME := $(dir $(KEYRING_FILE)) From 0c560457a4f969a329733147160b5624d077dcb1 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 23 Aug 2021 10:36:33 -0700 Subject: [PATCH 20/69] Node: export missing `ProfileKeyCredentialRequest` --- ffi/node/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ffi/node/index.ts b/ffi/node/index.ts index a6f1ce5..d0edc7b 100644 --- a/ffi/node/index.ts +++ b/ffi/node/index.ts @@ -35,6 +35,7 @@ export { default as ProfileKey } from './zkgroup/profiles/ProfileKey'; export { default as ProfileKeyCommitment } from './zkgroup/profiles/ProfileKeyCommitment'; export { default as ProfileKeyCredential } from './zkgroup/profiles/ProfileKeyCredential'; export { default as ProfileKeyCredentialPresentation } from './zkgroup/profiles/ProfileKeyCredentialPresentation'; +export { default as ProfileKeyCredentialRequest } from './zkgroup/profiles/ProfileKeyCredentialRequest'; export { default as ProfileKeyCredentialRequestContext } from './zkgroup/profiles/ProfileKeyCredentialRequestContext'; export { default as ProfileKeyCredentialResponse } from './zkgroup/profiles/ProfileKeyCredentialResponse'; export { default as ProfileKeyVersion } from './zkgroup/profiles/ProfileKeyVersion'; From 59d916811e83c8d3410cd06fc5c7b48634fda03d Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 27 Aug 2021 11:50:06 -0700 Subject: [PATCH 21/69] Bump version to 0.7.4 --- Cargo.lock | 2 +- ZKGroup.podspec | 2 +- deploy.gradle | 2 +- ffi/node/package-lock.json | 2 +- ffi/node/package.json | 2 +- rust/Cargo.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6b8f8a..e6d25e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1007,7 +1007,7 @@ checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" [[package]] name = "zkgroup" -version = "0.7.3" +version = "0.7.4" dependencies = [ "aead", "aes-gcm-siv", diff --git a/ZKGroup.podspec b/ZKGroup.podspec index 50133a2..3188fd1 100644 --- a/ZKGroup.podspec +++ b/ZKGroup.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "ZKGroup" - s.version = "0.7.3" + s.version = "0.7.4" s.summary = "Swift API for the Rust zkgroup crate." s.homepage = "https://signal.org/" s.license = { :type => "GPLv3", :file => "LICENSE" } diff --git a/deploy.gradle b/deploy.gradle index 62df031..29ea0f0 100644 --- a/deploy.gradle +++ b/deploy.gradle @@ -1,7 +1,7 @@ apply plugin: 'maven' apply plugin: 'signing' -version = '0.7.3' +version = '0.7.4' group = 'org.signal' def isReleaseBuild() { diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 6790e72..eab516a 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.7.3", + "version": "0.7.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/ffi/node/package.json b/ffi/node/package.json index 29f5cd7..8110db4 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.7.3", + "version": "0.7.4", "description": "zero-knowledge group functionality", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 01f208d..2ca00d2 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "zkgroup" -version = "0.7.3" +version = "0.7.4" authors = ["Trevor Perrin "] edition = "2018" description = "A zero-knowledge group library" From 0714c470cb119eece284f22e52fd220c78a9235a Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 17:14:08 -0500 Subject: [PATCH 22/69] Update to latest nightly toolchain --- ZKGroup.podspec | 8 ++++++-- rust-toolchain | 1 - rust-toolchain.toml | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) delete mode 100644 rust-toolchain create mode 100644 rust-toolchain.toml diff --git a/ZKGroup.podspec b/ZKGroup.podspec index 3188fd1..b30fef5 100644 --- a/ZKGroup.podspec +++ b/ZKGroup.podspec @@ -13,7 +13,7 @@ Pod::Spec.new do |s| s.homepage = "https://signal.org/" s.license = { :type => "GPLv3", :file => "LICENSE" } s.authors = { "Signal iOS" => "ios@signal.org" } - s.source = { :git => "https://github.com/signalapp/zkgroup.git", :tag => "#{s.version}" } + s.source = { :git => "https://github.com/signalapp/zkgroup.git", :tag => "v#{s.version}" } s.swift_version = '5' s.platform = :ios, '10' @@ -51,6 +51,10 @@ Pod::Spec.new do |s| 'ARCHS[sdk=iphoneos*]' => 'arm64', } + s.user_target_xcconfig = { + 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', + } + s.script_phases = [ { :name => 'Check libzkgroup', :execution_position => :before_compile, @@ -71,7 +75,7 @@ Pod::Spec.new do |s| set -euo pipefail CARGO_BUILD_TARGET=aarch64-apple-ios ffi/swift/build_ffi.sh --release CARGO_BUILD_TARGET=x86_64-apple-ios ffi/swift/build_ffi.sh --release - CARGO_BUILD_TARGET=aarch64-apple-ios-sim ffi/swift/build_ffi.sh --release --build-std + CARGO_BUILD_TARGET=aarch64-apple-ios-sim ffi/swift/build_ffi.sh --release CARGO_BUILD_TARGET=x86_64-apple-ios-macabi ffi/swift/build_ffi.sh --release --build-std CARGO_BUILD_TARGET=aarch64-apple-ios-macabi ffi/swift/build_ffi.sh --release --build-std ) diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 994890c..0000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-2021-06-08 \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..d9d9a86 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,20 @@ +[toolchain] +channel = "nightly-2021-09-19" +components = [ + "rust-src", +] +profile = "default" +targets = [ + "aarch64-apple-darwin", + "aarch64-apple-ios", + "aarch64-apple-ios-macabi", + "aarch64-apple-ios-sim", + "aarch64-linux-android", + "armv7-linux-androideabi", + "i686-linux-android", + "x86_64-apple-darwin", + "x86_64-apple-ios", + "x86_64-apple-ios-macabi", + "x86_64-linux-android", + "x86_64-unknown-linux-gnu", +] From 37a853097226adfeab4f6e95ca6148a79ccc3dd7 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 17:18:12 -0500 Subject: [PATCH 23/69] Update OVERVIEW.md --- OVERVIEW.md | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/OVERVIEW.md b/OVERVIEW.md index 70c1834..18a8bf2 100644 --- a/OVERVIEW.md +++ b/OVERVIEW.md @@ -18,26 +18,13 @@ This library provides zero-knowledge group functionality through several layers * Under `node` is some example code for declaring the FFI functions in javascript. Setup -== +===== -Set to `stable` toolchain. - -``` -rustup default stable -``` - -Install [rustup](https://rustup.rs/) and these targets: - -``` -rustup target add armv7-linux-androideabi # for arm -rustup target add i686-linux-android # for x86 -rustup target add aarch64-linux-android # for arm64 -rustup target add x86_64-linux-android # for x86_64 -rustup target add x86_64-unknown-linux-gnu # for linux-x86-64 -rustup target add x86_64-apple-darwin # for macOS (darwin) -``` +The rust-toolchain.toml file should get things automatically setup for you +provided you are using rustup. See it for the toolchain and channel and targets +in use for this build. Building Rust -== +============= Run `./gradlew tasks` and see `make` tasks under the "Rust tasks" group. From b9871796cbbd39318b1ba37fb3c592778312c838 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 17:19:48 -0500 Subject: [PATCH 24/69] Combine README.md and OVERVIEW.md --- OVERVIEW.md | 30 ------------------------------ README.md | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 OVERVIEW.md diff --git a/OVERVIEW.md b/OVERVIEW.md deleted file mode 100644 index 18a8bf2..0000000 --- a/OVERVIEW.md +++ /dev/null @@ -1,30 +0,0 @@ - -# Overview - -This library provides zero-knowledge group functionality through several layers of APIs. From lower-level to higher-level: - - * `internal.rs` provides the actual Rust implementations, based on Rust structures. - - * `simpleapi.rs` provides wrapper functions around internal.rs functions that use `serde` to serialize/deseralize byte arrays into Rust structures. - - * `ffiapi.rs` and `ffiapijava.rs` provide wrapper functions around `simpleapi.rs` functions to export them via C and JNI, respectively. - - * The subdirectories under `ffi` contain code in various host languages for accessing the exported functions: - - * Under `c` is a `zkgroup.h` header file. - - * Under `android` is a `ZKGroup.java` file and instructions for building an aar. - - * Under `node` is some example code for declaring the FFI functions in javascript. - -Setup -===== - -The rust-toolchain.toml file should get things automatically setup for you -provided you are using rustup. See it for the toolchain and channel and targets -in use for this build. - -Building Rust -============= - -Run `./gradlew tasks` and see `make` tasks under the "Rust tasks" group. diff --git a/README.md b/README.md index 91ac949..67ca995 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,34 @@ -# zkgroup - Library for the Signal Private Group System. Work in progress. Subject to change without notice, use outside Signal not yet recommended. +Overview +======== + +This library provides zero-knowledge group functionality through several layers of APIs. From lower-level to higher-level: + +* `internal.rs` provides the actual Rust implementations, based on Rust structures. + +* `simpleapi.rs` provides wrapper functions around internal.rs functions that use `serde` to serialize/deseralize byte arrays into Rust structures. + +* `ffiapi.rs` and `ffiapijava.rs` provide wrapper functions around `simpleapi.rs` functions to export them via C and JNI, respectively. + +* The subdirectories under `ffi` contain code in various host languages for accessing the exported functions: + + * Under `c` is a `zkgroup.h` header file. + + * Under `android` is a `ZKGroup.java` file and instructions for building an aar. + + * Under `node` is some example code for declaring the FFI functions in javascript. + +Setup +===== + +The rust-toolchain.toml file should get things automatically setup for you +provided you are using rustup. See it for the toolchain and channel and targets +in use for this build. + +Building Rust +============= + +Run `./gradlew tasks` and see `make` tasks under the "Rust tasks" group. From 6b5f818ba89080282864d4f456c2c6c6c251df43 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 17:24:03 -0500 Subject: [PATCH 25/69] Comment out two targets that don't ship rust-std --- rust-toolchain.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d9d9a86..74e786c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -7,14 +7,14 @@ profile = "default" targets = [ "aarch64-apple-darwin", "aarch64-apple-ios", - "aarch64-apple-ios-macabi", +# "aarch64-apple-ios-macabi", "aarch64-apple-ios-sim", "aarch64-linux-android", "armv7-linux-androideabi", "i686-linux-android", "x86_64-apple-darwin", "x86_64-apple-ios", - "x86_64-apple-ios-macabi", +# "x86_64-apple-ios-macabi", "x86_64-linux-android", "x86_64-unknown-linux-gnu", ] From da7013805fbc6b06232014f6e61e488c59f533f3 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 17:33:51 -0500 Subject: [PATCH 26/69] Update mod.rs to new module name style --- rust/src/{api/mod.rs => api.rs} | 0 rust/src/api/{auth/mod.rs => auth.rs} | 0 rust/src/api/{groups/mod.rs => groups.rs} | 0 rust/src/api/{profiles/mod.rs => profiles.rs} | 0 rust/src/{common/mod.rs => common.rs} | 0 rust/src/{crypto/mod.rs => crypto.rs} | 0 rust/src/{ffi/mod.rs => ffi.rs} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename rust/src/{api/mod.rs => api.rs} (100%) rename rust/src/api/{auth/mod.rs => auth.rs} (100%) rename rust/src/api/{groups/mod.rs => groups.rs} (100%) rename rust/src/api/{profiles/mod.rs => profiles.rs} (100%) rename rust/src/{common/mod.rs => common.rs} (100%) rename rust/src/{crypto/mod.rs => crypto.rs} (100%) rename rust/src/{ffi/mod.rs => ffi.rs} (100%) diff --git a/rust/src/api/mod.rs b/rust/src/api.rs similarity index 100% rename from rust/src/api/mod.rs rename to rust/src/api.rs diff --git a/rust/src/api/auth/mod.rs b/rust/src/api/auth.rs similarity index 100% rename from rust/src/api/auth/mod.rs rename to rust/src/api/auth.rs diff --git a/rust/src/api/groups/mod.rs b/rust/src/api/groups.rs similarity index 100% rename from rust/src/api/groups/mod.rs rename to rust/src/api/groups.rs diff --git a/rust/src/api/profiles/mod.rs b/rust/src/api/profiles.rs similarity index 100% rename from rust/src/api/profiles/mod.rs rename to rust/src/api/profiles.rs diff --git a/rust/src/common/mod.rs b/rust/src/common.rs similarity index 100% rename from rust/src/common/mod.rs rename to rust/src/common.rs diff --git a/rust/src/crypto/mod.rs b/rust/src/crypto.rs similarity index 100% rename from rust/src/crypto/mod.rs rename to rust/src/crypto.rs diff --git a/rust/src/ffi/mod.rs b/rust/src/ffi.rs similarity index 100% rename from rust/src/ffi/mod.rs rename to rust/src/ffi.rs From f344c0416f9244a2576181fb9dc91a872fde0fec Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 17:46:32 -0500 Subject: [PATCH 27/69] Add missing license header --- rust/benches/zkgroup_benchmarks.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rust/benches/zkgroup_benchmarks.rs b/rust/benches/zkgroup_benchmarks.rs index 26c7de6..51dc12d 100644 --- a/rust/benches/zkgroup_benchmarks.rs +++ b/rust/benches/zkgroup_benchmarks.rs @@ -1,3 +1,10 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + use criterion::{criterion_group, criterion_main, Criterion}; extern crate zkgroup; From 7e958922eb294aeee81e609ded13b98f30e2b1a2 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 19:38:58 -0500 Subject: [PATCH 28/69] Ignore __pycache__ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 82f5508..b57ca8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +__pycache__ build target .idea From 440a148f2bc94fe4ef0dbe9bd4171b2241f2d898 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 19:39:15 -0500 Subject: [PATCH 29/69] Remove trailing whitespace --- .../java/org/signal/zkgroup/auth/ServerZkAuthOperations.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java b/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java index 57d99c1..6588478 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java @@ -56,13 +56,13 @@ public AuthCredentialResponse issueAuthCredential(SecureRandom secureRandom, UUI public void verifyAuthCredentialPresentation(GroupPublicParams groupPublicParams, AuthCredentialPresentation authCredentialPresentation) throws VerificationFailedException, InvalidRedemptionTimeException { verifyAuthCredentialPresentation(groupPublicParams, authCredentialPresentation, System.currentTimeMillis()); } - + public void verifyAuthCredentialPresentation(GroupPublicParams groupPublicParams, AuthCredentialPresentation authCredentialPresentation, long currentTimeMillis) throws VerificationFailedException, InvalidRedemptionTimeException { long acceptableStartTime = TimeUnit.MILLISECONDS.convert(authCredentialPresentation.getRedemptionTime()-1, TimeUnit.DAYS); long acceptableEndTime = TimeUnit.MILLISECONDS.convert(authCredentialPresentation.getRedemptionTime()+2, TimeUnit.DAYS); if (currentTimeMillis < acceptableStartTime || currentTimeMillis > acceptableEndTime) { - throw new InvalidRedemptionTimeException(); + throw new InvalidRedemptionTimeException(); } int ffi_return = Native.serverSecretParamsVerifyAuthCredentialPresentationJNI(serverSecretParams.getInternalContentsForJNI(), groupPublicParams.getInternalContentsForJNI(), authCredentialPresentation.getInternalContentsForJNI()); From 5f6ddf0355af0109c343b5f2dd4ab245a417178e Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 19:39:33 -0500 Subject: [PATCH 30/69] Remove warning from codegen script as it blocks make --- codegen/codegen.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/codegen/codegen.py b/codegen/codegen.py index 248e136..77316d6 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -314,9 +314,6 @@ def define_classes(): -if input("WARNING: Running this generator may result in some code being lost. Continue? yes/NO ").strip() != "yes": - sys.exit() - classes = define_classes() codegen_java.produce_output(classes) codegen_ffiapi.produce_output(classes) From b2dae3a7667d4f6a4d26d0492054a3ceec4abe5f Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 19:40:06 -0500 Subject: [PATCH 31/69] Add custom patch to keep codegen output matching current code --- codegen/Makefile | 12 +- codegen/codegen_hack.patch | 441 +++++++++++++++++++++++++++++++++++++ 2 files changed, 452 insertions(+), 1 deletion(-) create mode 100644 codegen/codegen_hack.patch diff --git a/codegen/Makefile b/codegen/Makefile index 10b20f3..a0881cb 100644 --- a/codegen/Makefile +++ b/codegen/Makefile @@ -1,3 +1,10 @@ +.PHONY: all +all: + $(MAKE) output + $(MAKE) install + $(MAKE) clean + +.PHONY: output output: mkdir -p ffiapijava mkdir -p ffiapi @@ -13,13 +20,16 @@ output: rustfmt ffiapi/ffiapi.rs rustfmt simpleapi/simpleapi.rs +.PHONY: install install: cp ffiapijava/ffiapijava.rs ../rust/src/ffi/ cp ffiapi/ffiapi.rs ../rust/src/ffi/ cp simpleapi/simpleapi.rs ../rust/src/ffi/ cp -r java/* ../ffi/java/src/main/java/org/signal/zkgroup - cp -r swift/* ../ffi/swift/ZKGroup + cp -r swift/* ../ffi/swift/Sources/ZKGroup + patch -d .. -p1 < codegen_hack.patch +.PHONY: clean clean: rm -rf ffiapijava rm -rf ffiapi diff --git a/codegen/codegen_hack.patch b/codegen/codegen_hack.patch new file mode 100644 index 0000000..e175cac --- /dev/null +++ b/codegen/codegen_hack.patch @@ -0,0 +1,441 @@ +diff --git b/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java a/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java +index a2567a55ef32..57d99c13ed71 100644 +--- b/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java ++++ a/ffi/java/src/main/java/org/signal/zkgroup/auth/ServerZkAuthOperations.java +@@ -11,9 +11,11 @@ package org.signal.zkgroup.auth; + + import java.security.SecureRandom; + import java.util.UUID; ++import java.util.concurrent.TimeUnit; + import org.signal.zkgroup.InvalidInputException; + import org.signal.zkgroup.ServerSecretParams; + import org.signal.zkgroup.VerificationFailedException; ++import org.signal.zkgroup.InvalidRedemptionTimeException; + import org.signal.zkgroup.ZkGroupError; + import org.signal.zkgroup.groups.GroupPublicParams; + import org.signal.zkgroup.internal.Native; +@@ -51,7 +53,18 @@ public class ServerZkAuthOperations { + + } + +- public void verifyAuthCredentialPresentation(GroupPublicParams groupPublicParams, AuthCredentialPresentation authCredentialPresentation) throws VerificationFailedException { ++ public void verifyAuthCredentialPresentation(GroupPublicParams groupPublicParams, AuthCredentialPresentation authCredentialPresentation) throws VerificationFailedException, InvalidRedemptionTimeException { ++ verifyAuthCredentialPresentation(groupPublicParams, authCredentialPresentation, System.currentTimeMillis()); ++ } ++ ++ public void verifyAuthCredentialPresentation(GroupPublicParams groupPublicParams, AuthCredentialPresentation authCredentialPresentation, long currentTimeMillis) throws VerificationFailedException, InvalidRedemptionTimeException { ++ long acceptableStartTime = TimeUnit.MILLISECONDS.convert(authCredentialPresentation.getRedemptionTime()-1, TimeUnit.DAYS); ++ long acceptableEndTime = TimeUnit.MILLISECONDS.convert(authCredentialPresentation.getRedemptionTime()+2, TimeUnit.DAYS); ++ ++ if (currentTimeMillis < acceptableStartTime || currentTimeMillis > acceptableEndTime) { ++ throw new InvalidRedemptionTimeException(); ++ } ++ + int ffi_return = Native.serverSecretParamsVerifyAuthCredentialPresentationJNI(serverSecretParams.getInternalContentsForJNI(), groupPublicParams.getInternalContentsForJNI(), authCredentialPresentation.getInternalContentsForJNI()); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); +diff --git b/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java a/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java +index 464cf6d19ecc..5739505935b0 100644 +--- b/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java ++++ a/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java +@@ -9,6 +9,7 @@ + + package org.signal.zkgroup.groups; + ++import java.nio.ByteBuffer; + import java.security.SecureRandom; + import java.util.UUID; + import org.signal.zkgroup.InvalidInputException; +@@ -100,12 +101,16 @@ public class ClientZkGroupCipher { + } + + public byte[] encryptBlob(SecureRandom secureRandom, byte[] plaintext) throws VerificationFailedException { +- byte[] newContents = new byte[plaintext.length+29]; ++ ++ byte[] paddedPlaintext = new byte[plaintext.length + 4]; ++ System.arraycopy(plaintext, 0, paddedPlaintext, 4, plaintext.length); ++ ++ byte[] newContents = new byte[paddedPlaintext.length+29]; + byte[] random = new byte[Native.RANDOM_LENGTH]; + + secureRandom.nextBytes(random); + +- int ffi_return = Native.groupSecretParamsEncryptBlobDeterministicJNI(groupSecretParams.getInternalContentsForJNI(), random, plaintext, newContents); ++ int ffi_return = Native.groupSecretParamsEncryptBlobDeterministicJNI(groupSecretParams.getInternalContentsForJNI(), random, paddedPlaintext, newContents); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } +@@ -129,7 +134,21 @@ public class ClientZkGroupCipher { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + +- return newContents; ++ if (newContents.length < 4) { ++ throw new VerificationFailedException(); ++ } ++ ++ byte[] padLenBytes = new byte[4]; ++ System.arraycopy(newContents, 0, padLenBytes, 0, 4); ++ int padLen = ByteBuffer.wrap(newContents).getInt(); ++ if (newContents.length < (4 + padLen)) { ++ throw new VerificationFailedException(); ++ } ++ ++ byte[] depaddedContents = new byte[newContents.length - (4 + padLen)]; ++ System.arraycopy(newContents, 4, depaddedContents, 0, newContents.length - (4 + padLen)); ++ ++ return depaddedContents; + } + + } +diff --git b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java +index cbc73ac60bee..57a252f5886d 100644 +--- b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java ++++ a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java +@@ -52,6 +52,10 @@ public class ClientZkProfileOperations { + } + + public ProfileKeyCredential receiveProfileKeyCredential(ProfileKeyCredentialRequestContext profileKeyCredentialRequestContext, ProfileKeyCredentialResponse profileKeyCredentialResponse) throws VerificationFailedException { ++ if (profileKeyCredentialResponse == null) { ++ throw new VerificationFailedException(); ++ } ++ + byte[] newContents = new byte[ProfileKeyCredential.SIZE]; + + int ffi_return = Native.serverPublicParamsReceiveProfileKeyCredentialJNI(serverPublicParams.getInternalContentsForJNI(), profileKeyCredentialRequestContext.getInternalContentsForJNI(), profileKeyCredentialResponse.getInternalContentsForJNI(), newContents); +diff --git b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ProfileKey.java a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ProfileKey.java +index 2251da362b0e..9170b5fd9a5c 100644 +--- b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ProfileKey.java ++++ a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ProfileKey.java +@@ -25,14 +25,10 @@ public final class ProfileKey extends ByteArray { + super(contents, SIZE); + } + +- public ProfileKeyCommitment getCommitment(UUID uuid) throws VerificationFailedException { ++ public ProfileKeyCommitment getCommitment(UUID uuid) { + byte[] newContents = new byte[ProfileKeyCommitment.SIZE]; + + int ffi_return = Native.profileKeyGetCommitmentJNI(contents, UUIDUtil.serialize(uuid), newContents); +- if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { +- throw new VerificationFailedException(); +- } +- + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } +@@ -45,14 +41,10 @@ public final class ProfileKey extends ByteArray { + + } + +- public ProfileKeyVersion getProfileKeyVersion(UUID uuid) throws VerificationFailedException { ++ public ProfileKeyVersion getProfileKeyVersion(UUID uuid) { + byte[] newContents = new byte[ProfileKeyVersion.SIZE]; + + int ffi_return = Native.profileKeyGetProfileKeyVersionJNI(contents, UUIDUtil.serialize(uuid), newContents); +- if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { +- throw new VerificationFailedException(); +- } +- + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } +diff --git b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift a/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift +index 4d36edb46acf..fa7f1b4aba5c 100644 +--- b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift ++++ a/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift +@@ -85,7 +85,7 @@ public class ClientZkGroupCipher { + + } + +- public func encryptBlob(plaintext: [UInt8]) throws -> BlobCiphertext { ++ public func encryptBlob(plaintext: [UInt8]) throws -> [UInt8] { + var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) + let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) + guard result == errSecSuccess else { +@@ -96,9 +96,11 @@ public class ClientZkGroupCipher { + } + + public func encryptBlob(randomness: [UInt8], plaintext: [UInt8]) throws -> [UInt8] { +- var newContents: [UInt8] = Array(repeating: 0, count: Int(randomness.count+29)) ++ let paddedPlaintext = Array(repeating:0, count: 4) + plaintext + +- let ffi_return = FFI_GroupSecretParams_encryptBlobDeterministic(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), plaintext, UInt32(plaintext.count), &newContents, UInt32(newContents.count)) ++ var newContents: [UInt8] = Array(repeating: 0, count: Int(paddedPlaintext.count+29)) ++ ++ let ffi_return = FFI_GroupSecretParams_encryptBlobDeterministic(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), paddedPlaintext, UInt32(paddedPlaintext.count), &newContents, UInt32(newContents.count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } +@@ -111,9 +113,10 @@ public class ClientZkGroupCipher { + } + + public func decryptBlob(blobCiphertext: [UInt8]) throws -> [UInt8] { +- var newContents: [UInt8] = Array(repeating: 0, count: Int(blobCiphertext.count+-29)) ++ var newContents: [UInt8] = Array(repeating: 0, count: Int(blobCiphertext.count-29)) + + let ffi_return = FFI_GroupSecretParams_decryptBlob(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), blobCiphertext, UInt32(blobCiphertext.count), &newContents, UInt32(newContents.count)) ++ + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } +@@ -122,7 +125,18 @@ public class ClientZkGroupCipher { + throw ZkGroupException.ZkGroupError + } + +- return newContents ++ if newContents.count < 4 { ++ throw ZkGroupException.VerificationFailed ++ } ++ ++ var paddingLen = newContents.withUnsafeBytes({ $0.load(fromByteOffset:0, as: UInt32.self) }) ++ paddingLen = UInt32(bigEndian: paddingLen) ++ ++ if (newContents.count < (4 + paddingLen)) { ++ throw ZkGroupException.VerificationFailed ++ } ++ ++ return Array(newContents[4 ..< newContents.endIndex - Int(paddingLen)]) + } + + } +diff --git b/rust/src/ffi/ffiapi.rs a/rust/src/ffi/ffiapi.rs +index 23e0bdd604a8..810afe3f4af5 100644 +--- b/rust/src/ffi/ffiapi.rs ++++ a/rust/src/ffi/ffiapi.rs +@@ -30,7 +30,7 @@ pub extern "C" fn FFI_ProfileKey_getCommitment( + slice::from_raw_parts_mut(profileKeyCommitmentOut, profileKeyCommitmentLen as usize) + }; + +- simpleapi::ProfileKey_getCommitment(profile_key, &uuid, profile_key_commitment) ++ simpleapi::ProfileKey_getCommitment(profile_key, uuid, profile_key_commitment) + }); + + match result { +@@ -56,7 +56,7 @@ pub extern "C" fn FFI_ProfileKey_getProfileKeyVersion( + slice::from_raw_parts_mut(profileKeyVersionOut, profileKeyVersionLen as usize) + }; + +- simpleapi::ProfileKey_getProfileKeyVersion(profile_key, &uuid, profile_key_version) ++ simpleapi::ProfileKey_getProfileKeyVersion(profile_key, uuid, profile_key_version) + }); + + match result { +@@ -98,7 +98,7 @@ pub extern "C" fn FFI_GroupSecretParams_generateDeterministic( + slice::from_raw_parts_mut(groupSecretParamsOut, groupSecretParamsLen as usize) + }; + +- simpleapi::GroupSecretParams_generateDeterministic(&randomness, group_secret_params) ++ simpleapi::GroupSecretParams_generateDeterministic(randomness, group_secret_params) + }); + + match result { +@@ -121,7 +121,7 @@ pub extern "C" fn FFI_GroupSecretParams_deriveFromMasterKey( + slice::from_raw_parts_mut(groupSecretParamsOut, groupSecretParamsLen as usize) + }; + +- simpleapi::GroupSecretParams_deriveFromMasterKey(&group_master_key, group_secret_params) ++ simpleapi::GroupSecretParams_deriveFromMasterKey(group_master_key, group_secret_params) + }); + + match result { +@@ -209,7 +209,7 @@ pub extern "C" fn FFI_GroupSecretParams_encryptUuid( + let uuid_ciphertext: &mut [u8] = + unsafe { slice::from_raw_parts_mut(uuidCiphertextOut, uuidCiphertextLen as usize) }; + +- simpleapi::GroupSecretParams_encryptUuid(group_secret_params, &uuid, uuid_ciphertext) ++ simpleapi::GroupSecretParams_encryptUuid(group_secret_params, uuid, uuid_ciphertext) + }); + + match result { +@@ -234,7 +234,7 @@ pub extern "C" fn FFI_GroupSecretParams_decryptUuid( + unsafe { slice::from_raw_parts(uuidCiphertext, uuidCiphertextLen as usize) }; + let uuid: &mut [u8] = unsafe { slice::from_raw_parts_mut(uuidOut, uuidLen as usize) }; + +- simpleapi::GroupSecretParams_decryptUuid(group_secret_params, &uuid_ciphertext, uuid) ++ simpleapi::GroupSecretParams_decryptUuid(group_secret_params, uuid_ciphertext, uuid) + }); + + match result { +@@ -266,8 +266,8 @@ pub extern "C" fn FFI_GroupSecretParams_encryptProfileKey( + + simpleapi::GroupSecretParams_encryptProfileKey( + group_secret_params, +- &profile_key, +- &uuid, ++ profile_key, ++ uuid, + profile_key_ciphertext, + ) + }); +@@ -301,8 +301,8 @@ pub extern "C" fn FFI_GroupSecretParams_decryptProfileKey( + + simpleapi::GroupSecretParams_decryptProfileKey( + group_secret_params, +- &profile_key_ciphertext, +- &uuid, ++ profile_key_ciphertext, ++ uuid, + profile_key, + ) + }); +@@ -335,8 +335,8 @@ pub extern "C" fn FFI_GroupSecretParams_encryptBlobDeterministic( + + simpleapi::GroupSecretParams_encryptBlobDeterministic( + group_secret_params, +- &randomness, +- &plaintext, ++ randomness, ++ plaintext, + blob_ciphertext, + ) + }); +@@ -364,7 +364,7 @@ pub extern "C" fn FFI_GroupSecretParams_decryptBlob( + let plaintext: &mut [u8] = + unsafe { slice::from_raw_parts_mut(plaintextOut, plaintextLen as usize) }; + +- simpleapi::GroupSecretParams_decryptBlob(group_secret_params, &blob_ciphertext, plaintext) ++ simpleapi::GroupSecretParams_decryptBlob(group_secret_params, blob_ciphertext, plaintext) + }); + + match result { +@@ -387,7 +387,7 @@ pub extern "C" fn FFI_ServerSecretParams_generateDeterministic( + slice::from_raw_parts_mut(serverSecretParamsOut, serverSecretParamsLen as usize) + }; + +- simpleapi::ServerSecretParams_generateDeterministic(&randomness, server_secret_params) ++ simpleapi::ServerSecretParams_generateDeterministic(randomness, server_secret_params) + }); + + match result { +@@ -459,8 +459,8 @@ pub extern "C" fn FFI_ServerSecretParams_signDeterministic( + + simpleapi::ServerSecretParams_signDeterministic( + server_secret_params, +- &randomness, +- &message, ++ randomness, ++ message, + notary_signature, + ) + }); +@@ -496,9 +496,9 @@ pub extern "C" fn FFI_ServerPublicParams_receiveAuthCredential( + + simpleapi::ServerPublicParams_receiveAuthCredential( + server_public_params, +- &uuid, ++ uuid, + redemption_time, +- &auth_credential_response, ++ auth_credential_response, + auth_credential, + ) + }); +@@ -540,9 +540,9 @@ pub extern "C" fn FFI_ServerPublicParams_createAuthCredentialPresentationDetermi + + simpleapi::ServerPublicParams_createAuthCredentialPresentationDeterministic( + server_public_params, +- &randomness, +- &group_secret_params, +- &auth_credential, ++ randomness, ++ group_secret_params, ++ auth_credential, + auth_credential_presentation, + ) + }); +@@ -583,9 +583,9 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialRequestContex + + simpleapi::ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic( + server_public_params, +- &randomness, +- &uuid, +- &profile_key, ++ randomness, ++ uuid, ++ profile_key, + profile_key_credential_request_context, + ) + }); +@@ -628,8 +628,8 @@ pub extern "C" fn FFI_ServerPublicParams_receiveProfileKeyCredential( + + simpleapi::ServerPublicParams_receiveProfileKeyCredential( + server_public_params, +- &profile_key_credential_request_context, +- &profile_key_credential_response, ++ profile_key_credential_request_context, ++ profile_key_credential_response, + profile_key_credential, + ) + }); +@@ -672,9 +672,9 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialPresentationD + + simpleapi::ServerPublicParams_createProfileKeyCredentialPresentationDeterministic( + server_public_params, +- &randomness, +- &group_secret_params, +- &profile_key_credential, ++ randomness, ++ group_secret_params, ++ profile_key_credential, + profile_key_credential_presentation, + ) + }); +@@ -713,8 +713,8 @@ pub extern "C" fn FFI_ServerSecretParams_issueAuthCredentialDeterministic( + + simpleapi::ServerSecretParams_issueAuthCredentialDeterministic( + server_secret_params, +- &randomness, +- &uuid, ++ randomness, ++ uuid, + redemption_time, + auth_credential_response, + ) +@@ -749,8 +749,8 @@ pub extern "C" fn FFI_ServerSecretParams_verifyAuthCredentialPresentation( + + simpleapi::ServerSecretParams_verifyAuthCredentialPresentation( + server_secret_params, +- &group_public_params, +- &auth_credential_presentation, ++ group_public_params, ++ auth_credential_presentation, + ) + }); + +@@ -799,10 +799,10 @@ pub extern "C" fn FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic( + + simpleapi::ServerSecretParams_issueProfileKeyCredentialDeterministic( + server_secret_params, +- &randomness, +- &profile_key_credential_request, +- &uuid, +- &profile_key_commitment, ++ randomness, ++ profile_key_credential_request, ++ uuid, ++ profile_key_commitment, + profile_key_credential_response, + ) + }); +@@ -836,8 +836,8 @@ pub extern "C" fn FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation( + + simpleapi::ServerSecretParams_verifyProfileKeyCredentialPresentation( + server_secret_params, +- &group_public_params, +- &profile_key_credential_presentation, ++ group_public_params, ++ profile_key_credential_presentation, + ) + }); + +@@ -923,8 +923,8 @@ pub extern "C" fn FFI_ServerPublicParams_verifySignature( + + simpleapi::ServerPublicParams_verifySignature( + server_public_params, +- &message, +- ¬ary_signature, ++ message, ++ notary_signature, + ) + }); + From 99a759e1ec03484b577b20abacbfc9f4d532a826 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 19:47:44 -0500 Subject: [PATCH 32/69] Fix ffiapi codegen to reduce patch --- codegen/codegen_ffiapi.py | 5 +- codegen/codegen_hack.patch | 241 ------------------------------------- 2 files changed, 1 insertion(+), 245 deletions(-) diff --git a/codegen/codegen_ffiapi.py b/codegen/codegen_ffiapi.py index 29d31f8..64185ad 100644 --- a/codegen/codegen_ffiapi.py +++ b/codegen/codegen_ffiapi.py @@ -41,10 +41,7 @@ def get_args(params, commaAtEnd): s = "" for param in params: - if param[0] != "int": - s += "&" + param[1].snake() + ", " - else: - s += param[1].snake() + ", " + s += param[1].snake() + ", " if len(s) != 0 and not commaAtEnd: s = s[:-2] diff --git a/codegen/codegen_hack.patch b/codegen/codegen_hack.patch index e175cac..47d76a7 100644 --- a/codegen/codegen_hack.patch +++ b/codegen/codegen_hack.patch @@ -198,244 +198,3 @@ index 4d36edb46acf..fa7f1b4aba5c 100644 } } -diff --git b/rust/src/ffi/ffiapi.rs a/rust/src/ffi/ffiapi.rs -index 23e0bdd604a8..810afe3f4af5 100644 ---- b/rust/src/ffi/ffiapi.rs -+++ a/rust/src/ffi/ffiapi.rs -@@ -30,7 +30,7 @@ pub extern "C" fn FFI_ProfileKey_getCommitment( - slice::from_raw_parts_mut(profileKeyCommitmentOut, profileKeyCommitmentLen as usize) - }; - -- simpleapi::ProfileKey_getCommitment(profile_key, &uuid, profile_key_commitment) -+ simpleapi::ProfileKey_getCommitment(profile_key, uuid, profile_key_commitment) - }); - - match result { -@@ -56,7 +56,7 @@ pub extern "C" fn FFI_ProfileKey_getProfileKeyVersion( - slice::from_raw_parts_mut(profileKeyVersionOut, profileKeyVersionLen as usize) - }; - -- simpleapi::ProfileKey_getProfileKeyVersion(profile_key, &uuid, profile_key_version) -+ simpleapi::ProfileKey_getProfileKeyVersion(profile_key, uuid, profile_key_version) - }); - - match result { -@@ -98,7 +98,7 @@ pub extern "C" fn FFI_GroupSecretParams_generateDeterministic( - slice::from_raw_parts_mut(groupSecretParamsOut, groupSecretParamsLen as usize) - }; - -- simpleapi::GroupSecretParams_generateDeterministic(&randomness, group_secret_params) -+ simpleapi::GroupSecretParams_generateDeterministic(randomness, group_secret_params) - }); - - match result { -@@ -121,7 +121,7 @@ pub extern "C" fn FFI_GroupSecretParams_deriveFromMasterKey( - slice::from_raw_parts_mut(groupSecretParamsOut, groupSecretParamsLen as usize) - }; - -- simpleapi::GroupSecretParams_deriveFromMasterKey(&group_master_key, group_secret_params) -+ simpleapi::GroupSecretParams_deriveFromMasterKey(group_master_key, group_secret_params) - }); - - match result { -@@ -209,7 +209,7 @@ pub extern "C" fn FFI_GroupSecretParams_encryptUuid( - let uuid_ciphertext: &mut [u8] = - unsafe { slice::from_raw_parts_mut(uuidCiphertextOut, uuidCiphertextLen as usize) }; - -- simpleapi::GroupSecretParams_encryptUuid(group_secret_params, &uuid, uuid_ciphertext) -+ simpleapi::GroupSecretParams_encryptUuid(group_secret_params, uuid, uuid_ciphertext) - }); - - match result { -@@ -234,7 +234,7 @@ pub extern "C" fn FFI_GroupSecretParams_decryptUuid( - unsafe { slice::from_raw_parts(uuidCiphertext, uuidCiphertextLen as usize) }; - let uuid: &mut [u8] = unsafe { slice::from_raw_parts_mut(uuidOut, uuidLen as usize) }; - -- simpleapi::GroupSecretParams_decryptUuid(group_secret_params, &uuid_ciphertext, uuid) -+ simpleapi::GroupSecretParams_decryptUuid(group_secret_params, uuid_ciphertext, uuid) - }); - - match result { -@@ -266,8 +266,8 @@ pub extern "C" fn FFI_GroupSecretParams_encryptProfileKey( - - simpleapi::GroupSecretParams_encryptProfileKey( - group_secret_params, -- &profile_key, -- &uuid, -+ profile_key, -+ uuid, - profile_key_ciphertext, - ) - }); -@@ -301,8 +301,8 @@ pub extern "C" fn FFI_GroupSecretParams_decryptProfileKey( - - simpleapi::GroupSecretParams_decryptProfileKey( - group_secret_params, -- &profile_key_ciphertext, -- &uuid, -+ profile_key_ciphertext, -+ uuid, - profile_key, - ) - }); -@@ -335,8 +335,8 @@ pub extern "C" fn FFI_GroupSecretParams_encryptBlobDeterministic( - - simpleapi::GroupSecretParams_encryptBlobDeterministic( - group_secret_params, -- &randomness, -- &plaintext, -+ randomness, -+ plaintext, - blob_ciphertext, - ) - }); -@@ -364,7 +364,7 @@ pub extern "C" fn FFI_GroupSecretParams_decryptBlob( - let plaintext: &mut [u8] = - unsafe { slice::from_raw_parts_mut(plaintextOut, plaintextLen as usize) }; - -- simpleapi::GroupSecretParams_decryptBlob(group_secret_params, &blob_ciphertext, plaintext) -+ simpleapi::GroupSecretParams_decryptBlob(group_secret_params, blob_ciphertext, plaintext) - }); - - match result { -@@ -387,7 +387,7 @@ pub extern "C" fn FFI_ServerSecretParams_generateDeterministic( - slice::from_raw_parts_mut(serverSecretParamsOut, serverSecretParamsLen as usize) - }; - -- simpleapi::ServerSecretParams_generateDeterministic(&randomness, server_secret_params) -+ simpleapi::ServerSecretParams_generateDeterministic(randomness, server_secret_params) - }); - - match result { -@@ -459,8 +459,8 @@ pub extern "C" fn FFI_ServerSecretParams_signDeterministic( - - simpleapi::ServerSecretParams_signDeterministic( - server_secret_params, -- &randomness, -- &message, -+ randomness, -+ message, - notary_signature, - ) - }); -@@ -496,9 +496,9 @@ pub extern "C" fn FFI_ServerPublicParams_receiveAuthCredential( - - simpleapi::ServerPublicParams_receiveAuthCredential( - server_public_params, -- &uuid, -+ uuid, - redemption_time, -- &auth_credential_response, -+ auth_credential_response, - auth_credential, - ) - }); -@@ -540,9 +540,9 @@ pub extern "C" fn FFI_ServerPublicParams_createAuthCredentialPresentationDetermi - - simpleapi::ServerPublicParams_createAuthCredentialPresentationDeterministic( - server_public_params, -- &randomness, -- &group_secret_params, -- &auth_credential, -+ randomness, -+ group_secret_params, -+ auth_credential, - auth_credential_presentation, - ) - }); -@@ -583,9 +583,9 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialRequestContex - - simpleapi::ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic( - server_public_params, -- &randomness, -- &uuid, -- &profile_key, -+ randomness, -+ uuid, -+ profile_key, - profile_key_credential_request_context, - ) - }); -@@ -628,8 +628,8 @@ pub extern "C" fn FFI_ServerPublicParams_receiveProfileKeyCredential( - - simpleapi::ServerPublicParams_receiveProfileKeyCredential( - server_public_params, -- &profile_key_credential_request_context, -- &profile_key_credential_response, -+ profile_key_credential_request_context, -+ profile_key_credential_response, - profile_key_credential, - ) - }); -@@ -672,9 +672,9 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialPresentationD - - simpleapi::ServerPublicParams_createProfileKeyCredentialPresentationDeterministic( - server_public_params, -- &randomness, -- &group_secret_params, -- &profile_key_credential, -+ randomness, -+ group_secret_params, -+ profile_key_credential, - profile_key_credential_presentation, - ) - }); -@@ -713,8 +713,8 @@ pub extern "C" fn FFI_ServerSecretParams_issueAuthCredentialDeterministic( - - simpleapi::ServerSecretParams_issueAuthCredentialDeterministic( - server_secret_params, -- &randomness, -- &uuid, -+ randomness, -+ uuid, - redemption_time, - auth_credential_response, - ) -@@ -749,8 +749,8 @@ pub extern "C" fn FFI_ServerSecretParams_verifyAuthCredentialPresentation( - - simpleapi::ServerSecretParams_verifyAuthCredentialPresentation( - server_secret_params, -- &group_public_params, -- &auth_credential_presentation, -+ group_public_params, -+ auth_credential_presentation, - ) - }); - -@@ -799,10 +799,10 @@ pub extern "C" fn FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic( - - simpleapi::ServerSecretParams_issueProfileKeyCredentialDeterministic( - server_secret_params, -- &randomness, -- &profile_key_credential_request, -- &uuid, -- &profile_key_commitment, -+ randomness, -+ profile_key_credential_request, -+ uuid, -+ profile_key_commitment, - profile_key_credential_response, - ) - }); -@@ -836,8 +836,8 @@ pub extern "C" fn FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation( - - simpleapi::ServerSecretParams_verifyProfileKeyCredentialPresentation( - server_secret_params, -- &group_public_params, -- &profile_key_credential_presentation, -+ group_public_params, -+ profile_key_credential_presentation, - ) - }); - -@@ -923,8 +923,8 @@ pub extern "C" fn FFI_ServerPublicParams_verifySignature( - - simpleapi::ServerPublicParams_verifySignature( - server_public_params, -- &message, -- ¬ary_signature, -+ message, -+ notary_signature, - ) - }); - From a7c780da050f81883acb7877984ed2429f3f64c3 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Sun, 19 Sep 2021 20:26:38 -0500 Subject: [PATCH 33/69] Allow using the credential system with only two components --- rust/src/crypto/credentials.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rust/src/crypto/credentials.rs b/rust/src/crypto/credentials.rs index 0469c9b..4ee3612 100644 --- a/rust/src/crypto/credentials.rs +++ b/rust/src/crypto/credentials.rs @@ -181,7 +181,7 @@ impl SystemParams { impl KeyPair { pub fn generate(sho: &mut Sho, num_attributes: usize) -> Self { - if !(3..=4).contains(&num_attributes) { + if !(2..=4).contains(&num_attributes) { panic!(); } @@ -201,8 +201,11 @@ impl KeyPair { - (x0 * system.G_x0) - (x1 * system.G_x1) - (y1 * system.G_y1) - - (y2 * system.G_y2) - - (y3 * system.G_y3); + - (y2 * system.G_y2); + + if num_attributes > 2 { + I -= y3 * system.G_y3; + } if num_attributes > 3 { I -= y4 * system.G_y4; From 8df184630d43511eb53770acc328003fcecca960 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 20 Sep 2021 14:27:23 -0500 Subject: [PATCH 34/69] Add support for zk proofs of receipts --- rust/src/api.rs | 1 + rust/src/api/auth/auth_credential.rs | 5 +- rust/src/api/receipts.rs | 18 ++ rust/src/api/receipts/receipt_credential.rs | 21 ++ .../receipt_credential_presentation.rs | 25 ++ .../receipts/receipt_credential_request.rs | 20 ++ .../receipt_credential_request_context.rs | 35 +++ .../receipts/receipt_credential_response.rs | 22 ++ rust/src/api/server_params.rs | 10 +- rust/src/common/constants.rs | 8 +- rust/src/common/simple_types.rs | 35 ++- rust/src/crypto.rs | 2 + rust/src/crypto/credentials.rs | 89 +++++- rust/src/crypto/proofs.rs | 255 +++++++++++++++++- rust/src/crypto/receipt_credential_request.rs | 92 +++++++ rust/src/crypto/receipt_struct.rs | 50 ++++ 16 files changed, 664 insertions(+), 24 deletions(-) create mode 100644 rust/src/api/receipts.rs create mode 100644 rust/src/api/receipts/receipt_credential.rs create mode 100644 rust/src/api/receipts/receipt_credential_presentation.rs create mode 100644 rust/src/api/receipts/receipt_credential_request.rs create mode 100644 rust/src/api/receipts/receipt_credential_request_context.rs create mode 100644 rust/src/api/receipts/receipt_credential_response.rs create mode 100644 rust/src/crypto/receipt_credential_request.rs create mode 100644 rust/src/crypto/receipt_struct.rs diff --git a/rust/src/api.rs b/rust/src/api.rs index 24f71f5..0a45625 100644 --- a/rust/src/api.rs +++ b/rust/src/api.rs @@ -8,6 +8,7 @@ pub mod auth; pub mod groups; pub mod profiles; +pub mod receipts; pub mod server_params; diff --git a/rust/src/api/auth/auth_credential.rs b/rust/src/api/auth/auth_credential.rs index 04d6de1..3f73d6e 100644 --- a/rust/src/api/auth/auth_credential.rs +++ b/rust/src/api/auth/auth_credential.rs @@ -7,16 +7,15 @@ #![allow(non_snake_case)] -use crate::api; +use serde::{Deserialize, Serialize}; + use crate::common::simple_types::*; use crate::crypto; -use serde::{Deserialize, Serialize}; #[derive(Copy, Clone, Serialize, Deserialize)] pub struct AuthCredential { pub(crate) reserved: ReservedBytes, pub(crate) credential: crypto::credentials::AuthCredential, - pub(crate) server_public_params: api::ServerPublicParams, pub(crate) uid: crypto::uid_struct::UidStruct, pub(crate) redemption_time: RedemptionTime, } diff --git a/rust/src/api/receipts.rs b/rust/src/api/receipts.rs new file mode 100644 index 0000000..2eb3a22 --- /dev/null +++ b/rust/src/api/receipts.rs @@ -0,0 +1,18 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +pub mod receipt_credential; +pub mod receipt_credential_presentation; +pub mod receipt_credential_request; +pub mod receipt_credential_request_context; +pub mod receipt_credential_response; + +pub use receipt_credential::ReceiptCredential; +pub use receipt_credential_presentation::ReceiptCredentialPresentation; +pub use receipt_credential_request::ReceiptCredentialRequest; +pub use receipt_credential_request_context::ReceiptCredentialRequestContext; +pub use receipt_credential_response::ReceiptCredentialResponse; diff --git a/rust/src/api/receipts/receipt_credential.rs b/rust/src/api/receipts/receipt_credential.rs new file mode 100644 index 0000000..64009a6 --- /dev/null +++ b/rust/src/api/receipts/receipt_credential.rs @@ -0,0 +1,21 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#![allow(non_snake_case)] + +use serde::{Deserialize, Serialize}; + +use crate::common::simple_types::*; +use crate::crypto; + +#[derive(Copy, Clone, Serialize, Deserialize)] +pub struct ReceiptCredential { + pub(crate) reserved: ReservedBytes, + pub(crate) credential: crypto::credentials::ReceiptCredential, + pub(crate) receipt_expiration_time: ReceiptExpirationTime, + pub(crate) receipt_level: ReceiptLevel, +} diff --git a/rust/src/api/receipts/receipt_credential_presentation.rs b/rust/src/api/receipts/receipt_credential_presentation.rs new file mode 100644 index 0000000..daad1d5 --- /dev/null +++ b/rust/src/api/receipts/receipt_credential_presentation.rs @@ -0,0 +1,25 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#![allow(non_snake_case)] + +use serde::{Deserialize, Serialize}; + +use crate::crypto; +use crate::ReceiptExpirationTime; +use crate::ReceiptLevel; +use crate::ReceiptSerialBytes; +use crate::ReservedBytes; + +#[derive(Serialize, Deserialize)] +pub struct ReceiptCredentialPresentation { + pub(crate) reserved: ReservedBytes, + pub(crate) proof: crypto::proofs::ReceiptCredentialPresentationProof, + pub(crate) receipt_expiration_time: ReceiptExpirationTime, + pub(crate) receipt_level: ReceiptLevel, + pub(crate) receipt_serial_bytes: ReceiptSerialBytes, +} diff --git a/rust/src/api/receipts/receipt_credential_request.rs b/rust/src/api/receipts/receipt_credential_request.rs new file mode 100644 index 0000000..a50d466 --- /dev/null +++ b/rust/src/api/receipts/receipt_credential_request.rs @@ -0,0 +1,20 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#![allow(non_snake_case)] + +use serde::{Deserialize, Serialize}; + +use crate::common::simple_types::*; +use crate::crypto; + +#[derive(Serialize, Deserialize)] +pub struct ReceiptCredentialRequest { + pub(crate) reserved: ReservedBytes, + pub(crate) public_key: crypto::receipt_credential_request::PublicKey, + pub(crate) ciphertext: crypto::receipt_credential_request::Ciphertext, +} diff --git a/rust/src/api/receipts/receipt_credential_request_context.rs b/rust/src/api/receipts/receipt_credential_request_context.rs new file mode 100644 index 0000000..a77e3ac --- /dev/null +++ b/rust/src/api/receipts/receipt_credential_request_context.rs @@ -0,0 +1,35 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#![allow(non_snake_case)] + +use serde::{Deserialize, Serialize}; + +use crate::api; +use crate::common::simple_types::*; +use crate::crypto; + +#[derive(Serialize, Deserialize)] +pub struct ReceiptCredentialRequestContext { + pub(crate) reserved: ReservedBytes, + pub(crate) receipt_serial_bytes: ReceiptSerialBytes, + pub(crate) key_pair: crypto::receipt_credential_request::KeyPair, + pub(crate) ciphertext_with_secret_nonce: + crypto::receipt_credential_request::CiphertextWithSecretNonce, +} + +impl ReceiptCredentialRequestContext { + pub fn get_request(&self) -> api::receipts::ReceiptCredentialRequest { + let ciphertext = self.ciphertext_with_secret_nonce.get_ciphertext(); + let public_key = self.key_pair.get_public_key(); + api::receipts::ReceiptCredentialRequest { + reserved: Default::default(), + public_key, + ciphertext, + } + } +} diff --git a/rust/src/api/receipts/receipt_credential_response.rs b/rust/src/api/receipts/receipt_credential_response.rs new file mode 100644 index 0000000..c73ef70 --- /dev/null +++ b/rust/src/api/receipts/receipt_credential_response.rs @@ -0,0 +1,22 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#![allow(non_snake_case)] + +use serde::{Deserialize, Serialize}; + +use crate::common::simple_types::*; +use crate::crypto; + +#[derive(Serialize, Deserialize)] +pub struct ReceiptCredentialResponse { + pub(crate) reserved: ReservedBytes, + pub(crate) receipt_expiration_time: ReceiptExpirationTime, + pub(crate) receipt_level: ReceiptLevel, + pub(crate) blinded_credential: crypto::credentials::BlindedReceiptCredential, + pub(crate) proof: crypto::proofs::ReceiptCredentialIssuanceProof, +} diff --git a/rust/src/api/server_params.rs b/rust/src/api/server_params.rs index 047aca6..1231894 100644 --- a/rust/src/api/server_params.rs +++ b/rust/src/api/server_params.rs @@ -7,13 +7,14 @@ #![allow(non_snake_case)] +use serde::{Deserialize, Serialize}; + use crate::api; use crate::common::constants::*; use crate::common::errors::*; use crate::common::sho::*; use crate::common::simple_types::*; use crate::crypto; -use serde::{Deserialize, Serialize}; #[derive(Copy, Clone, Serialize, Deserialize)] pub struct ServerSecretParams { @@ -21,6 +22,7 @@ pub struct ServerSecretParams { pub(crate) auth_credentials_key_pair: crypto::credentials::KeyPair, pub(crate) profile_key_credentials_key_pair: crypto::credentials::KeyPair, sig_key_pair: crypto::signature::KeyPair, + receipt_credentials_key_pair: crypto::credentials::KeyPair, } #[derive(Copy, Clone, Serialize, Deserialize)] @@ -29,6 +31,7 @@ pub struct ServerPublicParams { pub(crate) auth_credentials_public_key: crypto::credentials::PublicKey, pub(crate) profile_key_credentials_public_key: crypto::credentials::PublicKey, sig_public_key: crypto::signature::PublicKey, + receipt_credentials_public_key: crypto::credentials::PublicKey, } impl ServerSecretParams { @@ -43,12 +46,15 @@ impl ServerSecretParams { let profile_key_credentials_key_pair = crypto::credentials::KeyPair::generate(&mut sho, NUM_PROFILE_KEY_CRED_ATTRIBUTES); let sig_key_pair = crypto::signature::KeyPair::generate(&mut sho); + let receipt_credentials_key_pair = + crypto::credentials::KeyPair::generate(&mut sho, NUM_RECEIPT_CRED_ATTRIBUTES); Self { reserved: Default::default(), auth_credentials_key_pair, profile_key_credentials_key_pair, sig_key_pair, + receipt_credentials_key_pair, } } @@ -60,6 +66,7 @@ impl ServerSecretParams { .profile_key_credentials_key_pair .get_public_key(), sig_public_key: self.sig_key_pair.get_public_key(), + receipt_credentials_public_key: self.receipt_credentials_key_pair.get_public_key(), } } @@ -207,7 +214,6 @@ impl ServerPublicParams { Ok(api::auth::AuthCredential { reserved: Default::default(), credential: response.credential, - server_public_params: *self, uid, redemption_time, }) diff --git a/rust/src/common/constants.rs b/rust/src/common/constants.rs index cc2990c..d8d294b 100644 --- a/rust/src/common/constants.rs +++ b/rust/src/common/constants.rs @@ -9,6 +9,7 @@ pub const NUM_AUTH_CRED_ATTRIBUTES: usize = 3; pub const NUM_PROFILE_KEY_CRED_ATTRIBUTES: usize = 4; +pub const NUM_RECEIPT_CRED_ATTRIBUTES: usize = 2; pub const AES_KEY_LEN: usize = 32; pub const AESGCM_NONCE_LEN: usize = 12; @@ -17,7 +18,7 @@ pub const GROUP_MASTER_KEY_LEN: usize = 32; pub const GROUP_SECRET_PARAMS_LEN: usize = 289; pub const GROUP_PUBLIC_PARAMS_LEN: usize = 97; pub const GROUP_IDENTIFIER_LEN: usize = 32; -pub const AUTH_CREDENTIAL_LEN: usize = 342; +pub const AUTH_CREDENTIAL_LEN: usize = 181; pub const AUTH_CREDENTIAL_PRESENTATION_LEN: usize = 493; pub const AUTH_CREDENTIAL_RESPONSE_LEN: usize = 361; pub const PROFILE_KEY_LEN: usize = 32; @@ -30,9 +31,10 @@ pub const PROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN: usize = 473; pub const PROFILE_KEY_CREDENTIAL_RESPONSE_LEN: usize = 457; pub const PROFILE_KEY_VERSION_LEN: usize = 32; pub const PROFILE_KEY_VERSION_ENCODED_LEN: usize = 64; +pub const RECEIPT_SERIAL_LEN: usize = 16; pub const RESERVED_LEN: usize = 1; -pub const SERVER_SECRET_PARAMS_LEN: usize = 769; -pub const SERVER_PUBLIC_PARAMS_LEN: usize = 161; +pub const SERVER_SECRET_PARAMS_LEN: usize = 1121; +pub const SERVER_PUBLIC_PARAMS_LEN: usize = 225; pub const UUID_CIPHERTEXT_LEN: usize = 65; pub const RANDOMNESS_LEN: usize = 32; pub const SIGNATURE_LEN: usize = 64; diff --git a/rust/src/common/simple_types.rs b/rust/src/common/simple_types.rs index a2af34d..15258c0 100644 --- a/rust/src/common/simple_types.rs +++ b/rust/src/common/simple_types.rs @@ -21,17 +21,40 @@ pub type ProfileKeyVersionBytes = [u8; PROFILE_KEY_VERSION_LEN]; pub type ProfileKeyVersionEncodedBytes = [u8; PROFILE_KEY_VERSION_ENCODED_LEN]; pub type RedemptionTime = u32; +// A random UUID that the receipt issuing server will blind authorize to redeem a given receipt +// level within a certain time frame. +pub type ReceiptSerialBytes = [u8; RECEIPT_SERIAL_LEN]; + +// Seconds past the epoch; clients should only accept round multiples of 86400 within a couple of +// days into the future. +pub type ReceiptExpirationTime = u64; + +// Used to tell the server handling receipt redemptions what to redeem the receipt for. Clients +// should validate this matches their expectations. +pub type ReceiptLevel = u64; + pub fn encode_redemption_time(redemption_time: u32) -> Scalar { let mut scalar_bytes: [u8; 32] = Default::default(); scalar_bytes[0..4].copy_from_slice(&redemption_time.to_be_bytes()); Scalar::from_bytes_mod_order(scalar_bytes) } -#[test] -fn test_encode_scalar() { - let s_bytes = [0xFF; 32]; - match bincode::deserialize::(&s_bytes) { - Err(_) => (), - Ok(_) => unreachable!(), +pub fn encode_receipt_serial_bytes(receipt_serial_bytes: ReceiptSerialBytes) -> Scalar { + let mut scalar_bytes: [u8; 32] = Default::default(); + scalar_bytes[0..16].copy_from_slice(&receipt_serial_bytes[..]); + Scalar::from_bytes_mod_order(scalar_bytes) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_encode_scalar() { + let s_bytes = [0xFF; 32]; + match bincode::deserialize::(&s_bytes) { + Err(_) => (), + Ok(_) => unreachable!(), + } } } diff --git a/rust/src/crypto.rs b/rust/src/crypto.rs index 2154c18..c009821 100644 --- a/rust/src/crypto.rs +++ b/rust/src/crypto.rs @@ -11,6 +11,8 @@ pub mod profile_key_credential_request; pub mod profile_key_encryption; pub mod profile_key_struct; pub mod proofs; +pub mod receipt_credential_request; +pub mod receipt_struct; pub mod signature; pub mod uid_encryption; pub mod uid_struct; diff --git a/rust/src/crypto/credentials.rs b/rust/src/crypto/credentials.rs index 4ee3612..a2a86c6 100644 --- a/rust/src/crypto/credentials.rs +++ b/rust/src/crypto/credentials.rs @@ -7,15 +7,17 @@ #![allow(non_snake_case)] -use crate::common::sho::*; -use crate::common::simple_types::*; -use crate::crypto::profile_key_credential_request; -use crate::crypto::uid_struct; use curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT; use curve25519_dalek::ristretto::RistrettoPoint; use curve25519_dalek::scalar::Scalar; use serde::{Deserialize, Serialize}; +use crate::common::sho::*; +use crate::common::simple_types::*; +use crate::crypto::receipt_struct::ReceiptStruct; +use crate::crypto::uid_struct; +use crate::crypto::{profile_key_credential_request, receipt_credential_request, receipt_struct}; + #[derive(Copy, Clone, Default, PartialEq, Serialize, Deserialize)] pub struct SystemParams { pub(crate) G_w: RistrettoPoint, @@ -71,7 +73,6 @@ pub struct ProfileKeyCredential { pub(crate) U: RistrettoPoint, pub(crate) V: RistrettoPoint, } - #[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] pub struct BlindedProfileKeyCredentialWithSecretNonce { pub(crate) rprime: Scalar, @@ -89,6 +90,30 @@ pub struct BlindedProfileKeyCredential { pub(crate) S2: RistrettoPoint, } +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct ReceiptCredential { + pub(crate) t: Scalar, + pub(crate) U: RistrettoPoint, + pub(crate) V: RistrettoPoint, +} + +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct BlindedReceiptCredentialWithSecretNonce { + pub(crate) rprime: Scalar, + pub(crate) t: Scalar, + pub(crate) U: RistrettoPoint, + pub(crate) S1: RistrettoPoint, + pub(crate) S2: RistrettoPoint, +} + +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct BlindedReceiptCredential { + pub(crate) t: Scalar, + pub(crate) U: RistrettoPoint, + pub(crate) S1: RistrettoPoint, + pub(crate) S2: RistrettoPoint, +} + pub(crate) fn convert_to_points_uid_struct( uid: uid_struct::UidStruct, redemption_time: RedemptionTime, @@ -98,6 +123,15 @@ pub(crate) fn convert_to_points_uid_struct( vec![uid.M1, uid.M2, redemption_time_scalar * system.G_m3] } +pub(crate) fn convert_to_points_receipt_struct( + receipt: receipt_struct::ReceiptStruct, +) -> Vec { + let system = SystemParams::get_hardcoded(); + let m1 = receipt.calc_m1(); + let receipt_serial_scalar = encode_receipt_serial_bytes(receipt.receipt_serial_bytes); + vec![m1 * system.G_m1, receipt_serial_scalar * system.G_m2] +} + impl SystemParams { pub fn generate() -> Self { let mut sho = Sho::new( @@ -257,7 +291,9 @@ impl KeyPair { let mut V = self.W + (self.x0 + self.x1 * t) * U; V += self.y1 * M[0]; - V += self.y2 * M[1]; + if M.len() > 1 { + V += self.y2 * M[1]; + } if M.len() > 2 { V += self.y3 * M[2]; } @@ -290,6 +326,33 @@ impl KeyPair { S2, } } + + pub fn create_blinded_receipt_credential( + &self, + public_key: receipt_credential_request::PublicKey, + ciphertext: receipt_credential_request::Ciphertext, + receipt_expiration_time: ReceiptExpirationTime, + receipt_level: ReceiptLevel, + sho: &mut Sho, + ) -> BlindedReceiptCredentialWithSecretNonce { + let params = SystemParams::get_hardcoded(); + let m1 = ReceiptStruct::calc_m1_from(receipt_expiration_time, receipt_level); + let M = vec![m1 * params.G_m1]; + + let (t, U, Vprime) = self.credential_core(M, sho); + let rprime = sho.get_scalar(); + let R1 = rprime * RISTRETTO_BASEPOINT_POINT; + let R2 = rprime * public_key.Y + Vprime; + let S1 = self.y2 * ciphertext.D1 + R1; + let S2 = self.y2 * ciphertext.D2 + R2; + BlindedReceiptCredentialWithSecretNonce { + rprime, + t, + U, + S1, + S2, + } + } } impl BlindedProfileKeyCredentialWithSecretNonce { @@ -303,12 +366,24 @@ impl BlindedProfileKeyCredentialWithSecretNonce { } } +impl BlindedReceiptCredentialWithSecretNonce { + pub fn get_blinded_receipt_credential(&self) -> BlindedReceiptCredential { + BlindedReceiptCredential { + t: self.t, + U: self.U, + S1: self.S1, + S2: self.S2, + } + } +} + #[cfg(test)] mod tests { - use super::*; use crate::common::constants::*; use crate::crypto::proofs; + use super::*; + #[test] fn test_system() { let params = SystemParams::generate(); diff --git a/rust/src/crypto/proofs.rs b/rust/src/crypto/proofs.rs index 2a9ba6f..6d0e894 100644 --- a/rust/src/crypto/proofs.rs +++ b/rust/src/crypto/proofs.rs @@ -6,6 +6,10 @@ // #![allow(non_snake_case)] + +use curve25519_dalek::ristretto::RistrettoPoint; +use serde::{Deserialize, Serialize}; + use crate::common::constants::*; use crate::common::errors::ZkGroupError::*; use crate::common::errors::*; @@ -16,10 +20,10 @@ use crate::crypto::profile_key_commitment; use crate::crypto::profile_key_credential_request; use crate::crypto::profile_key_encryption; use crate::crypto::profile_key_struct; +use crate::crypto::receipt_credential_request; +use crate::crypto::receipt_struct::ReceiptStruct; use crate::crypto::uid_encryption; use crate::crypto::uid_struct; -use curve25519_dalek::ristretto::RistrettoPoint; -use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone)] pub struct AuthCredentialIssuanceProof { @@ -36,6 +40,11 @@ pub struct ProfileKeyCredentialIssuanceProof { poksho_proof: Vec, } +#[derive(Serialize, Deserialize, Clone)] +pub struct ReceiptCredentialIssuanceProof { + poksho_proof: Vec, +} + #[derive(Serialize, Deserialize, Clone)] pub struct AuthCredentialPresentationProof { C_x0: RistrettoPoint, @@ -60,6 +69,16 @@ pub struct ProfileKeyCredentialPresentationProof { poksho_proof: Vec, } +#[derive(Serialize, Deserialize, Clone)] +pub struct ReceiptCredentialPresentationProof { + C_x0: RistrettoPoint, + C_x1: RistrettoPoint, + C_y1: RistrettoPoint, + C_y2: RistrettoPoint, + C_V: RistrettoPoint, + poksho_proof: Vec, +} + impl AuthCredentialIssuanceProof { pub fn get_poksho_statement() -> poksho::Statement { let mut st = poksho::Statement::new(); @@ -284,7 +303,7 @@ impl ProfileKeyCredentialIssuanceProof { blinded_credential: credentials::BlindedProfileKeyCredentialWithSecretNonce, uid: uid_struct::UidStruct, sho: &mut Sho, - ) -> ProfileKeyCredentialIssuanceProof { + ) -> Self { let credentials_system = credentials::SystemParams::get_hardcoded(); let mut scalar_args = poksho::ScalarArgs::new(); @@ -373,6 +392,123 @@ impl ProfileKeyCredentialIssuanceProof { } } +impl ReceiptCredentialIssuanceProof { + pub fn get_poksho_statement() -> poksho::Statement { + let mut st = poksho::Statement::new(); + + st.add("C_W", &[("w", "G_w"), ("wprime", "G_wprime")]); + st.add( + "G_V-I", + &[ + ("x0", "G_x0"), + ("x1", "G_x1"), + ("y1", "G_y1"), + ("y2", "G_y2"), + ], + ); + st.add("S1", &[("y2", "D1"), ("rprime", "G")]); + st.add( + "S2", + &[ + ("y2", "D2"), + ("rprime", "Y"), + ("w", "G_w"), + ("x0", "U"), + ("x1", "tU"), + ("y1", "M1"), + ], + ); + st + } + + pub fn new( + key_pair: credentials::KeyPair, + request_public_key: receipt_credential_request::PublicKey, + request: receipt_credential_request::Ciphertext, + blinded_credential: credentials::BlindedReceiptCredentialWithSecretNonce, + receipt_expiration_time: ReceiptExpirationTime, + receipt_level: ReceiptLevel, + sho: &mut Sho, + ) -> Self { + let credentials_system = credentials::SystemParams::get_hardcoded(); + + let m1 = ReceiptStruct::calc_m1_from(receipt_expiration_time, receipt_level); + + let mut scalar_args = poksho::ScalarArgs::new(); + scalar_args.add("w", key_pair.w); + scalar_args.add("wprime", key_pair.wprime); + scalar_args.add("x0", key_pair.x0); + scalar_args.add("x1", key_pair.x1); + scalar_args.add("y1", key_pair.y1); + scalar_args.add("y2", key_pair.y2); + scalar_args.add("rprime", blinded_credential.rprime); + + let mut point_args = poksho::PointArgs::new(); + point_args.add("C_W", key_pair.C_W); + point_args.add("G_w", credentials_system.G_w); + point_args.add("G_wprime", credentials_system.G_wprime); + point_args.add("G_V-I", credentials_system.G_V - key_pair.I); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y2", credentials_system.G_y2); + point_args.add("S1", blinded_credential.S1); + point_args.add("D1", request.D1); + point_args.add("S2", blinded_credential.S2); + point_args.add("D2", request.D2); + point_args.add("Y", request_public_key.Y); + point_args.add("U", blinded_credential.U); + point_args.add("tU", blinded_credential.t * blinded_credential.U); + point_args.add("M1", m1 * credentials_system.G_m1); + + let poksho_proof = Self::get_poksho_statement() + .prove( + &scalar_args, + &point_args, + &[], + &sho.squeeze(RANDOMNESS_LEN)[..], + ) + .unwrap(); + Self { poksho_proof } + } + + pub fn verify( + &self, + credentials_public_key: credentials::PublicKey, + request_public_key: receipt_credential_request::PublicKey, + request: receipt_credential_request::Ciphertext, + blinded_credential: credentials::BlindedReceiptCredential, + receipt_struct: ReceiptStruct, + ) -> Result<(), ZkGroupError> { + let credentials_system = credentials::SystemParams::get_hardcoded(); + + let M = credentials::convert_to_points_receipt_struct(receipt_struct); + + let mut point_args = poksho::PointArgs::new(); + point_args.add("C_W", credentials_public_key.C_W); + point_args.add("G_w", credentials_system.G_w); + point_args.add("G_wprime", credentials_system.G_wprime); + point_args.add("G_V-I", credentials_system.G_V - credentials_public_key.I); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y2", credentials_system.G_y2); + point_args.add("S1", blinded_credential.S1); + point_args.add("D1", request.D1); + point_args.add("S2", blinded_credential.S2); + point_args.add("D2", request.D2); + point_args.add("Y", request_public_key.Y); + point_args.add("U", blinded_credential.U); + point_args.add("tU", blinded_credential.t * blinded_credential.U); + point_args.add("M1", M[0]); + + match Self::get_poksho_statement().verify_proof(&self.poksho_proof, &point_args, &[]) { + Err(_) => Err(ProofVerificationFailure), + Ok(_) => Ok(()), + } + } +} + impl AuthCredentialPresentationProof { pub fn get_poksho_statement() -> poksho::Statement { let mut st = poksho::Statement::new(); @@ -729,3 +865,116 @@ impl ProfileKeyCredentialPresentationProof { } } } + +impl ReceiptCredentialPresentationProof { + pub fn get_poksho_statement() -> poksho::Statement { + let mut st = poksho::Statement::new(); + + st.add("Z", &[("z", "I")]); + st.add("C_x1", &[("t", "C_x0"), ("-zt", "G_x0"), ("z", "G_x1")]); + st.add("C_y1", &[("z", "G_y1")]); + st.add("C_y2", &[("z", "G_y2")]); + st + } + + pub fn new( + credentials_public_key: credentials::PublicKey, + credential: credentials::ReceiptCredential, + sho: &mut Sho, + ) -> Self { + let credentials_system = credentials::SystemParams::get_hardcoded(); + + let z = sho.get_scalar(); + + let C_y1 = z * credentials_system.G_y1; + let C_y2 = z * credentials_system.G_y2; + + let I = credentials_public_key.I; + let Z = z * I; + let C_x0 = z * credentials_system.G_x0 + credential.U; + let C_x1 = z * credentials_system.G_x1 + credential.t * credential.U; + let C_V = z * credentials_system.G_V + credential.V; + + // Scalars listed in order of stmts for debugging + let mut scalar_args = poksho::ScalarArgs::new(); + scalar_args.add("z", z); + scalar_args.add("t", credential.t); + scalar_args.add("-zt", -z * credential.t); + + // Points listed in order of stmts for debugging + let mut point_args = poksho::PointArgs::new(); + point_args.add("Z", Z); + point_args.add("I", I); + point_args.add("C_x0", C_x0); + point_args.add("C_x1", C_x1); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y2", credentials_system.G_y2); + + let poksho_proof = Self::get_poksho_statement() + .prove( + &scalar_args, + &point_args, + &[], + &sho.squeeze(RANDOMNESS_LEN)[..], + ) + .unwrap(); + + Self { + C_x0, + C_x1, + C_y1, + C_y2, + C_V, + poksho_proof, + } + } + + pub fn verify( + &self, + credentials_key_pair: credentials::KeyPair, + receipt_struct: ReceiptStruct, + ) -> Result<(), ZkGroupError> { + let credentials_system = credentials::SystemParams::get_hardcoded(); + let M = credentials::convert_to_points_receipt_struct(receipt_struct); + + let Self { + C_x0, + C_x1, + C_y1, + C_y2, + C_V, + poksho_proof, + } = self; + let (C_x0, C_x1, C_y1, C_y2, C_V) = (*C_x0, *C_x1, *C_y1, *C_y2, *C_V); + + let credentials::KeyPair { + W, + x0, + x1, + y1, + y2, + I, + .. + } = credentials_key_pair; + + let Z = C_V - W - x0 * C_x0 - x1 * C_x1 - y1 * (C_y1 + M[0]) - y2 * (C_y2 + M[1]); + + // Points listed in order of stmts for debugging + let mut point_args = poksho::PointArgs::new(); + point_args.add("Z", Z); + point_args.add("I", I); + point_args.add("C_x0", C_x0); + point_args.add("C_x1", C_x1); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y2", credentials_system.G_y2); + + match Self::get_poksho_statement().verify_proof(poksho_proof, &point_args, &[]) { + Err(_) => Err(ZkGroupError::ProofVerificationFailure), + Ok(_) => Ok(()), + } + } +} diff --git a/rust/src/crypto/receipt_credential_request.rs b/rust/src/crypto/receipt_credential_request.rs new file mode 100644 index 0000000..bfad7fa --- /dev/null +++ b/rust/src/crypto/receipt_credential_request.rs @@ -0,0 +1,92 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#![allow(non_snake_case)] + +use curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT; +use curve25519_dalek::ristretto::RistrettoPoint; +use curve25519_dalek::scalar::Scalar; +use serde::{Deserialize, Serialize}; + +use crate::common::sho::Sho; +use crate::crypto::credentials; +use crate::crypto::credentials::BlindedReceiptCredential; +use crate::crypto::credentials::ReceiptCredential; +use crate::crypto::receipt_struct::ReceiptStruct; + +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct KeyPair { + // private + pub(crate) y: Scalar, + + // public + pub(crate) Y: RistrettoPoint, +} + +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct PublicKey { + pub(crate) Y: RistrettoPoint, +} + +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct CiphertextWithSecretNonce { + pub(crate) r1: Scalar, + pub(crate) D1: RistrettoPoint, + pub(crate) D2: RistrettoPoint, +} + +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct Ciphertext { + pub(crate) D1: RistrettoPoint, + pub(crate) D2: RistrettoPoint, +} + +impl KeyPair { + pub fn generate(sho: &mut Sho) -> Self { + let y = sho.get_scalar(); + let Y = y * RISTRETTO_BASEPOINT_POINT; + KeyPair { y, Y } + } + + pub fn get_public_key(&self) -> PublicKey { + PublicKey { Y: self.Y } + } + + pub fn encrypt( + &self, + receipt_struct: ReceiptStruct, + sho: &mut Sho, + ) -> CiphertextWithSecretNonce { + let M = credentials::convert_to_points_receipt_struct(receipt_struct); + let r1 = sho.get_scalar(); + let D1 = r1 * RISTRETTO_BASEPOINT_POINT; + let D2 = r1 * (self.Y) + M[1]; + + CiphertextWithSecretNonce { r1, D1, D2 } + } + + pub fn decrypt_blinded_receipt_credential( + &self, + blinded_receipt_credential: BlindedReceiptCredential, + ) -> ReceiptCredential { + let V = blinded_receipt_credential.S2 - self.y * blinded_receipt_credential.S1; + ReceiptCredential { + t: blinded_receipt_credential.t, + U: blinded_receipt_credential.U, + V, + } + } +} + +impl CiphertextWithSecretNonce { + pub fn get_ciphertext(&self) -> Ciphertext { + Ciphertext { + D1: self.D1, + D2: self.D2, + } + } +} diff --git a/rust/src/crypto/receipt_struct.rs b/rust/src/crypto/receipt_struct.rs new file mode 100644 index 0000000..8fe1917 --- /dev/null +++ b/rust/src/crypto/receipt_struct.rs @@ -0,0 +1,50 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +#![allow(non_snake_case)] + +use curve25519_dalek::scalar::Scalar; +use serde::{Deserialize, Serialize}; + +use crate::common::sho::Sho; +use crate::common::simple_types::ReceiptExpirationTime; +use crate::common::simple_types::ReceiptLevel; +use crate::common::simple_types::ReceiptSerialBytes; + +/// The full set of information known by the client after receiving the credential response from +/// the issuing server. It will all be shared with the credential presentation. Initially the +/// client only knows the receipt_serial_bytes which is randomly generated. receipt_serial_bytes +/// should never be shared with the issuing service in unencrypted form. +/// +/// Clients must do validation on the returned receipt_expiration_time and receipt_level to ensure +/// no tagging has occurred. +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct ReceiptStruct { + pub(crate) receipt_serial_bytes: ReceiptSerialBytes, + pub(crate) receipt_expiration_time: ReceiptExpirationTime, + pub(crate) receipt_level: ReceiptLevel, +} + +impl ReceiptStruct { + pub fn calc_m1(&self) -> Scalar { + Self::calc_m1_from(self.receipt_expiration_time, self.receipt_level) + } + + pub fn calc_m1_from( + receipt_expiration_time: ReceiptExpirationTime, + receipt_level: ReceiptLevel, + ) -> Scalar { + let mut bytes = [0u8; std::mem::size_of::() + + std::mem::size_of::()]; + bytes[..std::mem::size_of::()] + .copy_from_slice(&receipt_expiration_time.to_be_bytes()); + bytes[std::mem::size_of::()..] + .copy_from_slice(&receipt_level.to_be_bytes()); + let mut sho = Sho::new(b"Signal_ZKGroup_20210919_Receipt_CalcM1", &bytes); + sho.get_scalar() + } +} From f57a31adbacb0c7aa181b982401dd80b2530475b Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 20 Sep 2021 14:29:07 -0500 Subject: [PATCH 35/69] Bump version strings to 0.8.0 to prepare for incompatible change --- Cargo.lock | 2 +- ZKGroup.podspec | 2 +- deploy.gradle | 2 +- ffi/node/package-lock.json | 2 +- ffi/node/package.json | 2 +- rust/Cargo.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6d25e6..4ce2fe5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1007,7 +1007,7 @@ checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" [[package]] name = "zkgroup" -version = "0.7.4" +version = "0.8.0" dependencies = [ "aead", "aes-gcm-siv", diff --git a/ZKGroup.podspec b/ZKGroup.podspec index b30fef5..15b0d58 100644 --- a/ZKGroup.podspec +++ b/ZKGroup.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "ZKGroup" - s.version = "0.7.4" + s.version = "0.8.0" s.summary = "Swift API for the Rust zkgroup crate." s.homepage = "https://signal.org/" s.license = { :type => "GPLv3", :file => "LICENSE" } diff --git a/deploy.gradle b/deploy.gradle index 29ea0f0..47f48ed 100644 --- a/deploy.gradle +++ b/deploy.gradle @@ -1,7 +1,7 @@ apply plugin: 'maven' apply plugin: 'signing' -version = '0.7.4' +version = '0.8.0' group = 'org.signal' def isReleaseBuild() { diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index eab516a..38afb8e 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.7.4", + "version": "0.8.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/ffi/node/package.json b/ffi/node/package.json index 8110db4..7388beb 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.7.4", + "version": "0.8.0", "description": "zero-knowledge group functionality", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 2ca00d2..da60260 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "zkgroup" -version = "0.7.4" +version = "0.8.0" authors = ["Trevor Perrin "] edition = "2018" description = "A zero-knowledge group library" From 0fbdb9f7638ff910209a334c0923d77343bf66c4 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 10:35:34 -0500 Subject: [PATCH 36/69] Fix error in copyright header for new file --- rust/src/api/receipts/receipt_credential_request_context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/api/receipts/receipt_credential_request_context.rs b/rust/src/api/receipts/receipt_credential_request_context.rs index a77e3ac..d3ff1b8 100644 --- a/rust/src/api/receipts/receipt_credential_request_context.rs +++ b/rust/src/api/receipts/receipt_credential_request_context.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2020 Signal Messenger, LLC. +// Copyright (C) 2021 Signal Messenger, LLC. // All rights reserved. // // SPDX-License-Identifier: GPL-3.0-only From 884de80d060728cd7c06148c6d24e708287855d4 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 11:44:22 -0500 Subject: [PATCH 37/69] write integration test and get it passing --- rust/src/crypto/credentials.rs | 8 ++ rust/src/crypto/proofs.rs | 4 + rust/src/crypto/receipt_credential_request.rs | 8 +- rust/src/crypto/receipt_struct.rs | 12 +++ rust/tests/receipt_flow.rs | 80 +++++++++++++++++++ 5 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 rust/tests/receipt_flow.rs diff --git a/rust/src/crypto/credentials.rs b/rust/src/crypto/credentials.rs index a2a86c6..68a2822 100644 --- a/rust/src/crypto/credentials.rs +++ b/rust/src/crypto/credentials.rs @@ -132,6 +132,14 @@ pub(crate) fn convert_to_points_receipt_struct( vec![m1 * system.G_m1, receipt_serial_scalar * system.G_m2] } +pub(crate) fn convert_to_point_M2_receipt_serial_bytes( + receipt_serial_bytes: ReceiptSerialBytes, +) -> RistrettoPoint { + let system = SystemParams::get_hardcoded(); + let receipt_serial_scalar = encode_receipt_serial_bytes(receipt_serial_bytes); + receipt_serial_scalar * system.G_m2 +} + impl SystemParams { pub fn generate() -> Self { let mut sho = Sho::new( diff --git a/rust/src/crypto/proofs.rs b/rust/src/crypto/proofs.rs index 6d0e894..eba84fa 100644 --- a/rust/src/crypto/proofs.rs +++ b/rust/src/crypto/proofs.rs @@ -907,6 +907,8 @@ impl ReceiptCredentialPresentationProof { point_args.add("I", I); point_args.add("C_x0", C_x0); point_args.add("C_x1", C_x1); + point_args.add("C_y1", z * credentials_system.G_y1); + point_args.add("C_y2", z * credentials_system.G_y2); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); point_args.add("G_y1", credentials_system.G_y1); @@ -967,6 +969,8 @@ impl ReceiptCredentialPresentationProof { point_args.add("I", I); point_args.add("C_x0", C_x0); point_args.add("C_x1", C_x1); + point_args.add("C_y1", C_y1); + point_args.add("C_y2", C_y2); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); point_args.add("G_y1", credentials_system.G_y1); diff --git a/rust/src/crypto/receipt_credential_request.rs b/rust/src/crypto/receipt_credential_request.rs index bfad7fa..2ee3be5 100644 --- a/rust/src/crypto/receipt_credential_request.rs +++ b/rust/src/crypto/receipt_credential_request.rs @@ -16,7 +16,7 @@ use crate::common::sho::Sho; use crate::crypto::credentials; use crate::crypto::credentials::BlindedReceiptCredential; use crate::crypto::credentials::ReceiptCredential; -use crate::crypto::receipt_struct::ReceiptStruct; +use crate::ReceiptSerialBytes; #[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] pub struct KeyPair { @@ -58,13 +58,13 @@ impl KeyPair { pub fn encrypt( &self, - receipt_struct: ReceiptStruct, + receipt_serial_bytes: ReceiptSerialBytes, sho: &mut Sho, ) -> CiphertextWithSecretNonce { - let M = credentials::convert_to_points_receipt_struct(receipt_struct); + let M2 = credentials::convert_to_point_M2_receipt_serial_bytes(receipt_serial_bytes); let r1 = sho.get_scalar(); let D1 = r1 * RISTRETTO_BASEPOINT_POINT; - let D2 = r1 * (self.Y) + M[1]; + let D2 = r1 * (self.Y) + M2; CiphertextWithSecretNonce { r1, D1, D2 } } diff --git a/rust/src/crypto/receipt_struct.rs b/rust/src/crypto/receipt_struct.rs index 8fe1917..5e03fa9 100644 --- a/rust/src/crypto/receipt_struct.rs +++ b/rust/src/crypto/receipt_struct.rs @@ -30,6 +30,18 @@ pub struct ReceiptStruct { } impl ReceiptStruct { + pub fn new( + receipt_serial_bytes: ReceiptSerialBytes, + receipt_expiration_time: ReceiptExpirationTime, + receipt_level: ReceiptLevel, + ) -> Self { + Self { + receipt_serial_bytes, + receipt_expiration_time, + receipt_level, + } + } + pub fn calc_m1(&self) -> Scalar { Self::calc_m1_from(self.receipt_expiration_time, self.receipt_level) } diff --git a/rust/tests/receipt_flow.rs b/rust/tests/receipt_flow.rs new file mode 100644 index 0000000..a80e78b --- /dev/null +++ b/rust/tests/receipt_flow.rs @@ -0,0 +1,80 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +use zkgroup::common::sho::Sho; +use zkgroup::crypto::credentials; +use zkgroup::crypto::proofs::{ReceiptCredentialIssuanceProof, ReceiptCredentialPresentationProof}; +use zkgroup::crypto::receipt_credential_request; +use zkgroup::crypto::receipt_struct::ReceiptStruct; +use zkgroup::{ReceiptExpirationTime, ReceiptLevel, NUM_RECEIPT_CRED_ATTRIBUTES}; + +#[test] +fn test_request_response() { + let mut sho = Sho::new(b"Test_Receipt_Credential_Request", b""); + + // client receives in response to initial request + let receipt_expiration_time: ReceiptExpirationTime = 42; + let receipt_level: ReceiptLevel = 3; + + // known to client and redemption server + let receipt_serial_bytes = [ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, + 0x0f, + ]; + + // client generated materials; issuance request + let client_key_pair = receipt_credential_request::KeyPair::generate(&mut sho); + let client_ciphertext = client_key_pair.encrypt(receipt_serial_bytes, &mut sho); + let given_to_server_ciphertext = client_ciphertext.get_ciphertext(); + let given_to_server_public_key = client_key_pair.get_public_key(); + + // server generated materials; issuance request -> issuance response + let server_key_pair = credentials::KeyPair::generate(&mut sho, NUM_RECEIPT_CRED_ATTRIBUTES); + let blinded_receipt_credential = server_key_pair.create_blinded_receipt_credential( + given_to_server_public_key, + given_to_server_ciphertext, + receipt_expiration_time, + receipt_level, + &mut sho, + ); + let given_to_client_blinded_receipt_credential = + blinded_receipt_credential.get_blinded_receipt_credential(); + let given_to_client_receipt_credential_issuance_proof = ReceiptCredentialIssuanceProof::new( + server_key_pair, + given_to_server_public_key, + given_to_server_ciphertext, + blinded_receipt_credential, + receipt_expiration_time, + receipt_level, + &mut sho, + ); + + // client generated materials; issuance response -> redemption request + let receipt_struct = + ReceiptStruct::new(receipt_serial_bytes, receipt_expiration_time, receipt_level); + given_to_client_receipt_credential_issuance_proof + .verify( + server_key_pair.get_public_key(), + given_to_server_public_key, + given_to_server_ciphertext, + given_to_client_blinded_receipt_credential, + receipt_struct, + ) + .expect("issuance proof validity check failed"); + let receipt_credential = client_key_pair + .decrypt_blinded_receipt_credential(given_to_client_blinded_receipt_credential); + let receipt_credential_presentation_proof = ReceiptCredentialPresentationProof::new( + server_key_pair.get_public_key(), + receipt_credential, + &mut sho, + ); + + // server verification of the credential presentation + receipt_credential_presentation_proof + .verify(server_key_pair, receipt_struct) + .expect("presentation proof validity check failed"); +} From 1819bd23699626a46be44cbff8ee26b6bf953daf Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 11:46:29 -0500 Subject: [PATCH 38/69] Don't compute C_y1 and C_y2 twice --- rust/src/crypto/proofs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/src/crypto/proofs.rs b/rust/src/crypto/proofs.rs index eba84fa..d1e6f6e 100644 --- a/rust/src/crypto/proofs.rs +++ b/rust/src/crypto/proofs.rs @@ -907,8 +907,8 @@ impl ReceiptCredentialPresentationProof { point_args.add("I", I); point_args.add("C_x0", C_x0); point_args.add("C_x1", C_x1); - point_args.add("C_y1", z * credentials_system.G_y1); - point_args.add("C_y2", z * credentials_system.G_y2); + point_args.add("C_y1", C_y1); + point_args.add("C_y2", C_y2); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); point_args.add("G_y1", credentials_system.G_y1); From d73c1425453e9eb58d3248107795194e21421dcc Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 16:28:49 -0500 Subject: [PATCH 39/69] Add the server params apis --- rust/src/api/receipts/receipt_credential.rs | 1 + .../receipt_credential_presentation.rs | 11 ++ rust/src/api/server_params.rs | 125 ++++++++++++++++++ rust/tests/receipt_flow.rs | 45 ++++++- 4 files changed, 181 insertions(+), 1 deletion(-) diff --git a/rust/src/api/receipts/receipt_credential.rs b/rust/src/api/receipts/receipt_credential.rs index 64009a6..d5e7da8 100644 --- a/rust/src/api/receipts/receipt_credential.rs +++ b/rust/src/api/receipts/receipt_credential.rs @@ -18,4 +18,5 @@ pub struct ReceiptCredential { pub(crate) credential: crypto::credentials::ReceiptCredential, pub(crate) receipt_expiration_time: ReceiptExpirationTime, pub(crate) receipt_level: ReceiptLevel, + pub(crate) receipt_serial_bytes: ReceiptSerialBytes, } diff --git a/rust/src/api/receipts/receipt_credential_presentation.rs b/rust/src/api/receipts/receipt_credential_presentation.rs index daad1d5..f48bbee 100644 --- a/rust/src/api/receipts/receipt_credential_presentation.rs +++ b/rust/src/api/receipts/receipt_credential_presentation.rs @@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize}; use crate::crypto; +use crate::crypto::receipt_struct::ReceiptStruct; use crate::ReceiptExpirationTime; use crate::ReceiptLevel; use crate::ReceiptSerialBytes; @@ -23,3 +24,13 @@ pub struct ReceiptCredentialPresentation { pub(crate) receipt_level: ReceiptLevel, pub(crate) receipt_serial_bytes: ReceiptSerialBytes, } + +impl ReceiptCredentialPresentation { + pub fn get_receipt_struct(&self) -> ReceiptStruct { + ReceiptStruct { + receipt_serial_bytes: self.receipt_serial_bytes, + receipt_expiration_time: self.receipt_expiration_time, + receipt_level: self.receipt_level, + } + } +} diff --git a/rust/src/api/server_params.rs b/rust/src/api/server_params.rs index 1231894..10f76fc 100644 --- a/rust/src/api/server_params.rs +++ b/rust/src/api/server_params.rs @@ -186,6 +186,58 @@ impl ServerSecretParams { proof, }) } + + pub fn issue_receipt_credential( + &self, + randomness: RandomnessBytes, + request: &api::receipts::ReceiptCredentialRequest, + receipt_expiration_time: ReceiptExpirationTime, + receipt_level: ReceiptLevel, + ) -> api::receipts::ReceiptCredentialResponse { + let mut sho = Sho::new( + b"Signal_ZKGroup_20210919_Random_ServerSecretParams_IssueReceiptCredential", + &randomness, + ); + + let blinded_credential_with_secret_nonce = self + .receipt_credentials_key_pair + .create_blinded_receipt_credential( + request.public_key, + request.ciphertext, + receipt_expiration_time, + receipt_level, + &mut sho, + ); + + let proof = crypto::proofs::ReceiptCredentialIssuanceProof::new( + self.receipt_credentials_key_pair, + request.public_key, + request.ciphertext, + blinded_credential_with_secret_nonce, + receipt_expiration_time, + receipt_level, + &mut sho, + ); + + api::receipts::ReceiptCredentialResponse { + reserved: Default::default(), + receipt_expiration_time, + receipt_level, + blinded_credential: blinded_credential_with_secret_nonce + .get_blinded_receipt_credential(), + proof, + } + } + + pub fn verify_receipt_credential_presentation( + &self, + presentation: &api::receipts::ReceiptCredentialPresentation, + ) -> Result<(), ZkGroupError> { + presentation.proof.verify( + self.receipt_credentials_key_pair, + presentation.get_receipt_struct(), + ) + } } impl ServerPublicParams { @@ -354,4 +406,77 @@ impl ServerPublicParams { profile_key_enc_ciphertext: profile_key_ciphertext.ciphertext, } } + + pub fn create_receipt_credential_request_context( + &self, + randomness: RandomnessBytes, + receipt_serial_bytes: ReceiptSerialBytes, + ) -> api::receipts::ReceiptCredentialRequestContext { + let mut sho = Sho::new( + b"Signal_ZKGroup_20210919_Random_ServerPublicParams_CreateReceiptCredentialRequestContext", + &randomness, + ); + + let key_pair = crypto::receipt_credential_request::KeyPair::generate(&mut sho); + let ciphertext_with_secret_nonce = key_pair.encrypt(receipt_serial_bytes, &mut sho); + + api::receipts::ReceiptCredentialRequestContext { + reserved: Default::default(), + receipt_serial_bytes, + key_pair, + ciphertext_with_secret_nonce, + } + } + + pub fn receive_receipt_credential( + &self, + context: &api::receipts::ReceiptCredentialRequestContext, + response: &api::receipts::ReceiptCredentialResponse, + ) -> Result { + let receipt_struct = crypto::receipt_struct::ReceiptStruct::new( + context.receipt_serial_bytes, + response.receipt_expiration_time, + response.receipt_level, + ); + response.proof.verify( + self.receipt_credentials_public_key, + context.key_pair.get_public_key(), + context.ciphertext_with_secret_nonce.get_ciphertext(), + response.blinded_credential, + receipt_struct, + )?; + let credential = context + .key_pair + .decrypt_blinded_receipt_credential(response.blinded_credential); + Ok(api::receipts::ReceiptCredential { + reserved: Default::default(), + credential, + receipt_expiration_time: response.receipt_expiration_time, + receipt_level: response.receipt_level, + receipt_serial_bytes: context.receipt_serial_bytes, + }) + } + + pub fn create_receipt_credential_presentation( + &self, + randomness: RandomnessBytes, + receipt_credential: &api::receipts::ReceiptCredential, + ) -> api::receipts::ReceiptCredentialPresentation { + let mut sho = Sho::new( + b"Signal_ZKGroup_20210919_Random_ServerPublicParams_CreateReceiptCredentialPresentation", + &randomness, + ); + let proof = crypto::proofs::ReceiptCredentialPresentationProof::new( + self.receipt_credentials_public_key, + receipt_credential.credential, + &mut sho, + ); + api::receipts::ReceiptCredentialPresentation { + reserved: Default::default(), + proof, + receipt_expiration_time: receipt_credential.receipt_expiration_time, + receipt_level: receipt_credential.receipt_level, + receipt_serial_bytes: receipt_credential.receipt_serial_bytes, + } + } } diff --git a/rust/tests/receipt_flow.rs b/rust/tests/receipt_flow.rs index a80e78b..8339603 100644 --- a/rust/tests/receipt_flow.rs +++ b/rust/tests/receipt_flow.rs @@ -10,7 +10,10 @@ use zkgroup::crypto::credentials; use zkgroup::crypto::proofs::{ReceiptCredentialIssuanceProof, ReceiptCredentialPresentationProof}; use zkgroup::crypto::receipt_credential_request; use zkgroup::crypto::receipt_struct::ReceiptStruct; -use zkgroup::{ReceiptExpirationTime, ReceiptLevel, NUM_RECEIPT_CRED_ATTRIBUTES}; +use zkgroup::{ + RandomnessBytes, ReceiptExpirationTime, ReceiptLevel, ReceiptSerialBytes, ServerSecretParams, + NUM_RECEIPT_CRED_ATTRIBUTES, RANDOMNESS_LEN, RECEIPT_SERIAL_LEN, +}; #[test] fn test_request_response() { @@ -78,3 +81,43 @@ fn test_request_response() { .verify(server_key_pair, receipt_struct) .expect("presentation proof validity check failed"); } + +/// Same as test_request_response but using the server params API. +#[test] +fn test_api() { + let randomness0: RandomnessBytes = [0x42u8; RANDOMNESS_LEN]; + let randomness1: RandomnessBytes = [0x43u8; RANDOMNESS_LEN]; + let randomness2: RandomnessBytes = [0x44u8; RANDOMNESS_LEN]; + let randomness3: RandomnessBytes = [0x45u8; RANDOMNESS_LEN]; + let receipt_serial_bytes: ReceiptSerialBytes = [0x84u8; RECEIPT_SERIAL_LEN]; + let mut sho = Sho::new(b"Test_Receipt_Credential_API", b""); + let server_secret_params = ServerSecretParams::generate(randomness0); + let server_public_params = server_secret_params.get_public_params(); + + // client + let context = server_public_params + .create_receipt_credential_request_context(randomness1, receipt_serial_bytes); + let request = context.get_request(); + + // issuance server + let receipt_expiration_time: ReceiptExpirationTime = 31337; + let receipt_level: ReceiptLevel = 3; + let response = server_secret_params.issue_receipt_credential( + randomness2, + &request, + receipt_expiration_time, + receipt_level, + ); + + // client + let credential = server_public_params + .receive_receipt_credential(&context, &response) + .expect("Invalid Receipt Credential Issuance"); + let presentation = + server_public_params.create_receipt_credential_presentation(randomness3, &credential); + + // redemption server + server_secret_params + .verify_receipt_credential_presentation(&presentation) + .expect("Invalid Receipt Credential Presentation"); +} From 3534241a6085a3bf9a92c5e4220a4dd3ae82f8d4 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 16:59:51 -0500 Subject: [PATCH 40/69] Add tests for length of receipt api structures --- rust/src/common/constants.rs | 6 ++++++ rust/tests/receipt_flow.rs | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/rust/src/common/constants.rs b/rust/src/common/constants.rs index d8d294b..a31ab72 100644 --- a/rust/src/common/constants.rs +++ b/rust/src/common/constants.rs @@ -11,6 +11,7 @@ pub const NUM_AUTH_CRED_ATTRIBUTES: usize = 3; pub const NUM_PROFILE_KEY_CRED_ATTRIBUTES: usize = 4; pub const NUM_RECEIPT_CRED_ATTRIBUTES: usize = 2; +// NOTE: When any of these values change, codegen.py must also be updated. pub const AES_KEY_LEN: usize = 32; pub const AESGCM_NONCE_LEN: usize = 12; pub const AESGCM_TAG_LEN: usize = 16; @@ -31,6 +32,11 @@ pub const PROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN: usize = 473; pub const PROFILE_KEY_CREDENTIAL_RESPONSE_LEN: usize = 457; pub const PROFILE_KEY_VERSION_LEN: usize = 32; pub const PROFILE_KEY_VERSION_ENCODED_LEN: usize = 64; +pub const RECEIPT_CREDENTIAL_LEN: usize = 129; +pub const RECEIPT_CREDENTIAL_PRESENTATION_LEN: usize = 329; +pub const RECEIPT_CREDENTIAL_REQUEST_LEN: usize = 97; +pub const RECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN: usize = 177; +pub const RECEIPT_CREDENTIAL_RESPONSE_LEN: usize = 409; pub const RECEIPT_SERIAL_LEN: usize = 16; pub const RESERVED_LEN: usize = 1; pub const SERVER_SECRET_PARAMS_LEN: usize = 1121; diff --git a/rust/tests/receipt_flow.rs b/rust/tests/receipt_flow.rs index 8339603..8b3faa6 100644 --- a/rust/tests/receipt_flow.rs +++ b/rust/tests/receipt_flow.rs @@ -90,7 +90,6 @@ fn test_api() { let randomness2: RandomnessBytes = [0x44u8; RANDOMNESS_LEN]; let randomness3: RandomnessBytes = [0x45u8; RANDOMNESS_LEN]; let receipt_serial_bytes: ReceiptSerialBytes = [0x84u8; RECEIPT_SERIAL_LEN]; - let mut sho = Sho::new(b"Test_Receipt_Credential_API", b""); let server_secret_params = ServerSecretParams::generate(randomness0); let server_public_params = server_secret_params.get_public_params(); @@ -120,4 +119,25 @@ fn test_api() { server_secret_params .verify_receipt_credential_presentation(&presentation) .expect("Invalid Receipt Credential Presentation"); + + assert_eq!( + zkgroup::common::constants::RECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN, + bincode::serialize(&context).unwrap().len(), + ); + assert_eq!( + zkgroup::common::constants::RECEIPT_CREDENTIAL_REQUEST_LEN, + bincode::serialize(&request).unwrap().len(), + ); + assert_eq!( + zkgroup::common::constants::RECEIPT_CREDENTIAL_RESPONSE_LEN, + bincode::serialize(&response).unwrap().len(), + ); + assert_eq!( + zkgroup::common::constants::RECEIPT_CREDENTIAL_LEN, + bincode::serialize(&credential).unwrap().len(), + ); + assert_eq!( + zkgroup::common::constants::RECEIPT_CREDENTIAL_PRESENTATION_LEN, + bincode::serialize(&presentation).unwrap().len(), + ); } From 309ff4b3781bd46bdd80cad8798517ec8f2e2f4a Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 17:00:09 -0500 Subject: [PATCH 41/69] Update sizes missed in codegen.py previously --- codegen/codegen.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codegen/codegen.py b/codegen/codegen.py index 77316d6..53eb390 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -96,6 +96,9 @@ def add_method(self, method_name, return_type, return_name, params, rustCode="", def define_classes(): classes = [] + c = ClassDescriptor("receipt_serial", "receipts", "simple_types::ReceiptSerialBytes", 16, check_valid_contents=False) + classes.append(c) + c = ClassDescriptor("group_identifier", "groups", "simple_types::GroupIdentifierBytes", 32, check_valid_contents=False) classes.append(c) @@ -169,7 +172,7 @@ def define_classes(): classes.append(c) - c = ClassDescriptor("server_secret_params", "", "api::ServerSecretParams", 769, runtime_error_on_serialize=True) + c = ClassDescriptor("server_secret_params", "", "api::ServerSecretParams", 1121, runtime_error_on_serialize=True) c.add_static_method("generate_deterministic", "class", "server_secret_params", [("class", "randomness")], """ let server_secret_params = api::ServerSecretParams::generate(randomness);""") @@ -253,7 +256,7 @@ def define_classes(): classes.append(c) - c = ClassDescriptor("server_public_params", "", "api::ServerPublicParams", 161, runtime_error_on_serialize=True) + c = ClassDescriptor("server_public_params", "", "api::ServerPublicParams", 225, runtime_error_on_serialize=True) c.add_method("verify_signature", "boolean", "None", [("byte[]", "message"), ("class", "notary_signature")], """ match server_public_params.verify_signature(message, notary_signature) { @@ -266,7 +269,7 @@ def define_classes(): c = ClassDescriptor("auth_credential_response", "auth", "api::auth::AuthCredentialResponse", 361) classes.append(c) - c = ClassDescriptor("auth_credential", "auth", "api::auth::AuthCredential", 342) + c = ClassDescriptor("auth_credential", "auth", "api::auth::AuthCredential", 181) classes.append(c) c = ClassDescriptor("auth_credential_presentation", "auth", "api::auth::AuthCredentialPresentation", 493) From 6941e49adad919650d9ed88248cdb2369549fa55 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 17:02:29 -0500 Subject: [PATCH 42/69] Check in updated codegen output --- codegen/Makefile | 1 + .../signal/zkgroup/ServerPublicParams.java | 2 +- .../signal/zkgroup/ServerSecretParams.java | 2 +- .../signal/zkgroup/auth/AuthCredential.java | 2 +- .../zkgroup/receipts/ReceiptSerial.java | 27 +++++++++++++++++++ .../Sources/ZKGroup/AuthCredential.swift | 2 +- ffi/swift/Sources/ZKGroup/ReceiptSerial.swift | 24 +++++++++++++++++ .../Sources/ZKGroup/ServerPublicParams.swift | 2 +- .../Sources/ZKGroup/ServerSecretParams.swift | 2 +- 9 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java create mode 100644 ffi/swift/Sources/ZKGroup/ReceiptSerial.swift diff --git a/codegen/Makefile b/codegen/Makefile index a0881cb..ad8719a 100644 --- a/codegen/Makefile +++ b/codegen/Makefile @@ -13,6 +13,7 @@ output: mkdir -p java/profiles mkdir -p java/groups mkdir -p java/internal + mkdir -p java/receipts mkdir -p simpleapi mkdir -p swift python3 ./codegen.py diff --git a/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java b/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java index 669dfcc..17d39c0 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java @@ -14,7 +14,7 @@ public final class ServerPublicParams extends ByteArray { - public static final int SIZE = 161; + public static final int SIZE = 225; public ServerPublicParams(byte[] contents) { super(contents, SIZE, true); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java b/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java index aae136b..a06ba1e 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java @@ -16,7 +16,7 @@ public final class ServerSecretParams extends ByteArray { - public static final int SIZE = 769; + public static final int SIZE = 1121; public static ServerSecretParams generate() { return generate(new SecureRandom()); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/auth/AuthCredential.java b/ffi/java/src/main/java/org/signal/zkgroup/auth/AuthCredential.java index 9af8d23..498ebcd 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/auth/AuthCredential.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/auth/AuthCredential.java @@ -16,7 +16,7 @@ public final class AuthCredential extends ByteArray { - public static final int SIZE = 342; + public static final int SIZE = 181; public AuthCredential(byte[] contents) throws InvalidInputException { super(contents, SIZE); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java new file mode 100644 index 0000000..65ecb7e --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java @@ -0,0 +1,27 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.internal.ByteArray; + +public final class ReceiptSerial extends ByteArray { + + public static final int SIZE = 16; + + public ReceiptSerial(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/swift/Sources/ZKGroup/AuthCredential.swift b/ffi/swift/Sources/ZKGroup/AuthCredential.swift index 5d6ffd8..6db55f2 100644 --- a/ffi/swift/Sources/ZKGroup/AuthCredential.swift +++ b/ffi/swift/Sources/ZKGroup/AuthCredential.swift @@ -11,7 +11,7 @@ import libzkgroup public class AuthCredential : ByteArray { - public static let SIZE: Int = 342 + public static let SIZE: Int = 181 public init(contents: [UInt8]) throws { try super.init(newContents: contents, expectedLength: AuthCredential.SIZE) diff --git a/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift b/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift new file mode 100644 index 0000000..c6555c6 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift @@ -0,0 +1,24 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + + + +public class ReceiptSerial : ByteArray { + + public static let SIZE: Int = 16 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: ReceiptSerial.SIZE) + + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift b/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift index 3d58c77..81a294a 100644 --- a/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift +++ b/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift @@ -11,7 +11,7 @@ import libzkgroup public class ServerPublicParams : ByteArray { - public static let SIZE: Int = 161 + public static let SIZE: Int = 225 public init(contents: [UInt8]) throws { try super.init(newContents: contents, expectedLength: ServerPublicParams.SIZE, unrecoverable: true) diff --git a/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift b/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift index d4b6012..34a5e6d 100644 --- a/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift +++ b/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift @@ -11,7 +11,7 @@ import libzkgroup public class ServerSecretParams : ByteArray { - public static let SIZE: Int = 769 + public static let SIZE: Int = 1121 public static func generate() throws -> ServerSecretParams { var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) From 79953d7751eaca54172c3464726b3f8f2ce74005 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 17:21:25 -0500 Subject: [PATCH 43/69] Add new api classes to codegen --- codegen/codegen.py | 17 ++ .../org/signal/zkgroup/internal/Native.java | 6 + .../zkgroup/receipts/ReceiptCredential.java | 39 +++++ .../ReceiptCredentialPresentation.java | 39 +++++ .../receipts/ReceiptCredentialRequest.java | 39 +++++ .../ReceiptCredentialRequestContext.java | 56 +++++++ .../receipts/ReceiptCredentialResponse.java | 39 +++++ .../Sources/ZKGroup/ReceiptCredential.swift | 35 ++++ .../ReceiptCredentialPresentation.swift | 35 ++++ .../ZKGroup/ReceiptCredentialRequest.swift | 35 ++++ .../ReceiptCredentialRequestContext.swift | 52 ++++++ .../ZKGroup/ReceiptCredentialResponse.swift | 35 ++++ rust/src/ffi/ffiapi.rs | 141 ++++++++++++++++ rust/src/ffi/ffiapijava.rs | 158 ++++++++++++++++++ rust/src/ffi/simpleapi.rs | 68 ++++++++ 15 files changed, 794 insertions(+) create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequest.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequestContext.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialResponse.java create mode 100644 ffi/swift/Sources/ZKGroup/ReceiptCredential.swift create mode 100644 ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift create mode 100644 ffi/swift/Sources/ZKGroup/ReceiptCredentialRequest.swift create mode 100644 ffi/swift/Sources/ZKGroup/ReceiptCredentialRequestContext.swift create mode 100644 ffi/swift/Sources/ZKGroup/ReceiptCredentialResponse.swift diff --git a/codegen/codegen.py b/codegen/codegen.py index 53eb390..f5fbeeb 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -301,6 +301,23 @@ def define_classes(): classes.append(c) + c = ClassDescriptor("receipt_credential_request_context", "receipts", "api::receipts::ReceiptCredentialRequestContext", 177) + c.add_method("get_request", "class", "receipt_credential_request", [], + """ let receipt_credential_request = receipt_credential_request_context.get_request();""") + classes.append(c) + + c = ClassDescriptor("receipt_credential_request", "receipts", "api::receipts::ReceiptCredentialRequest", 97) + classes.append(c) + + c = ClassDescriptor("receipt_credential_response", "receipts", "api::receipts::ReceiptCredentialResponse", 409) + classes.append(c) + + c = ClassDescriptor("receipt_credential", "receipts", "api::receipts::ReceiptCredential", 129) + classes.append(c) + + c = ClassDescriptor("receipt_credential_presentation", "receipts", "api::receipts::ReceiptCredentialPresentation", 329) + classes.append(c) + c = ClassDescriptor("uuid_ciphertext", "groups", "api::groups::UuidCiphertext", 65) classes.append(c) diff --git a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java index 45d38cb..4264c9e 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java @@ -100,6 +100,12 @@ private static void copyToTempFileAndLoad(InputStream in, String extension) thro public static native int profileKeyCredentialPresentationGetUuidCiphertextJNI(byte[] self, byte[] output); public static native int profileKeyCredentialPresentationGetProfileKeyCiphertextJNI(byte[] self, byte[] output); public static native int profileKeyCredentialPresentationCheckValidContentsJNI(byte[] self); + public static native int receiptCredentialRequestContextGetRequestJNI(byte[] self, byte[] output); + public static native int receiptCredentialRequestContextCheckValidContentsJNI(byte[] self); + public static native int receiptCredentialRequestCheckValidContentsJNI(byte[] self); + public static native int receiptCredentialResponseCheckValidContentsJNI(byte[] self); + public static native int receiptCredentialCheckValidContentsJNI(byte[] self); + public static native int receiptCredentialPresentationCheckValidContentsJNI(byte[] self); public static native int uuidCiphertextCheckValidContentsJNI(byte[] self); public static native int profileKeyCiphertextCheckValidContentsJNI(byte[] self); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java new file mode 100644 index 0000000..9de846b --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java @@ -0,0 +1,39 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class ReceiptCredential extends ByteArray { + + public static final int SIZE = 129; + + public ReceiptCredential(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.receiptCredentialCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java new file mode 100644 index 0000000..58c7341 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java @@ -0,0 +1,39 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class ReceiptCredentialPresentation extends ByteArray { + + public static final int SIZE = 329; + + public ReceiptCredentialPresentation(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.receiptCredentialPresentationCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequest.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequest.java new file mode 100644 index 0000000..5cdbe2f --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequest.java @@ -0,0 +1,39 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class ReceiptCredentialRequest extends ByteArray { + + public static final int SIZE = 97; + + public ReceiptCredentialRequest(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.receiptCredentialRequestCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequestContext.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequestContext.java new file mode 100644 index 0000000..3735d83 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialRequestContext.java @@ -0,0 +1,56 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class ReceiptCredentialRequestContext extends ByteArray { + + public static final int SIZE = 177; + + public ReceiptCredentialRequestContext(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.receiptCredentialRequestContextCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public ReceiptCredentialRequest getRequest() { + byte[] newContents = new byte[ReceiptCredentialRequest.SIZE]; + + int ffi_return = Native.receiptCredentialRequestContextGetRequestJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ReceiptCredentialRequest(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialResponse.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialResponse.java new file mode 100644 index 0000000..4c58003 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialResponse.java @@ -0,0 +1,39 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class ReceiptCredentialResponse extends ByteArray { + + public static final int SIZE = 409; + + public ReceiptCredentialResponse(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.receiptCredentialResponseCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ReceiptCredential.swift b/ffi/swift/Sources/ZKGroup/ReceiptCredential.swift new file mode 100644 index 0000000..2459031 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ReceiptCredential.swift @@ -0,0 +1,35 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class ReceiptCredential : ByteArray { + + public static let SIZE: Int = 129 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: ReceiptCredential.SIZE) + + + let ffi_return = FFI_ReceiptCredential_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift b/ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift new file mode 100644 index 0000000..30a77a5 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift @@ -0,0 +1,35 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class ReceiptCredentialPresentation : ByteArray { + + public static let SIZE: Int = 329 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: ReceiptCredentialPresentation.SIZE) + + + let ffi_return = FFI_ReceiptCredentialPresentation_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ReceiptCredentialRequest.swift b/ffi/swift/Sources/ZKGroup/ReceiptCredentialRequest.swift new file mode 100644 index 0000000..394feed --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ReceiptCredentialRequest.swift @@ -0,0 +1,35 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class ReceiptCredentialRequest : ByteArray { + + public static let SIZE: Int = 97 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: ReceiptCredentialRequest.SIZE) + + + let ffi_return = FFI_ReceiptCredentialRequest_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ReceiptCredentialRequestContext.swift b/ffi/swift/Sources/ZKGroup/ReceiptCredentialRequestContext.swift new file mode 100644 index 0000000..125ac37 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ReceiptCredentialRequestContext.swift @@ -0,0 +1,52 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class ReceiptCredentialRequestContext : ByteArray { + + public static let SIZE: Int = 177 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: ReceiptCredentialRequestContext.SIZE) + + + let ffi_return = FFI_ReceiptCredentialRequestContext_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func getRequest() throws -> ReceiptCredentialRequest { + var newContents: [UInt8] = Array(repeating: 0, count: ReceiptCredentialRequest.SIZE) + + let ffi_return = FFI_ReceiptCredentialRequestContext_getRequest(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ReceiptCredentialRequest(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ReceiptCredentialResponse.swift b/ffi/swift/Sources/ZKGroup/ReceiptCredentialResponse.swift new file mode 100644 index 0000000..e6da5c5 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ReceiptCredentialResponse.swift @@ -0,0 +1,35 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class ReceiptCredentialResponse : ByteArray { + + public static let SIZE: Int = 409 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: ReceiptCredentialResponse.SIZE) + + + let ffi_return = FFI_ReceiptCredentialResponse_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index 810afe3..ed80db1 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -1254,6 +1254,147 @@ pub extern "C" fn FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext( } } +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialRequestContext_checkValidContents( + receiptCredentialRequestContext: *const u8, + receiptCredentialRequestContextLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_request_context: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialRequestContext, + receiptCredentialRequestContextLen as usize, + ) + }; + + simpleapi::ReceiptCredentialRequestContext_checkValidContents( + receipt_credential_request_context, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialRequestContext_getRequest( + receiptCredentialRequestContext: *const u8, + receiptCredentialRequestContextLen: u32, + receiptCredentialRequestOut: *mut u8, + receiptCredentialRequestLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_request_context: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialRequestContext, + receiptCredentialRequestContextLen as usize, + ) + }; + let receipt_credential_request: &mut [u8] = unsafe { + slice::from_raw_parts_mut( + receiptCredentialRequestOut, + receiptCredentialRequestLen as usize, + ) + }; + + simpleapi::ReceiptCredentialRequestContext_getRequest( + receipt_credential_request_context, + receipt_credential_request, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialRequest_checkValidContents( + receiptCredentialRequest: *const u8, + receiptCredentialRequestLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_request: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialRequest, + receiptCredentialRequestLen as usize, + ) + }; + + simpleapi::ReceiptCredentialRequest_checkValidContents(receipt_credential_request) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialResponse_checkValidContents( + receiptCredentialResponse: *const u8, + receiptCredentialResponseLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_response: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialResponse, + receiptCredentialResponseLen as usize, + ) + }; + + simpleapi::ReceiptCredentialResponse_checkValidContents(receipt_credential_response) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredential_checkValidContents( + receiptCredential: *const u8, + receiptCredentialLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential: &[u8] = + unsafe { slice::from_raw_parts(receiptCredential, receiptCredentialLen as usize) }; + + simpleapi::ReceiptCredential_checkValidContents(receipt_credential) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialPresentation_checkValidContents( + receiptCredentialPresentation: *const u8, + receiptCredentialPresentationLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialPresentation, + receiptCredentialPresentationLen as usize, + ) + }; + + simpleapi::ReceiptCredentialPresentation_checkValidContents(receipt_credential_presentation) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_UuidCiphertext_checkValidContents( uuidCiphertext: *const u8, diff --git a/rust/src/ffi/ffiapijava.rs b/rust/src/ffi/ffiapijava.rs index 03f0fcd..8b7054d 100644 --- a/rust/src/ffi/ffiapijava.rs +++ b/rust/src/ffi/ffiapijava.rs @@ -1473,6 +1473,164 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredent } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialRequestContextCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialRequestContext: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_request_context = env + .convert_byte_array(receiptCredentialRequestContext) + .unwrap(); + + let ffi_return = simpleapi::ReceiptCredentialRequestContext_checkValidContents( + &receipt_credential_request_context, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialRequestContextGetRequestJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialRequestContext: jbyteArray, + receiptCredentialRequestOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_request_context = env + .convert_byte_array(receiptCredentialRequestContext) + .unwrap(); + let mut receipt_credential_request: Vec = + vec![0; env.get_array_length(receiptCredentialRequestOut).unwrap() as usize]; + + let ffi_return = simpleapi::ReceiptCredentialRequestContext_getRequest( + &receipt_credential_request_context, + &mut receipt_credential_request, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + receiptCredentialRequestOut, + 0, + &u8toi8(receipt_credential_request)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialRequestCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialRequest: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_request = env.convert_byte_array(receiptCredentialRequest).unwrap(); + + let ffi_return = + simpleapi::ReceiptCredentialRequest_checkValidContents(&receipt_credential_request); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialResponseCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialResponse: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_response = + env.convert_byte_array(receiptCredentialResponse).unwrap(); + + let ffi_return = + simpleapi::ReceiptCredentialResponse_checkValidContents(&receipt_credential_response); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + receiptCredential: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential = env.convert_byte_array(receiptCredential).unwrap(); + + let ffi_return = simpleapi::ReceiptCredential_checkValidContents(&receipt_credential); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialPresentationCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialPresentation: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation = env + .convert_byte_array(receiptCredentialPresentation) + .unwrap(); + + let ffi_return = simpleapi::ReceiptCredentialPresentation_checkValidContents( + &receipt_credential_presentation, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_uuidCiphertextCheckValidContentsJNI( env: JNIEnv, diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index bd481ab..a0dac82 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -864,6 +864,74 @@ pub fn ProfileKeyCredentialPresentation_getProfileKeyCiphertext( FFI_RETURN_OK } +pub fn ReceiptCredentialRequestContext_checkValidContents( + receiptCredentialRequestContextIn: &[u8], +) -> i32 { + let _: api::receipts::ReceiptCredentialRequestContext = + match bincode::deserialize(receiptCredentialRequestContextIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + +pub fn ReceiptCredentialRequestContext_getRequest( + receiptCredentialRequestContextIn: &[u8], + receiptCredentialRequestOut: &mut [u8], +) -> i32 { + let receipt_credential_request_context: api::receipts::ReceiptCredentialRequestContext = + match bincode::deserialize(receiptCredentialRequestContextIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let receipt_credential_request = receipt_credential_request_context.get_request(); + receiptCredentialRequestOut + .copy_from_slice(&bincode::serialize(&receipt_credential_request).unwrap()); + FFI_RETURN_OK +} + +pub fn ReceiptCredentialRequest_checkValidContents(receiptCredentialRequestIn: &[u8]) -> i32 { + let _: api::receipts::ReceiptCredentialRequest = + match bincode::deserialize(receiptCredentialRequestIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + +pub fn ReceiptCredentialResponse_checkValidContents(receiptCredentialResponseIn: &[u8]) -> i32 { + let _: api::receipts::ReceiptCredentialResponse = + match bincode::deserialize(receiptCredentialResponseIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + +pub fn ReceiptCredential_checkValidContents(receiptCredentialIn: &[u8]) -> i32 { + let _: api::receipts::ReceiptCredential = match bincode::deserialize(receiptCredentialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + +pub fn ReceiptCredentialPresentation_checkValidContents( + receiptCredentialPresentationIn: &[u8], +) -> i32 { + let _: api::receipts::ReceiptCredentialPresentation = + match bincode::deserialize(receiptCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + pub fn UuidCiphertext_checkValidContents(uuidCiphertextIn: &[u8]) -> i32 { let _: api::groups::UuidCiphertext = match bincode::deserialize(uuidCiphertextIn) { Ok(result) => result, From 82fa8fa5fb0635d4d3207d36a12574e620942598 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Tue, 21 Sep 2021 17:29:58 -0500 Subject: [PATCH 44/69] Remove the class for ReceiptSerial --- codegen/Makefile | 7 +++++ codegen/codegen.py | 6 ++--- .../zkgroup/receipts/ReceiptSerial.java | 27 ------------------- ffi/swift/Sources/ZKGroup/ReceiptSerial.swift | 24 ----------------- rust/src/ffi/ffiapi.rs | 18 +++++++++++++ rust/src/ffi/ffiapijava.rs | 22 +++++++++++++++ rust/src/ffi/simpleapi.rs | 9 +++++++ 7 files changed, 59 insertions(+), 54 deletions(-) delete mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java delete mode 100644 ffi/swift/Sources/ZKGroup/ReceiptSerial.swift diff --git a/codegen/Makefile b/codegen/Makefile index ad8719a..712dd67 100644 --- a/codegen/Makefile +++ b/codegen/Makefile @@ -37,3 +37,10 @@ clean: rm -rf java rm -rf simpleapi rm -rf swift + +.PHONY: clean-destination +clean-destination: + rm -rf ../ffi/java/src/main/java/org/signal/zkgroup + mkdir -p ../ffi/java/src/main/java/org/signal/zkgroup + rm -rf ../ffi/swift/Sources/ZKGroup + mkdir -p ../ffi/swift/Sources/ZKGroup diff --git a/codegen/codegen.py b/codegen/codegen.py index f5fbeeb..09cadd3 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -96,9 +96,6 @@ def add_method(self, method_name, return_type, return_name, params, rustCode="", def define_classes(): classes = [] - c = ClassDescriptor("receipt_serial", "receipts", "simple_types::ReceiptSerialBytes", 16, check_valid_contents=False) - classes.append(c) - c = ClassDescriptor("group_identifier", "groups", "simple_types::GroupIdentifierBytes", 32, check_valid_contents=False) classes.append(c) @@ -330,6 +327,9 @@ def define_classes(): c = ClassDescriptor("uuid", "", "simple_types::UidBytes", 32, no_class=True) classes.append(c) + c = ClassDescriptor("receipt_serial", "receipts", "simple_types::ReceiptSerialBytes", 16, no_class=True) + classes.append(c) + return classes diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java deleted file mode 100644 index 65ecb7e..0000000 --- a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright (C) 2020 Signal Messenger, LLC. -// All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-only -// - -// Generated by zkgroup/codegen/codegen.py - do not edit - -package org.signal.zkgroup.receipts; - -import org.signal.zkgroup.InvalidInputException; -import org.signal.zkgroup.internal.ByteArray; - -public final class ReceiptSerial extends ByteArray { - - public static final int SIZE = 16; - - public ReceiptSerial(byte[] contents) throws InvalidInputException { - super(contents, SIZE); - } - - public byte[] serialize() { - return contents.clone(); - } - -} diff --git a/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift b/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift deleted file mode 100644 index c6555c6..0000000 --- a/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (C) 2020 Signal Messenger, LLC. -// All rights reserved. -// -// SPDX-License-Identifier: GPL-3.0-only -// -// Generated by zkgroup/codegen/codegen.py - do not edit - - - -public class ReceiptSerial : ByteArray { - - public static let SIZE: Int = 16 - - public init(contents: [UInt8]) throws { - try super.init(newContents: contents, expectedLength: ReceiptSerial.SIZE) - - } - - public func serialize() -> [UInt8] { - return contents - } - -} diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index ed80db1..2b398ff 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -1463,3 +1463,21 @@ pub extern "C" fn FFI_Uuid_checkValidContents(uuid: *const u8, uuidLen: u32) -> Err(_) => FFI_RETURN_INTERNAL_ERROR, } } + +#[no_mangle] +pub extern "C" fn FFI_ReceiptSerial_checkValidContents( + receiptSerial: *const u8, + receiptSerialLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_serial: &[u8] = + unsafe { slice::from_raw_parts(receiptSerial, receiptSerialLen as usize) }; + + simpleapi::ReceiptSerial_checkValidContents(receipt_serial) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} diff --git a/rust/src/ffi/ffiapijava.rs b/rust/src/ffi/ffiapijava.rs index 8b7054d..356cf21 100644 --- a/rust/src/ffi/ffiapijava.rs +++ b/rust/src/ffi/ffiapijava.rs @@ -1719,3 +1719,25 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_uuidCheckValidCon Err(_) => FFI_RETURN_INTERNAL_ERROR, } } + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptSerialCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + receiptSerial: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_serial = env.convert_byte_array(receiptSerial).unwrap(); + + let ffi_return = simpleapi::ReceiptSerial_checkValidContents(&receipt_serial); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index a0dac82..d2db7db 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -967,3 +967,12 @@ pub fn Uuid_checkValidContents(uuidIn: &[u8]) -> i32 { FFI_RETURN_OK } + +pub fn ReceiptSerial_checkValidContents(receiptSerialIn: &[u8]) -> i32 { + let _: simple_types::ReceiptSerialBytes = match bincode::deserialize(receiptSerialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} From e51c4cd9bf417ee05cb98867c46ebb8ec71311f8 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 22 Sep 2021 16:33:33 -0500 Subject: [PATCH 45/69] Update codegen with receipt operations --- codegen/codegen.py | 34 +++ codegen/codegen_ffiapi.py | 20 +- codegen/codegen_ffiapijava.py | 25 ++- codegen/codegen_java.py | 36 ++- codegen/codegen_simpleapi.py | 4 +- codegen/codegen_swift.py | 35 ++- .../org/signal/zkgroup/internal/Native.java | 5 + .../receipts/ClientZkReceiptOperations.java | 101 +++++++++ .../receipts/ServerZkReceiptOperations.java | 65 ++++++ .../ZKGroup/ClientZkReceiptOperations.swift | 94 ++++++++ .../ZKGroup/ServerZkReceiptOperations.swift | 55 +++++ rust/src/ffi/ffiapi.rs | 200 +++++++++++++++++ rust/src/ffi/ffiapijava.rs | 208 ++++++++++++++++++ rust/src/ffi/simpleapi.rs | 153 +++++++++++++ 14 files changed, 1002 insertions(+), 33 deletions(-) create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ClientZkReceiptOperations.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ServerZkReceiptOperations.java create mode 100644 ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift create mode 100644 ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift diff --git a/codegen/codegen.py b/codegen/codegen.py index 09cadd3..77013a0 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -213,6 +213,22 @@ def define_classes(): classes.append(c) + c = ClassDescriptor("client_zk_receipt_operations", "receipts", "api::receipts::ClientZkReceiptOperations", 256, wrap_class="server_public_params") + + c.add_method("create_receipt_credential_request_context_deterministic", "class", "receipt_credential_request_context", [("class", "randomness"), ("class", "receipt_serial")], + """ let receipt_credential_request_context = server_public_params.create_receipt_credential_request_context(randomness, receipt_serial);""") + + c.add_method("receive_receipt_credential", "class", "receipt_credential", [("class", "receipt_credential_request_context"), ("class", "receipt_credential_response")], + """ let receipt_credential = match server_public_params.receive_receipt_credential(&receipt_credential_request_context, &receipt_credential_response) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + };""") + + c.add_method("create_receipt_credential_presentation_deterministic", "class", "receipt_credential_presentation", [("class", "randomness"), ("class", "receipt_credential")], + """ let receipt_credential_presentation = server_public_params.create_receipt_credential_presentation(randomness, &receipt_credential);""") + + classes.append(c) + c = ClassDescriptor("server_zk_auth_operations", "auth", "api::auth::ServerZkAuthOperations", 544, wrap_class="server_secret_params") c.add_method("issue_auth_credential_deterministic", "class", "auth_credential_response", [("class", "randomness"), ("UUID", "uuid"), ("int", "redemption_time")], @@ -247,6 +263,24 @@ def define_classes(): classes.append(c) + c = ClassDescriptor("server_zk_receipt_operations", "receipts", "api::receipts::ServerZkReceiptOperations", 544, wrap_class="server_secret_params") + + c.add_method("issue_receipt_credential_deterministic", "class", "receipt_credential_response", [("class", "randomness"), ("class", "receipt_credential_request"), ("long", "receipt_expiration_time"), ("long", "receipt_level")], + """ let receipt_credential_response = server_secret_params.issue_receipt_credential( + randomness, + &receipt_credential_request, + receipt_expiration_time, + receipt_level, + );""") + + c.add_method("verify_receipt_credential_presentation", "boolean", "None", [("class", "receipt_credential_presentation")], + """ match server_secret_params.verify_receipt_credential_presentation(&receipt_credential_presentation) { + Ok(_) => (), + Err(_) => return FFI_RETURN_INPUT_ERROR, + }""") + + classes.append(c) + c = ClassDescriptor("group_public_params", "groups", "api::groups::GroupPublicParams", 97) c.add_method("get_group_identifier", "class", "group_identifier", [], """ let group_identifier = group_public_params.get_group_identifier();""") diff --git a/codegen/codegen_ffiapi.py b/codegen/codegen_ffiapi.py index 64185ad..9aa7a5b 100644 --- a/codegen/codegen_ffiapi.py +++ b/codegen/codegen_ffiapi.py @@ -64,12 +64,14 @@ def print_method(c, m, static): s += " " + class_name.lower_camel() + ": *const u8,\n" s += " " + class_name.lower_camel() + "Len: u32,\n" for param in m.params: - if param[0] != "int": - s += " " + param[1].lower_camel() + ": *const u8,\n" - s += " " + param[1].lower_camel() + "Len: u32,\n" + if param[0] == "int": + s += f" {param[1].lower_camel()}: u32,\n" + elif param[0] == "long": + s += f" {param[1].lower_camel()}: u64,\n" else: - s += " " + param[1].lower_camel() + ": u32,\n" - if m.return_type != "boolean": + s += f" {param[1].lower_camel()}: *const u8,\n" + s += f" {param[1].lower_camel()}Len: u32,\n" + if m.return_type != "boolean": s += " " + m.return_name.lower_camel() + "Out: *mut u8,\n" s += " " + m.return_name.lower_camel() + "Len: u32,\n" s += template_method_decl_end @@ -80,10 +82,12 @@ def print_method(c, m, static): if not static: s += " let " + class_name.snake() + ": &[u8] = unsafe { slice::from_raw_parts(%s, %sLen as usize) };\n" % (class_name.lower_camel(), class_name.lower_camel()) for param in m.params: - if param[0] != "int": - s += " let " + param[1].snake() + ": &[u8] = unsafe { slice::from_raw_parts(%s, %sLen as usize) };\n" % (param[1].lower_camel(), param[1].lower_camel()) + if param[0] == "int": + s += f" let {param[1].snake()} = {param[1].lower_camel()} as u32;\n" + elif param[0] == "long": + s += f" let {param[1].snake()} = {param[1].lower_camel()} as u64;\n" else: - s += " let " + param[1].snake() + " = %s as u32;\n" % param[1].lower_camel() + s += f" let {param[1].snake()}: &[u8] = unsafe {{ slice::from_raw_parts({param[1].lower_camel()}, {param[1].lower_camel()}Len as usize) }};\n" if m.return_type != "boolean": s += " let %s: &mut [u8] = unsafe { slice::from_raw_parts_mut(%sOut, %sLen as usize) };\n" % (m.return_name.snake(), m.return_name.lower_camel(), m.return_name.lower_camel()) diff --git a/codegen/codegen_ffiapijava.py b/codegen/codegen_ffiapijava.py index 605802f..7ade500 100644 --- a/codegen/codegen_ffiapijava.py +++ b/codegen/codegen_ffiapijava.py @@ -20,6 +20,7 @@ use super::simpleapi; use jni::sys::jint; +use jni::sys::jlong; // This is the interface to the JVM that we'll // call the majority of our methods on. @@ -71,10 +72,10 @@ def get_args(params, commaAtEnd): s = "" for param in params: - if param[0] != "int": - s += "&" + param[1].snake() + ", " - else: + if param[0] == "int" or param[0] == "long": s += param[1].snake() + ", " + else: + s += "&" + param[1].snake() + ", " if len(s) != 0 and not commaAtEnd: s = s[:-2] @@ -96,11 +97,13 @@ def print_method(c, m, static): if not static: s += " " + class_name.lower_camel() + ": jbyteArray,\n" for param in m.params: - if param[0] != "int": - s += " " + param[1].lower_camel() + ": jbyteArray,\n" + if param[0] == "int": + s += f" {param[1].lower_camel()}: jint,\n" + elif param[0] == "long": + s += f" {param[1].lower_camel()}: jlong,\n" else: - s += " " + param[1].lower_camel() + ": jint,\n" - if m.return_type != "boolean": + s += f" {param[1].lower_camel()}: jbyteArray,\n" + if m.return_type != "boolean": s += " " + m.return_name.lower_camel() + "Out: jbyteArray,\n" s += template_method_decl_end @@ -110,10 +113,12 @@ def print_method(c, m, static): if not static: s += " let " + class_name.snake() + " = env.convert_byte_array(%s).unwrap();\n" % class_name.lower_camel() for param in m.params: - if param[0] != "int": - s += " let " + param[1].snake() + " = env.convert_byte_array(%s).unwrap();\n" % param[1].lower_camel() + if param[0] == "int": + s += f" let {param[1].snake()} = {param[1].lower_camel()} as u32;\n" + elif param[0] == "long": + s += f" let {param[1].snake()} = {param[1].lower_camel()} as u64;\n" else: - s += " let " + param[1].snake() + " = %s as u32;\n" % param[1].lower_camel() + s += f" let {param[1].snake()} = env.convert_byte_array({param[1].lower_camel()}).unwrap();\n" if m.return_type != "boolean": s += " let mut %s: Vec = vec![0; env.get_array_length(%sOut).unwrap() as usize];\n" % (m.return_name.snake(), m.return_name.lower_camel()) diff --git a/codegen/codegen_java.py b/codegen/codegen_java.py index d8dd151..2498925 100644 --- a/codegen/codegen_java.py +++ b/codegen/codegen_java.py @@ -241,6 +241,21 @@ } """ +template_method_long = \ +""" + %(access)s int %(method_name)s(%(param_decls)s) %(exception_decl)s{ + byte[] newContents = new byte[8]; + + int ffi_return = Native.%(jni_method_name)s(%(contents)s, %(param_args)snewContents);%(exception_check)s + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return ByteBuffer.wrap(newContents).getLong(); + } +""" + template_method_rand_wrapper = \ """ public %(return_name)s %(method_name)s(%(param_decls)s) %(exception_decl)s{ @@ -367,7 +382,7 @@ def get_rand_wrapper_decls(params): def get_args(params, import_strings, commaAtEnd): s = "" for param in params: - if param[0] == "byte[]" or param[0] == "int": + if param[0] == "byte[]" or param[0] == "int" or param[0] == "long": s += param[1].lower_camel() + ", " elif param[0] == "UUID": s += "UUIDUtil.serialize(" + param[1].lower_camel() + "), " @@ -388,16 +403,12 @@ def get_jni_arg_decls(params, selfBool, commaAtEndBool): s += "byte[] self, " counter = 0 for param in params: - if param[0] == "byte[]": - s += "byte[] %s, " % param[1].lower_camel() - elif param[0] == "int": - s += "int %s, " % param[1].lower_camel() - elif param[0] == "UUID": - s += "byte[] %s, " % param[1].lower_camel() - elif param[1].snake() == "randomness": - s += "byte[] %s, " % param[1].lower_camel() + if param[0] == "int": + s += f"int {param[1].lower_camel()}, " + elif param[0] == "long": + s += f"long {param[1].lower_camel()}, " else: - s += "byte[] %s, " % param[1].lower_camel() + s += f"byte[] {param[1].lower_camel()}, " counter += 1 if len(s) != 0 and not commaAtEndBool: @@ -579,6 +590,11 @@ def print_class(c, runtime_error_on_serialize_dict, class_dir_dict): param_args = get_args(method.params, import_strings, False) append_jni_function_decl(jni_method_name, method.params, True, True) import_strings += "import java.nio.ByteBuffer;", + elif method.return_type == "long": + template = template_method_long + param_args = get_args(method.params, import_strings, False) + append_jni_function_decl(jni_method_name, method.params, True, True) + import_strings += "import java.nio.ByteBuffer;", elif method.return_type == "UUID": import_strings.append("import java.util.UUID;") template = template_method_uuid diff --git a/codegen/codegen_simpleapi.py b/codegen/codegen_simpleapi.py index 55664fa..8f7b7f5 100644 --- a/codegen/codegen_simpleapi.py +++ b/codegen/codegen_simpleapi.py @@ -52,6 +52,8 @@ def get_args(c, m, class_name, static=True): for param in m.params: if param[0] == "int": s += param[1].lower_camel() + "In: u32, " + elif param[0] == "long": + s += param[1].lower_camel() + "In: u64, " else: s += param[1].lower_camel() + "In: &[u8], " @@ -92,7 +94,7 @@ def print_method(c, m, rustClasses, static): error_name = "FFI_RETURN_INPUT_ERROR" for param in m.params: - if param[0] == "int" or param[0] == "byte[]": + if param[0] == "int" or param[0] == "long" or param[0] == "byte[]": s += " let %s = %sIn;\n" % (param[1].snake(), param[1].lower_camel()) elif param[1].snake() == "notary_signature": s += """ let mut notary_signature: simple_types::NotarySignatureBytes = [0u8; SIGNATURE_LEN]; diff --git a/codegen/codegen_swift.py b/codegen/codegen_swift.py index b9fa588..78c33fa 100644 --- a/codegen/codegen_swift.py +++ b/codegen/codegen_swift.py @@ -239,6 +239,23 @@ } """ +template_method_long = \ +""" + public func %(method_name)s(%(param_decls)s) %(exception_decl)s -> UInt64 { + var newContents: [UInt8] = Array(repeating: 0, count: Int(8)) + + let ffi_return = FFI_%(jni_method_name)s(%(contents)s, %(param_args)s&newContents, UInt32(newContents.count))%(exception_check)s + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + let data = Data(bytes: newContents) + let value = UInt64(bigEndian: data.withUnsafeBytes { $0.pointee }) + return value + } +""" + template_method_rand_wrapper = \ """ public func %(method_name)s(%(param_decls)s) %(exception_decl)s -> %(return_name)s { @@ -280,6 +297,9 @@ def get_decls(params, import_strings, class_dir_dict, my_dir_name): elif param[0] == "int": s += param[1].lower_camel() + ": UInt32, " #SWIFT add_import(import_strings, class_dir_dict, my_dir_name, param[1]) + elif param[0] == "long": + s += param[1].lower_camel() + ": Uint64, " + #SWIFT add_import(import_strings, class_dir_dict, my_dir_name, param[1]) elif param[0] == "UUID": s += param[1].lower_camel() + ": ZKGUuid, " #SWIFT add_import(import_strings, class_dir_dict, my_dir_name, param[1]) @@ -299,6 +319,8 @@ def get_rand_wrapper_decls(params): s += param[1].lower_camel() + ": [UInt8], " elif param[0] == "int": s += param[1].lower_camel() + ": UInt32, " + elif param[0] == "long": + s += param[1].lower_camel() + ": UInt64, " elif param[0] == "UUID": s += param[1].lower_camel() + ": ZKGUuid, " else: @@ -311,7 +333,7 @@ def get_rand_wrapper_decls(params): def get_args(params, import_strings, commaAtEnd): s = "" for param in params: - if param[0] == "byte[]" or param[0] == "int": + if param[0] == "byte[]" or param[0] == "int" or param[0] == "long": term = param[1].lower_camel() # SWIFT elif param[0] == "UUID": # SWIFT term = "UUIDUtil.serialize(" + param[1].lower_camel() + ")" @@ -320,10 +342,10 @@ def get_args(params, import_strings, commaAtEnd): else: term = param[1].lower_camel() + ".getInternalContentsForFFI()" - if param[0] != "int": - s += term + ", UInt32(" + term + ".count), " - else: + if param[0] == "int" or param[0] == "long": s += term + ", " + else: + s += term + ", UInt32(" + term + ".count), " if len(s) != 0 and not commaAtEnd: s = s[:-2] @@ -339,6 +361,8 @@ def get_jni_arg_decls(params, selfBool, commaAtEndBool): s += "byte[] %s, " % param[1].lower_camel() elif param[0] == "int": s += "int %s, " % param[1].lower_camel() + elif param[0] == "long": + s += "long %s, " % param[1].lower_camel() # elif param[0] == "UUID": # s += "byte[] %s, " % param[1].lower_camel() elif param[1].snake() == "randomness": @@ -505,6 +529,9 @@ def print_class(c, runtime_error_on_serialize_dict, class_dir_dict): elif method.return_type == "int": template = template_method_int param_args = get_args(method.params, import_strings, False) + elif method.return_type == "long": + template = template_method_long + param_args = get_args(method.params, import_strings, False) elif method.return_type == "byte[]": # copied from UUID? template = template_method_bytearray param_args = get_args(method.params, import_strings, True) diff --git a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java index 4264c9e..9907044 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java @@ -79,10 +79,15 @@ private static void copyToTempFileAndLoad(InputStream in, String extension) thro public static native int serverPublicParamsCreateProfileKeyCredentialRequestContextDeterministicJNI(byte[] self, byte[] randomness, byte[] uuid, byte[] profileKey, byte[] output); public static native int serverPublicParamsReceiveProfileKeyCredentialJNI(byte[] self, byte[] profileKeyCredentialRequestContext, byte[] profileKeyCredentialResponse, byte[] output); public static native int serverPublicParamsCreateProfileKeyCredentialPresentationDeterministicJNI(byte[] self, byte[] randomness, byte[] groupSecretParams, byte[] profileKeyCredential, byte[] output); + public static native int serverPublicParamsCreateReceiptCredentialRequestContextDeterministicJNI(byte[] self, byte[] randomness, byte[] receiptSerial, byte[] output); + public static native int serverPublicParamsReceiveReceiptCredentialJNI(byte[] self, byte[] receiptCredentialRequestContext, byte[] receiptCredentialResponse, byte[] output); + public static native int serverPublicParamsCreateReceiptCredentialPresentationDeterministicJNI(byte[] self, byte[] randomness, byte[] receiptCredential, byte[] output); public static native int serverSecretParamsIssueAuthCredentialDeterministicJNI(byte[] self, byte[] randomness, byte[] uuid, int redemptionTime, byte[] output); public static native int serverSecretParamsVerifyAuthCredentialPresentationJNI(byte[] self, byte[] groupPublicParams, byte[] authCredentialPresentation); public static native int serverSecretParamsIssueProfileKeyCredentialDeterministicJNI(byte[] self, byte[] randomness, byte[] profileKeyCredentialRequest, byte[] uuid, byte[] profileKeyCommitment, byte[] output); public static native int serverSecretParamsVerifyProfileKeyCredentialPresentationJNI(byte[] self, byte[] groupPublicParams, byte[] profileKeyCredentialPresentation); + public static native int serverSecretParamsIssueReceiptCredentialDeterministicJNI(byte[] self, byte[] randomness, byte[] receiptCredentialRequest, long receiptExpirationTime, long receiptLevel, byte[] output); + public static native int serverSecretParamsVerifyReceiptCredentialPresentationJNI(byte[] self, byte[] receiptCredentialPresentation); public static native int groupPublicParamsGetGroupIdentifierJNI(byte[] self, byte[] output); public static native int groupPublicParamsCheckValidContentsJNI(byte[] self); public static native int serverPublicParamsVerifySignatureJNI(byte[] self, byte[] message, byte[] notarySignature); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ClientZkReceiptOperations.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ClientZkReceiptOperations.java new file mode 100644 index 0000000..38fecaf --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ClientZkReceiptOperations.java @@ -0,0 +1,101 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import java.security.SecureRandom; +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ServerPublicParams; +import org.signal.zkgroup.VerificationFailedException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.Native; + +public class ClientZkReceiptOperations { + + private final ServerPublicParams serverPublicParams; + + public ClientZkReceiptOperations(ServerPublicParams serverPublicParams) { + this.serverPublicParams = serverPublicParams; + } + + public ReceiptCredentialRequestContext createReceiptCredentialRequestContext(ReceiptSerial receiptSerial) throws VerificationFailedException { + return createReceiptCredentialRequestContext(new SecureRandom(), receiptSerial); + } + + public ReceiptCredentialRequestContext createReceiptCredentialRequestContext(SecureRandom secureRandom, ReceiptSerial receiptSerial) throws VerificationFailedException { + byte[] newContents = new byte[ReceiptCredentialRequestContext.SIZE]; + byte[] random = new byte[Native.RANDOM_LENGTH]; + + secureRandom.nextBytes(random); + + int ffi_return = Native.serverPublicParamsCreateReceiptCredentialRequestContextDeterministicJNI(serverPublicParams.getInternalContentsForJNI(), random, receiptSerial.getInternalContentsForJNI(), newContents); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ReceiptCredentialRequestContext(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public ReceiptCredential receiveReceiptCredential(ReceiptCredentialRequestContext receiptCredentialRequestContext, ReceiptCredentialResponse receiptCredentialResponse) throws VerificationFailedException { + byte[] newContents = new byte[ReceiptCredential.SIZE]; + + int ffi_return = Native.serverPublicParamsReceiveReceiptCredentialJNI(serverPublicParams.getInternalContentsForJNI(), receiptCredentialRequestContext.getInternalContentsForJNI(), receiptCredentialResponse.getInternalContentsForJNI(), newContents); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ReceiptCredential(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public ReceiptCredentialPresentation createReceiptCredentialPresentation(ReceiptCredential receiptCredential) throws VerificationFailedException { + return createReceiptCredentialPresentation(new SecureRandom(), receiptCredential); + } + + public ReceiptCredentialPresentation createReceiptCredentialPresentation(SecureRandom secureRandom, ReceiptCredential receiptCredential) throws VerificationFailedException { + byte[] newContents = new byte[ReceiptCredentialPresentation.SIZE]; + byte[] random = new byte[Native.RANDOM_LENGTH]; + + secureRandom.nextBytes(random); + + int ffi_return = Native.serverPublicParamsCreateReceiptCredentialPresentationDeterministicJNI(serverPublicParams.getInternalContentsForJNI(), random, receiptCredential.getInternalContentsForJNI(), newContents); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ReceiptCredentialPresentation(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ServerZkReceiptOperations.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ServerZkReceiptOperations.java new file mode 100644 index 0000000..5cfd188 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ServerZkReceiptOperations.java @@ -0,0 +1,65 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import java.security.SecureRandom; +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ServerSecretParams; +import org.signal.zkgroup.VerificationFailedException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.Native; + +public class ServerZkReceiptOperations { + + private final ServerSecretParams serverSecretParams; + + public ServerZkReceiptOperations(ServerSecretParams serverSecretParams) { + this.serverSecretParams = serverSecretParams; + } + + public ReceiptCredentialResponse issueReceiptCredential(ReceiptCredentialRequest receiptCredentialRequest, long receiptExpirationTime, long receiptLevel) throws VerificationFailedException { + return issueReceiptCredential(new SecureRandom(), receiptCredentialRequest, receiptExpirationTime, receiptLevel); + } + + public ReceiptCredentialResponse issueReceiptCredential(SecureRandom secureRandom, ReceiptCredentialRequest receiptCredentialRequest, long receiptExpirationTime, long receiptLevel) throws VerificationFailedException { + byte[] newContents = new byte[ReceiptCredentialResponse.SIZE]; + byte[] random = new byte[Native.RANDOM_LENGTH]; + + secureRandom.nextBytes(random); + + int ffi_return = Native.serverSecretParamsIssueReceiptCredentialDeterministicJNI(serverSecretParams.getInternalContentsForJNI(), random, receiptCredentialRequest.getInternalContentsForJNI(), receiptExpirationTime, receiptLevel, newContents); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ReceiptCredentialResponse(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public void verifyReceiptCredentialPresentation(ReceiptCredentialPresentation receiptCredentialPresentation) throws VerificationFailedException { + int ffi_return = Native.serverSecretParamsVerifyReceiptCredentialPresentationJNI(serverSecretParams.getInternalContentsForJNI(), receiptCredentialPresentation.getInternalContentsForJNI()); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift b/ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift new file mode 100644 index 0000000..581b7f8 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift @@ -0,0 +1,94 @@ +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class ClientZkReceiptOperations { + + let serverPublicParams: ServerPublicParams + + public init(serverPublicParams: ServerPublicParams) { + self.serverPublicParams = serverPublicParams + } + + public func createReceiptCredentialRequestContext(receiptSerial: ReceiptSerial) throws -> ReceiptCredentialRequestContext { + var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) + let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) + guard result == errSecSuccess else { + throw ZkGroupException.AssertionError + } + + return try createReceiptCredentialRequestContext(randomness: randomness, receiptSerial: receiptSerial) + } + + public func createReceiptCredentialRequestContext(randomness: [UInt8], receiptSerial: ReceiptSerial) throws -> ReceiptCredentialRequestContext { + var newContents: [UInt8] = Array(repeating: 0, count: ReceiptCredentialRequestContext.SIZE) + + let ffi_return = FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic(serverPublicParams.getInternalContentsForFFI(), UInt32(serverPublicParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), receiptSerial.getInternalContentsForFFI(), UInt32(receiptSerial.getInternalContentsForFFI().count), &newContents, UInt32(newContents.count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ReceiptCredentialRequestContext(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func receiveReceiptCredential(receiptCredentialRequestContext: ReceiptCredentialRequestContext, receiptCredentialResponse: ReceiptCredentialResponse) throws -> ReceiptCredential { + var newContents: [UInt8] = Array(repeating: 0, count: ReceiptCredential.SIZE) + + let ffi_return = FFI_ServerPublicParams_receiveReceiptCredential(serverPublicParams.getInternalContentsForFFI(), UInt32(serverPublicParams.getInternalContentsForFFI().count), receiptCredentialRequestContext.getInternalContentsForFFI(), UInt32(receiptCredentialRequestContext.getInternalContentsForFFI().count), receiptCredentialResponse.getInternalContentsForFFI(), UInt32(receiptCredentialResponse.getInternalContentsForFFI().count), &newContents, UInt32(newContents.count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ReceiptCredential(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func createReceiptCredentialPresentation(receiptCredential: ReceiptCredential) throws -> ReceiptCredentialPresentation { + var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) + let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) + guard result == errSecSuccess else { + throw ZkGroupException.AssertionError + } + + return try createReceiptCredentialPresentation(randomness: randomness, receiptCredential: receiptCredential) + } + + public func createReceiptCredentialPresentation(randomness: [UInt8], receiptCredential: ReceiptCredential) throws -> ReceiptCredentialPresentation { + var newContents: [UInt8] = Array(repeating: 0, count: ReceiptCredentialPresentation.SIZE) + + let ffi_return = FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic(serverPublicParams.getInternalContentsForFFI(), UInt32(serverPublicParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), receiptCredential.getInternalContentsForFFI(), UInt32(receiptCredential.getInternalContentsForFFI().count), &newContents, UInt32(newContents.count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ReceiptCredentialPresentation(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift new file mode 100644 index 0000000..71a6900 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift @@ -0,0 +1,55 @@ +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class ServerZkReceiptOperations { + + let serverSecretParams: ServerSecretParams + + public init(serverSecretParams: ServerSecretParams) { + self.serverSecretParams = serverSecretParams + } + + public func issueReceiptCredential(receiptCredentialRequest: ReceiptCredentialRequest, receiptExpirationTime: UInt64, receiptLevel: UInt64) throws -> ReceiptCredentialResponse { + var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) + let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) + guard result == errSecSuccess else { + throw ZkGroupException.AssertionError + } + + return try issueReceiptCredential(randomness: randomness, receiptCredentialRequest: receiptCredentialRequest, receiptExpirationTime: receiptExpirationTime, receiptLevel: receiptLevel) + } + + public func issueReceiptCredential(randomness: [UInt8], receiptCredentialRequest: ReceiptCredentialRequest, receiptExpirationTime: Uint64, receiptLevel: Uint64) throws -> ReceiptCredentialResponse { + var newContents: [UInt8] = Array(repeating: 0, count: ReceiptCredentialResponse.SIZE) + + let ffi_return = FFI_ServerSecretParams_issueReceiptCredentialDeterministic(serverSecretParams.getInternalContentsForFFI(), UInt32(serverSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), receiptCredentialRequest.getInternalContentsForFFI(), UInt32(receiptCredentialRequest.getInternalContentsForFFI().count), receiptExpirationTime, receiptLevel, &newContents, UInt32(newContents.count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ReceiptCredentialResponse(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func verifyReceiptCredentialPresentation(receiptCredentialPresentation: ReceiptCredentialPresentation) throws { + let ffi_return = FFI_ServerSecretParams_verifyReceiptCredentialPresentation(serverSecretParams.getInternalContentsForFFI(), UInt32(serverSecretParams.getInternalContentsForFFI().count), receiptCredentialPresentation.getInternalContentsForFFI(), UInt32(receiptCredentialPresentation.getInternalContentsForFFI().count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + +} diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index 2b398ff..a869a5b 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -685,6 +685,128 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialPresentationD } } +#[no_mangle] +pub extern "C" fn FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic( + serverPublicParams: *const u8, + serverPublicParamsLen: u32, + randomness: *const u8, + randomnessLen: u32, + receiptSerial: *const u8, + receiptSerialLen: u32, + receiptCredentialRequestContextOut: *mut u8, + receiptCredentialRequestContextLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params: &[u8] = + unsafe { slice::from_raw_parts(serverPublicParams, serverPublicParamsLen as usize) }; + let randomness: &[u8] = + unsafe { slice::from_raw_parts(randomness, randomnessLen as usize) }; + let receipt_serial: &[u8] = + unsafe { slice::from_raw_parts(receiptSerial, receiptSerialLen as usize) }; + let receipt_credential_request_context: &mut [u8] = unsafe { + slice::from_raw_parts_mut( + receiptCredentialRequestContextOut, + receiptCredentialRequestContextLen as usize, + ) + }; + + simpleapi::ServerPublicParams_createReceiptCredentialRequestContextDeterministic( + server_public_params, + randomness, + receipt_serial, + receipt_credential_request_context, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ServerPublicParams_receiveReceiptCredential( + serverPublicParams: *const u8, + serverPublicParamsLen: u32, + receiptCredentialRequestContext: *const u8, + receiptCredentialRequestContextLen: u32, + receiptCredentialResponse: *const u8, + receiptCredentialResponseLen: u32, + receiptCredentialOut: *mut u8, + receiptCredentialLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params: &[u8] = + unsafe { slice::from_raw_parts(serverPublicParams, serverPublicParamsLen as usize) }; + let receipt_credential_request_context: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialRequestContext, + receiptCredentialRequestContextLen as usize, + ) + }; + let receipt_credential_response: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialResponse, + receiptCredentialResponseLen as usize, + ) + }; + let receipt_credential: &mut [u8] = unsafe { + slice::from_raw_parts_mut(receiptCredentialOut, receiptCredentialLen as usize) + }; + + simpleapi::ServerPublicParams_receiveReceiptCredential( + server_public_params, + receipt_credential_request_context, + receipt_credential_response, + receipt_credential, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic( + serverPublicParams: *const u8, + serverPublicParamsLen: u32, + randomness: *const u8, + randomnessLen: u32, + receiptCredential: *const u8, + receiptCredentialLen: u32, + receiptCredentialPresentationOut: *mut u8, + receiptCredentialPresentationLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params: &[u8] = + unsafe { slice::from_raw_parts(serverPublicParams, serverPublicParamsLen as usize) }; + let randomness: &[u8] = + unsafe { slice::from_raw_parts(randomness, randomnessLen as usize) }; + let receipt_credential: &[u8] = + unsafe { slice::from_raw_parts(receiptCredential, receiptCredentialLen as usize) }; + let receipt_credential_presentation: &mut [u8] = unsafe { + slice::from_raw_parts_mut( + receiptCredentialPresentationOut, + receiptCredentialPresentationLen as usize, + ) + }; + + simpleapi::ServerPublicParams_createReceiptCredentialPresentationDeterministic( + server_public_params, + randomness, + receipt_credential, + receipt_credential_presentation, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ServerSecretParams_issueAuthCredentialDeterministic( serverSecretParams: *const u8, @@ -847,6 +969,84 @@ pub extern "C" fn FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation( } } +#[no_mangle] +pub extern "C" fn FFI_ServerSecretParams_issueReceiptCredentialDeterministic( + serverSecretParams: *const u8, + serverSecretParamsLen: u32, + randomness: *const u8, + randomnessLen: u32, + receiptCredentialRequest: *const u8, + receiptCredentialRequestLen: u32, + receiptExpirationTime: u64, + receiptLevel: u64, + receiptCredentialResponseOut: *mut u8, + receiptCredentialResponseLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params: &[u8] = + unsafe { slice::from_raw_parts(serverSecretParams, serverSecretParamsLen as usize) }; + let randomness: &[u8] = + unsafe { slice::from_raw_parts(randomness, randomnessLen as usize) }; + let receipt_credential_request: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialRequest, + receiptCredentialRequestLen as usize, + ) + }; + let receipt_expiration_time = receiptExpirationTime as u64; + let receipt_level = receiptLevel as u64; + let receipt_credential_response: &mut [u8] = unsafe { + slice::from_raw_parts_mut( + receiptCredentialResponseOut, + receiptCredentialResponseLen as usize, + ) + }; + + simpleapi::ServerSecretParams_issueReceiptCredentialDeterministic( + server_secret_params, + randomness, + receipt_credential_request, + receipt_expiration_time, + receipt_level, + receipt_credential_response, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ServerSecretParams_verifyReceiptCredentialPresentation( + serverSecretParams: *const u8, + serverSecretParamsLen: u32, + receiptCredentialPresentation: *const u8, + receiptCredentialPresentationLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params: &[u8] = + unsafe { slice::from_raw_parts(serverSecretParams, serverSecretParamsLen as usize) }; + let receipt_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialPresentation, + receiptCredentialPresentationLen as usize, + ) + }; + + simpleapi::ServerSecretParams_verifyReceiptCredentialPresentation( + server_secret_params, + receipt_credential_presentation, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_GroupPublicParams_checkValidContents( groupPublicParams: *const u8, diff --git a/rust/src/ffi/ffiapijava.rs b/rust/src/ffi/ffiapijava.rs index 356cf21..4e42cf3 100644 --- a/rust/src/ffi/ffiapijava.rs +++ b/rust/src/ffi/ffiapijava.rs @@ -18,6 +18,7 @@ extern crate jni; use super::simpleapi; use jni::sys::jint; +use jni::sys::jlong; // This is the interface to the JVM that we'll // call the majority of our methods on. @@ -841,6 +842,137 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParam } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsCreateReceiptCredentialRequestContextDeterministicJNI( + env: JNIEnv, + _class: JClass, + serverPublicParams: jbyteArray, + randomness: jbyteArray, + receiptSerial: jbyteArray, + receiptCredentialRequestContextOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params = env.convert_byte_array(serverPublicParams).unwrap(); + let randomness = env.convert_byte_array(randomness).unwrap(); + let receipt_serial = env.convert_byte_array(receiptSerial).unwrap(); + let mut receipt_credential_request_context: Vec = vec![ + 0; + env.get_array_length(receiptCredentialRequestContextOut) + .unwrap() + as usize + ]; + + let ffi_return = + simpleapi::ServerPublicParams_createReceiptCredentialRequestContextDeterministic( + &server_public_params, + &randomness, + &receipt_serial, + &mut receipt_credential_request_context, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + receiptCredentialRequestContextOut, + 0, + &u8toi8(receipt_credential_request_context)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsReceiveReceiptCredentialJNI( + env: JNIEnv, + _class: JClass, + serverPublicParams: jbyteArray, + receiptCredentialRequestContext: jbyteArray, + receiptCredentialResponse: jbyteArray, + receiptCredentialOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params = env.convert_byte_array(serverPublicParams).unwrap(); + let receipt_credential_request_context = env + .convert_byte_array(receiptCredentialRequestContext) + .unwrap(); + let receipt_credential_response = + env.convert_byte_array(receiptCredentialResponse).unwrap(); + let mut receipt_credential: Vec = + vec![0; env.get_array_length(receiptCredentialOut).unwrap() as usize]; + + let ffi_return = simpleapi::ServerPublicParams_receiveReceiptCredential( + &server_public_params, + &receipt_credential_request_context, + &receipt_credential_response, + &mut receipt_credential, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region(receiptCredentialOut, 0, &u8toi8(receipt_credential)[..]) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsCreateReceiptCredentialPresentationDeterministicJNI( + env: JNIEnv, + _class: JClass, + serverPublicParams: jbyteArray, + randomness: jbyteArray, + receiptCredential: jbyteArray, + receiptCredentialPresentationOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params = env.convert_byte_array(serverPublicParams).unwrap(); + let randomness = env.convert_byte_array(randomness).unwrap(); + let receipt_credential = env.convert_byte_array(receiptCredential).unwrap(); + let mut receipt_credential_presentation: Vec = vec![ + 0; + env.get_array_length(receiptCredentialPresentationOut) + .unwrap() as usize + ]; + + let ffi_return = + simpleapi::ServerPublicParams_createReceiptCredentialPresentationDeterministic( + &server_public_params, + &randomness, + &receipt_credential, + &mut receipt_credential_presentation, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + receiptCredentialPresentationOut, + 0, + &u8toi8(receipt_credential_presentation)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParamsIssueAuthCredentialDeterministicJNI( env: JNIEnv, @@ -999,6 +1131,82 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParam } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParamsIssueReceiptCredentialDeterministicJNI( + env: JNIEnv, + _class: JClass, + serverSecretParams: jbyteArray, + randomness: jbyteArray, + receiptCredentialRequest: jbyteArray, + receiptExpirationTime: jlong, + receiptLevel: jlong, + receiptCredentialResponseOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params = env.convert_byte_array(serverSecretParams).unwrap(); + let randomness = env.convert_byte_array(randomness).unwrap(); + let receipt_credential_request = env.convert_byte_array(receiptCredentialRequest).unwrap(); + let receipt_expiration_time = receiptExpirationTime as u64; + let receipt_level = receiptLevel as u64; + let mut receipt_credential_response: Vec = + vec![0; env.get_array_length(receiptCredentialResponseOut).unwrap() as usize]; + + let ffi_return = simpleapi::ServerSecretParams_issueReceiptCredentialDeterministic( + &server_secret_params, + &randomness, + &receipt_credential_request, + receipt_expiration_time, + receipt_level, + &mut receipt_credential_response, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + receiptCredentialResponseOut, + 0, + &u8toi8(receipt_credential_response)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParamsVerifyReceiptCredentialPresentationJNI( + env: JNIEnv, + _class: JClass, + serverSecretParams: jbyteArray, + receiptCredentialPresentation: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params = env.convert_byte_array(serverSecretParams).unwrap(); + let receipt_credential_presentation = env + .convert_byte_array(receiptCredentialPresentation) + .unwrap(); + + let ffi_return = simpleapi::ServerSecretParams_verifyReceiptCredentialPresentation( + &server_secret_params, + &receipt_credential_presentation, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_groupPublicParamsCheckValidContentsJNI( env: JNIEnv, diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index d2db7db..1c1f802 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -514,6 +514,98 @@ pub fn ServerPublicParams_createProfileKeyCredentialPresentationDeterministic( FFI_RETURN_OK } +pub fn ServerPublicParams_createReceiptCredentialRequestContextDeterministic( + serverPublicParamsIn: &[u8], + randomnessIn: &[u8], + receiptSerialIn: &[u8], + receiptCredentialRequestContextOut: &mut [u8], +) -> i32 { + let server_public_params: api::ServerPublicParams = + match bincode::deserialize(serverPublicParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let randomness: simple_types::RandomnessBytes = match bincode::deserialize(randomnessIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let receipt_serial: simple_types::ReceiptSerialBytes = + match bincode::deserialize(receiptSerialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let receipt_credential_request_context = + server_public_params.create_receipt_credential_request_context(randomness, receipt_serial); + receiptCredentialRequestContextOut + .copy_from_slice(&bincode::serialize(&receipt_credential_request_context).unwrap()); + FFI_RETURN_OK +} + +pub fn ServerPublicParams_receiveReceiptCredential( + serverPublicParamsIn: &[u8], + receiptCredentialRequestContextIn: &[u8], + receiptCredentialResponseIn: &[u8], + receiptCredentialOut: &mut [u8], +) -> i32 { + let server_public_params: api::ServerPublicParams = + match bincode::deserialize(serverPublicParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let receipt_credential_request_context: api::receipts::ReceiptCredentialRequestContext = + match bincode::deserialize(receiptCredentialRequestContextIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let receipt_credential_response: api::receipts::ReceiptCredentialResponse = + match bincode::deserialize(receiptCredentialResponseIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let receipt_credential = match server_public_params.receive_receipt_credential( + &receipt_credential_request_context, + &receipt_credential_response, + ) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + receiptCredentialOut.copy_from_slice(&bincode::serialize(&receipt_credential).unwrap()); + FFI_RETURN_OK +} + +pub fn ServerPublicParams_createReceiptCredentialPresentationDeterministic( + serverPublicParamsIn: &[u8], + randomnessIn: &[u8], + receiptCredentialIn: &[u8], + receiptCredentialPresentationOut: &mut [u8], +) -> i32 { + let server_public_params: api::ServerPublicParams = + match bincode::deserialize(serverPublicParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let randomness: simple_types::RandomnessBytes = match bincode::deserialize(randomnessIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let receipt_credential: api::receipts::ReceiptCredential = + match bincode::deserialize(receiptCredentialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let receipt_credential_presentation = server_public_params + .create_receipt_credential_presentation(randomness, &receipt_credential); + receiptCredentialPresentationOut + .copy_from_slice(&bincode::serialize(&receipt_credential_presentation).unwrap()); + FFI_RETURN_OK +} + pub fn ServerSecretParams_issueAuthCredentialDeterministic( serverSecretParamsIn: &[u8], randomnessIn: &[u8], @@ -656,6 +748,67 @@ pub fn ServerSecretParams_verifyProfileKeyCredentialPresentation( FFI_RETURN_OK } +pub fn ServerSecretParams_issueReceiptCredentialDeterministic( + serverSecretParamsIn: &[u8], + randomnessIn: &[u8], + receiptCredentialRequestIn: &[u8], + receiptExpirationTimeIn: u64, + receiptLevelIn: u64, + receiptCredentialResponseOut: &mut [u8], +) -> i32 { + let server_secret_params: api::ServerSecretParams = + match bincode::deserialize(serverSecretParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let randomness: simple_types::RandomnessBytes = match bincode::deserialize(randomnessIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let receipt_credential_request: api::receipts::ReceiptCredentialRequest = + match bincode::deserialize(receiptCredentialRequestIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let receipt_expiration_time = receiptExpirationTimeIn; + let receipt_level = receiptLevelIn; + let receipt_credential_response = server_secret_params.issue_receipt_credential( + randomness, + &receipt_credential_request, + receipt_expiration_time, + receipt_level, + ); + receiptCredentialResponseOut + .copy_from_slice(&bincode::serialize(&receipt_credential_response).unwrap()); + FFI_RETURN_OK +} + +pub fn ServerSecretParams_verifyReceiptCredentialPresentation( + serverSecretParamsIn: &[u8], + receiptCredentialPresentationIn: &[u8], +) -> i32 { + let server_secret_params: api::ServerSecretParams = + match bincode::deserialize(serverSecretParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let receipt_credential_presentation: api::receipts::ReceiptCredentialPresentation = + match bincode::deserialize(receiptCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + match server_secret_params + .verify_receipt_credential_presentation(&receipt_credential_presentation) + { + Ok(_) => (), + Err(_) => return FFI_RETURN_INPUT_ERROR, + } + FFI_RETURN_OK +} + pub fn GroupPublicParams_checkValidContents(groupPublicParamsIn: &[u8]) -> i32 { let _: api::groups::GroupPublicParams = match bincode::deserialize(groupPublicParamsIn) { Ok(result) => result, From 3df179693f30fae03f032d8d629882a213a18d54 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 22 Sep 2021 16:48:17 -0500 Subject: [PATCH 46/69] Fix Dockerfile for rust-toolchain file change --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fdef1fa..f609bab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ ENV SHELL /bin/bash WORKDIR /home/zkgroup # Rust setup... -COPY rust-toolchain rust-toolchain +COPY rust-toolchain.toml rust-toolchain.toml ARG RUST_TOOLCHAIN_SHA=ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b ARG CARGO_NDK_VERSION=1.0.0 ENV PATH="/home/zkgroup/.cargo/bin:${PATH}" From e84cb90c5762421da786bda7cc25cdeeb8891ffc Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 22 Sep 2021 17:38:35 -0500 Subject: [PATCH 47/69] Create ReceiptSerial class --- codegen/codegen.py | 6 ++--- .../zkgroup/receipts/ReceiptSerial.java | 27 +++++++++++++++++++ ffi/swift/Sources/ZKGroup/ReceiptSerial.swift | 24 +++++++++++++++++ rust/src/ffi/ffiapi.rs | 18 ------------- rust/src/ffi/ffiapijava.rs | 22 --------------- rust/src/ffi/simpleapi.rs | 9 ------- 6 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java create mode 100644 ffi/swift/Sources/ZKGroup/ReceiptSerial.swift diff --git a/codegen/codegen.py b/codegen/codegen.py index 77013a0..c18303c 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -105,6 +105,9 @@ def define_classes(): c = ClassDescriptor("notary_signature", "", "simple_types::NotarySignatureBytes", 64, check_valid_contents=False) classes.append(c) + c = ClassDescriptor("receipt_serial", "receipts", "simple_types::ReceiptSerialBytes", 16, check_valid_contents=False) + classes.append(c) + c = ClassDescriptor("profile_key", "profiles", "api::profiles::ProfileKey", 32, check_valid_contents=False) c.add_method("get_commitment", "class", "profile_key_commitment", [("UUID", "uuid")], """ let profile_key_commitment = profile_key.get_commitment(uuid);"""); @@ -361,9 +364,6 @@ def define_classes(): c = ClassDescriptor("uuid", "", "simple_types::UidBytes", 32, no_class=True) classes.append(c) - c = ClassDescriptor("receipt_serial", "receipts", "simple_types::ReceiptSerialBytes", 16, no_class=True) - classes.append(c) - return classes diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java new file mode 100644 index 0000000..65ecb7e --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptSerial.java @@ -0,0 +1,27 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.receipts; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.internal.ByteArray; + +public final class ReceiptSerial extends ByteArray { + + public static final int SIZE = 16; + + public ReceiptSerial(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift b/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift new file mode 100644 index 0000000..c6555c6 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/ReceiptSerial.swift @@ -0,0 +1,24 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + + + +public class ReceiptSerial : ByteArray { + + public static let SIZE: Int = 16 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: ReceiptSerial.SIZE) + + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index a869a5b..11f34fb 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -1663,21 +1663,3 @@ pub extern "C" fn FFI_Uuid_checkValidContents(uuid: *const u8, uuidLen: u32) -> Err(_) => FFI_RETURN_INTERNAL_ERROR, } } - -#[no_mangle] -pub extern "C" fn FFI_ReceiptSerial_checkValidContents( - receiptSerial: *const u8, - receiptSerialLen: u32, -) -> i32 { - let result = panic::catch_unwind(|| { - let receipt_serial: &[u8] = - unsafe { slice::from_raw_parts(receiptSerial, receiptSerialLen as usize) }; - - simpleapi::ReceiptSerial_checkValidContents(receipt_serial) - }); - - match result { - Ok(result) => result, - Err(_) => FFI_RETURN_INTERNAL_ERROR, - } -} diff --git a/rust/src/ffi/ffiapijava.rs b/rust/src/ffi/ffiapijava.rs index 4e42cf3..dc314c9 100644 --- a/rust/src/ffi/ffiapijava.rs +++ b/rust/src/ffi/ffiapijava.rs @@ -1927,25 +1927,3 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_uuidCheckValidCon Err(_) => FFI_RETURN_INTERNAL_ERROR, } } - -#[no_mangle] -pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptSerialCheckValidContentsJNI( - env: JNIEnv, - _class: JClass, - receiptSerial: jbyteArray, -) -> i32 { - let result = panic::catch_unwind(|| { - let receipt_serial = env.convert_byte_array(receiptSerial).unwrap(); - - let ffi_return = simpleapi::ReceiptSerial_checkValidContents(&receipt_serial); - if ffi_return != FFI_RETURN_OK { - return ffi_return; - } - FFI_RETURN_OK - }); - - match result { - Ok(result) => result, - Err(_) => FFI_RETURN_INTERNAL_ERROR, - } -} diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index 1c1f802..6b9d9ee 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -1120,12 +1120,3 @@ pub fn Uuid_checkValidContents(uuidIn: &[u8]) -> i32 { FFI_RETURN_OK } - -pub fn ReceiptSerial_checkValidContents(receiptSerialIn: &[u8]) -> i32 { - let _: simple_types::ReceiptSerialBytes = match bincode::deserialize(receiptSerialIn) { - Ok(result) => result, - Err(_) => return FFI_RETURN_INPUT_ERROR, - }; - - FFI_RETURN_OK -} From 27ba04d7874e164d8e4c6ea26111ac4d94101ec9 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 22 Sep 2021 17:39:56 -0500 Subject: [PATCH 48/69] Update rustup in the Dockerfile --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f609bab..72a91fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,15 +44,17 @@ WORKDIR /home/zkgroup # Rust setup... COPY rust-toolchain.toml rust-toolchain.toml -ARG RUST_TOOLCHAIN_SHA=ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b +ARG RUSTUP_SHA256=3dc5ef50861ee18657f9db2eeb7392f9c2a6c95c90ab41e45ab4ca71476b4338 ARG CARGO_NDK_VERSION=1.0.0 ENV PATH="/home/zkgroup/.cargo/bin:${PATH}" -RUN curl -f https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-unknown-linux-gnu/rustup-init -o /tmp/rustup-init \ - && echo "${RUST_TOOLCHAIN_SHA} /tmp/rustup-init" | sha256sum -c - \ +RUN curl -f https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-unknown-linux-gnu/rustup-init -o /tmp/rustup-init \ + && echo "${RUSTUP_SHA256} /tmp/rustup-init" | sha256sum -c - \ && chmod a+x /tmp/rustup-init \ - && /tmp/rustup-init -y --profile minimal --default-toolchain "$(cat rust-toolchain)" \ + && /tmp/rustup-init -y --profile default --default-toolchain nightly-2021-09-19 \ && rm -rf /tmp/rustup-init \ + && rustup component add rust-src \ + && rustup target add aarch64-apple-darwin aarch64-apple-ios aarch64-apple-ios-sim aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-apple-darwin x86_64-apple-ios x86_64-linux-android x86_64-unknown-linux-gnu \ && rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android \ && cargo install --version ${CARGO_NDK_VERSION} cargo-ndk From 1bdcdf530bb2e2ef397370dae186e296d5cbfdcd Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 22 Sep 2021 17:47:26 -0500 Subject: [PATCH 49/69] Fix rustup toolchain for macos build --- .github/workflows/tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0e7232f..9125a57 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -72,13 +72,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - profile: minimal - - - name: Add iOS targets - run: rustup target add aarch64-apple-ios x86_64-apple-ios - - - name: Add rust-src component - run: rustup component add rust-src + toolchain: nightly-2021-09-19 - name: Run pod lint # No import validation because it tries to build unsupported platforms (like 32-bit iOS). From 40b603c5055a5a52a82f17ec1476f5f52facad83 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 11:41:51 -0500 Subject: [PATCH 50/69] No need for toolchain action with rust-toolchain.toml --- .github/workflows/tests.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9125a57..5dce187 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -69,10 +69,8 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly-2021-09-19 + - name: Setup rust toolchain + run: rustup show - name: Run pod lint # No import validation because it tries to build unsupported platforms (like 32-bit iOS). From 3c5dc57af2419152a81b0290e997a599d7427984 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 11:58:57 -0500 Subject: [PATCH 51/69] Update cbindgen output --- ffi/c/Makefile | 10 +- ffi/c/main.c | 22 --- ffi/c/zkgroup.h | 490 +++++++++++++++++++++++++++--------------------- 3 files changed, 282 insertions(+), 240 deletions(-) delete mode 100644 ffi/c/main.c diff --git a/ffi/c/Makefile b/ffi/c/Makefile index cf0e956..1c0e2cc 100644 --- a/ffi/c/Makefile +++ b/ffi/c/Makefile @@ -1,9 +1,3 @@ - -.PHONY: ctest -.PHONY: zkgroup.h - -ctest: - gcc main.c ../../target/release/libzkgroup.a -o ctest -ldl -lpthread -lm - +.PHONY: zkgroup.h zkgroup.h: - cbindgen --lang c ../.. -o zkgroup.h + cbindgen --lang c ../../rust -o zkgroup.h diff --git a/ffi/c/main.c b/ffi/c/main.c deleted file mode 100644 index 666d1e2..0000000 --- a/ffi/c/main.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "zkgroup.h" -#include - - -int main() { - - unsigned char testbufi[] = {0,1,2}; - unsigned char testbufo[] = {0,0,0}; - zktestfunc(testbufi, 3, testbufo, 3); - printf("Result (should be 1 2 3) = %d %d %d\n", testbufo[0], testbufo[1], testbufo[2]); - - unsigned char clientkeypair[CLIENT_KEY_PAIR_LEN]; - unsigned char serverkeypair[SERVER_KEY_PAIR_LEN]; - unsigned char randomness[RANDOMNESS_LEN]; - ClientKeyPair_derive(randomness, 32, clientkeypair, CLIENT_KEY_PAIR_LEN); - ServerKeyPair_generate(randomness, 32, serverkeypair, SERVER_KEY_PAIR_LEN); - - unsigned char clientpublickey[CLIENT_PUBLIC_KEY_LEN]; - unsigned char serverpublickey[SERVER_PUBLIC_KEY_LEN]; - ClientKeyPair_getPublicKey(clientkeypair, CLIENT_KEY_PAIR_LEN, clientpublickey, CLIENT_PUBLIC_KEY_LEN); - ServerKeyPair_getPublicKey(serverkeypair, SERVER_KEY_PAIR_LEN, serverpublickey, SERVER_PUBLIC_KEY_LEN); -} diff --git a/ffi/c/zkgroup.h b/ffi/c/zkgroup.h index 2273096..45774dc 100644 --- a/ffi/c/zkgroup.h +++ b/ffi/c/zkgroup.h @@ -3,155 +3,114 @@ #include #include -#define AUTH_CREDENTIAL_LEN 372 +#define NUM_AUTH_CRED_ATTRIBUTES 3 -#define AUTH_CREDENTIAL_PRESENTATION_LEN 620 +#define NUM_PROFILE_KEY_CRED_ATTRIBUTES 4 -#define AUTH_CREDENTIAL_RESPONSE_LEN 392 +#define NUM_RECEIPT_CRED_ATTRIBUTES 2 -#define CLIENT_CREDENTIAL_MANAGER_LEN 256 +#define AES_KEY_LEN 32 -#define FFI_RETURN_INPUT_ERROR 2 - -#define FFI_RETURN_INTERNAL_ERROR 1 +#define AESGCM_NONCE_LEN 12 -#define FFI_RETURN_OK 0 - -#define GROUP_IDENTIFIER_LEN 32 +#define AESGCM_TAG_LEN 16 #define GROUP_MASTER_KEY_LEN 32 -#define GROUP_PUBLIC_PARAMS_LEN 128 +#define GROUP_SECRET_PARAMS_LEN 289 -#define GROUP_SECRET_PARAMS_LEN 320 +#define GROUP_PUBLIC_PARAMS_LEN 97 -#define MAX_CRED_ATTRIBUTES 5 +#define GROUP_IDENTIFIER_LEN 32 -#define PROFILE_KEY_CIPHERTEXT_LEN 64 +#define AUTH_CREDENTIAL_LEN 181 -#define PROFILE_KEY_COMMITMENT_LEN 64 +#define AUTH_CREDENTIAL_PRESENTATION_LEN 493 -#define PROFILE_KEY_CREDENTIAL_LEN 160 +#define AUTH_CREDENTIAL_RESPONSE_LEN 361 -#define PROFILE_KEY_CREDENTIAL_PRESENTATION_LEN 760 +#define PROFILE_KEY_LEN 32 -#define PROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN 360 +#define PROFILE_KEY_CIPHERTEXT_LEN 65 -#define PROFILE_KEY_CREDENTIAL_REQUEST_LEN 232 +#define PROFILE_KEY_COMMITMENT_LEN 97 -#define PROFILE_KEY_CREDENTIAL_RESPONSE_LEN 488 +#define PROFILE_KEY_CREDENTIAL_LEN 145 -#define PROFILE_KEY_HALF_LEN 16 +#define PROFILE_KEY_CREDENTIAL_PRESENTATION_LEN 713 -#define PROFILE_KEY_LEN 32 +#define PROFILE_KEY_CREDENTIAL_REQUEST_LEN 329 -#define PROFILE_KEY_VERSION_ENCODED_LEN 64 +#define PROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN 473 + +#define PROFILE_KEY_CREDENTIAL_RESPONSE_LEN 457 #define PROFILE_KEY_VERSION_LEN 32 -#define RANDOMNESS_LEN 32 +#define PROFILE_KEY_VERSION_ENCODED_LEN 64 -#define SERVER_PUBLIC_PARAMS_LEN 256 +#define RECEIPT_CREDENTIAL_LEN 129 -#define SERVER_SECRET_PARAMS_LEN 608 +#define RECEIPT_CREDENTIAL_PRESENTATION_LEN 329 -#define SIGNATURE_LEN 64 +#define RECEIPT_CREDENTIAL_REQUEST_LEN 97 -#define UUID_CIPHERTEXT_LEN 64 +#define RECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN 177 -#define UUID_LEN 16 +#define RECEIPT_CREDENTIAL_RESPONSE_LEN 409 -int32_t FFI_AuthCredentialPresentation_checkValidContents(const uint8_t *authCredentialPresentation, - uint32_t authCredentialPresentationLen); +#define RECEIPT_SERIAL_LEN 16 -int32_t FFI_AuthCredentialPresentation_getRedemptionTime(const uint8_t *authCredentialPresentation, - uint32_t authCredentialPresentationLen, - uint8_t *redemptionTimeOut, - uint32_t redemptionTimeLen); +#define RESERVED_LEN 1 -int32_t FFI_AuthCredentialPresentation_getUuidCiphertext(const uint8_t *authCredentialPresentation, - uint32_t authCredentialPresentationLen, - uint8_t *uuidCiphertextOut, - uint32_t uuidCiphertextLen); +#define SERVER_SECRET_PARAMS_LEN 1121 -int32_t FFI_AuthCredentialResponse_checkValidContents(const uint8_t *authCredentialResponse, - uint32_t authCredentialResponseLen); +#define SERVER_PUBLIC_PARAMS_LEN 225 -int32_t FFI_AuthCredential_checkValidContents(const uint8_t *authCredential, - uint32_t authCredentialLen); +#define UUID_CIPHERTEXT_LEN 65 -int32_t FFI_GroupPublicParams_checkValidContents(const uint8_t *groupPublicParams, - uint32_t groupPublicParamsLen); - -int32_t FFI_GroupPublicParams_getGroupIdentifier(const uint8_t *groupPublicParams, - uint32_t groupPublicParamsLen, - uint8_t *groupIdentifierOut, - uint32_t groupIdentifierLen); +#define RANDOMNESS_LEN 32 -int32_t FFI_GroupPublicParams_verifySignature(const uint8_t *groupPublicParams, - uint32_t groupPublicParamsLen, - const uint8_t *message, - uint32_t messageLen, - const uint8_t *changeSignature, - uint32_t changeSignatureLen); +#define SIGNATURE_LEN 64 -int32_t FFI_GroupSecretParams_checkValidContents(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen); +#define UUID_LEN 16 -int32_t FFI_GroupSecretParams_decryptBlob(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *blobCiphertext, - uint32_t blobCiphertextLen, - uint8_t *plaintextOut, - uint32_t plaintextLen); +#define FFI_RETURN_OK 0 -int32_t FFI_GroupSecretParams_decryptProfileKey(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *profileKeyCiphertext, - uint32_t profileKeyCiphertextLen, - uint8_t *profileKeyOut, - uint32_t profileKeyLen); +#define FFI_RETURN_INTERNAL_ERROR 1 -int32_t FFI_GroupSecretParams_decryptUuid(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *uuidCiphertext, - uint32_t uuidCiphertextLen, - uint8_t *uuidOut, - uint32_t uuidLen); +#define FFI_RETURN_INPUT_ERROR 2 -int32_t FFI_GroupSecretParams_deriveFromMasterKey(const uint8_t *groupMasterKey, - uint32_t groupMasterKeyLen, - uint8_t *groupSecretParamsOut, - uint32_t groupSecretParamsLen); +int32_t FFI_ProfileKey_getCommitment(const uint8_t *profileKey, + uint32_t profileKeyLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyCommitmentOut, + uint32_t profileKeyCommitmentLen); -int32_t FFI_GroupSecretParams_encryptBlob(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *plaintext, - uint32_t plaintextLen, - uint8_t *blobCiphertextOut, - uint32_t blobCiphertextLen); - -int32_t FFI_GroupSecretParams_encryptProfileKeyDeterministic(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *randomness, - uint32_t randomnessLen, - const uint8_t *profileKey, - uint32_t profileKeyLen, - uint8_t *profileKeyCiphertextOut, - uint32_t profileKeyCiphertextLen); +int32_t FFI_ProfileKey_getProfileKeyVersion(const uint8_t *profileKey, + uint32_t profileKeyLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyVersionOut, + uint32_t profileKeyVersionLen); -int32_t FFI_GroupSecretParams_encryptUuid(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *uuid, - uint32_t uuidLen, - uint8_t *uuidCiphertextOut, - uint32_t uuidCiphertextLen); +int32_t FFI_ProfileKeyCommitment_checkValidContents(const uint8_t *profileKeyCommitment, + uint32_t profileKeyCommitmentLen); int32_t FFI_GroupSecretParams_generateDeterministic(const uint8_t *randomness, uint32_t randomnessLen, uint8_t *groupSecretParamsOut, uint32_t groupSecretParamsLen); +int32_t FFI_GroupSecretParams_deriveFromMasterKey(const uint8_t *groupMasterKey, + uint32_t groupMasterKeyLen, + uint8_t *groupSecretParamsOut, + uint32_t groupSecretParamsLen); + +int32_t FFI_GroupSecretParams_checkValidContents(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen); + int32_t FFI_GroupSecretParams_getMasterKey(const uint8_t *groupSecretParams, uint32_t groupSecretParamsLen, uint8_t *groupMasterKeyOut, @@ -162,70 +121,85 @@ int32_t FFI_GroupSecretParams_getPublicParams(const uint8_t *groupSecretParams, uint8_t *groupPublicParamsOut, uint32_t groupPublicParamsLen); -int32_t FFI_GroupSecretParams_signDeterministic(const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *randomness, - uint32_t randomnessLen, - const uint8_t *message, - uint32_t messageLen, - uint8_t *changeSignatureOut, - uint32_t changeSignatureLen); - -int32_t FFI_ProfileKeyCiphertext_checkValidContents(const uint8_t *profileKeyCiphertext, - uint32_t profileKeyCiphertextLen); - -int32_t FFI_ProfileKeyCommitment_checkValidContents(const uint8_t *profileKeyCommitment, - uint32_t profileKeyCommitmentLen); - -int32_t FFI_ProfileKeyCommitment_getProfileKeyVersion(const uint8_t *profileKeyCommitment, - uint32_t profileKeyCommitmentLen, - uint8_t *profileKeyVersionOut, - uint32_t profileKeyVersionLen); - -int32_t FFI_ProfileKeyCredentialPresentation_checkValidContents(const uint8_t *profileKeyCredentialPresentation, - uint32_t profileKeyCredentialPresentationLen); - -int32_t FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext(const uint8_t *profileKeyCredentialPresentation, - uint32_t profileKeyCredentialPresentationLen, - uint8_t *profileKeyCiphertextOut, - uint32_t profileKeyCiphertextLen); +int32_t FFI_GroupSecretParams_encryptUuid(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); -int32_t FFI_ProfileKeyCredentialPresentation_getUuidCiphertext(const uint8_t *profileKeyCredentialPresentation, - uint32_t profileKeyCredentialPresentationLen, - uint8_t *uuidCiphertextOut, - uint32_t uuidCiphertextLen); +int32_t FFI_GroupSecretParams_decryptUuid(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *uuidCiphertext, + uint32_t uuidCiphertextLen, + uint8_t *uuidOut, + uint32_t uuidLen); -int32_t FFI_ProfileKeyCredentialRequestContext_checkValidContents(const uint8_t *profileKeyCredentialRequestContext, - uint32_t profileKeyCredentialRequestContextLen); +int32_t FFI_GroupSecretParams_encryptProfileKey(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *profileKey, + uint32_t profileKeyLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyCiphertextOut, + uint32_t profileKeyCiphertextLen); -int32_t FFI_ProfileKeyCredentialRequestContext_getRequest(const uint8_t *profileKeyCredentialRequestContext, - uint32_t profileKeyCredentialRequestContextLen, - uint8_t *profileKeyCredentialRequestOut, - uint32_t profileKeyCredentialRequestLen); +int32_t FFI_GroupSecretParams_decryptProfileKey(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *profileKeyCiphertext, + uint32_t profileKeyCiphertextLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint8_t *profileKeyOut, + uint32_t profileKeyLen); -int32_t FFI_ProfileKeyCredentialRequest_checkValidContents(const uint8_t *profileKeyCredentialRequest, - uint32_t profileKeyCredentialRequestLen); +int32_t FFI_GroupSecretParams_encryptBlobDeterministic(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *plaintext, + uint32_t plaintextLen, + uint8_t *blobCiphertextOut, + uint32_t blobCiphertextLen); -int32_t FFI_ProfileKeyCredentialResponse_checkValidContents(const uint8_t *profileKeyCredentialResponse, - uint32_t profileKeyCredentialResponseLen); +int32_t FFI_GroupSecretParams_decryptBlob(const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *blobCiphertext, + uint32_t blobCiphertextLen, + uint8_t *plaintextOut, + uint32_t plaintextLen); -int32_t FFI_ProfileKeyCredential_checkValidContents(const uint8_t *profileKeyCredential, - uint32_t profileKeyCredentialLen); +int32_t FFI_ServerSecretParams_generateDeterministic(const uint8_t *randomness, + uint32_t randomnessLen, + uint8_t *serverSecretParamsOut, + uint32_t serverSecretParamsLen); -int32_t FFI_ProfileKey_getCommitment(const uint8_t *profileKey, - uint32_t profileKeyLen, - uint8_t *profileKeyCommitmentOut, - uint32_t profileKeyCommitmentLen); +int32_t FFI_ServerSecretParams_checkValidContents(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen); -int32_t FFI_ProfileKey_getProfileKeyVersion(const uint8_t *profileKey, - uint32_t profileKeyLen, - uint8_t *profileKeyVersionOut, - uint32_t profileKeyVersionLen); +int32_t FFI_ServerSecretParams_getPublicParams(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + uint8_t *serverPublicParamsOut, + uint32_t serverPublicParamsLen); -int32_t FFI_Randomness_checkValidContents(const uint8_t *randomness, uint32_t randomnessLen); +int32_t FFI_ServerSecretParams_signDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *message, + uint32_t messageLen, + uint8_t *notarySignatureOut, + uint32_t notarySignatureLen); -int32_t FFI_ServerPublicParams_checkValidContents(const uint8_t *serverPublicParams, - uint32_t serverPublicParamsLen); +int32_t FFI_ServerPublicParams_receiveAuthCredential(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *uuid, + uint32_t uuidLen, + uint32_t redemptionTime, + const uint8_t *authCredentialResponse, + uint32_t authCredentialResponseLen, + uint8_t *authCredentialOut, + uint32_t authCredentialLen); int32_t FFI_ServerPublicParams_createAuthCredentialPresentationDeterministic(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, @@ -238,17 +212,6 @@ int32_t FFI_ServerPublicParams_createAuthCredentialPresentationDeterministic(con uint8_t *authCredentialPresentationOut, uint32_t authCredentialPresentationLen); -int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic(const uint8_t *serverPublicParams, - uint32_t serverPublicParamsLen, - const uint8_t *randomness, - uint32_t randomnessLen, - const uint8_t *groupSecretParams, - uint32_t groupSecretParamsLen, - const uint8_t *profileKeyCredential, - uint32_t profileKeyCredentialLen, - uint8_t *profileKeyCredentialPresentationOut, - uint32_t profileKeyCredentialPresentationLen); - int32_t FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *randomness, @@ -260,16 +223,6 @@ int32_t FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDetermini uint8_t *profileKeyCredentialRequestContextOut, uint32_t profileKeyCredentialRequestContextLen); -int32_t FFI_ServerPublicParams_receiveAuthCredential(const uint8_t *serverPublicParams, - uint32_t serverPublicParamsLen, - const uint8_t *uuid, - uint32_t uuidLen, - uint32_t redemptionTime, - const uint8_t *authCredentialResponse, - uint32_t authCredentialResponseLen, - uint8_t *authCredentialOut, - uint32_t authCredentialLen); - int32_t FFI_ServerPublicParams_receiveProfileKeyCredential(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *profileKeyCredentialRequestContext, @@ -279,25 +232,43 @@ int32_t FFI_ServerPublicParams_receiveProfileKeyCredential(const uint8_t *server uint8_t *profileKeyCredentialOut, uint32_t profileKeyCredentialLen); -int32_t FFI_ServerPublicParams_verifySignature(const uint8_t *serverPublicParams, - uint32_t serverPublicParamsLen, - const uint8_t *message, - uint32_t messageLen, - const uint8_t *notarySignature, - uint32_t notarySignatureLen); - -int32_t FFI_ServerSecretParams_checkValidContents(const uint8_t *serverSecretParams, - uint32_t serverSecretParamsLen); - -int32_t FFI_ServerSecretParams_generateDeterministic(const uint8_t *randomness, - uint32_t randomnessLen, - uint8_t *serverSecretParamsOut, - uint32_t serverSecretParamsLen); +int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *profileKeyCredential, + uint32_t profileKeyCredentialLen, + uint8_t *profileKeyCredentialPresentationOut, + uint32_t profileKeyCredentialPresentationLen); -int32_t FFI_ServerSecretParams_getPublicParams(const uint8_t *serverSecretParams, - uint32_t serverSecretParamsLen, - uint8_t *serverPublicParamsOut, - uint32_t serverPublicParamsLen); +int32_t FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *receiptSerial, + uint32_t receiptSerialLen, + uint8_t *receiptCredentialRequestContextOut, + uint32_t receiptCredentialRequestContextLen); + +int32_t FFI_ServerPublicParams_receiveReceiptCredential(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *receiptCredentialRequestContext, + uint32_t receiptCredentialRequestContextLen, + const uint8_t *receiptCredentialResponse, + uint32_t receiptCredentialResponseLen, + uint8_t *receiptCredentialOut, + uint32_t receiptCredentialLen); + +int32_t FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *receiptCredential, + uint32_t receiptCredentialLen, + uint8_t *receiptCredentialPresentationOut, + uint32_t receiptCredentialPresentationLen); int32_t FFI_ServerSecretParams_issueAuthCredentialDeterministic(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, @@ -309,6 +280,13 @@ int32_t FFI_ServerSecretParams_issueAuthCredentialDeterministic(const uint8_t *s uint8_t *authCredentialResponseOut, uint32_t authCredentialResponseLen); +int32_t FFI_ServerSecretParams_verifyAuthCredentialPresentation(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen, + const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen); + int32_t FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, const uint8_t *randomness, @@ -322,22 +300,6 @@ int32_t FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic(const uint uint8_t *profileKeyCredentialResponseOut, uint32_t profileKeyCredentialResponseLen); -int32_t FFI_ServerSecretParams_signDeterministic(const uint8_t *serverSecretParams, - uint32_t serverSecretParamsLen, - const uint8_t *randomness, - uint32_t randomnessLen, - const uint8_t *message, - uint32_t messageLen, - uint8_t *notarySignatureOut, - uint32_t notarySignatureLen); - -int32_t FFI_ServerSecretParams_verifyAuthCredentialPresentation(const uint8_t *serverSecretParams, - uint32_t serverSecretParamsLen, - const uint8_t *groupPublicParams, - uint32_t groupPublicParamsLen, - const uint8_t *authCredentialPresentation, - uint32_t authCredentialPresentationLen); - int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, const uint8_t *groupPublicParams, @@ -345,7 +307,115 @@ int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint const uint8_t *profileKeyCredentialPresentation, uint32_t profileKeyCredentialPresentationLen); +int32_t FFI_ServerSecretParams_issueReceiptCredentialDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *receiptCredentialRequest, + uint32_t receiptCredentialRequestLen, + uint64_t receiptExpirationTime, + uint64_t receiptLevel, + uint8_t *receiptCredentialResponseOut, + uint32_t receiptCredentialResponseLen); + +int32_t FFI_ServerSecretParams_verifyReceiptCredentialPresentation(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen); + +int32_t FFI_GroupPublicParams_checkValidContents(const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen); + +int32_t FFI_GroupPublicParams_getGroupIdentifier(const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen, + uint8_t *groupIdentifierOut, + uint32_t groupIdentifierLen); + +int32_t FFI_ServerPublicParams_checkValidContents(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen); + +int32_t FFI_ServerPublicParams_verifySignature(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *message, + uint32_t messageLen, + const uint8_t *notarySignature, + uint32_t notarySignatureLen); + +int32_t FFI_AuthCredentialResponse_checkValidContents(const uint8_t *authCredentialResponse, + uint32_t authCredentialResponseLen); + +int32_t FFI_AuthCredential_checkValidContents(const uint8_t *authCredential, + uint32_t authCredentialLen); + +int32_t FFI_AuthCredentialPresentation_checkValidContents(const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen); + +int32_t FFI_AuthCredentialPresentation_getUuidCiphertext(const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_AuthCredentialPresentation_getRedemptionTime(const uint8_t *authCredentialPresentation, + uint32_t authCredentialPresentationLen, + uint8_t *redemptionTimeOut, + uint32_t redemptionTimeLen); + +int32_t FFI_ProfileKeyCredentialRequestContext_checkValidContents(const uint8_t *profileKeyCredentialRequestContext, + uint32_t profileKeyCredentialRequestContextLen); + +int32_t FFI_ProfileKeyCredentialRequestContext_getRequest(const uint8_t *profileKeyCredentialRequestContext, + uint32_t profileKeyCredentialRequestContextLen, + uint8_t *profileKeyCredentialRequestOut, + uint32_t profileKeyCredentialRequestLen); + +int32_t FFI_ProfileKeyCredentialRequest_checkValidContents(const uint8_t *profileKeyCredentialRequest, + uint32_t profileKeyCredentialRequestLen); + +int32_t FFI_ProfileKeyCredentialResponse_checkValidContents(const uint8_t *profileKeyCredentialResponse, + uint32_t profileKeyCredentialResponseLen); + +int32_t FFI_ProfileKeyCredential_checkValidContents(const uint8_t *profileKeyCredential, + uint32_t profileKeyCredentialLen); + +int32_t FFI_ProfileKeyCredentialPresentation_checkValidContents(const uint8_t *profileKeyCredentialPresentation, + uint32_t profileKeyCredentialPresentationLen); + +int32_t FFI_ProfileKeyCredentialPresentation_getUuidCiphertext(const uint8_t *profileKeyCredentialPresentation, + uint32_t profileKeyCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext(const uint8_t *profileKeyCredentialPresentation, + uint32_t profileKeyCredentialPresentationLen, + uint8_t *profileKeyCiphertextOut, + uint32_t profileKeyCiphertextLen); + +int32_t FFI_ReceiptCredentialRequestContext_checkValidContents(const uint8_t *receiptCredentialRequestContext, + uint32_t receiptCredentialRequestContextLen); + +int32_t FFI_ReceiptCredentialRequestContext_getRequest(const uint8_t *receiptCredentialRequestContext, + uint32_t receiptCredentialRequestContextLen, + uint8_t *receiptCredentialRequestOut, + uint32_t receiptCredentialRequestLen); + +int32_t FFI_ReceiptCredentialRequest_checkValidContents(const uint8_t *receiptCredentialRequest, + uint32_t receiptCredentialRequestLen); + +int32_t FFI_ReceiptCredentialResponse_checkValidContents(const uint8_t *receiptCredentialResponse, + uint32_t receiptCredentialResponseLen); + +int32_t FFI_ReceiptCredential_checkValidContents(const uint8_t *receiptCredential, + uint32_t receiptCredentialLen); + +int32_t FFI_ReceiptCredentialPresentation_checkValidContents(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen); + int32_t FFI_UuidCiphertext_checkValidContents(const uint8_t *uuidCiphertext, uint32_t uuidCiphertextLen); +int32_t FFI_ProfileKeyCiphertext_checkValidContents(const uint8_t *profileKeyCiphertext, + uint32_t profileKeyCiphertextLen); + +int32_t FFI_Randomness_checkValidContents(const uint8_t *randomness, uint32_t randomnessLen); + int32_t FFI_Uuid_checkValidContents(const uint8_t *uuid, uint32_t uuidLen); From a701afbdcf96349628d7771d2fab3e4e66579ef2 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 12:02:40 -0500 Subject: [PATCH 52/69] Use .PHONY instead of FORCE rule --- ffi/node/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffi/node/Makefile b/ffi/node/Makefile index be72fa3..9652e11 100644 --- a/ffi/node/Makefile +++ b/ffi/node/Makefile @@ -31,14 +31,14 @@ clean: rm $(TARGET_LIB) rm -r node_modules -libzkgroup: FORCE +.PHONY: libzkgroup +libzkgroup: RUSTFLAGS=$(RUSTFLAGS) cargo build --manifest-path=$(ZKGROUP_RUST_DIR)/Cargo.toml --release rm -f $(TARGET_LIB) mv $(ZKGROUP_TARGET_DIR)/${CARGO_BUILD_TARGET}/release/$(SOURCE_LIB) $(TARGET_LIB) -test: FORCE +.PHONY: test +test: npm install npm run build npm test - -FORCE: From 4e43ca79161b9556208e5e73add7894e508eb73a Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 13:59:20 -0500 Subject: [PATCH 53/69] Add receipts to the typescript libraryx --- ffi/node/index.ts | 13 + ffi/node/package-lock.json | 1570 ++++++++++++++++- ffi/node/test/ZKGroup-test.ts | 27 + ffi/node/zkgroup/ServerPublicParams.ts | 2 +- ffi/node/zkgroup/ServerSecretParams.ts | 2 +- ffi/node/zkgroup/auth/AuthCredential.ts | 2 +- ffi/node/zkgroup/internal/Native.ts | 23 + .../receipts/ClientZkReceiptOperations.ts | 94 + .../zkgroup/receipts/ReceiptCredential.ts | 33 + .../receipts/ReceiptCredentialPresentation.ts | 33 + .../receipts/ReceiptCredentialRequest.ts | 33 + .../ReceiptCredentialRequestContext.ts | 46 + .../receipts/ReceiptCredentialResponse.ts | 33 + ffi/node/zkgroup/receipts/ReceiptSerial.ts | 20 + .../receipts/ServerZkReceiptOperations.ts | 74 + 15 files changed, 2001 insertions(+), 4 deletions(-) create mode 100644 ffi/node/zkgroup/receipts/ClientZkReceiptOperations.ts create mode 100644 ffi/node/zkgroup/receipts/ReceiptCredential.ts create mode 100644 ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts create mode 100644 ffi/node/zkgroup/receipts/ReceiptCredentialRequest.ts create mode 100644 ffi/node/zkgroup/receipts/ReceiptCredentialRequestContext.ts create mode 100644 ffi/node/zkgroup/receipts/ReceiptCredentialResponse.ts create mode 100644 ffi/node/zkgroup/receipts/ReceiptSerial.ts create mode 100644 ffi/node/zkgroup/receipts/ServerZkReceiptOperations.ts diff --git a/ffi/node/index.ts b/ffi/node/index.ts index d0edc7b..fa79805 100644 --- a/ffi/node/index.ts +++ b/ffi/node/index.ts @@ -1,4 +1,6 @@ // Root +import exp = require("constants"); + export { default as ServerPublicParams } from './zkgroup/ServerPublicParams'; export { default as ServerSecretParams } from './zkgroup/ServerSecretParams'; @@ -39,3 +41,14 @@ export { default as ProfileKeyCredentialRequest } from './zkgroup/profiles/Profi export { default as ProfileKeyCredentialRequestContext } from './zkgroup/profiles/ProfileKeyCredentialRequestContext'; export { default as ProfileKeyCredentialResponse } from './zkgroup/profiles/ProfileKeyCredentialResponse'; export { default as ProfileKeyVersion } from './zkgroup/profiles/ProfileKeyVersion'; + +// Receipts +export { default as ClientZkReceiptOperations } from './zkgroup/receipts/ClientZkReceiptOperations'; +export { default as ServerZkReceiptOperations } from './zkgroup/receipts/ServerZkReceiptOperations'; + +export { default as ReceiptCredential } from './zkgroup/receipts/ReceiptCredential'; +export { default as ReceiptCredentialPresentation } from './zkgroup/receipts/ReceiptCredentialPresentation'; +export { default as ReceiptCredentialRequest } from './zkgroup/receipts/ReceiptCredentialRequest'; +export { default as ReceiptCredentialRequestContext } from './zkgroup/receipts/ReceiptCredentialRequestContext'; +export { default as ReceiptCredentialResponse } from './zkgroup/receipts/ReceiptCredentialResponse'; +export { default as ReceiptSerial } from './zkgroup/receipts/ReceiptSerial' diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 38afb8e..1311835 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,8 +1,1576 @@ { "name": "zkgroup", "version": "0.8.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "zkgroup", + "version": "0.8.0", + "license": "ISC", + "dependencies": { + "@types/ffi-napi": "^4.0.1", + "@types/ref-napi": "^3.0.1", + "ffi-napi": "4.0.3", + "ref-array-napi": "1.2.2", + "ref-napi": "3.0.3" + }, + "devDependencies": { + "@types/chai": "4.2.7", + "@types/mocha": "5.2.7", + "@types/node": "13.1.8", + "chai": "4.2.0", + "mocha": "7.1.1", + "rimraf": "3.0.1", + "typescript": "3.7.4" + } + }, + "node_modules/@types/chai": { + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.7.tgz", + "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", + "dev": true + }, + "node_modules/@types/ffi-napi": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/ffi-napi/-/ffi-napi-4.0.1.tgz", + "integrity": "sha512-UOzFWt8jCQRo07WmiPbnEeMI5gfvisokMP3M751clxG3WRQb6+0shWLR0NI8Mqq/0l1zYA1ZPwOaN7H/O2vDlQ==", + "dependencies": { + "@types/node": "*", + "@types/ref-napi": "*", + "@types/ref-struct-di": "*" + } + }, + "node_modules/@types/mocha": { + "version": "5.2.7", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz", + "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==", + "dev": true + }, + "node_modules/@types/node": { + "version": "13.1.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.8.tgz", + "integrity": "sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A==" + }, + "node_modules/@types/ref-napi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/ref-napi/-/ref-napi-3.0.1.tgz", + "integrity": "sha512-tBRp8JLW0IoXiqP8bRoArlfXB84JSKkLvVfCNdQGSgBPOAKvhmgW7mjVCDyxypiUMR0RXwHsu6hZlPpunKEPzg==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/ref-struct-di": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/ref-struct-di/-/ref-struct-di-1.1.3.tgz", + "integrity": "sha512-OdsiCc10hByKZ27R8Bd+09EhiciuD6V9eAn+RjiLNx0YJum8E6CKg8zws5OmHKDtYA5Ke7kUvBJlUwITSZdvzA==", + "dependencies": { + "@types/ref-napi": "*" + } + }, + "node_modules/ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/array-index": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-index/-/array-index-1.0.0.tgz", + "integrity": "sha1-7FanSe4QPk4Ix5C5w1PfFgVbl/k=", + "dependencies": { + "debug": "^2.2.0", + "es6-symbol": "^3.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/array-index/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/array-index/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.2.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.1.1" + } + }, + "node_modules/cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "dependencies": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "node_modules/debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "dependencies": { + "object-keys": "^1.0.12" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "node_modules/es-abstract": { + "version": "1.17.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", + "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "dev": true, + "dependencies": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es5-ext": { + "version": "0.10.53", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", + "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", + "dependencies": { + "es6-iterator": "~2.0.3", + "es6-symbol": "~3.1.3", + "next-tick": "~1.0.0" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/ext": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", + "integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==", + "dependencies": { + "type": "^2.0.0" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.5.0.tgz", + "integrity": "sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw==" + }, + "node_modules/ffi-napi": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/ffi-napi/-/ffi-napi-4.0.3.tgz", + "integrity": "sha512-PMdLCIvDY9mS32RxZ0XGb95sonPRal8aqRhLbeEtWKZTe2A87qRFG9HjOhvG8EX2UmQw5XNRMIOT+1MYlWmdeg==", + "hasInstallScript": true, + "dependencies": { + "debug": "^4.1.1", + "get-uv-event-loop-napi-h": "^1.0.5", + "node-addon-api": "^3.0.0", + "node-gyp-build": "^4.2.1", + "ref-napi": "^2.0.1 || ^3.0.2", + "ref-struct-di": "^1.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ffi-napi/node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/flat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", + "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", + "deprecated": "Fixed a prototype pollution security issue in 4.1.0, please upgrade to ^4.1.1 or ^5.0.1.", + "dev": true, + "dependencies": { + "is-buffer": "~2.0.3" + }, + "bin": { + "flat": "cli.js" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", + "deprecated": "\"Please update to latest v2.3 or v2.2\"", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/get-symbol-from-current-process-h": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/get-symbol-from-current-process-h/-/get-symbol-from-current-process-h-1.0.2.tgz", + "integrity": "sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw==" + }, + "node_modules/get-uv-event-loop-napi-h": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/get-uv-event-loop-napi-h/-/get-uv-event-loop-napi-h-1.0.6.tgz", + "integrity": "sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg==", + "dependencies": { + "get-symbol-from-current-process-h": "^1.0.1" + } + }, + "node_modules/glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true, + "engines": { + "node": ">=4.x" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/is-callable": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-regex": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/log-symbols": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", + "dev": true, + "dependencies": { + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "node_modules/mkdirp": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.3.tgz", + "integrity": "sha512-P+2gwrFqx8lhew375MQHHeTlY8AuOJSrGf0R5ddkEndUkmwpgUob/vQuBD1V22/Cw1/lJr4x+EjllSezBThzBg==", + "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", + "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mocha": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.1.1.tgz", + "integrity": "sha512-3qQsu3ijNS3GkWcccT5Zw0hf/rWvu1fTN9sPvEd81hlwsr30GX2GcDSSoBxo24IR8FelmrAydGC6/1J5QQP4WA==", + "dev": true, + "dependencies": { + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "chokidar": "3.3.0", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "find-up": "3.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "3.0.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.3", + "ms": "2.1.1", + "node-environment-flags": "1.0.6", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.3.2", + "yargs-parser": "13.1.2", + "yargs-unparser": "1.6.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 8.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/next-tick": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" + }, + "node_modules/node-addon-api": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", + "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==" + }, + "node_modules/node-environment-flags": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz", + "integrity": "sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==", + "dev": true, + "dependencies": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, + "node_modules/node-gyp-build": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.getownpropertydescriptors": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz", + "integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", + "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", + "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/readdirp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", + "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", + "dev": true, + "dependencies": { + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/ref-array-napi": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/ref-array-napi/-/ref-array-napi-1.2.2.tgz", + "integrity": "sha512-EGQzUQpyqD/hN9eIn3uF68UPBmwJXdWkumHCmvK3ncjw128bkjd8TbJ51ur+2PZ4UrfCOQCcPQkuWZ6mNHch9A==", + "dependencies": { + "array-index": "1", + "debug": "2", + "ref-napi": "^3.0.1" + } + }, + "node_modules/ref-array-napi/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/ref-array-napi/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "node_modules/ref-napi": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/ref-napi/-/ref-napi-3.0.3.tgz", + "integrity": "sha512-LiMq/XDGcgodTYOMppikEtJelWsKQERbLQsYm0IOOnzhwE9xYZC7x8txNnFC9wJNOkPferQI4vD4ZkC0mDyrOA==", + "hasInstallScript": true, + "dependencies": { + "debug": "^4.1.1", + "get-symbol-from-current-process-h": "^1.0.2", + "node-addon-api": "^3.0.0", + "node-gyp-build": "^4.2.1" + }, + "engines": { + "node": ">= 10.0" + } + }, + "node_modules/ref-napi/node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/ref-struct-di": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ref-struct-di/-/ref-struct-di-1.1.1.tgz", + "integrity": "sha512-2Xyn/0Qgz89VT+++WP0sTosdm9oeowLP23wRJYhG4BFdMUrLj3jhwHZNEytYNYgtPKLNTP3KJX4HEgBvM1/Y2g==", + "dependencies": { + "debug": "^3.1.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "node_modules/rimraf": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.1.tgz", + "integrity": "sha512-IQ4ikL8SjBiEDZfk+DFVwqRK8md24RWMEJkdSlgNLkyyAImcjf8SWvU1qFMDOb4igBClbTQ/ugPqXcRwdFTxZw==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/string.prototype.trimleft": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", + "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimright": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", + "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz", + "integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "node_modules/y18n": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", + "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", + "dev": true + }, + "node_modules/yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "dependencies": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + } + }, + "node_modules/yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "node_modules/yargs-unparser": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", + "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", + "dev": true, + "dependencies": { + "flat": "^4.1.0", + "lodash": "^4.17.15", + "yargs": "^13.3.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + } + }, "dependencies": { "@types/chai": { "version": "4.2.7", diff --git a/ffi/node/test/ZKGroup-test.ts b/ffi/node/test/ZKGroup-test.ts index 6a27a78..bd238d8 100644 --- a/ffi/node/test/ZKGroup-test.ts +++ b/ffi/node/test/ZKGroup-test.ts @@ -14,6 +14,9 @@ import ServerZkProfileOperations from '../zkgroup/profiles/ServerZkProfileOperat import ClientZkProfileOperations from '../zkgroup/profiles/ClientZkProfileOperations'; import ProfileKey from '../zkgroup/profiles/ProfileKey'; import ProfileKeyVersion from '../zkgroup/profiles/ProfileKeyVersion'; +import ClientZkReceiptOperations from "../zkgroup/receipts/ClientZkReceiptOperations"; +import ServerZkReceiptOperations from "../zkgroup/receipts/ServerZkReceiptOperations"; +import ReceiptSerial from "../zkgroup/receipts/ReceiptSerial"; function hexToCompatArray(hex: string) { const buffer = Buffer.from(hex, 'hex'); @@ -237,4 +240,28 @@ describe('ZKGroup', () => { const plaintext257 = clientZkGroupCipher.decryptBlob(ciphertextPaddedWith257); assertArrayEquals(plaintext, plaintext257); }); + + it('testReceiptFlow', () => { + const serverSecretParams = ServerSecretParams.generateWithRandom(TEST_ARRAY_32); + const serverPublicParams = serverSecretParams.getPublicParams(); + const serverOps = new ServerZkReceiptOperations(serverSecretParams); + const clientOps = new ClientZkReceiptOperations(serverPublicParams); + const receiptSerial = new ReceiptSerial(hexToCompatArray('00112233445566778899aabbccddeeff')); + + // client + const context = clientOps.createReceiptCredentialRequestContext(receiptSerial); + const request = context.getRequest(); + + // issuance server + const receiptExpirationTime = "31337"; + const receiptLevel = "3"; + const response = serverOps.issueReceiptCredential(request, receiptExpirationTime, receiptLevel); + + // client + const credential = clientOps.receiveReceiptCredential(context, response); + const presentation = clientOps.createReceiptCredentialPresentation(credential); + + // redemption server + serverOps.verifyReceiptCredentialPresentation(presentation); + }) }); diff --git a/ffi/node/zkgroup/ServerPublicParams.ts b/ffi/node/zkgroup/ServerPublicParams.ts index 0ee9dcc..e4817fc 100644 --- a/ffi/node/zkgroup/ServerPublicParams.ts +++ b/ffi/node/zkgroup/ServerPublicParams.ts @@ -11,7 +11,7 @@ import FFICompatArray, { FFICompatArrayType } from './internal/FFICompatArray' export default class ServerPublicParams extends ByteArray { - static SIZE = 161; + static SIZE = 225; constructor (contents: FFICompatArrayType) { super(contents, ServerPublicParams.SIZE, true); diff --git a/ffi/node/zkgroup/ServerSecretParams.ts b/ffi/node/zkgroup/ServerSecretParams.ts index 7305dcd..4ee8a05 100644 --- a/ffi/node/zkgroup/ServerSecretParams.ts +++ b/ffi/node/zkgroup/ServerSecretParams.ts @@ -12,7 +12,7 @@ import NotarySignature from './NotarySignature'; export default class ServerSecretParams extends ByteArray { - static SIZE = 769; + static SIZE = 1121; static generate(): ServerSecretParams { const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); diff --git a/ffi/node/zkgroup/auth/AuthCredential.ts b/ffi/node/zkgroup/auth/AuthCredential.ts index 81e57b0..759a53c 100644 --- a/ffi/node/zkgroup/auth/AuthCredential.ts +++ b/ffi/node/zkgroup/auth/AuthCredential.ts @@ -8,7 +8,7 @@ import Native, { FFI_RETURN_OK, FFI_RETURN_INPUT_ERROR } from '../internal/Nativ export default class AuthCredential extends ByteArray { - static SIZE = 342; + static SIZE = 181; constructor(contents: FFICompatArrayType) { super(contents, AuthCredential.SIZE, true); diff --git a/ffi/node/zkgroup/internal/Native.ts b/ffi/node/zkgroup/internal/Native.ts index 5c75045..a3a46ec 100644 --- a/ffi/node/zkgroup/internal/Native.ts +++ b/ffi/node/zkgroup/internal/Native.ts @@ -5,6 +5,7 @@ import * as process from 'process'; type IntType = number; type UInt32Type = number; +type UInt64Type = string; export const FFI_RETURN_OK = 0; export const FFI_RETURN_INTERNAL_ERROR = 1; // ZkGroupError @@ -38,6 +39,8 @@ interface NativeCalls { FFI_ServerSecretParams_getPublicParams: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ServerSecretParams_signDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, FFI_ServerSecretParams_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, + FFI_ServerSecretParams_issueReceiptCredentialDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: UInt64Type, param8: UInt64Type, param9: FFICompatArrayType, param10: UInt32Type) => IntType, + FFI_ServerSecretParams_verifyReceiptCredentialPresentation: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ServerPublicParams_receiveAuthCredential: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: IntType, param6: FFICompatArrayType, param7: UInt32Type, param8: FFICompatArrayType, param9: UInt32Type) => IntType; FFI_ServerPublicParams_createAuthCredentialPresentationDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type) => IntType, FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type) => IntType, @@ -47,6 +50,9 @@ interface NativeCalls { FFI_ServerSecretParams_verifyAuthCredentialPresentation: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type) => IntType, FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type, param11: FFICompatArrayType, param12: UInt32Type) => IntType, FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type) => IntType, + FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, + FFI_ServerPublicParams_receiveReceiptCredential: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, + FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, FFI_GroupPublicParams_getGroupIdentifier: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_GroupPublicParams_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ServerPublicParams_verifySignature: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type) => IntType, @@ -64,6 +70,12 @@ interface NativeCalls { FFI_ProfileKeyCredentialPresentation_getUuidCiphertext: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ProfileKeyCredentialPresentation_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, + FFI_ReceiptCredentialRequestContext_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, + FFI_ReceiptCredentialRequestContext_getRequest: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_ReceiptCredentialRequest_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, + FFI_ReceiptCredentialResponse_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, + FFI_ReceiptCredential_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, + FFI_ReceiptCredentialPresentation_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, FFI_UuidCiphertext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCiphertext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, } @@ -87,11 +99,16 @@ const library: NativeCalls = Library(libraryPath, { 'FFI_ServerSecretParams_getPublicParams': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerSecretParams_signDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerSecretParams_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], + 'FFI_ServerSecretParams_issueReceiptCredentialDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', 'uint64', 'uint64', FFICompatArray, 'uint32', ] ], + 'FFI_ServerSecretParams_verifyReceiptCredentialPresentation': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_receiveAuthCredential': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', 'int', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createAuthCredentialPresentationDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_receiveProfileKeyCredential': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ServerPublicParams_receiveReceiptCredential': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerSecretParams_issueAuthCredentialDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', 'int', FFICompatArray, 'uint32', ] ], 'FFI_ServerSecretParams_verifyAuthCredentialPresentation': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], 'FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], @@ -113,6 +130,12 @@ const library: NativeCalls = Library(libraryPath, { 'FFI_ProfileKeyCredentialPresentation_getUuidCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ProfileKeyCredentialPresentation_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], + 'FFI_ReceiptCredentialRequestContext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredentialRequestContext_getRequest': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredentialRequest_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredentialResponse_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredential_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredentialPresentation_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], 'FFI_UuidCiphertext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCiphertext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], }); diff --git a/ffi/node/zkgroup/receipts/ClientZkReceiptOperations.ts b/ffi/node/zkgroup/receipts/ClientZkReceiptOperations.ts new file mode 100644 index 0000000..c7dffd5 --- /dev/null +++ b/ffi/node/zkgroup/receipts/ClientZkReceiptOperations.ts @@ -0,0 +1,94 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import {randomBytes} from 'crypto'; +import FFICompatArray, {FFICompatArrayType} from '../internal/FFICompatArray'; +import ZkGroupError from '../errors/ZkGroupError'; +import {RANDOM_LENGTH} from '../internal/Constants'; +import Native, {FFI_RETURN_OK} from '../internal/Native'; +import ServerPublicParams from '../ServerPublicParams'; +import ReceiptCredential from "./ReceiptCredential"; +import ReceiptCredentialPresentation from "./ReceiptCredentialPresentation"; +import ReceiptCredentialRequestContext from "./ReceiptCredentialRequestContext"; +import ReceiptCredentialResponse from "./ReceiptCredentialResponse"; +import ReceiptSerial from "./ReceiptSerial"; + +export default class ClientZkReceiptOperations { + + serverPublicParams: ServerPublicParams + + constructor(serverPublicParams: ServerPublicParams) { + this.serverPublicParams = serverPublicParams; + } + + createReceiptCredentialRequestContext(receiptSerial: ReceiptSerial): ReceiptCredentialRequestContext { + const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); + return this.createReceiptCredentialRequestContextWithRandom(random, receiptSerial); + } + + createReceiptCredentialRequestContextWithRandom(random: FFICompatArrayType, receiptSerial: ReceiptSerial): ReceiptCredentialRequestContext { + const newContents = new FFICompatArray(ReceiptCredentialRequestContext.SIZE); + const serverPublicParamsContents = this.serverPublicParams.getContents(); + const receiptSerialContents = receiptSerial.getContents(); + + const ffi_return = Native.FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic( + serverPublicParamsContents, serverPublicParamsContents.length, + random, random.length, + receiptSerialContents, receiptSerialContents.length, + newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return new ReceiptCredentialRequestContext(newContents); + } + + receiveReceiptCredential(receiptCredentialRequestContext: ReceiptCredentialRequestContext, receiptCredentialResponse: ReceiptCredentialResponse): ReceiptCredential { + const newContents = new FFICompatArray(ReceiptCredential.SIZE); + const serverPublicParamsContents = this.serverPublicParams.getContents(); + const receiptCredentialRequestContextContents = receiptCredentialRequestContext.getContents(); + const receiptCredentialResponseContents = receiptCredentialResponse.getContents(); + + const ffi_return = Native.FFI_ServerPublicParams_receiveReceiptCredential( + serverPublicParamsContents, serverPublicParamsContents.length, + receiptCredentialRequestContextContents, receiptCredentialRequestContextContents.length, + receiptCredentialResponseContents, receiptCredentialResponseContents.length, + newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return new ReceiptCredential(newContents); + } + + createReceiptCredentialPresentation(receiptCredential: ReceiptCredential): ReceiptCredentialPresentation { + const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); + return this.createReceiptCredentialPresentationWithRandom(random, receiptCredential); + } + + createReceiptCredentialPresentationWithRandom(random: FFICompatArrayType, receiptCredential: ReceiptCredential): ReceiptCredentialPresentation { + const newContents = new FFICompatArray(ReceiptCredentialPresentation.SIZE); + const serverPublicParamsContents = this.serverPublicParams.getContents(); + const receiptCredentialContents = receiptCredential.getContents(); + + const ffi_return = Native.FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic( + serverPublicParamsContents, serverPublicParamsContents.length, + random, random.length, + receiptCredentialContents, receiptCredentialContents.length, + newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return new ReceiptCredentialPresentation(newContents); + } +} diff --git a/ffi/node/zkgroup/receipts/ReceiptCredential.ts b/ffi/node/zkgroup/receipts/ReceiptCredential.ts new file mode 100644 index 0000000..3df583b --- /dev/null +++ b/ffi/node/zkgroup/receipts/ReceiptCredential.ts @@ -0,0 +1,33 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import ByteArray from '../internal/ByteArray'; +import {FFICompatArrayType} from '../internal/FFICompatArray'; +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; +import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; + +export default class ReceiptCredential extends ByteArray { + + static SIZE = 129; + + constructor(contents: FFICompatArrayType) { + super(contents, ReceiptCredential.SIZE, true); + + const ffi_return = Native.FFI_ReceiptCredential_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } +} diff --git a/ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts b/ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts new file mode 100644 index 0000000..f4c5581 --- /dev/null +++ b/ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts @@ -0,0 +1,33 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import ByteArray from '../internal/ByteArray'; +import {FFICompatArrayType} from '../internal/FFICompatArray'; +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; +import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; + +export default class ReceiptCredentialPresentation extends ByteArray { + + static SIZE = 329; + + constructor(contents: FFICompatArrayType) { + super(contents, ReceiptCredentialPresentation.SIZE, true); + + const ffi_return = Native.FFI_ReceiptCredentialPresentation_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } +} diff --git a/ffi/node/zkgroup/receipts/ReceiptCredentialRequest.ts b/ffi/node/zkgroup/receipts/ReceiptCredentialRequest.ts new file mode 100644 index 0000000..214e6bf --- /dev/null +++ b/ffi/node/zkgroup/receipts/ReceiptCredentialRequest.ts @@ -0,0 +1,33 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import ByteArray from '../internal/ByteArray'; +import {FFICompatArrayType} from '../internal/FFICompatArray'; +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; +import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; + +export default class ReceiptCredentialRequest extends ByteArray { + + static SIZE = 97; + + constructor(contents: FFICompatArrayType) { + super(contents, ReceiptCredentialRequest.SIZE, true); + + const ffi_return = Native.FFI_ReceiptCredentialRequest_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } +} diff --git a/ffi/node/zkgroup/receipts/ReceiptCredentialRequestContext.ts b/ffi/node/zkgroup/receipts/ReceiptCredentialRequestContext.ts new file mode 100644 index 0000000..36cc603 --- /dev/null +++ b/ffi/node/zkgroup/receipts/ReceiptCredentialRequestContext.ts @@ -0,0 +1,46 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import ByteArray from '../internal/ByteArray'; +import FFICompatArray, {FFICompatArrayType} from '../internal/FFICompatArray'; +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; +import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; +import ReceiptCredentialRequest from "./ReceiptCredentialRequest"; + +export default class ReceiptCredentialRequestContext extends ByteArray { + + static SIZE = 177; + + constructor(contents: FFICompatArrayType) { + super(contents, ReceiptCredentialRequestContext.SIZE, true); + + const ffi_return = Native.FFI_ReceiptCredentialRequestContext_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } + + getRequest(): ReceiptCredentialRequest { + const newContents = new FFICompatArray(ReceiptCredentialRequest.SIZE); + + const ffi_return = Native.FFI_ReceiptCredentialRequestContext_getRequest(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + + return new ReceiptCredentialRequest(newContents); + } +} diff --git a/ffi/node/zkgroup/receipts/ReceiptCredentialResponse.ts b/ffi/node/zkgroup/receipts/ReceiptCredentialResponse.ts new file mode 100644 index 0000000..848f11d --- /dev/null +++ b/ffi/node/zkgroup/receipts/ReceiptCredentialResponse.ts @@ -0,0 +1,33 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import ByteArray from '../internal/ByteArray'; +import {FFICompatArrayType} from '../internal/FFICompatArray'; +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; +import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; + +export default class ReceiptCredentialResponse extends ByteArray { + + static SIZE = 409; + + constructor(contents: FFICompatArrayType) { + super(contents, ReceiptCredentialResponse.SIZE, true); + + const ffi_return = Native.FFI_ReceiptCredentialResponse_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } +} diff --git a/ffi/node/zkgroup/receipts/ReceiptSerial.ts b/ffi/node/zkgroup/receipts/ReceiptSerial.ts new file mode 100644 index 0000000..39303b2 --- /dev/null +++ b/ffi/node/zkgroup/receipts/ReceiptSerial.ts @@ -0,0 +1,20 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import ByteArray from "../internal/ByteArray"; +import {FFICompatArrayType} from "../internal/FFICompatArray"; + +export default class ReceiptSerial extends ByteArray { + + static SIZE = 16; + + constructor(contents: FFICompatArrayType) { + super(contents, ReceiptSerial.SIZE, true); + } +} diff --git a/ffi/node/zkgroup/receipts/ServerZkReceiptOperations.ts b/ffi/node/zkgroup/receipts/ServerZkReceiptOperations.ts new file mode 100644 index 0000000..5ce3c5f --- /dev/null +++ b/ffi/node/zkgroup/receipts/ServerZkReceiptOperations.ts @@ -0,0 +1,74 @@ +/* + * + * Copyright (C) 2021 Signal Messenger, LLC. + * All rights reserved. + * + * SPDX-License-Identifier: GPL-3.0-only + * + */ + +import {randomBytes} from 'crypto'; +import FFICompatArray, {FFICompatArrayType} from '../internal/FFICompatArray'; +import VerificationFailedException from '../errors/VerificationFailedException'; +import ZkGroupError from '../errors/ZkGroupError'; +import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; +import {RANDOM_LENGTH} from '../internal/Constants'; +import ServerSecretParams from '../ServerSecretParams'; +import ReceiptCredentialRequest from "./ReceiptCredentialRequest"; +import ReceiptCredentialResponse from "./ReceiptCredentialResponse"; +import ReceiptCredentialPresentation from "./ReceiptCredentialPresentation"; + +export default class ServerZkReceiptOperations { + + serverSecretParams: ServerSecretParams; + + constructor(serverSecretParams: ServerSecretParams) { + this.serverSecretParams = serverSecretParams; + } + + issueReceiptCredential(receiptCredentialRequest: ReceiptCredentialRequest, receiptExpirationTime: string, receiptLevel: string): ReceiptCredentialResponse { + const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); + return this.issueReceiptCredentialWithRandom(random, receiptCredentialRequest, receiptExpirationTime, receiptLevel); + } + + issueReceiptCredentialWithRandom(random: FFICompatArrayType, receiptCredentialRequest: ReceiptCredentialRequest, receiptExpirationTime: string, receiptLevel: string): ReceiptCredentialResponse { + const newContents = new FFICompatArray(ReceiptCredentialResponse.SIZE); + const serverSecretParamsContents = this.serverSecretParams.getContents(); + const receiptCredentialRequestContents = receiptCredentialRequest.getContents(); + + const ffi_return = Native.FFI_ServerSecretParams_issueReceiptCredentialDeterministic( + serverSecretParamsContents, serverSecretParamsContents.length, + random, random.length, + receiptCredentialRequestContents, receiptCredentialRequestContents.length, + receiptExpirationTime, + receiptLevel, + newContents, newContents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + + return new ReceiptCredentialResponse(newContents); + } + + verifyReceiptCredentialPresentation(receiptCredentialPresentation: ReceiptCredentialPresentation) { + const serverSecretParamsContents = this.serverSecretParams.getContents(); + const receiptCredentialPresentationContents = receiptCredentialPresentation.getContents(); + + const ffi_return = Native.FFI_ServerSecretParams_verifyReceiptCredentialPresentation( + serverSecretParamsContents, serverSecretParamsContents.length, + receiptCredentialPresentationContents, receiptCredentialPresentationContents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } +} From 6a9f1ae0d7acdff8d68ee638edac3de85f82e500 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 14:00:33 -0500 Subject: [PATCH 54/69] Update swift's copy of the c header --- ffi/swift/Sources/libzkgroup/zkgroup.h | 83 +++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/ffi/swift/Sources/libzkgroup/zkgroup.h b/ffi/swift/Sources/libzkgroup/zkgroup.h index 6587518..45774dc 100644 --- a/ffi/swift/Sources/libzkgroup/zkgroup.h +++ b/ffi/swift/Sources/libzkgroup/zkgroup.h @@ -7,6 +7,8 @@ #define NUM_PROFILE_KEY_CRED_ATTRIBUTES 4 +#define NUM_RECEIPT_CRED_ATTRIBUTES 2 + #define AES_KEY_LEN 32 #define AESGCM_NONCE_LEN 12 @@ -21,7 +23,7 @@ #define GROUP_IDENTIFIER_LEN 32 -#define AUTH_CREDENTIAL_LEN 342 +#define AUTH_CREDENTIAL_LEN 181 #define AUTH_CREDENTIAL_PRESENTATION_LEN 493 @@ -47,11 +49,23 @@ #define PROFILE_KEY_VERSION_ENCODED_LEN 64 +#define RECEIPT_CREDENTIAL_LEN 129 + +#define RECEIPT_CREDENTIAL_PRESENTATION_LEN 329 + +#define RECEIPT_CREDENTIAL_REQUEST_LEN 97 + +#define RECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN 177 + +#define RECEIPT_CREDENTIAL_RESPONSE_LEN 409 + +#define RECEIPT_SERIAL_LEN 16 + #define RESERVED_LEN 1 -#define SERVER_SECRET_PARAMS_LEN 769 +#define SERVER_SECRET_PARAMS_LEN 1121 -#define SERVER_PUBLIC_PARAMS_LEN 161 +#define SERVER_PUBLIC_PARAMS_LEN 225 #define UUID_CIPHERTEXT_LEN 65 @@ -229,6 +243,33 @@ int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterminist uint8_t *profileKeyCredentialPresentationOut, uint32_t profileKeyCredentialPresentationLen); +int32_t FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *receiptSerial, + uint32_t receiptSerialLen, + uint8_t *receiptCredentialRequestContextOut, + uint32_t receiptCredentialRequestContextLen); + +int32_t FFI_ServerPublicParams_receiveReceiptCredential(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *receiptCredentialRequestContext, + uint32_t receiptCredentialRequestContextLen, + const uint8_t *receiptCredentialResponse, + uint32_t receiptCredentialResponseLen, + uint8_t *receiptCredentialOut, + uint32_t receiptCredentialLen); + +int32_t FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *receiptCredential, + uint32_t receiptCredentialLen, + uint8_t *receiptCredentialPresentationOut, + uint32_t receiptCredentialPresentationLen); + int32_t FFI_ServerSecretParams_issueAuthCredentialDeterministic(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, const uint8_t *randomness, @@ -266,6 +307,22 @@ int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint const uint8_t *profileKeyCredentialPresentation, uint32_t profileKeyCredentialPresentationLen); +int32_t FFI_ServerSecretParams_issueReceiptCredentialDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *receiptCredentialRequest, + uint32_t receiptCredentialRequestLen, + uint64_t receiptExpirationTime, + uint64_t receiptLevel, + uint8_t *receiptCredentialResponseOut, + uint32_t receiptCredentialResponseLen); + +int32_t FFI_ServerSecretParams_verifyReceiptCredentialPresentation(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen); + int32_t FFI_GroupPublicParams_checkValidContents(const uint8_t *groupPublicParams, uint32_t groupPublicParamsLen); @@ -333,6 +390,26 @@ int32_t FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext(const uint8 uint8_t *profileKeyCiphertextOut, uint32_t profileKeyCiphertextLen); +int32_t FFI_ReceiptCredentialRequestContext_checkValidContents(const uint8_t *receiptCredentialRequestContext, + uint32_t receiptCredentialRequestContextLen); + +int32_t FFI_ReceiptCredentialRequestContext_getRequest(const uint8_t *receiptCredentialRequestContext, + uint32_t receiptCredentialRequestContextLen, + uint8_t *receiptCredentialRequestOut, + uint32_t receiptCredentialRequestLen); + +int32_t FFI_ReceiptCredentialRequest_checkValidContents(const uint8_t *receiptCredentialRequest, + uint32_t receiptCredentialRequestLen); + +int32_t FFI_ReceiptCredentialResponse_checkValidContents(const uint8_t *receiptCredentialResponse, + uint32_t receiptCredentialResponseLen); + +int32_t FFI_ReceiptCredential_checkValidContents(const uint8_t *receiptCredential, + uint32_t receiptCredentialLen); + +int32_t FFI_ReceiptCredentialPresentation_checkValidContents(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen); + int32_t FFI_UuidCiphertext_checkValidContents(const uint8_t *uuidCiphertext, uint32_t uuidCiphertextLen); From 99f68cd9229545c0623a119cda65180079a4ff02 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 14:11:53 -0500 Subject: [PATCH 55/69] Add missing copyright header to generated swift files --- codegen/codegen_hack.patch | 8 ++++---- codegen/codegen_swift.py | 8 +++++++- ffi/swift/Sources/ZKGroup/ClientZkAuthOperations.swift | 6 ++++++ ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift | 6 ++++++ ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift | 6 ++++++ ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift | 6 ++++++ ffi/swift/Sources/ZKGroup/ServerZkAuthOperations.swift | 6 ++++++ ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift | 6 ++++++ ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift | 6 ++++++ 9 files changed, 53 insertions(+), 5 deletions(-) diff --git a/codegen/codegen_hack.patch b/codegen/codegen_hack.patch index 47d76a7..d192df2 100644 --- a/codegen/codegen_hack.patch +++ b/codegen/codegen_hack.patch @@ -143,7 +143,7 @@ diff --git b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift a/ffi/swift/Sou index 4d36edb46acf..fa7f1b4aba5c 100644 --- b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift +++ a/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift -@@ -85,7 +85,7 @@ public class ClientZkGroupCipher { +@@ -91,7 +91,7 @@ public class ClientZkGroupCipher { } @@ -152,7 +152,7 @@ index 4d36edb46acf..fa7f1b4aba5c 100644 var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) guard result == errSecSuccess else { -@@ -96,9 +96,11 @@ public class ClientZkGroupCipher { +@@ -102,9 +102,11 @@ public class ClientZkGroupCipher { } public func encryptBlob(randomness: [UInt8], plaintext: [UInt8]) throws -> [UInt8] { @@ -166,7 +166,7 @@ index 4d36edb46acf..fa7f1b4aba5c 100644 if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { throw ZkGroupException.VerificationFailed } -@@ -111,9 +113,10 @@ public class ClientZkGroupCipher { +@@ -117,9 +120,10 @@ public class ClientZkGroupCipher { } public func decryptBlob(blobCiphertext: [UInt8]) throws -> [UInt8] { @@ -178,7 +178,7 @@ index 4d36edb46acf..fa7f1b4aba5c 100644 if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { throw ZkGroupException.VerificationFailed } -@@ -122,7 +125,18 @@ public class ClientZkGroupCipher { +@@ -128,7 +131,18 @@ public class ClientZkGroupCipher { throw ZkGroupException.ZkGroupError } diff --git a/codegen/codegen_swift.py b/codegen/codegen_swift.py index 78c33fa..d843197 100644 --- a/codegen/codegen_swift.py +++ b/codegen/codegen_swift.py @@ -54,7 +54,13 @@ """ template_wrapping_class = \ -"""// Generated by zkgroup/codegen/codegen.py - do not edit +"""// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit %(imports)s diff --git a/ffi/swift/Sources/ZKGroup/ClientZkAuthOperations.swift b/ffi/swift/Sources/ZKGroup/ClientZkAuthOperations.swift index d2f2711..24ef767 100644 --- a/ffi/swift/Sources/ZKGroup/ClientZkAuthOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ClientZkAuthOperations.swift @@ -1,3 +1,9 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// // Generated by zkgroup/codegen/codegen.py - do not edit import Foundation diff --git a/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift index fa7f1b4..5ab8a86 100644 --- a/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift +++ b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift @@ -1,3 +1,9 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// // Generated by zkgroup/codegen/codegen.py - do not edit import Foundation diff --git a/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift b/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift index a59dc72..40ae47e 100644 --- a/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift @@ -1,3 +1,9 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// // Generated by zkgroup/codegen/codegen.py - do not edit import Foundation diff --git a/ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift b/ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift index 581b7f8..960fe0b 100644 --- a/ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ClientZkReceiptOperations.swift @@ -1,3 +1,9 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// // Generated by zkgroup/codegen/codegen.py - do not edit import Foundation diff --git a/ffi/swift/Sources/ZKGroup/ServerZkAuthOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkAuthOperations.swift index b20fc78..7a6bb32 100644 --- a/ffi/swift/Sources/ZKGroup/ServerZkAuthOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ServerZkAuthOperations.swift @@ -1,3 +1,9 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// // Generated by zkgroup/codegen/codegen.py - do not edit import Foundation diff --git a/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift index 60d3df4..ef976a5 100644 --- a/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift @@ -1,3 +1,9 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// // Generated by zkgroup/codegen/codegen.py - do not edit import Foundation diff --git a/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift index 71a6900..b8654fc 100644 --- a/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift @@ -1,3 +1,9 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// // Generated by zkgroup/codegen/codegen.py - do not edit import Foundation From 42e6b9599605406cba8818907c512d02ee018cdd Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 14:14:28 -0500 Subject: [PATCH 56/69] Fix typo --- codegen/codegen_swift.py | 2 +- ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen/codegen_swift.py b/codegen/codegen_swift.py index d843197..5f7f0fe 100644 --- a/codegen/codegen_swift.py +++ b/codegen/codegen_swift.py @@ -304,7 +304,7 @@ def get_decls(params, import_strings, class_dir_dict, my_dir_name): s += param[1].lower_camel() + ": UInt32, " #SWIFT add_import(import_strings, class_dir_dict, my_dir_name, param[1]) elif param[0] == "long": - s += param[1].lower_camel() + ": Uint64, " + s += param[1].lower_camel() + ": UInt64, " #SWIFT add_import(import_strings, class_dir_dict, my_dir_name, param[1]) elif param[0] == "UUID": s += param[1].lower_camel() + ": ZKGUuid, " diff --git a/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift index b8654fc..927fbc1 100644 --- a/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ServerZkReceiptOperations.swift @@ -27,7 +27,7 @@ public class ServerZkReceiptOperations { return try issueReceiptCredential(randomness: randomness, receiptCredentialRequest: receiptCredentialRequest, receiptExpirationTime: receiptExpirationTime, receiptLevel: receiptLevel) } - public func issueReceiptCredential(randomness: [UInt8], receiptCredentialRequest: ReceiptCredentialRequest, receiptExpirationTime: Uint64, receiptLevel: Uint64) throws -> ReceiptCredentialResponse { + public func issueReceiptCredential(randomness: [UInt8], receiptCredentialRequest: ReceiptCredentialRequest, receiptExpirationTime: UInt64, receiptLevel: UInt64) throws -> ReceiptCredentialResponse { var newContents: [UInt8] = Array(repeating: 0, count: ReceiptCredentialResponse.SIZE) let ffi_return = FFI_ServerSecretParams_issueReceiptCredentialDeterministic(serverSecretParams.getInternalContentsForFFI(), UInt32(serverSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), receiptCredentialRequest.getInternalContentsForFFI(), UInt32(receiptCredentialRequest.getInternalContentsForFFI().count), receiptExpirationTime, receiptLevel, &newContents, UInt32(newContents.count)) From 2d26e8527d3ecaf95716110748274761c9b29ec6 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 23 Sep 2021 14:22:33 -0500 Subject: [PATCH 57/69] Add a test for the presentation verify failing if modified --- rust/tests/receipt_flow.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rust/tests/receipt_flow.rs b/rust/tests/receipt_flow.rs index 8b3faa6..6eb1e01 100644 --- a/rust/tests/receipt_flow.rs +++ b/rust/tests/receipt_flow.rs @@ -5,6 +5,7 @@ // SPDX-License-Identifier: GPL-3.0-only // +use zkgroup::api::receipts::ReceiptCredentialPresentation; use zkgroup::common::sho::Sho; use zkgroup::crypto::credentials; use zkgroup::crypto::proofs::{ReceiptCredentialIssuanceProof, ReceiptCredentialPresentationProof}; @@ -140,4 +141,14 @@ fn test_api() { zkgroup::common::constants::RECEIPT_CREDENTIAL_PRESENTATION_LEN, bincode::serialize(&presentation).unwrap().len(), ); + + let mut presentation_bytes = bincode::serialize(&presentation).unwrap(); + // change it ever so slightly; maybe try a higher level for instance + let i = presentation_bytes.len() - 17; + presentation_bytes[i] += 1; + let bad_presentation = + bincode::deserialize::(&presentation_bytes).unwrap(); + server_secret_params + .verify_receipt_credential_presentation(&bad_presentation) + .expect_err("This Presentation Should Be Bad"); } From ea454e8eca3f1f745856fef768a54d660efc8736 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Fri, 24 Sep 2021 09:42:02 -0500 Subject: [PATCH 58/69] Remove redundant line in Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 72a91fa..1374230 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,7 +55,6 @@ RUN curl -f https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-unknown && rm -rf /tmp/rustup-init \ && rustup component add rust-src \ && rustup target add aarch64-apple-darwin aarch64-apple-ios aarch64-apple-ios-sim aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-apple-darwin x86_64-apple-ios x86_64-linux-android x86_64-unknown-linux-gnu \ - && rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android \ && cargo install --version ${CARGO_NDK_VERSION} cargo-ndk # Android SDK setup... From f064f5fa85edb4f929a0f8f7834a6d9957230782 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 27 Sep 2021 14:24:18 -0500 Subject: [PATCH 59/69] Add getters for receipt expiration and level to credential --- rust/src/api/receipts/receipt_credential.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rust/src/api/receipts/receipt_credential.rs b/rust/src/api/receipts/receipt_credential.rs index d5e7da8..c67a3aa 100644 --- a/rust/src/api/receipts/receipt_credential.rs +++ b/rust/src/api/receipts/receipt_credential.rs @@ -20,3 +20,13 @@ pub struct ReceiptCredential { pub(crate) receipt_level: ReceiptLevel, pub(crate) receipt_serial_bytes: ReceiptSerialBytes, } + +impl ReceiptCredential { + pub fn get_receipt_expiration_time(&self) -> ReceiptExpirationTime { + self.receipt_expiration_time + } + + pub fn get_receipt_level(&self) -> ReceiptLevel { + self.receipt_level + } +} From e860f0ac2356fe4c96613b862b35f37b5a66b124 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 27 Sep 2021 14:24:37 -0500 Subject: [PATCH 60/69] Add calls through codegen to get the receipt level and expiration --- codegen/codegen.py | 4 ++ .../org/signal/zkgroup/internal/Native.java | 2 + .../zkgroup/receipts/ReceiptCredential.java | 25 ++++++++ .../Sources/ZKGroup/ReceiptCredential.swift | 28 ++++++++ rust/src/ffi/ffiapi.rs | 48 ++++++++++++++ rust/src/ffi/ffiapijava.rs | 64 +++++++++++++++++++ rust/src/ffi/simpleapi.rs | 29 +++++++++ 7 files changed, 200 insertions(+) diff --git a/codegen/codegen.py b/codegen/codegen.py index c18303c..e4fbfc2 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -347,6 +347,10 @@ def define_classes(): classes.append(c) c = ClassDescriptor("receipt_credential", "receipts", "api::receipts::ReceiptCredential", 129) + c.add_method("get_receipt_expiration_time", "long", "receipt_expiration_time", [], + """ let receipt_expiration_time = receipt_credential.get_receipt_expiration_time();""") + c.add_method("get_receipt_level", "long", "receipt_level", [], + """ let receipt_level = receipt_credential.get_receipt_level();""") classes.append(c) c = ClassDescriptor("receipt_credential_presentation", "receipts", "api::receipts::ReceiptCredentialPresentation", 329) diff --git a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java index 9907044..a9b912c 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java @@ -109,6 +109,8 @@ private static void copyToTempFileAndLoad(InputStream in, String extension) thro public static native int receiptCredentialRequestContextCheckValidContentsJNI(byte[] self); public static native int receiptCredentialRequestCheckValidContentsJNI(byte[] self); public static native int receiptCredentialResponseCheckValidContentsJNI(byte[] self); + public static native int receiptCredentialGetReceiptExpirationTimeJNI(byte[] self, byte[] output); + public static native int receiptCredentialGetReceiptLevelJNI(byte[] self, byte[] output); public static native int receiptCredentialCheckValidContentsJNI(byte[] self); public static native int receiptCredentialPresentationCheckValidContentsJNI(byte[] self); public static native int uuidCiphertextCheckValidContentsJNI(byte[] self); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java index 9de846b..283c14c 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java @@ -9,6 +9,7 @@ package org.signal.zkgroup.receipts; +import java.nio.ByteBuffer; import org.signal.zkgroup.InvalidInputException; import org.signal.zkgroup.ZkGroupError; import org.signal.zkgroup.internal.ByteArray; @@ -32,6 +33,30 @@ public ReceiptCredential(byte[] contents) throws InvalidInputException { } } + public int getReceiptExpirationTime() { + byte[] newContents = new byte[8]; + + int ffi_return = Native.receiptCredentialGetReceiptExpirationTimeJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return ByteBuffer.wrap(newContents).getLong(); + } + + public int getReceiptLevel() { + byte[] newContents = new byte[8]; + + int ffi_return = Native.receiptCredentialGetReceiptLevelJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return ByteBuffer.wrap(newContents).getLong(); + } + public byte[] serialize() { return contents.clone(); } diff --git a/ffi/swift/Sources/ZKGroup/ReceiptCredential.swift b/ffi/swift/Sources/ZKGroup/ReceiptCredential.swift index 2459031..04f2145 100644 --- a/ffi/swift/Sources/ZKGroup/ReceiptCredential.swift +++ b/ffi/swift/Sources/ZKGroup/ReceiptCredential.swift @@ -28,6 +28,34 @@ public class ReceiptCredential : ByteArray { } } + public func getReceiptExpirationTime() throws -> UInt64 { + var newContents: [UInt8] = Array(repeating: 0, count: Int(8)) + + let ffi_return = FFI_ReceiptCredential_getReceiptExpirationTime(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + let data = Data(bytes: newContents) + let value = UInt64(bigEndian: data.withUnsafeBytes { $0.pointee }) + return value + } + + public func getReceiptLevel() throws -> UInt64 { + var newContents: [UInt8] = Array(repeating: 0, count: Int(8)) + + let ffi_return = FFI_ReceiptCredential_getReceiptLevel(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + let data = Data(bytes: newContents) + let value = UInt64(bigEndian: data.withUnsafeBytes { $0.pointee }) + return value + } + public func serialize() -> [UInt8] { return contents } diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index 11f34fb..5aa63fe 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -1573,6 +1573,54 @@ pub extern "C" fn FFI_ReceiptCredential_checkValidContents( } } +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredential_getReceiptExpirationTime( + receiptCredential: *const u8, + receiptCredentialLen: u32, + receiptExpirationTimeOut: *mut u8, + receiptExpirationTimeLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential: &[u8] = + unsafe { slice::from_raw_parts(receiptCredential, receiptCredentialLen as usize) }; + let receipt_expiration_time: &mut [u8] = unsafe { + slice::from_raw_parts_mut(receiptExpirationTimeOut, receiptExpirationTimeLen as usize) + }; + + simpleapi::ReceiptCredential_getReceiptExpirationTime( + receipt_credential, + receipt_expiration_time, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredential_getReceiptLevel( + receiptCredential: *const u8, + receiptCredentialLen: u32, + receiptLevelOut: *mut u8, + receiptLevelLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential: &[u8] = + unsafe { slice::from_raw_parts(receiptCredential, receiptCredentialLen as usize) }; + let receipt_level: &mut [u8] = + unsafe { slice::from_raw_parts_mut(receiptLevelOut, receiptLevelLen as usize) }; + + simpleapi::ReceiptCredential_getReceiptLevel(receipt_credential, receipt_level) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ReceiptCredentialPresentation_checkValidContents( receiptCredentialPresentation: *const u8, diff --git a/rust/src/ffi/ffiapijava.rs b/rust/src/ffi/ffiapijava.rs index dc314c9..1b16a02 100644 --- a/rust/src/ffi/ffiapijava.rs +++ b/rust/src/ffi/ffiapijava.rs @@ -1813,6 +1813,70 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredential } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialGetReceiptExpirationTimeJNI( + env: JNIEnv, + _class: JClass, + receiptCredential: jbyteArray, + receiptExpirationTimeOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential = env.convert_byte_array(receiptCredential).unwrap(); + let mut receipt_expiration_time: Vec = + vec![0; env.get_array_length(receiptExpirationTimeOut).unwrap() as usize]; + + let ffi_return = simpleapi::ReceiptCredential_getReceiptExpirationTime( + &receipt_credential, + &mut receipt_expiration_time, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + receiptExpirationTimeOut, + 0, + &u8toi8(receipt_expiration_time)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialGetReceiptLevelJNI( + env: JNIEnv, + _class: JClass, + receiptCredential: jbyteArray, + receiptLevelOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential = env.convert_byte_array(receiptCredential).unwrap(); + let mut receipt_level: Vec = + vec![0; env.get_array_length(receiptLevelOut).unwrap() as usize]; + + let ffi_return = + simpleapi::ReceiptCredential_getReceiptLevel(&receipt_credential, &mut receipt_level); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region(receiptLevelOut, 0, &u8toi8(receipt_level)[..]) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialPresentationCheckValidContentsJNI( env: JNIEnv, diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index 6b9d9ee..356c4e2 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -1073,6 +1073,35 @@ pub fn ReceiptCredential_checkValidContents(receiptCredentialIn: &[u8]) -> i32 { FFI_RETURN_OK } +pub fn ReceiptCredential_getReceiptExpirationTime( + receiptCredentialIn: &[u8], + receiptExpirationTimeOut: &mut [u8], +) -> i32 { + let receipt_credential: api::receipts::ReceiptCredential = + match bincode::deserialize(receiptCredentialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let receipt_expiration_time = receipt_credential.get_receipt_expiration_time(); + receiptExpirationTimeOut + .copy_from_slice(&bincode::serialize(&receipt_expiration_time).unwrap()); + FFI_RETURN_OK +} + +pub fn ReceiptCredential_getReceiptLevel( + receiptCredentialIn: &[u8], + receiptLevelOut: &mut [u8], +) -> i32 { + let receipt_credential: api::receipts::ReceiptCredential = + match bincode::deserialize(receiptCredentialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let receipt_level = receipt_credential.get_receipt_level(); + receiptLevelOut.copy_from_slice(&bincode::serialize(&receipt_level).unwrap()); + FFI_RETURN_OK +} + pub fn ReceiptCredentialPresentation_checkValidContents( receiptCredentialPresentationIn: &[u8], ) -> i32 { From f9a47907d23ea9e39ad7d83d82a70313130a27a3 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 27 Sep 2021 14:27:11 -0500 Subject: [PATCH 61/69] Fix java codegen long return type --- codegen/codegen_java.py | 2 +- .../java/org/signal/zkgroup/receipts/ReceiptCredential.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codegen/codegen_java.py b/codegen/codegen_java.py index 2498925..ca6aeee 100644 --- a/codegen/codegen_java.py +++ b/codegen/codegen_java.py @@ -243,7 +243,7 @@ template_method_long = \ """ - %(access)s int %(method_name)s(%(param_decls)s) %(exception_decl)s{ + %(access)s long %(method_name)s(%(param_decls)s) %(exception_decl)s{ byte[] newContents = new byte[8]; int ffi_return = Native.%(jni_method_name)s(%(contents)s, %(param_args)snewContents);%(exception_check)s diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java index 283c14c..5cc6302 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredential.java @@ -33,7 +33,7 @@ public ReceiptCredential(byte[] contents) throws InvalidInputException { } } - public int getReceiptExpirationTime() { + public long getReceiptExpirationTime() { byte[] newContents = new byte[8]; int ffi_return = Native.receiptCredentialGetReceiptExpirationTimeJNI(contents, newContents); @@ -45,7 +45,7 @@ public int getReceiptExpirationTime() { return ByteBuffer.wrap(newContents).getLong(); } - public int getReceiptLevel() { + public long getReceiptLevel() { byte[] newContents = new byte[8]; int ffi_return = Native.receiptCredentialGetReceiptLevelJNI(contents, newContents); From eab70c81e1a53d4831e3255f7b29924dabe968dc Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 27 Sep 2021 14:40:11 -0500 Subject: [PATCH 62/69] Use be bytes instead of bincode's default le --- codegen/codegen_simpleapi.py | 8 ++++++-- rust/src/ffi/simpleapi.rs | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/codegen/codegen_simpleapi.py b/codegen/codegen_simpleapi.py index 8f7b7f5..39a065b 100644 --- a/codegen/codegen_simpleapi.py +++ b/codegen/codegen_simpleapi.py @@ -37,6 +37,10 @@ """ %sOut.copy_from_slice(&%s);""" +template_ret_int = \ +""" + %sOut.copy_from_slice(&%s.to_be_bytes());""" + template_method_decl_end = \ """ @@ -107,8 +111,8 @@ def print_method(c, m, rustClasses, static): if m.return_name.snake() == "change_signature" or m.return_name.snake() == "notary_signature" or \ m.return_type == "byte[]": s += template_ret_simple % (m.return_name.lower_camel(), m.return_name.snake()) - elif m.return_name.snake() == "redemption_time": - s += "\n redemptionTimeOut.copy_from_slice(&redemption_time.to_be_bytes());" + elif m.return_type == "int" or m.return_type == "long": + s += template_ret_int % (m.return_name.lower_camel(), m.return_name.snake()) elif m.return_type != "boolean": s += template_ret % (m.return_name.lower_camel(), m.return_name.snake()) diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index 356c4e2..565c12f 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -1083,8 +1083,7 @@ pub fn ReceiptCredential_getReceiptExpirationTime( Err(_) => return FFI_RETURN_INTERNAL_ERROR, }; let receipt_expiration_time = receipt_credential.get_receipt_expiration_time(); - receiptExpirationTimeOut - .copy_from_slice(&bincode::serialize(&receipt_expiration_time).unwrap()); + receiptExpirationTimeOut.copy_from_slice(&receipt_expiration_time.to_be_bytes()); FFI_RETURN_OK } @@ -1098,7 +1097,7 @@ pub fn ReceiptCredential_getReceiptLevel( Err(_) => return FFI_RETURN_INTERNAL_ERROR, }; let receipt_level = receipt_credential.get_receipt_level(); - receiptLevelOut.copy_from_slice(&bincode::serialize(&receipt_level).unwrap()); + receiptLevelOut.copy_from_slice(&receipt_level.to_be_bytes()); FFI_RETURN_OK } From 39708c27684e9033fbc2019b0a7d202afdd0e96b Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 27 Sep 2021 15:11:10 -0500 Subject: [PATCH 63/69] Add receipt level and expiration time getters to node --- ffi/node/test/ZKGroup-test.ts | 2 ++ ffi/node/zkgroup/internal/Native.ts | 4 +++ .../zkgroup/receipts/ReceiptCredential.ts | 26 ++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ffi/node/test/ZKGroup-test.ts b/ffi/node/test/ZKGroup-test.ts index bd238d8..a4e1f44 100644 --- a/ffi/node/test/ZKGroup-test.ts +++ b/ffi/node/test/ZKGroup-test.ts @@ -259,6 +259,8 @@ describe('ZKGroup', () => { // client const credential = clientOps.receiveReceiptCredential(context, response); + assert(receiptExpirationTime == credential.getReceiptExpirationTime()); + assert(receiptLevel == credential.getReceiptLevel()); const presentation = clientOps.createReceiptCredentialPresentation(credential); // redemption server diff --git a/ffi/node/zkgroup/internal/Native.ts b/ffi/node/zkgroup/internal/Native.ts index a3a46ec..fc4e53c 100644 --- a/ffi/node/zkgroup/internal/Native.ts +++ b/ffi/node/zkgroup/internal/Native.ts @@ -75,6 +75,8 @@ interface NativeCalls { FFI_ReceiptCredentialRequest_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, FFI_ReceiptCredentialResponse_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, FFI_ReceiptCredential_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, + FFI_ReceiptCredential_getReceiptExpirationTime: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_ReceiptCredential_getReceiptLevel: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ReceiptCredentialPresentation_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, FFI_UuidCiphertext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCiphertext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, @@ -127,6 +129,8 @@ const library: NativeCalls = Library(libraryPath, { 'FFI_ProfileKeyCredentialRequest_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredentialResponse_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredential_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], + 'FFI_ReceiptCredential_getReceiptExpirationTime': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], + 'FFI_ReceiptCredential_getReceiptLevel': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredentialPresentation_getUuidCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ProfileKeyCredentialPresentation_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], diff --git a/ffi/node/zkgroup/receipts/ReceiptCredential.ts b/ffi/node/zkgroup/receipts/ReceiptCredential.ts index 3df583b..0f724b1 100644 --- a/ffi/node/zkgroup/receipts/ReceiptCredential.ts +++ b/ffi/node/zkgroup/receipts/ReceiptCredential.ts @@ -8,7 +8,7 @@ */ import ByteArray from '../internal/ByteArray'; -import {FFICompatArrayType} from '../internal/FFICompatArray'; +import FFICompatArray, {FFICompatArrayType} from '../internal/FFICompatArray'; import InvalidInputException from '../errors/InvalidInputException'; import ZkGroupError from '../errors/ZkGroupError'; import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; @@ -30,4 +30,28 @@ export default class ReceiptCredential extends ByteArray { throw new ZkGroupError('FFI_RETURN!=OK'); } } + + getReceiptExpirationTime(): string | number { + const newContents = new FFICompatArray(Buffer.alloc(8)); + + const ffi_return = Native.FFI_ReceiptCredential_getReceiptExpirationTime(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return newContents.buffer.readUInt64BE(0); + } + + getReceiptLevel(): string | number { + const newContents = new FFICompatArray(Buffer.alloc(8)); + + const ffi_return = Native.FFI_ReceiptCredential_getReceiptLevel(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return newContents.buffer.readUInt64BE(0); + } } From e5958e49e31369e991473ec4173378f3359988d1 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 27 Sep 2021 15:13:07 -0500 Subject: [PATCH 64/69] Bump version to 0.8.1 --- Cargo.lock | 2 +- ZKGroup.podspec | 2 +- deploy.gradle | 2 +- ffi/node/package-lock.json | 4 ++-- ffi/node/package.json | 2 +- rust/Cargo.toml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ce2fe5..507f593 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1007,7 +1007,7 @@ checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" [[package]] name = "zkgroup" -version = "0.8.0" +version = "0.8.1" dependencies = [ "aead", "aes-gcm-siv", diff --git a/ZKGroup.podspec b/ZKGroup.podspec index 15b0d58..8ab81eb 100644 --- a/ZKGroup.podspec +++ b/ZKGroup.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "ZKGroup" - s.version = "0.8.0" + s.version = "0.8.1" s.summary = "Swift API for the Rust zkgroup crate." s.homepage = "https://signal.org/" s.license = { :type => "GPLv3", :file => "LICENSE" } diff --git a/deploy.gradle b/deploy.gradle index 47f48ed..77a3489 100644 --- a/deploy.gradle +++ b/deploy.gradle @@ -1,7 +1,7 @@ apply plugin: 'maven' apply plugin: 'signing' -version = '0.8.0' +version = '0.8.1' group = 'org.signal' def isReleaseBuild() { diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 1311835..6e79cd0 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,12 +1,12 @@ { "name": "zkgroup", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "zkgroup", - "version": "0.8.0", + "version": "0.8.1", "license": "ISC", "dependencies": { "@types/ffi-napi": "^4.0.1", diff --git a/ffi/node/package.json b/ffi/node/package.json index 7388beb..58349f1 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.8.0", + "version": "0.8.1", "description": "zero-knowledge group functionality", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index da60260..b46d124 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "zkgroup" -version = "0.8.0" +version = "0.8.1" authors = ["Trevor Perrin "] edition = "2018" description = "A zero-knowledge group library" From 82ea1a21913d67e2d207052860ad94b92f1d0241 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Mon, 27 Sep 2021 15:26:31 -0500 Subject: [PATCH 65/69] Update C header files --- ffi/c/zkgroup.h | 10 ++++++++++ ffi/swift/Sources/libzkgroup/zkgroup.h | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/ffi/c/zkgroup.h b/ffi/c/zkgroup.h index 45774dc..bdb0384 100644 --- a/ffi/c/zkgroup.h +++ b/ffi/c/zkgroup.h @@ -407,6 +407,16 @@ int32_t FFI_ReceiptCredentialResponse_checkValidContents(const uint8_t *receiptC int32_t FFI_ReceiptCredential_checkValidContents(const uint8_t *receiptCredential, uint32_t receiptCredentialLen); +int32_t FFI_ReceiptCredential_getReceiptExpirationTime(const uint8_t *receiptCredential, + uint32_t receiptCredentialLen, + uint8_t *receiptExpirationTimeOut, + uint32_t receiptExpirationTimeLen); + +int32_t FFI_ReceiptCredential_getReceiptLevel(const uint8_t *receiptCredential, + uint32_t receiptCredentialLen, + uint8_t *receiptLevelOut, + uint32_t receiptLevelLen); + int32_t FFI_ReceiptCredentialPresentation_checkValidContents(const uint8_t *receiptCredentialPresentation, uint32_t receiptCredentialPresentationLen); diff --git a/ffi/swift/Sources/libzkgroup/zkgroup.h b/ffi/swift/Sources/libzkgroup/zkgroup.h index 45774dc..bdb0384 100644 --- a/ffi/swift/Sources/libzkgroup/zkgroup.h +++ b/ffi/swift/Sources/libzkgroup/zkgroup.h @@ -407,6 +407,16 @@ int32_t FFI_ReceiptCredentialResponse_checkValidContents(const uint8_t *receiptC int32_t FFI_ReceiptCredential_checkValidContents(const uint8_t *receiptCredential, uint32_t receiptCredentialLen); +int32_t FFI_ReceiptCredential_getReceiptExpirationTime(const uint8_t *receiptCredential, + uint32_t receiptCredentialLen, + uint8_t *receiptExpirationTimeOut, + uint32_t receiptExpirationTimeLen); + +int32_t FFI_ReceiptCredential_getReceiptLevel(const uint8_t *receiptCredential, + uint32_t receiptCredentialLen, + uint8_t *receiptLevelOut, + uint32_t receiptLevelLen); + int32_t FFI_ReceiptCredentialPresentation_checkValidContents(const uint8_t *receiptCredentialPresentation, uint32_t receiptCredentialPresentationLen); From bbd71fd1fb56cbaf5af6e20d3837b210d5bbd5e2 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Wed, 29 Sep 2021 15:06:45 -0500 Subject: [PATCH 66/69] Add three new accessor methods for the presentation --- Cargo.lock | 2 +- ZKGroup.podspec | 2 +- codegen/Makefile | 5 + codegen/codegen.py | 58 ++++++---- codegen/codegen_hack.patch | 24 +--- codegen/codegen_java.py | 12 +- codegen/codegen_swift.py | 11 +- deploy.gradle | 2 +- ffi/c/Makefile | 3 - ffi/c/zkgroup.h | 15 +++ .../zkgroup/groups/ClientZkGroupCipher.java | 6 +- .../org/signal/zkgroup/internal/Native.java | 3 + .../profiles/ClientZkProfileOperations.java | 2 +- .../ReceiptCredentialPresentation.java | 42 +++++++ ffi/node/package-lock.json | 4 +- ffi/node/package.json | 2 +- ffi/node/zkgroup/internal/Native.ts | 6 + .../receipts/ReceiptCredentialPresentation.ts | 39 ++++++- .../Sources/ZKGroup/ClientZkGroupCipher.swift | 5 +- .../ReceiptCredentialPresentation.swift | 45 ++++++++ ffi/swift/Sources/libzkgroup/zkgroup.h | 15 +++ rust/Cargo.toml | 2 +- .../receipt_credential_presentation.rs | 12 ++ rust/src/ffi/ffiapi.rs | 88 +++++++++++++++ rust/src/ffi/ffiapijava.rs | 103 ++++++++++++++++++ rust/src/ffi/simpleapi.rs | 42 +++++++ 26 files changed, 474 insertions(+), 76 deletions(-) delete mode 100644 ffi/c/Makefile diff --git a/Cargo.lock b/Cargo.lock index 507f593..2ae6a61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1007,7 +1007,7 @@ checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" [[package]] name = "zkgroup" -version = "0.8.1" +version = "0.8.2" dependencies = [ "aead", "aes-gcm-siv", diff --git a/ZKGroup.podspec b/ZKGroup.podspec index 8ab81eb..3a4b1ab 100644 --- a/ZKGroup.podspec +++ b/ZKGroup.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "ZKGroup" - s.version = "0.8.1" + s.version = "0.8.2" s.summary = "Swift API for the Rust zkgroup crate." s.homepage = "https://signal.org/" s.license = { :type => "GPLv3", :file => "LICENSE" } diff --git a/codegen/Makefile b/codegen/Makefile index 712dd67..c322c53 100644 --- a/codegen/Makefile +++ b/codegen/Makefile @@ -6,6 +6,7 @@ all: .PHONY: output output: + mkdir -p c mkdir -p ffiapijava mkdir -p ffiapi mkdir -p java @@ -20,6 +21,7 @@ output: rustfmt ffiapijava/ffiapijava.rs rustfmt ffiapi/ffiapi.rs rustfmt simpleapi/simpleapi.rs + cbindgen --quiet --lang c ../rust -o c/zkgroup.h .PHONY: install install: @@ -28,10 +30,13 @@ install: cp simpleapi/simpleapi.rs ../rust/src/ffi/ cp -r java/* ../ffi/java/src/main/java/org/signal/zkgroup cp -r swift/* ../ffi/swift/Sources/ZKGroup + cp c/zkgroup.h ../ffi/c/zkgroup.h + cp c/zkgroup.h ../ffi/swift/Sources/libzkgroup/zkgroup.h patch -d .. -p1 < codegen_hack.patch .PHONY: clean clean: + rm -rf c rm -rf ffiapijava rm -rf ffiapi rm -rf java diff --git a/codegen/codegen.py b/codegen/codegen.py index e4fbfc2..238bf86 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -3,7 +3,6 @@ import codegen_ffiapijava import codegen_simpleapi import codegen_swift -import sys class Name: def __init__(self, name): @@ -32,8 +31,8 @@ def lower_camel(self): return ret class StaticMethodDescriptor: - def __init__(self, method_name, return_type, return_name, params, rustCode, verification=False, runtime_error=False, - return_size_increment=0): + def __init__(self, method_name, return_type, return_name, params, rustCode, verification=False, runtime_error=False, + return_size_increment=0, relative_return_size=None): self.method_name = Name(method_name) self.return_type = return_type self.return_name = Name(return_name) @@ -42,10 +41,11 @@ def __init__(self, method_name, return_type, return_name, params, rustCode, veri self.verification = verification self.runtime_error = runtime_error self.return_size_increment = return_size_increment + self.relative_return_size = relative_return_size class MethodDescriptor: def __init__(self, method_name, return_type, return_name, params, rustCode, verification=False, runtime_error=False, - unused_self=False, return_size_increment=0): + unused_self=False, return_size_increment=0, relative_return_size=None): self.method_name = Name(method_name) self.return_type = return_type self.return_name = Name(return_name) @@ -55,9 +55,9 @@ def __init__(self, method_name, return_type, return_name, params, rustCode, veri self.runtime_error = runtime_error self.unused_self = unused_self self.return_size_increment = return_size_increment + self.relative_return_size = relative_return_size class ClassDescriptor: - def __init__(self, class_name, dir_name, rust_class_name, class_len_int, check_valid_contents=True, no_class=False, no_serialize=False, runtime_error_on_serialize=False, string_contents=False, wrap_class=None): self.class_name = Name(class_name) @@ -81,17 +81,21 @@ def __init__(self, class_name, dir_name, rust_class_name, class_len_int, check_v else: self.wrap_class = None - def add_static_method(self, method_name, return_type, return_name, params, rustCode="", verification=False, runtime_error=False, - return_size_increment=0): + def add_static_method( + self, method_name, return_type, return_name, params, rust_code="", verification=False, runtime_error=False, + return_size_increment=0, relative_return_size=None): params2 = [(p[0], Name(p[1])) for p in params] - self.static_methods.append(StaticMethodDescriptor(method_name, return_type, return_name, params2, rustCode, verification, runtime_error, - return_size_increment)) + self.static_methods.append(StaticMethodDescriptor( + method_name, return_type, return_name, params2, rust_code, verification, runtime_error, + return_size_increment, relative_return_size=relative_return_size)) - def add_method(self, method_name, return_type, return_name, params, rustCode="", verification=False, runtime_error=False, - return_size_increment=0, unused_self=False): + def add_method( + self, method_name, return_type, return_name, params, rust_code="", verification=False, runtime_error=False, + return_size_increment=0, unused_self=False, relative_return_size=None): params2 = [(p[0], Name(p[1])) for p in params] - self.methods.append(MethodDescriptor(method_name, return_type, return_name, params2, rustCode, verification, runtime_error, - unused_self, return_size_increment)) + self.methods.append(MethodDescriptor( + method_name, return_type, return_name, params2, rust_code, verification, runtime_error, unused_self, + return_size_increment, relative_return_size=relative_return_size)) def define_classes(): classes = [] @@ -125,7 +129,7 @@ def define_classes(): c = ClassDescriptor("group_secret_params", "groups", "api::groups::GroupSecretParams", 289, runtime_error_on_serialize=True) c.add_static_method("generate_deterministic", "class", "group_secret_params", [("class", "randomness")], - """ let group_secret_params = api::groups::GroupSecretParams::generate(randomness);""" ) + """ let group_secret_params = api::groups::GroupSecretParams::generate(randomness);""" ) c.add_static_method("derive_from_master_key", "class", "group_secret_params", [("class", "group_master_key")], """ let group_secret_params = api::groups::GroupSecretParams::derive_from_master_key(group_master_key);""", runtime_error=True) @@ -140,19 +144,19 @@ def define_classes(): c = ClassDescriptor("client_zk_group_cipher", "groups", "api::groups::ClientZkGroupCipher", 192, wrap_class="group_secret_params") - c.add_method("encrypt_uuid", "class", "uuid_ciphertext", [("UUID", "uuid")], + c.add_method("encrypt_uuid", "class", "uuid_ciphertext", [("UUID", "uuid")], """ let uuid_ciphertext = group_secret_params.encrypt_uuid(uuid);""", runtime_error=True) - c.add_method("decrypt_uuid", "UUID", "uuid", [("class", "uuid_ciphertext")], + c.add_method("decrypt_uuid", "UUID", "uuid", [("class", "uuid_ciphertext")], """ let uuid = match group_secret_params.decrypt_uuid(uuid_ciphertext) { Ok(result) => result, Err(_) => return FFI_RETURN_INPUT_ERROR, };""") - c.add_method("encrypt_profile_key", "class", "profile_key_ciphertext", [("class", "profile_key"), ("UUID", "uuid")], + c.add_method("encrypt_profile_key", "class", "profile_key_ciphertext", [("class", "profile_key"), ("UUID", "uuid")], """ let profile_key_ciphertext = group_secret_params.encrypt_profile_key(profile_key, uuid);""", runtime_error=True) - c.add_method("decrypt_profile_key", "class", "profile_key", [("class", "profile_key_ciphertext"), ("UUID", "uuid")], + c.add_method("decrypt_profile_key", "class", "profile_key", [("class", "profile_key_ciphertext"), ("UUID", "uuid")], """ let profile_key = match group_secret_params.decrypt_profile_key(profile_key_ciphertext, uuid) { Ok(result) => result, Err(_) => return FFI_RETURN_INPUT_ERROR, @@ -162,13 +166,13 @@ def define_classes(): """ let blob_ciphertext = match group_secret_params.encrypt_blob(randomness, plaintext) { Ok(result) => result, Err(_) => return FFI_RETURN_INPUT_ERROR, - };""", return_size_increment=+29) + };""", return_size_increment=+29, relative_return_size=1) - c.add_method("decrypt_blob", "byte[]", "plaintext", [("byte[]", "blob_ciphertext")], + c.add_method("decrypt_blob", "byte[]", "plaintext", [("byte[]", "blob_ciphertext")], """ let plaintext = match group_secret_params.decrypt_blob(blob_ciphertext) { Ok(result) => result, Err(_) => return FFI_RETURN_INPUT_ERROR, - };""", return_size_increment=-29) + };""", return_size_increment=-29, relative_return_size=0) classes.append(c) @@ -188,7 +192,7 @@ def define_classes(): classes.append(c) c = ClassDescriptor("client_zk_auth_operations", "auth", "api::auth::ClientZkAuthOperations", 256, wrap_class="server_public_params") - + c.add_method("receive_auth_credential", "class", "auth_credential", [("UUID", "uuid"), ("int", "redemption_time"), ("class", "auth_credential_response")], """ let auth_credential = match server_public_params.receive_auth_credential(uuid, redemption_time, &auth_credential_response) { Ok(result) => result, @@ -201,8 +205,8 @@ def define_classes(): classes.append(c) c = ClassDescriptor("client_zk_profile_operations", "profiles", "api::profiles::ClientZkProfileOperations", 256, wrap_class="server_public_params") - - c.add_method("create_profile_key_credential_request_context_deterministic", "class", "profile_key_credential_request_context", [("class", "randomness"), ("UUID", "uuid"), ("class", "profile_key")], + + c.add_method("create_profile_key_credential_request_context_deterministic", "class", "profile_key_credential_request_context", [("class", "randomness"), ("UUID", "uuid"), ("class", "profile_key")], """ let profile_key_credential_request_context = server_public_params.create_profile_key_credential_request_context(randomness, uuid, profile_key);""", runtime_error=True) c.add_method("receive_profile_key_credential", "class", "profile_key_credential", [("class", "profile_key_credential_request_context"), ("class", "profile_key_credential_response")], @@ -354,6 +358,12 @@ def define_classes(): classes.append(c) c = ClassDescriptor("receipt_credential_presentation", "receipts", "api::receipts::ReceiptCredentialPresentation", 329) + c.add_method("get_receipt_expiration_time", "long", "receipt_expiration_time", [], + """ let receipt_expiration_time = receipt_credential_presentation.get_receipt_expiration_time();""") + c.add_method("get_receipt_level", "long", "receipt_level", [], + """ let receipt_level = receipt_credential_presentation.get_receipt_level();""") + c.add_method("get_receipt_serial", "class", "receipt_serial", [], + """ let receipt_serial = receipt_credential_presentation.get_receipt_serial_bytes();""") classes.append(c) c = ClassDescriptor("uuid_ciphertext", "groups", "api::groups::UuidCiphertext", 65) diff --git a/codegen/codegen_hack.patch b/codegen/codegen_hack.patch index d192df2..7a5ad56 100644 --- a/codegen/codegen_hack.patch +++ b/codegen/codegen_hack.patch @@ -50,12 +50,12 @@ index 464cf6d19ecc..5739505935b0 100644 } public byte[] encryptBlob(SecureRandom secureRandom, byte[] plaintext) throws VerificationFailedException { -- byte[] newContents = new byte[plaintext.length+29]; +- byte[] newContents = new byte[plaintext.length + 29]; + + byte[] paddedPlaintext = new byte[plaintext.length + 4]; + System.arraycopy(plaintext, 0, paddedPlaintext, 4, plaintext.length); + -+ byte[] newContents = new byte[paddedPlaintext.length+29]; ++ byte[] newContents = new byte[paddedPlaintext.length + 29]; byte[] random = new byte[Native.RANDOM_LENGTH]; secureRandom.nextBytes(random); @@ -80,7 +80,7 @@ index 464cf6d19ecc..5739505935b0 100644 + if (newContents.length < (4 + padLen)) { + throw new VerificationFailedException(); + } -+ ++ + byte[] depaddedContents = new byte[newContents.length - (4 + padLen)]; + System.arraycopy(newContents, 4, depaddedContents, 0, newContents.length - (4 + padLen)); + @@ -99,7 +99,7 @@ index cbc73ac60bee..57a252f5886d 100644 + if (profileKeyCredentialResponse == null) { + throw new VerificationFailedException(); + } -+ ++ byte[] newContents = new byte[ProfileKeyCredential.SIZE]; int ffi_return = Native.serverPublicParamsReceiveProfileKeyCredentialJNI(serverPublicParams.getInternalContentsForJNI(), profileKeyCredentialRequestContext.getInternalContentsForJNI(), profileKeyCredentialResponse.getInternalContentsForJNI(), newContents); @@ -156,28 +156,16 @@ index 4d36edb46acf..fa7f1b4aba5c 100644 } public func encryptBlob(randomness: [UInt8], plaintext: [UInt8]) throws -> [UInt8] { -- var newContents: [UInt8] = Array(repeating: 0, count: Int(randomness.count+29)) +- var newContents: [UInt8] = Array(repeating: 0, count: Int(plaintext.count + 29)) + let paddedPlaintext = Array(repeating:0, count: 4) + plaintext - let ffi_return = FFI_GroupSecretParams_encryptBlobDeterministic(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), plaintext, UInt32(plaintext.count), &newContents, UInt32(newContents.count)) -+ var newContents: [UInt8] = Array(repeating: 0, count: Int(paddedPlaintext.count+29)) ++ var newContents: [UInt8] = Array(repeating: 0, count: Int(paddedPlaintext.count + 29)) + + let ffi_return = FFI_GroupSecretParams_encryptBlobDeterministic(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), paddedPlaintext, UInt32(paddedPlaintext.count), &newContents, UInt32(newContents.count)) if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { throw ZkGroupException.VerificationFailed } -@@ -117,9 +120,10 @@ public class ClientZkGroupCipher { - } - - public func decryptBlob(blobCiphertext: [UInt8]) throws -> [UInt8] { -- var newContents: [UInt8] = Array(repeating: 0, count: Int(blobCiphertext.count+-29)) -+ var newContents: [UInt8] = Array(repeating: 0, count: Int(blobCiphertext.count-29)) - - let ffi_return = FFI_GroupSecretParams_decryptBlob(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), blobCiphertext, UInt32(blobCiphertext.count), &newContents, UInt32(newContents.count)) -+ - if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { - throw ZkGroupException.VerificationFailed - } @@ -128,7 +131,18 @@ public class ClientZkGroupCipher { throw ZkGroupException.ZkGroupError } diff --git a/codegen/codegen_java.py b/codegen/codegen_java.py index ca6aeee..c87f173 100644 --- a/codegen/codegen_java.py +++ b/codegen/codegen_java.py @@ -604,14 +604,8 @@ def print_class(c, runtime_error_on_serialize_dict, class_dir_dict): template = template_method_bytearray param_args = get_args(method.params, import_strings, True) append_jni_function_decl(jni_method_name, method.params, True, True) - if method.params[0][1].lower_camel() == "randomness": - return_len = method.params[1][1].lower_camel() # hardcode to second arg if first is randomness - else: - return_len = method.params[0][1].lower_camel() # hardcode to first arg - if method.return_size_increment >= 0: - return_len += ".length+%d" % method.return_size_increment - if method.return_size_increment < 0: - return_len += ".length%d" % method.return_size_increment + if method.relative_return_size is not None: + return_len = f"{method.params[method.relative_return_size][1].lower_camel()}.length + {method.return_size_increment}" else: add_import(import_strings, class_dir_dict, my_dir_name, method.return_name) if runtime_error_on_serialize_dict[method.return_name.snake()]: @@ -623,7 +617,7 @@ def print_class(c, runtime_error_on_serialize_dict, class_dir_dict): append_jni_function_decl(jni_method_name, method.params, True, True) if method.return_name.snake() == "uuid": return_len = "UUIDUtil.UUID_LENGTH" - elif return_len == None: + elif return_len is None: return_len = method.return_name.camel() + ".SIZE" diff --git a/codegen/codegen_swift.py b/codegen/codegen_swift.py index 5f7f0fe..e4c0bfd 100644 --- a/codegen/codegen_swift.py +++ b/codegen/codegen_swift.py @@ -541,11 +541,8 @@ def print_class(c, runtime_error_on_serialize_dict, class_dir_dict): elif method.return_type == "byte[]": # copied from UUID? template = template_method_bytearray param_args = get_args(method.params, import_strings, True) - return_len = method.params[0][1].lower_camel() # hardcode to first arg - if method.return_size_increment >= 0: - return_len += ".count+%d" % method.return_size_increment - if method.return_size_increment < 0: - return_len += ".count+%d" % method.return_size_increment + if method.relative_return_size is not None: + return_len = f"{method.params[method.relative_return_size][1].lower_camel()}.count + {method.return_size_increment}" else: add_import(import_strings, class_dir_dict, my_dir_name, method.return_name) if runtime_error_on_serialize_dict[method.return_name.snake()]: @@ -553,9 +550,9 @@ def print_class(c, runtime_error_on_serialize_dict, class_dir_dict): else: template = template_method param_args = get_args(method.params, import_strings, True) - if return_name == None: + if return_name is None: return_name = method.return_name.camel() - if return_len == None: + if return_len is None: return_len = method.return_name.camel() + ".SIZE" diff --git a/deploy.gradle b/deploy.gradle index 77a3489..b2ce322 100644 --- a/deploy.gradle +++ b/deploy.gradle @@ -1,7 +1,7 @@ apply plugin: 'maven' apply plugin: 'signing' -version = '0.8.1' +version = '0.8.2' group = 'org.signal' def isReleaseBuild() { diff --git a/ffi/c/Makefile b/ffi/c/Makefile deleted file mode 100644 index 1c0e2cc..0000000 --- a/ffi/c/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -.PHONY: zkgroup.h -zkgroup.h: - cbindgen --lang c ../../rust -o zkgroup.h diff --git a/ffi/c/zkgroup.h b/ffi/c/zkgroup.h index bdb0384..d93e53d 100644 --- a/ffi/c/zkgroup.h +++ b/ffi/c/zkgroup.h @@ -420,6 +420,21 @@ int32_t FFI_ReceiptCredential_getReceiptLevel(const uint8_t *receiptCredential, int32_t FFI_ReceiptCredentialPresentation_checkValidContents(const uint8_t *receiptCredentialPresentation, uint32_t receiptCredentialPresentationLen); +int32_t FFI_ReceiptCredentialPresentation_getReceiptExpirationTime(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen, + uint8_t *receiptExpirationTimeOut, + uint32_t receiptExpirationTimeLen); + +int32_t FFI_ReceiptCredentialPresentation_getReceiptLevel(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen, + uint8_t *receiptLevelOut, + uint32_t receiptLevelLen); + +int32_t FFI_ReceiptCredentialPresentation_getReceiptSerial(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen, + uint8_t *receiptSerialOut, + uint32_t receiptSerialLen); + int32_t FFI_UuidCiphertext_checkValidContents(const uint8_t *uuidCiphertext, uint32_t uuidCiphertextLen); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java b/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java index 5739505..9fcf347 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/groups/ClientZkGroupCipher.java @@ -105,7 +105,7 @@ public byte[] encryptBlob(SecureRandom secureRandom, byte[] plaintext) throws Ve byte[] paddedPlaintext = new byte[plaintext.length + 4]; System.arraycopy(plaintext, 0, paddedPlaintext, 4, plaintext.length); - byte[] newContents = new byte[paddedPlaintext.length+29]; + byte[] newContents = new byte[paddedPlaintext.length + 29]; byte[] random = new byte[Native.RANDOM_LENGTH]; secureRandom.nextBytes(random); @@ -123,7 +123,7 @@ public byte[] encryptBlob(SecureRandom secureRandom, byte[] plaintext) throws Ve } public byte[] decryptBlob(byte[] blobCiphertext) throws VerificationFailedException { - byte[] newContents = new byte[blobCiphertext.length-29]; + byte[] newContents = new byte[blobCiphertext.length + -29]; int ffi_return = Native.groupSecretParamsDecryptBlobJNI(groupSecretParams.getInternalContentsForJNI(), blobCiphertext, newContents); if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { @@ -144,7 +144,7 @@ public byte[] decryptBlob(byte[] blobCiphertext) throws VerificationFailedExcept if (newContents.length < (4 + padLen)) { throw new VerificationFailedException(); } - + byte[] depaddedContents = new byte[newContents.length - (4 + padLen)]; System.arraycopy(newContents, 4, depaddedContents, 0, newContents.length - (4 + padLen)); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java index a9b912c..f7d7b77 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java @@ -112,6 +112,9 @@ private static void copyToTempFileAndLoad(InputStream in, String extension) thro public static native int receiptCredentialGetReceiptExpirationTimeJNI(byte[] self, byte[] output); public static native int receiptCredentialGetReceiptLevelJNI(byte[] self, byte[] output); public static native int receiptCredentialCheckValidContentsJNI(byte[] self); + public static native int receiptCredentialPresentationGetReceiptExpirationTimeJNI(byte[] self, byte[] output); + public static native int receiptCredentialPresentationGetReceiptLevelJNI(byte[] self, byte[] output); + public static native int receiptCredentialPresentationGetReceiptSerialJNI(byte[] self, byte[] output); public static native int receiptCredentialPresentationCheckValidContentsJNI(byte[] self); public static native int uuidCiphertextCheckValidContentsJNI(byte[] self); public static native int profileKeyCiphertextCheckValidContentsJNI(byte[] self); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java index 57a252f..65566a5 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java @@ -55,7 +55,7 @@ public ProfileKeyCredential receiveProfileKeyCredential(ProfileKeyCredentialRequ if (profileKeyCredentialResponse == null) { throw new VerificationFailedException(); } - + byte[] newContents = new byte[ProfileKeyCredential.SIZE]; int ffi_return = Native.serverPublicParamsReceiveProfileKeyCredentialJNI(serverPublicParams.getInternalContentsForJNI(), profileKeyCredentialRequestContext.getInternalContentsForJNI(), profileKeyCredentialResponse.getInternalContentsForJNI(), newContents); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java index 58c7341..716d9be 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/receipts/ReceiptCredentialPresentation.java @@ -9,6 +9,7 @@ package org.signal.zkgroup.receipts; +import java.nio.ByteBuffer; import org.signal.zkgroup.InvalidInputException; import org.signal.zkgroup.ZkGroupError; import org.signal.zkgroup.internal.ByteArray; @@ -32,6 +33,47 @@ public ReceiptCredentialPresentation(byte[] contents) throws InvalidInputExcepti } } + public long getReceiptExpirationTime() { + byte[] newContents = new byte[8]; + + int ffi_return = Native.receiptCredentialPresentationGetReceiptExpirationTimeJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return ByteBuffer.wrap(newContents).getLong(); + } + + public long getReceiptLevel() { + byte[] newContents = new byte[8]; + + int ffi_return = Native.receiptCredentialPresentationGetReceiptLevelJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return ByteBuffer.wrap(newContents).getLong(); + } + + public ReceiptSerial getReceiptSerial() { + byte[] newContents = new byte[ReceiptSerial.SIZE]; + + int ffi_return = Native.receiptCredentialPresentationGetReceiptSerialJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ReceiptSerial(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + public byte[] serialize() { return contents.clone(); } diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 6e79cd0..6c8f409 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,12 +1,12 @@ { "name": "zkgroup", - "version": "0.8.1", + "version": "0.8.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "zkgroup", - "version": "0.8.1", + "version": "0.8.2", "license": "ISC", "dependencies": { "@types/ffi-napi": "^4.0.1", diff --git a/ffi/node/package.json b/ffi/node/package.json index 58349f1..e8c6114 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.8.1", + "version": "0.8.2", "description": "zero-knowledge group functionality", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/ffi/node/zkgroup/internal/Native.ts b/ffi/node/zkgroup/internal/Native.ts index fc4e53c..a893915 100644 --- a/ffi/node/zkgroup/internal/Native.ts +++ b/ffi/node/zkgroup/internal/Native.ts @@ -78,6 +78,9 @@ interface NativeCalls { FFI_ReceiptCredential_getReceiptExpirationTime: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ReceiptCredential_getReceiptLevel: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ReceiptCredentialPresentation_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, + FFI_ReceiptCredentialPresentation_getReceiptExpirationTime: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_ReceiptCredentialPresentation_getReceiptLevel: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_ReceiptCredentialPresentation_getReceiptSerial: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_UuidCiphertext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCiphertext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, } @@ -139,6 +142,9 @@ const library: NativeCalls = Library(libraryPath, { 'FFI_ReceiptCredentialRequest_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], 'FFI_ReceiptCredentialResponse_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], 'FFI_ReceiptCredential_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredentialPresentation_getReceiptExpirationTime': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredentialPresentation_getReceiptLevel': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ReceiptCredentialPresentation_getReceiptSerial': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ReceiptCredentialPresentation_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], 'FFI_UuidCiphertext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCiphertext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], diff --git a/ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts b/ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts index f4c5581..7e3d828 100644 --- a/ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts +++ b/ffi/node/zkgroup/receipts/ReceiptCredentialPresentation.ts @@ -8,10 +8,11 @@ */ import ByteArray from '../internal/ByteArray'; -import {FFICompatArrayType} from '../internal/FFICompatArray'; +import FFICompatArray, {FFICompatArrayType} from '../internal/FFICompatArray'; import InvalidInputException from '../errors/InvalidInputException'; import ZkGroupError from '../errors/ZkGroupError'; import Native, {FFI_RETURN_INPUT_ERROR, FFI_RETURN_OK} from '../internal/Native'; +import ReceiptSerial from "./ReceiptSerial"; export default class ReceiptCredentialPresentation extends ByteArray { @@ -30,4 +31,40 @@ export default class ReceiptCredentialPresentation extends ByteArray { throw new ZkGroupError('FFI_RETURN!=OK'); } } + + getReceiptExpirationTime(): string | number { + const newContents = new FFICompatArray(Buffer.alloc(8)); + + const ffi_return = Native.FFI_ReceiptCredentialPresentation_getReceiptExpirationTime(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return newContents.buffer.readUInt64BE(0); + } + + getReceiptLevel(): string | number { + const newContents = new FFICompatArray(Buffer.alloc(8)); + + const ffi_return = Native.FFI_ReceiptCredentialPresentation_getReceiptLevel(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return newContents.buffer.readUInt64BE(0); + } + + getReceiptSerialBytes(): ReceiptSerial { + const newContents = new FFICompatArray(Buffer.alloc(ReceiptSerial.SIZE)); + + const ffi_return = Native.FFI_ReceiptCredentialPresentation_getReceiptSerial(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return new ReceiptSerial(newContents); + } } diff --git a/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift index 5ab8a86..19bc270 100644 --- a/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift +++ b/ffi/swift/Sources/ZKGroup/ClientZkGroupCipher.swift @@ -104,7 +104,7 @@ public class ClientZkGroupCipher { public func encryptBlob(randomness: [UInt8], plaintext: [UInt8]) throws -> [UInt8] { let paddedPlaintext = Array(repeating:0, count: 4) + plaintext - var newContents: [UInt8] = Array(repeating: 0, count: Int(paddedPlaintext.count+29)) + var newContents: [UInt8] = Array(repeating: 0, count: Int(paddedPlaintext.count + 29)) let ffi_return = FFI_GroupSecretParams_encryptBlobDeterministic(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), paddedPlaintext, UInt32(paddedPlaintext.count), &newContents, UInt32(newContents.count)) if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { @@ -119,10 +119,9 @@ public class ClientZkGroupCipher { } public func decryptBlob(blobCiphertext: [UInt8]) throws -> [UInt8] { - var newContents: [UInt8] = Array(repeating: 0, count: Int(blobCiphertext.count-29)) + var newContents: [UInt8] = Array(repeating: 0, count: Int(blobCiphertext.count + -29)) let ffi_return = FFI_GroupSecretParams_decryptBlob(groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), blobCiphertext, UInt32(blobCiphertext.count), &newContents, UInt32(newContents.count)) - if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { throw ZkGroupException.VerificationFailed } diff --git a/ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift b/ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift index 30a77a5..07741b3 100644 --- a/ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift +++ b/ffi/swift/Sources/ZKGroup/ReceiptCredentialPresentation.swift @@ -28,6 +28,51 @@ public class ReceiptCredentialPresentation : ByteArray { } } + public func getReceiptExpirationTime() throws -> UInt64 { + var newContents: [UInt8] = Array(repeating: 0, count: Int(8)) + + let ffi_return = FFI_ReceiptCredentialPresentation_getReceiptExpirationTime(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + let data = Data(bytes: newContents) + let value = UInt64(bigEndian: data.withUnsafeBytes { $0.pointee }) + return value + } + + public func getReceiptLevel() throws -> UInt64 { + var newContents: [UInt8] = Array(repeating: 0, count: Int(8)) + + let ffi_return = FFI_ReceiptCredentialPresentation_getReceiptLevel(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + let data = Data(bytes: newContents) + let value = UInt64(bigEndian: data.withUnsafeBytes { $0.pointee }) + return value + } + + public func getReceiptSerial() throws -> ReceiptSerial { + var newContents: [UInt8] = Array(repeating: 0, count: ReceiptSerial.SIZE) + + let ffi_return = FFI_ReceiptCredentialPresentation_getReceiptSerial(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ReceiptSerial(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + public func serialize() -> [UInt8] { return contents } diff --git a/ffi/swift/Sources/libzkgroup/zkgroup.h b/ffi/swift/Sources/libzkgroup/zkgroup.h index bdb0384..d93e53d 100644 --- a/ffi/swift/Sources/libzkgroup/zkgroup.h +++ b/ffi/swift/Sources/libzkgroup/zkgroup.h @@ -420,6 +420,21 @@ int32_t FFI_ReceiptCredential_getReceiptLevel(const uint8_t *receiptCredential, int32_t FFI_ReceiptCredentialPresentation_checkValidContents(const uint8_t *receiptCredentialPresentation, uint32_t receiptCredentialPresentationLen); +int32_t FFI_ReceiptCredentialPresentation_getReceiptExpirationTime(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen, + uint8_t *receiptExpirationTimeOut, + uint32_t receiptExpirationTimeLen); + +int32_t FFI_ReceiptCredentialPresentation_getReceiptLevel(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen, + uint8_t *receiptLevelOut, + uint32_t receiptLevelLen); + +int32_t FFI_ReceiptCredentialPresentation_getReceiptSerial(const uint8_t *receiptCredentialPresentation, + uint32_t receiptCredentialPresentationLen, + uint8_t *receiptSerialOut, + uint32_t receiptSerialLen); + int32_t FFI_UuidCiphertext_checkValidContents(const uint8_t *uuidCiphertext, uint32_t uuidCiphertextLen); diff --git a/rust/Cargo.toml b/rust/Cargo.toml index b46d124..f6478b2 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "zkgroup" -version = "0.8.1" +version = "0.8.2" authors = ["Trevor Perrin "] edition = "2018" description = "A zero-knowledge group library" diff --git a/rust/src/api/receipts/receipt_credential_presentation.rs b/rust/src/api/receipts/receipt_credential_presentation.rs index f48bbee..3fbe3af 100644 --- a/rust/src/api/receipts/receipt_credential_presentation.rs +++ b/rust/src/api/receipts/receipt_credential_presentation.rs @@ -33,4 +33,16 @@ impl ReceiptCredentialPresentation { receipt_level: self.receipt_level, } } + + pub fn get_receipt_expiration_time(&self) -> ReceiptExpirationTime { + self.receipt_expiration_time + } + + pub fn get_receipt_level(&self) -> ReceiptLevel { + self.receipt_level + } + + pub fn get_receipt_serial_bytes(&self) -> ReceiptSerialBytes { + self.receipt_serial_bytes + } } diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index 5aa63fe..3b36bac 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -1643,6 +1643,94 @@ pub extern "C" fn FFI_ReceiptCredentialPresentation_checkValidContents( } } +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialPresentation_getReceiptExpirationTime( + receiptCredentialPresentation: *const u8, + receiptCredentialPresentationLen: u32, + receiptExpirationTimeOut: *mut u8, + receiptExpirationTimeLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialPresentation, + receiptCredentialPresentationLen as usize, + ) + }; + let receipt_expiration_time: &mut [u8] = unsafe { + slice::from_raw_parts_mut(receiptExpirationTimeOut, receiptExpirationTimeLen as usize) + }; + + simpleapi::ReceiptCredentialPresentation_getReceiptExpirationTime( + receipt_credential_presentation, + receipt_expiration_time, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialPresentation_getReceiptLevel( + receiptCredentialPresentation: *const u8, + receiptCredentialPresentationLen: u32, + receiptLevelOut: *mut u8, + receiptLevelLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialPresentation, + receiptCredentialPresentationLen as usize, + ) + }; + let receipt_level: &mut [u8] = + unsafe { slice::from_raw_parts_mut(receiptLevelOut, receiptLevelLen as usize) }; + + simpleapi::ReceiptCredentialPresentation_getReceiptLevel( + receipt_credential_presentation, + receipt_level, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_ReceiptCredentialPresentation_getReceiptSerial( + receiptCredentialPresentation: *const u8, + receiptCredentialPresentationLen: u32, + receiptSerialOut: *mut u8, + receiptSerialLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + receiptCredentialPresentation, + receiptCredentialPresentationLen as usize, + ) + }; + let receipt_serial: &mut [u8] = + unsafe { slice::from_raw_parts_mut(receiptSerialOut, receiptSerialLen as usize) }; + + simpleapi::ReceiptCredentialPresentation_getReceiptSerial( + receipt_credential_presentation, + receipt_serial, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_UuidCiphertext_checkValidContents( uuidCiphertext: *const u8, diff --git a/rust/src/ffi/ffiapijava.rs b/rust/src/ffi/ffiapijava.rs index 1b16a02..f466246 100644 --- a/rust/src/ffi/ffiapijava.rs +++ b/rust/src/ffi/ffiapijava.rs @@ -1903,6 +1903,109 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredential } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialPresentationGetReceiptExpirationTimeJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialPresentation: jbyteArray, + receiptExpirationTimeOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation = env + .convert_byte_array(receiptCredentialPresentation) + .unwrap(); + let mut receipt_expiration_time: Vec = + vec![0; env.get_array_length(receiptExpirationTimeOut).unwrap() as usize]; + + let ffi_return = simpleapi::ReceiptCredentialPresentation_getReceiptExpirationTime( + &receipt_credential_presentation, + &mut receipt_expiration_time, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + receiptExpirationTimeOut, + 0, + &u8toi8(receipt_expiration_time)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialPresentationGetReceiptLevelJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialPresentation: jbyteArray, + receiptLevelOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation = env + .convert_byte_array(receiptCredentialPresentation) + .unwrap(); + let mut receipt_level: Vec = + vec![0; env.get_array_length(receiptLevelOut).unwrap() as usize]; + + let ffi_return = simpleapi::ReceiptCredentialPresentation_getReceiptLevel( + &receipt_credential_presentation, + &mut receipt_level, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region(receiptLevelOut, 0, &u8toi8(receipt_level)[..]) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialPresentationGetReceiptSerialJNI( + env: JNIEnv, + _class: JClass, + receiptCredentialPresentation: jbyteArray, + receiptSerialOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let receipt_credential_presentation = env + .convert_byte_array(receiptCredentialPresentation) + .unwrap(); + let mut receipt_serial: Vec = + vec![0; env.get_array_length(receiptSerialOut).unwrap() as usize]; + + let ffi_return = simpleapi::ReceiptCredentialPresentation_getReceiptSerial( + &receipt_credential_presentation, + &mut receipt_serial, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region(receiptSerialOut, 0, &u8toi8(receipt_serial)[..]) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_uuidCiphertextCheckValidContentsJNI( env: JNIEnv, diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index 565c12f..1cafea4 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -1113,6 +1113,48 @@ pub fn ReceiptCredentialPresentation_checkValidContents( FFI_RETURN_OK } +pub fn ReceiptCredentialPresentation_getReceiptExpirationTime( + receiptCredentialPresentationIn: &[u8], + receiptExpirationTimeOut: &mut [u8], +) -> i32 { + let receipt_credential_presentation: api::receipts::ReceiptCredentialPresentation = + match bincode::deserialize(receiptCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let receipt_expiration_time = receipt_credential_presentation.get_receipt_expiration_time(); + receiptExpirationTimeOut.copy_from_slice(&receipt_expiration_time.to_be_bytes()); + FFI_RETURN_OK +} + +pub fn ReceiptCredentialPresentation_getReceiptLevel( + receiptCredentialPresentationIn: &[u8], + receiptLevelOut: &mut [u8], +) -> i32 { + let receipt_credential_presentation: api::receipts::ReceiptCredentialPresentation = + match bincode::deserialize(receiptCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let receipt_level = receipt_credential_presentation.get_receipt_level(); + receiptLevelOut.copy_from_slice(&receipt_level.to_be_bytes()); + FFI_RETURN_OK +} + +pub fn ReceiptCredentialPresentation_getReceiptSerial( + receiptCredentialPresentationIn: &[u8], + receiptSerialOut: &mut [u8], +) -> i32 { + let receipt_credential_presentation: api::receipts::ReceiptCredentialPresentation = + match bincode::deserialize(receiptCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let receipt_serial = receipt_credential_presentation.get_receipt_serial_bytes(); + receiptSerialOut.copy_from_slice(&bincode::serialize(&receipt_serial).unwrap()); + FFI_RETURN_OK +} + pub fn UuidCiphertext_checkValidContents(uuidCiphertextIn: &[u8]) -> i32 { let _: api::groups::UuidCiphertext = match bincode::deserialize(uuidCiphertextIn) { Ok(result) => result, From 20dd8a248594a6d3bfd5a5266605ec405f77e0c2 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 16 Nov 2021 14:58:13 -0800 Subject: [PATCH 67/69] Add Rust implementation of PniCredential from libsignal-client --- rust/src/api/profiles.rs | 8 + rust/src/api/profiles/pni_credential.rs | 19 + .../profiles/pni_credential_presentation.rs | 43 ++ .../pni_credential_request_context.rs | 38 ++ .../api/profiles/pni_credential_response.rs | 17 + rust/src/api/server_params.rs | 189 ++++++- rust/src/common.rs | 1 + rust/src/common/array_utils.rs | 88 +++ rust/src/common/constants.rs | 8 +- rust/src/crypto/credentials.rs | 297 +++++++--- .../crypto/profile_key_credential_request.rs | 16 +- rust/src/crypto/proofs.rs | 530 +++++++++++++++--- rust/tests/integration_tests.rs | 142 ++++- rust/tests/receipt_flow.rs | 5 +- 14 files changed, 1218 insertions(+), 183 deletions(-) create mode 100644 rust/src/api/profiles/pni_credential.rs create mode 100644 rust/src/api/profiles/pni_credential_presentation.rs create mode 100644 rust/src/api/profiles/pni_credential_request_context.rs create mode 100644 rust/src/api/profiles/pni_credential_response.rs create mode 100644 rust/src/common/array_utils.rs diff --git a/rust/src/api/profiles.rs b/rust/src/api/profiles.rs index 36137dd..32a7053 100644 --- a/rust/src/api/profiles.rs +++ b/rust/src/api/profiles.rs @@ -5,6 +5,10 @@ // SPDX-License-Identifier: GPL-3.0-only // +pub mod pni_credential; +pub mod pni_credential_presentation; +pub mod pni_credential_request_context; +pub mod pni_credential_response; pub mod profile_key; pub mod profile_key_commitment; pub mod profile_key_credential; @@ -14,6 +18,10 @@ pub mod profile_key_credential_request_context; pub mod profile_key_credential_response; pub mod profile_key_version; +pub use pni_credential::PniCredential; +pub use pni_credential_presentation::PniCredentialPresentation; +pub use pni_credential_request_context::PniCredentialRequestContext; +pub use pni_credential_response::PniCredentialResponse; pub use profile_key::ProfileKey; pub use profile_key_commitment::ProfileKeyCommitment; pub use profile_key_credential::ProfileKeyCredential; diff --git a/rust/src/api/profiles/pni_credential.rs b/rust/src/api/profiles/pni_credential.rs new file mode 100644 index 0000000..3d30c39 --- /dev/null +++ b/rust/src/api/profiles/pni_credential.rs @@ -0,0 +1,19 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +use crate::common::simple_types::*; +use crate::crypto; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Serialize, Deserialize)] +pub struct PniCredential { + pub(crate) reserved: ReservedBytes, + pub(crate) credential: crypto::credentials::PniCredential, + pub(crate) aci_bytes: UidBytes, + pub(crate) pni_bytes: UidBytes, + pub(crate) profile_key_bytes: ProfileKeyBytes, +} diff --git a/rust/src/api/profiles/pni_credential_presentation.rs b/rust/src/api/profiles/pni_credential_presentation.rs new file mode 100644 index 0000000..4991017 --- /dev/null +++ b/rust/src/api/profiles/pni_credential_presentation.rs @@ -0,0 +1,43 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +use crate::api; +use crate::common::simple_types::*; +use crate::crypto; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct PniCredentialPresentation { + pub(crate) reserved: ReservedBytes, + pub(crate) proof: crypto::proofs::PniCredentialPresentationProof, + pub(crate) aci_enc_ciphertext: crypto::uid_encryption::Ciphertext, + pub(crate) pni_enc_ciphertext: crypto::uid_encryption::Ciphertext, + pub(crate) profile_key_enc_ciphertext: crypto::profile_key_encryption::Ciphertext, +} + +impl PniCredentialPresentation { + pub fn get_aci_ciphertext(&self) -> api::groups::UuidCiphertext { + api::groups::UuidCiphertext { + reserved: Default::default(), + ciphertext: self.aci_enc_ciphertext, + } + } + + pub fn get_pni_ciphertext(&self) -> api::groups::UuidCiphertext { + api::groups::UuidCiphertext { + reserved: Default::default(), + ciphertext: self.pni_enc_ciphertext, + } + } + + pub fn get_profile_key_ciphertext(&self) -> api::groups::ProfileKeyCiphertext { + api::groups::ProfileKeyCiphertext { + reserved: Default::default(), + ciphertext: self.profile_key_enc_ciphertext, + } + } +} diff --git a/rust/src/api/profiles/pni_credential_request_context.rs b/rust/src/api/profiles/pni_credential_request_context.rs new file mode 100644 index 0000000..60b0622 --- /dev/null +++ b/rust/src/api/profiles/pni_credential_request_context.rs @@ -0,0 +1,38 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +use crate::api; +use crate::common::simple_types::*; +use crate::crypto; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct PniCredentialRequestContext { + pub(crate) reserved: ReservedBytes, + pub(crate) aci_bytes: UidBytes, + pub(crate) pni_bytes: UidBytes, + pub(crate) profile_key_bytes: ProfileKeyBytes, + pub(crate) key_pair: crypto::profile_key_credential_request::KeyPair, + pub(crate) ciphertext_with_secret_nonce: + crypto::profile_key_credential_request::CiphertextWithSecretNonce, + pub(crate) proof: crypto::proofs::ProfileKeyCredentialRequestProof, +} + +impl PniCredentialRequestContext { + // This is correct: PniCredentialRequestContext and ProfileKeyCredentialRequestContext share a + // request type. + pub fn get_request(&self) -> api::profiles::ProfileKeyCredentialRequest { + let ciphertext = self.ciphertext_with_secret_nonce.get_ciphertext(); + let public_key = self.key_pair.get_public_key(); + api::profiles::ProfileKeyCredentialRequest { + reserved: Default::default(), + public_key, + ciphertext, + proof: self.proof.clone(), + } + } +} diff --git a/rust/src/api/profiles/pni_credential_response.rs b/rust/src/api/profiles/pni_credential_response.rs new file mode 100644 index 0000000..916d3e8 --- /dev/null +++ b/rust/src/api/profiles/pni_credential_response.rs @@ -0,0 +1,17 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +use crate::common::simple_types::*; +use crate::crypto; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize)] +pub struct PniCredentialResponse { + pub(crate) reserved: ReservedBytes, + pub(crate) blinded_credential: crypto::credentials::BlindedPniCredential, + pub(crate) proof: crypto::proofs::PniCredentialIssuanceProof, +} diff --git a/rust/src/api/server_params.rs b/rust/src/api/server_params.rs index 10f76fc..47e1d5e 100644 --- a/rust/src/api/server_params.rs +++ b/rust/src/api/server_params.rs @@ -1,16 +1,11 @@ // -// Copyright (C) 2020 Signal Messenger, LLC. +// Copyright (C) 2020-2021 Signal Messenger, LLC. // All rights reserved. // -// SPDX-License-Identifier: GPL-3.0-only -// - -#![allow(non_snake_case)] use serde::{Deserialize, Serialize}; use crate::api; -use crate::common::constants::*; use crate::common::errors::*; use crate::common::sho::*; use crate::common::simple_types::*; @@ -19,10 +14,14 @@ use crate::crypto; #[derive(Copy, Clone, Serialize, Deserialize)] pub struct ServerSecretParams { pub(crate) reserved: ReservedBytes, - pub(crate) auth_credentials_key_pair: crypto::credentials::KeyPair, - pub(crate) profile_key_credentials_key_pair: crypto::credentials::KeyPair, + pub(crate) auth_credentials_key_pair: + crypto::credentials::KeyPair, + pub(crate) profile_key_credentials_key_pair: + crypto::credentials::KeyPair, sig_key_pair: crypto::signature::KeyPair, - receipt_credentials_key_pair: crypto::credentials::KeyPair, + receipt_credentials_key_pair: + crypto::credentials::KeyPair, + pni_credentials_key_pair: crypto::credentials::KeyPair, } #[derive(Copy, Clone, Serialize, Deserialize)] @@ -32,6 +31,7 @@ pub struct ServerPublicParams { pub(crate) profile_key_credentials_public_key: crypto::credentials::PublicKey, sig_public_key: crypto::signature::PublicKey, receipt_credentials_public_key: crypto::credentials::PublicKey, + pni_credentials_public_key: crypto::credentials::PublicKey, } impl ServerSecretParams { @@ -41,13 +41,11 @@ impl ServerSecretParams { &randomness, ); - let auth_credentials_key_pair = - crypto::credentials::KeyPair::generate(&mut sho, NUM_AUTH_CRED_ATTRIBUTES); - let profile_key_credentials_key_pair = - crypto::credentials::KeyPair::generate(&mut sho, NUM_PROFILE_KEY_CRED_ATTRIBUTES); + let auth_credentials_key_pair = crypto::credentials::KeyPair::generate(&mut sho); + let profile_key_credentials_key_pair = crypto::credentials::KeyPair::generate(&mut sho); let sig_key_pair = crypto::signature::KeyPair::generate(&mut sho); - let receipt_credentials_key_pair = - crypto::credentials::KeyPair::generate(&mut sho, NUM_RECEIPT_CRED_ATTRIBUTES); + let receipt_credentials_key_pair = crypto::credentials::KeyPair::generate(&mut sho); + let pni_credentials_key_pair = crypto::credentials::KeyPair::generate(&mut sho); Self { reserved: Default::default(), @@ -55,6 +53,7 @@ impl ServerSecretParams { profile_key_credentials_key_pair, sig_key_pair, receipt_credentials_key_pair, + pni_credentials_key_pair, } } @@ -67,6 +66,7 @@ impl ServerSecretParams { .get_public_key(), sig_public_key: self.sig_key_pair.get_public_key(), receipt_credentials_public_key: self.receipt_credentials_key_pair.get_public_key(), + pni_credentials_public_key: self.pni_credentials_key_pair.get_public_key(), } } @@ -142,6 +142,25 @@ impl ServerSecretParams { ) } + pub fn verify_pni_credential_presentation( + &self, + group_public_params: api::groups::GroupPublicParams, + presentation: &api::profiles::PniCredentialPresentation, + ) -> Result<(), ZkGroupError> { + let credentials_key_pair = self.pni_credentials_key_pair; + let uid_enc_public_key = group_public_params.uid_enc_public_key; + let profile_key_enc_public_key = group_public_params.profile_key_enc_public_key; + + presentation.proof.verify( + credentials_key_pair, + presentation.aci_enc_ciphertext, + uid_enc_public_key, + presentation.profile_key_enc_ciphertext, + profile_key_enc_public_key, + presentation.pni_enc_ciphertext, + ) + } + pub fn issue_profile_key_credential( &self, randomness: RandomnessBytes, @@ -187,6 +206,53 @@ impl ServerSecretParams { }) } + pub fn issue_pni_credential( + &self, + randomness: RandomnessBytes, + request: &api::profiles::ProfileKeyCredentialRequest, + uid_bytes: UidBytes, + pni_bytes: UidBytes, + commitment: api::profiles::ProfileKeyCommitment, + ) -> Result { + let mut sho = Sho::new( + b"Signal_ZKGroup_20211111_Random_ServerSecretParams_IssuePniCredential", + &randomness, + ); + + request.proof.verify( + request.public_key, + request.ciphertext, + commitment.commitment, + )?; + + let uid = crypto::uid_struct::UidStruct::new(uid_bytes); + let pni = crypto::uid_struct::UidStruct::new(pni_bytes); + let blinded_credential_with_secret_nonce = + self.pni_credentials_key_pair.create_blinded_pni_credential( + uid, + pni, + request.public_key, + request.ciphertext, + &mut sho, + ); + + let proof = crypto::proofs::PniCredentialIssuanceProof::new( + self.pni_credentials_key_pair, + request.public_key, + request.ciphertext, + blinded_credential_with_secret_nonce, + uid, + pni, + &mut sho, + ); + + Ok(api::profiles::PniCredentialResponse { + reserved: Default::default(), + blinded_credential: blinded_credential_with_secret_nonce.get_blinded_pni_credential(), + proof, + }) + } + pub fn issue_receipt_credential( &self, randomness: RandomnessBytes, @@ -341,6 +407,29 @@ impl ServerPublicParams { } } + pub fn create_pni_credential_request_context( + &self, + randomness: RandomnessBytes, + aci_bytes: UidBytes, + pni_bytes: UidBytes, + profile_key: api::profiles::ProfileKey, + ) -> api::profiles::PniCredentialRequestContext { + // We want to provide an encryption of the profile key and prove that it matches the + // ProfileKeyCommitment in *exactly* the same way as a non-PNI request, so just invoke that + // and then add the PNI to the result. + let profile_key_request_context = + self.create_profile_key_credential_request_context(randomness, aci_bytes, profile_key); + api::profiles::PniCredentialRequestContext { + reserved: Default::default(), + aci_bytes, + pni_bytes, + profile_key_bytes: profile_key_request_context.profile_key_bytes, + key_pair: profile_key_request_context.key_pair, + ciphertext_with_secret_nonce: profile_key_request_context.ciphertext_with_secret_nonce, + proof: profile_key_request_context.proof, + } + } + pub fn receive_profile_key_credential( &self, context: &api::profiles::ProfileKeyCredentialRequestContext, @@ -366,6 +455,33 @@ impl ServerPublicParams { }) } + pub fn receive_pni_credential( + &self, + context: &api::profiles::PniCredentialRequestContext, + response: &api::profiles::PniCredentialResponse, + ) -> Result { + response.proof.verify( + self.pni_credentials_public_key, + context.key_pair.get_public_key(), + context.aci_bytes, + context.pni_bytes, + context.ciphertext_with_secret_nonce.get_ciphertext(), + response.blinded_credential, + )?; + + let credential = context + .key_pair + .decrypt_blinded_pni_credential(response.blinded_credential); + + Ok(api::profiles::PniCredential { + reserved: Default::default(), + credential, + aci_bytes: context.aci_bytes, + pni_bytes: context.pni_bytes, + profile_key_bytes: context.profile_key_bytes, + }) + } + pub fn create_profile_key_credential_presentation( &self, randomness: RandomnessBytes, @@ -407,6 +523,49 @@ impl ServerPublicParams { } } + pub fn create_pni_credential_presentation( + &self, + randomness: RandomnessBytes, + group_secret_params: api::groups::GroupSecretParams, + pni_credential: api::profiles::PniCredential, + ) -> api::profiles::PniCredentialPresentation { + let mut sho = Sho::new( + b"Signal_ZKGroup_20211111_Random_ServerPublicParams_CreatePniCredentialPresentation", + &randomness, + ); + + let uid_enc_key_pair = group_secret_params.uid_enc_key_pair; + let profile_key_enc_key_pair = group_secret_params.profile_key_enc_key_pair; + let credentials_public_key = self.pni_credentials_public_key; + + let aci_ciphertext = group_secret_params.encrypt_uuid(pni_credential.aci_bytes); + let pni_ciphertext = group_secret_params.encrypt_uuid(pni_credential.pni_bytes); + let profile_key_ciphertext = group_secret_params + .encrypt_profile_key_bytes(pni_credential.profile_key_bytes, pni_credential.aci_bytes); + + let proof = crypto::proofs::PniCredentialPresentationProof::new( + uid_enc_key_pair, + profile_key_enc_key_pair, + credentials_public_key, + pni_credential.credential, + aci_ciphertext.ciphertext, + pni_ciphertext.ciphertext, + profile_key_ciphertext.ciphertext, + pni_credential.aci_bytes, + pni_credential.pni_bytes, + pni_credential.profile_key_bytes, + &mut sho, + ); + + api::profiles::PniCredentialPresentation { + reserved: Default::default(), + proof, + aci_enc_ciphertext: aci_ciphertext.ciphertext, + pni_enc_ciphertext: pni_ciphertext.ciphertext, + profile_key_enc_ciphertext: profile_key_ciphertext.ciphertext, + } + } + pub fn create_receipt_credential_request_context( &self, randomness: RandomnessBytes, diff --git a/rust/src/common.rs b/rust/src/common.rs index 7d2e1dc..38eb0e0 100644 --- a/rust/src/common.rs +++ b/rust/src/common.rs @@ -5,6 +5,7 @@ // SPDX-License-Identifier: GPL-3.0-only // +pub mod array_utils; pub mod constants; pub mod errors; pub mod sho; diff --git a/rust/src/common/array_utils.rs b/rust/src/common/array_utils.rs new file mode 100644 index 0000000..67c6ddc --- /dev/null +++ b/rust/src/common/array_utils.rs @@ -0,0 +1,88 @@ +// +// Copyright (C) 2021 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +use std::ops::Index; + +use serde::{Deserialize, Serialize}; + +/// Abstracts over fixed-length arrays (and similar types) with an element type `T`. +/// +/// Provides `iter` and `Index` rather than `Deref` or `AsRef<[T]>` to allow for alternate forms of +/// indexing, for which exposing a slice could be confusing. See [`OneBased`]. +pub trait ArrayLike: Index { + const LEN: usize; + fn create(create_element: impl FnMut() -> T) -> Self; + fn iter(&self) -> std::slice::Iter; +} + +impl ArrayLike for [T; LEN] { + const LEN: usize = LEN; + fn create(mut create_element: impl FnMut() -> T) -> Self { + [0; LEN].map(|_| create_element()) + } + fn iter(&self) -> std::slice::Iter { + self[..].iter() + } +} + +/// A wrapper around an array or slice to use one-based indexing. +#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, Serialize, Deserialize)] +pub struct OneBased(pub T); + +impl Index for OneBased +where + T: Index, +{ + type Output = T::Output; + fn index(&self, index: usize) -> &Self::Output { + assert!(index > 0, "one-based index cannot be zero"); + &self.0[index - 1] + } +} + +impl ArrayLike for OneBased +where + Ts: ArrayLike, +{ + const LEN: usize = Ts::LEN; + + fn create(create_element: impl FnMut() -> T) -> Self { + OneBased(Ts::create(create_element)) + } + + fn iter(&self) -> std::slice::Iter { + self.0.iter() + } +} + +#[test] +fn test_one_based_indexing() { + let array = OneBased([10, 20, 30]); + assert_eq!(10, array[1]); + assert_eq!(20, array[2]); + assert_eq!(30, array[3]); +} + +#[test] +#[should_panic] +fn test_one_based_indexing_with_zero() { + let array = OneBased([10, 20, 30]); + let _ = array[0]; +} + +#[test] +#[should_panic] +fn test_one_based_indexing_past_end() { + let array = OneBased([10, 20, 30]); + let _ = array[4]; +} + +#[test] +fn test_one_based_iter() { + let array = OneBased([10, 20, 30]); + assert_eq!(vec![10, 20, 30], array.iter().copied().collect::>()); +} diff --git a/rust/src/common/constants.rs b/rust/src/common/constants.rs index a31ab72..362db3e 100644 --- a/rust/src/common/constants.rs +++ b/rust/src/common/constants.rs @@ -22,6 +22,10 @@ pub const GROUP_IDENTIFIER_LEN: usize = 32; pub const AUTH_CREDENTIAL_LEN: usize = 181; pub const AUTH_CREDENTIAL_PRESENTATION_LEN: usize = 493; pub const AUTH_CREDENTIAL_RESPONSE_LEN: usize = 361; +pub const PNI_CREDENTIAL_LEN: usize = 161; +pub const PNI_CREDENTIAL_PRESENTATION_LEN: usize = 841; +pub const PNI_CREDENTIAL_REQUEST_CONTEXT_LEN: usize = 489; +pub const PNI_CREDENTIAL_RESPONSE_LEN: usize = 521; pub const PROFILE_KEY_LEN: usize = 32; pub const PROFILE_KEY_CIPHERTEXT_LEN: usize = 65; pub const PROFILE_KEY_COMMITMENT_LEN: usize = 97; @@ -39,8 +43,8 @@ pub const RECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN: usize = 177; pub const RECEIPT_CREDENTIAL_RESPONSE_LEN: usize = 409; pub const RECEIPT_SERIAL_LEN: usize = 16; pub const RESERVED_LEN: usize = 1; -pub const SERVER_SECRET_PARAMS_LEN: usize = 1121; -pub const SERVER_PUBLIC_PARAMS_LEN: usize = 225; +pub const SERVER_SECRET_PARAMS_LEN: usize = 1537; +pub const SERVER_PUBLIC_PARAMS_LEN: usize = 289; pub const UUID_CIPHERTEXT_LEN: usize = 65; pub const RANDOMNESS_LEN: usize = 32; pub const SIGNATURE_LEN: usize = 64; diff --git a/rust/src/crypto/credentials.rs b/rust/src/crypto/credentials.rs index 68a2822..b049052 100644 --- a/rust/src/crypto/credentials.rs +++ b/rust/src/crypto/credentials.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2020 Signal Messenger, LLC. +// Copyright (C) 2020-2021 Signal Messenger, LLC. // All rights reserved. // // SPDX-License-Identifier: GPL-3.0-only @@ -12,22 +12,24 @@ use curve25519_dalek::ristretto::RistrettoPoint; use curve25519_dalek::scalar::Scalar; use serde::{Deserialize, Serialize}; +use crate::common::array_utils::{ArrayLike, OneBased}; use crate::common::sho::*; use crate::common::simple_types::*; use crate::crypto::receipt_struct::ReceiptStruct; use crate::crypto::uid_struct; use crate::crypto::{profile_key_credential_request, receipt_credential_request, receipt_struct}; +use crate::{ + NUM_AUTH_CRED_ATTRIBUTES, NUM_PROFILE_KEY_CRED_ATTRIBUTES, NUM_RECEIPT_CRED_ATTRIBUTES, +}; +const NUM_SUPPORTED_ATTRS: usize = 6; #[derive(Copy, Clone, Default, PartialEq, Serialize, Deserialize)] pub struct SystemParams { pub(crate) G_w: RistrettoPoint, pub(crate) G_wprime: RistrettoPoint, pub(crate) G_x0: RistrettoPoint, pub(crate) G_x1: RistrettoPoint, - pub(crate) G_y1: RistrettoPoint, - pub(crate) G_y2: RistrettoPoint, - pub(crate) G_y3: RistrettoPoint, - pub(crate) G_y4: RistrettoPoint, + pub(crate) G_y: OneBased<[RistrettoPoint; NUM_SUPPORTED_ATTRS]>, pub(crate) G_m1: RistrettoPoint, pub(crate) G_m2: RistrettoPoint, pub(crate) G_m3: RistrettoPoint, @@ -36,24 +38,79 @@ pub struct SystemParams { pub(crate) G_z: RistrettoPoint, } -#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] -pub struct KeyPair { +/// Used to specialize a [`KeyPair`] to support a certain number of attributes. +/// +/// The only required member is `Storage`, which should be a fixed-size array of [`Scalar`], one for +/// each attribute. However, for backwards compatibility some systems support fewer attributes than +/// are actually stored, and in this case the `NUM_ATTRS` member can be set to a custom value. Note +/// that `NUM_ATTRS` must always be less than or equal to the number of elements in `Storage`. +pub trait AttrScalars { + /// The storage (should be a fixed-size array of Scalar). + type Storage: ArrayLike + Copy + Eq + Serialize + for<'a> Deserialize<'a>; + + /// The number of attributes supported in this system. + /// + /// Defaults to the full set stored in `Self::Storage`. + const NUM_ATTRS: usize = Self::Storage::LEN; +} + +impl AttrScalars for AuthCredential { + // Store four scalars for backwards compatibility. + type Storage = [Scalar; 4]; + const NUM_ATTRS: usize = NUM_AUTH_CRED_ATTRIBUTES; +} +impl AttrScalars for ProfileKeyCredential { + // Store four scalars for backwards compatibility. + type Storage = [Scalar; 4]; + const NUM_ATTRS: usize = NUM_PROFILE_KEY_CRED_ATTRIBUTES; +} +impl AttrScalars for ReceiptCredential { + // Store four scalars for backwards compatibility. + type Storage = [Scalar; 4]; + const NUM_ATTRS: usize = NUM_RECEIPT_CRED_ATTRIBUTES; +} +impl AttrScalars for PniCredential { + type Storage = [Scalar; 6]; +} + +#[derive(Serialize, Deserialize)] +pub struct KeyPair { // private pub(crate) w: Scalar, pub(crate) wprime: Scalar, pub(crate) W: RistrettoPoint, pub(crate) x0: Scalar, pub(crate) x1: Scalar, - pub(crate) y1: Scalar, - pub(crate) y2: Scalar, - pub(crate) y3: Scalar, - pub(crate) y4: Scalar, + pub(crate) y: OneBased, // public pub(crate) C_W: RistrettoPoint, pub(crate) I: RistrettoPoint, } +impl Clone for KeyPair { + fn clone(&self) -> Self { + // Rely on Copy + *self + } +} + +impl Copy for KeyPair {} + +impl PartialEq for KeyPair { + fn eq(&self, other: &Self) -> bool { + self.w == other.w + && self.wprime == other.wprime + && self.W == other.W + && self.x0 == other.x0 + && self.x1 == other.x1 + && self.y == other.y + && self.C_W == other.C_W + && self.I == other.I + } +} +impl Eq for KeyPair {} + #[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] pub struct PublicKey { pub(crate) C_W: RistrettoPoint, @@ -90,6 +147,29 @@ pub struct BlindedProfileKeyCredential { pub(crate) S2: RistrettoPoint, } +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct PniCredential { + pub(crate) t: Scalar, + pub(crate) U: RistrettoPoint, + pub(crate) V: RistrettoPoint, +} +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct BlindedPniCredentialWithSecretNonce { + pub(crate) rprime: Scalar, + pub(crate) t: Scalar, + pub(crate) U: RistrettoPoint, + pub(crate) S1: RistrettoPoint, + pub(crate) S2: RistrettoPoint, +} + +#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] +pub struct BlindedPniCredential { + pub(crate) t: Scalar, + pub(crate) U: RistrettoPoint, + pub(crate) S1: RistrettoPoint, + pub(crate) S2: RistrettoPoint, +} + #[derive(Copy, Clone, PartialEq, Serialize, Deserialize)] pub struct ReceiptCredential { pub(crate) t: Scalar, @@ -141,7 +221,8 @@ pub(crate) fn convert_to_point_M2_receipt_serial_bytes( } impl SystemParams { - pub fn generate() -> Self { + #[cfg(test)] + fn generate() -> Self { let mut sho = Sho::new( b"Signal_ZKGroup_20200424_Constant_Credentials_SystemParams_Generate", b"", @@ -165,15 +246,17 @@ impl SystemParams { let G_V = sho.get_point(); let G_z = sho.get_point(); + // We don't ever want to use existing generator points in new ways, + // so new points have to be added at the end. + let G_y5 = sho.get_point(); + let G_y6 = sho.get_point(); + SystemParams { G_w, G_wprime, G_x0, G_x1, - G_y1, - G_y2, - G_y3, - G_y4, + G_y: OneBased([G_y1, G_y2, G_y3, G_y4, G_y5, G_y6]), G_m1, G_m2, G_m3, @@ -184,10 +267,10 @@ impl SystemParams { } pub fn get_hardcoded() -> SystemParams { - bincode::deserialize::(&SystemParams::SYSTEM_HARDCODED).unwrap() + bincode::deserialize::(SystemParams::SYSTEM_HARDCODED).unwrap() } - const SYSTEM_HARDCODED: [u8; 448] = [ + const SYSTEM_HARDCODED: &'static [u8] = &[ 0x9a, 0xe7, 0xc8, 0xe5, 0xed, 0x77, 0x9b, 0x11, 0x4a, 0xe7, 0x70, 0x8a, 0xa2, 0xf7, 0x94, 0x67, 0xa, 0xdd, 0xa3, 0x24, 0x98, 0x7b, 0x65, 0x99, 0x13, 0x12, 0x2c, 0x35, 0x50, 0x5b, 0x10, 0x5e, 0x6c, 0xa3, 0x10, 0x25, 0xd2, 0xd7, 0x6b, 0xe7, 0xfd, 0x34, 0x94, 0x4f, 0x98, @@ -205,27 +288,38 @@ impl SystemParams { 0xb7, 0xac, 0xc, 0x3a, 0x14, 0xb1, 0x9, 0x80, 0x4f, 0xc7, 0x48, 0xd7, 0xfa, 0x45, 0x6c, 0xff, 0xb4, 0x93, 0x4f, 0x98, 0xb, 0x6e, 0x9, 0xa2, 0x48, 0xa6, 0xf, 0x44, 0xa6, 0x15, 0xa, 0xe6, 0xc1, 0x3d, 0x7e, 0x3c, 0x6, 0x26, 0x1d, 0x7e, 0x4e, 0xed, 0x37, 0xf3, 0x9f, 0x60, - 0xcc, 0x60, 0x37, 0xdc, 0x31, 0xc2, 0xe8, 0xd4, 0x47, 0x4f, 0xb5, 0x19, 0x58, 0x7a, 0x44, - 0x86, 0x93, 0x18, 0x2a, 0xd9, 0xd6, 0xd8, 0x6b, 0x53, 0x59, 0x57, 0x85, 0x8f, 0x54, 0x7b, - 0x93, 0x40, 0x12, 0x7d, 0xa7, 0x5f, 0x80, 0x74, 0xca, 0xee, 0x94, 0x4a, 0xc3, 0x6c, 0xa, - 0xc6, 0x62, 0xd3, 0x8c, 0x9b, 0x3c, 0xcc, 0xe0, 0x3a, 0x9, 0x3f, 0xcd, 0x96, 0x44, 0x4, - 0x73, 0x98, 0xb8, 0x6b, 0x6e, 0x83, 0x37, 0x2f, 0xf1, 0x4f, 0xb8, 0xbb, 0xd, 0xea, 0x65, - 0x53, 0x12, 0x52, 0xac, 0x70, 0xd5, 0x8a, 0x4a, 0x8, 0x10, 0xd6, 0x82, 0xa0, 0xe7, 0x9, - 0xc9, 0x22, 0x7b, 0x30, 0xef, 0x6c, 0x8e, 0x17, 0xc5, 0x91, 0x5d, 0x52, 0x72, 0x21, 0xbb, - 0x0, 0xda, 0x81, 0x75, 0xcd, 0x64, 0x89, 0xaa, 0x8a, 0xa4, 0x92, 0xa5, 0x0, 0xf9, 0xab, - 0xee, 0x56, 0x90, 0xb9, 0xdf, 0xca, 0x88, 0x55, 0x4, 0xb6, 0x16, 0xc7, 0x6, 0xc8, 0xc, - 0x75, 0x6c, 0x11, 0xa3, 0x1, 0x6b, 0xbf, 0xb6, 0x9, 0x77, 0xf4, 0x64, 0x8b, 0x5f, 0x23, - 0x95, 0xa4, 0xb4, 0x28, 0xb7, 0x21, 0x19, 0x40, 0x81, 0x3e, 0x3a, 0xfd, 0xe2, 0xb8, 0x7a, - 0xa9, 0xc2, 0xc3, 0x7b, 0xf7, 0x16, 0xe2, 0x57, 0x8f, 0x95, 0x65, 0x6d, 0xf1, 0x2c, 0x2f, - 0xb6, 0xf5, 0xd0, 0x63, 0x1f, 0x6f, 0x71, 0xe2, 0xc3, 0x19, 0x3f, 0x6d, + 0xb0, 0x4d, 0xd9, 0xd6, 0x7, 0xfd, 0x35, 0x70, 0x12, 0x27, 0x4d, 0x3c, 0x63, 0xdb, 0xb3, + 0x8e, 0x73, 0x78, 0x59, 0x9c, 0x9e, 0x97, 0xdf, 0xbb, 0x28, 0x84, 0x26, 0x94, 0x89, 0x1d, + 0x5f, 0xd, 0xdc, 0x72, 0x99, 0x19, 0xb7, 0x98, 0xb4, 0x13, 0x15, 0x3, 0x40, 0x8c, 0xc5, + 0x7a, 0x9c, 0x53, 0x2f, 0x44, 0x27, 0x63, 0x2c, 0x88, 0xf5, 0x4c, 0xea, 0x53, 0x86, 0x1a, + 0x5b, 0xc4, 0x4c, 0x61, 0xcc, 0x60, 0x37, 0xdc, 0x31, 0xc2, 0xe8, 0xd4, 0x47, 0x4f, 0xb5, + 0x19, 0x58, 0x7a, 0x44, 0x86, 0x93, 0x18, 0x2a, 0xd9, 0xd6, 0xd8, 0x6b, 0x53, 0x59, 0x57, + 0x85, 0x8f, 0x54, 0x7b, 0x93, 0x40, 0x12, 0x7d, 0xa7, 0x5f, 0x80, 0x74, 0xca, 0xee, 0x94, + 0x4a, 0xc3, 0x6c, 0xa, 0xc6, 0x62, 0xd3, 0x8c, 0x9b, 0x3c, 0xcc, 0xe0, 0x3a, 0x9, 0x3f, + 0xcd, 0x96, 0x44, 0x4, 0x73, 0x98, 0xb8, 0x6b, 0x6e, 0x83, 0x37, 0x2f, 0xf1, 0x4f, 0xb8, + 0xbb, 0xd, 0xea, 0x65, 0x53, 0x12, 0x52, 0xac, 0x70, 0xd5, 0x8a, 0x4a, 0x8, 0x10, 0xd6, + 0x82, 0xa0, 0xe7, 0x9, 0xc9, 0x22, 0x7b, 0x30, 0xef, 0x6c, 0x8e, 0x17, 0xc5, 0x91, 0x5d, + 0x52, 0x72, 0x21, 0xbb, 0x0, 0xda, 0x81, 0x75, 0xcd, 0x64, 0x89, 0xaa, 0x8a, 0xa4, 0x92, + 0xa5, 0x0, 0xf9, 0xab, 0xee, 0x56, 0x90, 0xb9, 0xdf, 0xca, 0x88, 0x55, 0x4, 0xb6, 0x16, + 0xc7, 0x6, 0xc8, 0xc, 0x75, 0x6c, 0x11, 0xa3, 0x1, 0x6b, 0xbf, 0xb6, 0x9, 0x77, 0xf4, 0x64, + 0x8b, 0x5f, 0x23, 0x95, 0xa4, 0xb4, 0x28, 0xb7, 0x21, 0x19, 0x40, 0x81, 0x3e, 0x3a, 0xfd, + 0xe2, 0xb8, 0x7a, 0xa9, 0xc2, 0xc3, 0x7b, 0xf7, 0x16, 0xe2, 0x57, 0x8f, 0x95, 0x65, 0x6d, + 0xf1, 0x2c, 0x2f, 0xb6, 0xf5, 0xd0, 0x63, 0x1f, 0x6f, 0x71, 0xe2, 0xc3, 0x19, 0x3f, 0x6d, ]; } -impl KeyPair { - pub fn generate(sho: &mut Sho, num_attributes: usize) -> Self { - if !(2..=4).contains(&num_attributes) { - panic!(); - } +impl KeyPair { + pub fn generate(sho: &mut Sho) -> Self { + assert!(S::NUM_ATTRS >= 1, "at least one attribute required"); + assert!( + S::NUM_ATTRS <= NUM_SUPPORTED_ATTRS, + "more than {} attributes not supported", + NUM_SUPPORTED_ATTRS + ); + assert!( + S::NUM_ATTRS <= S::Storage::LEN, + "more attributes than storage", + ); let system = SystemParams::get_hardcoded(); let w = sho.get_scalar(); @@ -233,24 +327,14 @@ impl KeyPair { let wprime = sho.get_scalar(); let x0 = sho.get_scalar(); let x1 = sho.get_scalar(); - let y1 = sho.get_scalar(); - let y2 = sho.get_scalar(); - let y3 = sho.get_scalar(); - let y4 = sho.get_scalar(); + + let y = OneBased::::create(|| sho.get_scalar()); let C_W = (w * system.G_w) + (wprime * system.G_wprime); - let mut I = system.G_V - - (x0 * system.G_x0) - - (x1 * system.G_x1) - - (y1 * system.G_y1) - - (y2 * system.G_y2); - - if num_attributes > 2 { - I -= y3 * system.G_y3; - } + let mut I = system.G_V - (x0 * system.G_x0) - (x1 * system.G_x1); - if num_attributes > 3 { - I -= y4 * system.G_y4; + for (yn, G_yn) in y.iter().zip(system.G_y.iter()).take(S::NUM_ATTRS) { + I -= yn * G_yn; } KeyPair { @@ -259,10 +343,7 @@ impl KeyPair { W, x0, x1, - y1, - y2, - y3, - y4, + y, C_W, I, } @@ -275,42 +356,41 @@ impl KeyPair { } } - pub fn create_auth_credential( - &self, - uid: uid_struct::UidStruct, - redemption_time: RedemptionTime, - sho: &mut Sho, - ) -> AuthCredential { - let M = convert_to_points_uid_struct(uid, redemption_time); - let (t, U, V) = self.credential_core(M, sho); - AuthCredential { t, U, V } - } - fn credential_core( &self, - M: Vec, + M: &[RistrettoPoint], sho: &mut Sho, ) -> (Scalar, RistrettoPoint, RistrettoPoint) { - if M.len() > 4 { - panic!(); - } + assert!( + M.len() <= S::NUM_ATTRS, + "more than {} attributes not supported", + S::NUM_ATTRS + ); let t = sho.get_scalar(); let U = sho.get_point(); let mut V = self.W + (self.x0 + self.x1 * t) * U; - V += self.y1 * M[0]; - if M.len() > 1 { - V += self.y2 * M[1]; - } - if M.len() > 2 { - V += self.y3 * M[2]; - } - if M.len() > 3 { - V += self.y4 * M[3]; + for (yn, Mn) in self.y.iter().zip(M) { + V += yn * Mn; } (t, U, V) } +} + +impl KeyPair { + pub fn create_auth_credential( + &self, + uid: uid_struct::UidStruct, + redemption_time: RedemptionTime, + sho: &mut Sho, + ) -> AuthCredential { + let M = convert_to_points_uid_struct(uid, redemption_time); + let (t, U, V) = self.credential_core(&M, sho); + AuthCredential { t, U, V } + } +} +impl KeyPair { pub fn create_blinded_profile_key_credential( &self, uid: uid_struct::UidStruct, @@ -318,14 +398,14 @@ impl KeyPair { ciphertext: profile_key_credential_request::Ciphertext, sho: &mut Sho, ) -> BlindedProfileKeyCredentialWithSecretNonce { - let M = vec![uid.M1, uid.M2]; + let M = [uid.M1, uid.M2]; - let (t, U, Vprime) = self.credential_core(M, sho); + let (t, U, Vprime) = self.credential_core(&M, sho); let rprime = sho.get_scalar(); let R1 = rprime * RISTRETTO_BASEPOINT_POINT; let R2 = rprime * public_key.Y + Vprime; - let S1 = R1 + (self.y3 * ciphertext.D1) + (self.y4 * ciphertext.E1); - let S2 = R2 + (self.y3 * ciphertext.D2) + (self.y4 * ciphertext.E2); + let S1 = R1 + (self.y[3] * ciphertext.D1) + (self.y[4] * ciphertext.E1); + let S2 = R2 + (self.y[3] * ciphertext.D2) + (self.y[4] * ciphertext.E2); BlindedProfileKeyCredentialWithSecretNonce { rprime, t, @@ -334,7 +414,37 @@ impl KeyPair { S2, } } +} +impl KeyPair { + pub fn create_blinded_pni_credential( + &self, + uid: uid_struct::UidStruct, + pni: uid_struct::UidStruct, + public_key: profile_key_credential_request::PublicKey, + ciphertext: profile_key_credential_request::Ciphertext, + sho: &mut Sho, + ) -> BlindedPniCredentialWithSecretNonce { + let M = [uid.M1, uid.M2]; + + let (t, U, Vprime) = self.credential_core(&M, sho); + let Vprime_with_pni = Vprime + (self.y[5] * pni.M1) + (self.y[6] * pni.M2); + let rprime = sho.get_scalar(); + let R1 = rprime * RISTRETTO_BASEPOINT_POINT; + let R2 = rprime * public_key.Y + Vprime_with_pni; + let S1 = R1 + (self.y[3] * ciphertext.D1) + (self.y[4] * ciphertext.E1); + let S2 = R2 + (self.y[3] * ciphertext.D2) + (self.y[4] * ciphertext.E2); + BlindedPniCredentialWithSecretNonce { + rprime, + t, + U, + S1, + S2, + } + } +} + +impl KeyPair { pub fn create_blinded_receipt_credential( &self, public_key: receipt_credential_request::PublicKey, @@ -345,14 +455,14 @@ impl KeyPair { ) -> BlindedReceiptCredentialWithSecretNonce { let params = SystemParams::get_hardcoded(); let m1 = ReceiptStruct::calc_m1_from(receipt_expiration_time, receipt_level); - let M = vec![m1 * params.G_m1]; + let M = [m1 * params.G_m1]; - let (t, U, Vprime) = self.credential_core(M, sho); + let (t, U, Vprime) = self.credential_core(&M, sho); let rprime = sho.get_scalar(); let R1 = rprime * RISTRETTO_BASEPOINT_POINT; let R2 = rprime * public_key.Y + Vprime; - let S1 = self.y2 * ciphertext.D1 + R1; - let S2 = self.y2 * ciphertext.D2 + R2; + let S1 = self.y[2] * ciphertext.D1 + R1; + let S2 = self.y[2] * ciphertext.D2 + R2; BlindedReceiptCredentialWithSecretNonce { rprime, t, @@ -374,6 +484,17 @@ impl BlindedProfileKeyCredentialWithSecretNonce { } } +impl BlindedPniCredentialWithSecretNonce { + pub fn get_blinded_pni_credential(&self) -> BlindedPniCredential { + BlindedPniCredential { + t: self.t, + U: self.U, + S1: self.S1, + S2: self.S2, + } + } +} + impl BlindedReceiptCredentialWithSecretNonce { pub fn get_blinded_receipt_credential(&self) -> BlindedReceiptCredential { BlindedReceiptCredential { @@ -402,7 +523,7 @@ mod tests { #[test] fn test_mac() { let mut sho = Sho::new(b"Test_Credentials", b""); - let keypair = KeyPair::generate(&mut sho, NUM_AUTH_CRED_ATTRIBUTES); + let keypair = KeyPair::::generate(&mut sho); let uid_bytes = TEST_ARRAY_16; let redemption_time = 37; diff --git a/rust/src/crypto/profile_key_credential_request.rs b/rust/src/crypto/profile_key_credential_request.rs index 8a402dd..963447d 100644 --- a/rust/src/crypto/profile_key_credential_request.rs +++ b/rust/src/crypto/profile_key_credential_request.rs @@ -8,7 +8,9 @@ #![allow(non_snake_case)] use crate::common::sho::*; -use crate::crypto::credentials::{BlindedProfileKeyCredential, ProfileKeyCredential}; +use crate::crypto::credentials::{ + BlindedPniCredential, BlindedProfileKeyCredential, PniCredential, ProfileKeyCredential, +}; use crate::crypto::profile_key_struct; use curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT; use curve25519_dalek::ristretto::RistrettoPoint; @@ -92,6 +94,18 @@ impl KeyPair { V, } } + + pub fn decrypt_blinded_pni_credential( + &self, + blinded_pni_credential: BlindedPniCredential, + ) -> PniCredential { + let V = blinded_pni_credential.S2 - self.y * blinded_pni_credential.S1; + PniCredential { + t: blinded_pni_credential.t, + U: blinded_pni_credential.U, + V, + } + } } impl CiphertextWithSecretNonce { diff --git a/rust/src/crypto/proofs.rs b/rust/src/crypto/proofs.rs index d1e6f6e..1c615c9 100644 --- a/rust/src/crypto/proofs.rs +++ b/rust/src/crypto/proofs.rs @@ -1,5 +1,5 @@ // -// Copyright (C) 2020 Signal Messenger, LLC. +// Copyright (C) 2020-2021 Signal Messenger, LLC. // All rights reserved. // // SPDX-License-Identifier: GPL-3.0-only @@ -10,6 +10,7 @@ use curve25519_dalek::ristretto::RistrettoPoint; use serde::{Deserialize, Serialize}; +use crate::common::array_utils::OneBased; use crate::common::constants::*; use crate::common::errors::ZkGroupError::*; use crate::common::errors::*; @@ -40,6 +41,11 @@ pub struct ProfileKeyCredentialIssuanceProof { poksho_proof: Vec, } +#[derive(Serialize, Deserialize, Clone)] +pub struct PniCredentialIssuanceProof { + poksho_proof: Vec, +} + #[derive(Serialize, Deserialize, Clone)] pub struct ReceiptCredentialIssuanceProof { poksho_proof: Vec, @@ -69,6 +75,21 @@ pub struct ProfileKeyCredentialPresentationProof { poksho_proof: Vec, } +#[derive(Serialize, Deserialize, Clone)] +pub struct PniCredentialPresentationProof { + C_x0: RistrettoPoint, + C_x1: RistrettoPoint, + C_y1: RistrettoPoint, + C_y2: RistrettoPoint, + C_y3: RistrettoPoint, + C_y4: RistrettoPoint, + C_y5: RistrettoPoint, + C_y6: RistrettoPoint, + C_V: RistrettoPoint, + C_z: RistrettoPoint, + poksho_proof: Vec, +} + #[derive(Serialize, Deserialize, Clone)] pub struct ReceiptCredentialPresentationProof { C_x0: RistrettoPoint, @@ -108,7 +129,7 @@ impl AuthCredentialIssuanceProof { } pub fn new( - key_pair: credentials::KeyPair, + key_pair: credentials::KeyPair, credential: credentials::AuthCredential, uid: uid_struct::UidStruct, redemption_time: RedemptionTime, @@ -123,9 +144,9 @@ impl AuthCredentialIssuanceProof { scalar_args.add("wprime", key_pair.wprime); scalar_args.add("x0", key_pair.x0); scalar_args.add("x1", key_pair.x1); - scalar_args.add("y1", key_pair.y1); - scalar_args.add("y2", key_pair.y2); - scalar_args.add("y3", key_pair.y3); + scalar_args.add("y1", key_pair.y[1]); + scalar_args.add("y2", key_pair.y[2]); + scalar_args.add("y3", key_pair.y[3]); let mut point_args = poksho::PointArgs::new(); point_args.add("C_W", key_pair.C_W); @@ -134,9 +155,9 @@ impl AuthCredentialIssuanceProof { point_args.add("G_V-I", system.G_V - key_pair.I); point_args.add("G_x0", system.G_x0); point_args.add("G_x1", system.G_x1); - point_args.add("G_y1", system.G_y1); - point_args.add("G_y2", system.G_y2); - point_args.add("G_y3", system.G_y3); + point_args.add("G_y1", system.G_y[1]); + point_args.add("G_y2", system.G_y[2]); + point_args.add("G_y3", system.G_y[3]); point_args.add("V", credential.V); point_args.add("U", credential.U); point_args.add("tU", credential.t * credential.U); @@ -173,9 +194,9 @@ impl AuthCredentialIssuanceProof { point_args.add("G_V-I", system.G_V - public_key.I); point_args.add("G_x0", system.G_x0); point_args.add("G_x1", system.G_x1); - point_args.add("G_y1", system.G_y1); - point_args.add("G_y2", system.G_y2); - point_args.add("G_y3", system.G_y3); + point_args.add("G_y1", system.G_y[1]); + point_args.add("G_y2", system.G_y[2]); + point_args.add("G_y3", system.G_y[3]); point_args.add("V", credential.V); point_args.add("U", credential.U); point_args.add("tU", credential.t * credential.U); @@ -297,7 +318,7 @@ impl ProfileKeyCredentialIssuanceProof { } pub fn new( - key_pair: credentials::KeyPair, + key_pair: credentials::KeyPair, request_public_key: profile_key_credential_request::PublicKey, request: profile_key_credential_request::Ciphertext, blinded_credential: credentials::BlindedProfileKeyCredentialWithSecretNonce, @@ -311,10 +332,10 @@ impl ProfileKeyCredentialIssuanceProof { scalar_args.add("wprime", key_pair.wprime); scalar_args.add("x0", key_pair.x0); scalar_args.add("x1", key_pair.x1); - scalar_args.add("y1", key_pair.y1); - scalar_args.add("y2", key_pair.y2); - scalar_args.add("y3", key_pair.y3); - scalar_args.add("y4", key_pair.y4); + scalar_args.add("y1", key_pair.y[1]); + scalar_args.add("y2", key_pair.y[2]); + scalar_args.add("y3", key_pair.y[3]); + scalar_args.add("y4", key_pair.y[4]); scalar_args.add("rprime", blinded_credential.rprime); let mut point_args = poksho::PointArgs::new(); @@ -324,10 +345,10 @@ impl ProfileKeyCredentialIssuanceProof { point_args.add("G_V-I", credentials_system.G_V - key_pair.I); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); - point_args.add("G_y1", credentials_system.G_y1); - point_args.add("G_y2", credentials_system.G_y2); - point_args.add("G_y3", credentials_system.G_y3); - point_args.add("G_y4", credentials_system.G_y4); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); + point_args.add("G_y3", credentials_system.G_y[3]); + point_args.add("G_y4", credentials_system.G_y[4]); point_args.add("S1", blinded_credential.S1); point_args.add("D1", request.D1); point_args.add("E1", request.E1); @@ -369,10 +390,153 @@ impl ProfileKeyCredentialIssuanceProof { point_args.add("G_V-I", credentials_system.G_V - credentials_public_key.I); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); - point_args.add("G_y1", credentials_system.G_y1); - point_args.add("G_y2", credentials_system.G_y2); - point_args.add("G_y3", credentials_system.G_y3); - point_args.add("G_y4", credentials_system.G_y4); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); + point_args.add("G_y3", credentials_system.G_y[3]); + point_args.add("G_y4", credentials_system.G_y[4]); + point_args.add("S1", blinded_credential.S1); + point_args.add("D1", request.D1); + point_args.add("E1", request.E1); + point_args.add("S2", blinded_credential.S2); + point_args.add("D2", request.D2); + point_args.add("E2", request.E2); + point_args.add("Y", request_public_key.Y); + point_args.add("U", blinded_credential.U); + point_args.add("tU", blinded_credential.t * blinded_credential.U); + point_args.add("M1", uid.M1); + point_args.add("M2", uid.M2); + + match Self::get_poksho_statement().verify_proof(&self.poksho_proof, &point_args, &[]) { + Err(_) => Err(ProofVerificationFailure), + Ok(_) => Ok(()), + } + } +} + +impl PniCredentialIssuanceProof { + pub fn get_poksho_statement() -> poksho::Statement { + let mut st = poksho::Statement::new(); + st.add("C_W", &[("w", "G_w"), ("wprime", "G_wprime")]); + st.add( + "G_V-I", + &[ + ("x0", "G_x0"), + ("x1", "G_x1"), + ("y1", "G_y1"), + ("y2", "G_y2"), + ("y3", "G_y3"), + ("y4", "G_y4"), + ("y5", "G_y5"), + ("y6", "G_y6"), + ], + ); + st.add("S1", &[("y3", "D1"), ("y4", "E1"), ("rprime", "G")]); + st.add( + "S2", + &[ + ("y3", "D2"), + ("y4", "E2"), + ("rprime", "Y"), + ("w", "G_w"), + ("x0", "U"), + ("x1", "tU"), + ("y1", "M1"), + ("y2", "M2"), + ("y5", "M5"), + ("y6", "M6"), + ], + ); + st + } + + pub fn new( + key_pair: credentials::KeyPair, + request_public_key: profile_key_credential_request::PublicKey, + request: profile_key_credential_request::Ciphertext, + blinded_credential: credentials::BlindedPniCredentialWithSecretNonce, + uid: uid_struct::UidStruct, + pni: uid_struct::UidStruct, + sho: &mut Sho, + ) -> Self { + let credentials_system = credentials::SystemParams::get_hardcoded(); + + let mut scalar_args = poksho::ScalarArgs::new(); + scalar_args.add("w", key_pair.w); + scalar_args.add("wprime", key_pair.wprime); + scalar_args.add("x0", key_pair.x0); + scalar_args.add("x1", key_pair.x1); + scalar_args.add("y1", key_pair.y[1]); + scalar_args.add("y2", key_pair.y[2]); + scalar_args.add("y3", key_pair.y[3]); + scalar_args.add("y4", key_pair.y[4]); + scalar_args.add("y5", key_pair.y[5]); + scalar_args.add("y6", key_pair.y[6]); + scalar_args.add("rprime", blinded_credential.rprime); + + let mut point_args = poksho::PointArgs::new(); + point_args.add("C_W", key_pair.C_W); + point_args.add("G_w", credentials_system.G_w); + point_args.add("G_wprime", credentials_system.G_wprime); + point_args.add("G_V-I", credentials_system.G_V - key_pair.I); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); + point_args.add("G_y3", credentials_system.G_y[3]); + point_args.add("G_y4", credentials_system.G_y[4]); + point_args.add("G_y5", credentials_system.G_y[5]); + point_args.add("G_y6", credentials_system.G_y[6]); + point_args.add("S1", blinded_credential.S1); + point_args.add("D1", request.D1); + point_args.add("E1", request.E1); + point_args.add("S2", blinded_credential.S2); + point_args.add("D2", request.D2); + point_args.add("E2", request.E2); + point_args.add("Y", request_public_key.Y); + point_args.add("U", blinded_credential.U); + point_args.add("tU", blinded_credential.t * blinded_credential.U); + point_args.add("M1", uid.M1); + point_args.add("M2", uid.M2); + point_args.add("M5", pni.M1); + point_args.add("M6", pni.M2); + + let poksho_proof = Self::get_poksho_statement() + .prove( + &scalar_args, + &point_args, + &[], + &sho.squeeze(RANDOMNESS_LEN)[..], + ) + .unwrap(); + Self { poksho_proof } + } + + pub fn verify( + &self, + credentials_public_key: credentials::PublicKey, + request_public_key: profile_key_credential_request::PublicKey, + uid_bytes: UidBytes, + pni_bytes: UidBytes, + request: profile_key_credential_request::Ciphertext, + blinded_credential: credentials::BlindedPniCredential, + ) -> Result<(), ZkGroupError> { + let credentials_system = credentials::SystemParams::get_hardcoded(); + let uid = uid_struct::UidStruct::new(uid_bytes); + let pni = uid_struct::UidStruct::new(pni_bytes); + + let mut point_args = poksho::PointArgs::new(); + point_args.add("C_W", credentials_public_key.C_W); + point_args.add("G_w", credentials_system.G_w); + point_args.add("G_wprime", credentials_system.G_wprime); + point_args.add("G_V-I", credentials_system.G_V - credentials_public_key.I); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); + point_args.add("G_y3", credentials_system.G_y[3]); + point_args.add("G_y4", credentials_system.G_y[4]); + point_args.add("G_y5", credentials_system.G_y[5]); + point_args.add("G_y6", credentials_system.G_y[6]); point_args.add("S1", blinded_credential.S1); point_args.add("D1", request.D1); point_args.add("E1", request.E1); @@ -384,6 +548,8 @@ impl ProfileKeyCredentialIssuanceProof { point_args.add("tU", blinded_credential.t * blinded_credential.U); point_args.add("M1", uid.M1); point_args.add("M2", uid.M2); + point_args.add("M5", pni.M1); + point_args.add("M6", pni.M2); match Self::get_poksho_statement().verify_proof(&self.poksho_proof, &point_args, &[]) { Err(_) => Err(ProofVerificationFailure), @@ -422,7 +588,7 @@ impl ReceiptCredentialIssuanceProof { } pub fn new( - key_pair: credentials::KeyPair, + key_pair: credentials::KeyPair, request_public_key: receipt_credential_request::PublicKey, request: receipt_credential_request::Ciphertext, blinded_credential: credentials::BlindedReceiptCredentialWithSecretNonce, @@ -439,8 +605,8 @@ impl ReceiptCredentialIssuanceProof { scalar_args.add("wprime", key_pair.wprime); scalar_args.add("x0", key_pair.x0); scalar_args.add("x1", key_pair.x1); - scalar_args.add("y1", key_pair.y1); - scalar_args.add("y2", key_pair.y2); + scalar_args.add("y1", key_pair.y[1]); + scalar_args.add("y2", key_pair.y[2]); scalar_args.add("rprime", blinded_credential.rprime); let mut point_args = poksho::PointArgs::new(); @@ -450,8 +616,8 @@ impl ReceiptCredentialIssuanceProof { point_args.add("G_V-I", credentials_system.G_V - key_pair.I); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); - point_args.add("G_y1", credentials_system.G_y1); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); point_args.add("S1", blinded_credential.S1); point_args.add("D1", request.D1); point_args.add("S2", blinded_credential.S2); @@ -491,8 +657,8 @@ impl ReceiptCredentialIssuanceProof { point_args.add("G_V-I", credentials_system.G_V - credentials_public_key.I); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); - point_args.add("G_y1", credentials_system.G_y1); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); point_args.add("S1", blinded_credential.S1); point_args.add("D1", request.D1); point_args.add("S2", blinded_credential.S2); @@ -537,9 +703,9 @@ impl AuthCredentialPresentationProof { let z = sho.get_scalar(); - let C_y1 = z * credentials_system.G_y1 + M[0]; - let C_y2 = z * credentials_system.G_y2 + M[1]; - let C_y3 = z * credentials_system.G_y3; + let C_y1 = z * credentials_system.G_y[1] + M[0]; + let C_y2 = z * credentials_system.G_y[2] + M[1]; + let C_y3 = z * credentials_system.G_y[3]; let C_x0 = z * credentials_system.G_x0 + credential.U; let C_V = z * credentials_system.G_V + credential.V; @@ -572,13 +738,13 @@ impl AuthCredentialPresentationProof { point_args.add("G_a1", uid_system.G_a1); point_args.add("G_a2", uid_system.G_a2); point_args.add("C_y2-E_A2", C_y2 - uid_ciphertext.E_A2); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y2", credentials_system.G_y[2]); point_args.add("-E_A1", -uid_ciphertext.E_A1); point_args.add("E_A1", uid_ciphertext.E_A1); point_args.add("C_y1", C_y1); - point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y1", credentials_system.G_y[1]); point_args.add("C_y3", C_y3); - point_args.add("G_y3", credentials_system.G_y3); + point_args.add("G_y3", credentials_system.G_y[3]); let poksho_proof = Self::get_poksho_statement() .prove( @@ -602,7 +768,7 @@ impl AuthCredentialPresentationProof { pub fn verify( &self, - credentials_key_pair: credentials::KeyPair, + credentials_key_pair: credentials::KeyPair, uid_enc_public_key: uid_encryption::PublicKey, uid_ciphertext: uid_encryption::Ciphertext, redemption_time: RedemptionTime, @@ -626,9 +792,7 @@ impl AuthCredentialPresentationProof { W, x0, x1, - y1, - y2, - y3, + y: OneBased([y1, y2, y3, ..]), I, .. } = credentials_key_pair; @@ -649,13 +813,13 @@ impl AuthCredentialPresentationProof { point_args.add("G_a1", enc_system.G_a1); point_args.add("G_a2", enc_system.G_a2); point_args.add("C_y2-E_A2", C_y2 - uid_ciphertext.E_A2); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y2", credentials_system.G_y[2]); point_args.add("-E_A1", -uid_ciphertext.E_A1); point_args.add("E_A1", uid_ciphertext.E_A1); point_args.add("C_y1", C_y1); - point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y1", credentials_system.G_y[1]); point_args.add("C_y3", C_y3); - point_args.add("G_y3", credentials_system.G_y3); + point_args.add("G_y3", credentials_system.G_y[3]); match Self::get_poksho_statement().verify_proof(poksho_proof, &point_args, &[]) { Err(_) => Err(ZkGroupError::ProofVerificationFailure), @@ -699,10 +863,10 @@ impl ProfileKeyCredentialPresentationProof { let z = sho.get_scalar(); - let C_y1 = z * credentials_system.G_y1 + uid.M1; - let C_y2 = z * credentials_system.G_y2 + uid.M2; - let C_y3 = z * credentials_system.G_y3 + profile_key.M3; - let C_y4 = z * credentials_system.G_y4 + profile_key.M4; + let C_y1 = z * credentials_system.G_y[1] + uid.M1; + let C_y2 = z * credentials_system.G_y[2] + uid.M2; + let C_y3 = z * credentials_system.G_y[3] + profile_key.M3; + let C_y4 = z * credentials_system.G_y[4] + profile_key.M4; let C_x0 = z * credentials_system.G_x0 + credential.U; let C_V = z * credentials_system.G_V + credential.V; @@ -749,18 +913,18 @@ impl ProfileKeyCredentialPresentationProof { point_args.add("G_b2", profile_key_system.G_b2); point_args.add("C_y2-E_A2", C_y2 - uid_ciphertext.E_A2); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y2", credentials_system.G_y[2]); point_args.add("-E_A1", -uid_ciphertext.E_A1); point_args.add("E_A1", uid_ciphertext.E_A1); point_args.add("C_y1", C_y1); - point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y1", credentials_system.G_y[1]); point_args.add("C_y4-E_B2", C_y4 - profile_key_ciphertext.E_B2); - point_args.add("G_y4", credentials_system.G_y4); + point_args.add("G_y4", credentials_system.G_y[4]); point_args.add("-E_B1", -profile_key_ciphertext.E_B1); point_args.add("E_B1", profile_key_ciphertext.E_B1); point_args.add("C_y3", C_y3); - point_args.add("G_y3", credentials_system.G_y3); + point_args.add("G_y3", credentials_system.G_y[3]); let poksho_proof = Self::get_poksho_statement() .prove( @@ -786,7 +950,7 @@ impl ProfileKeyCredentialPresentationProof { pub fn verify( &self, - credentials_key_pair: credentials::KeyPair, + credentials_key_pair: credentials::KeyPair, uid_ciphertext: uid_encryption::Ciphertext, uid_enc_public_key: uid_encryption::PublicKey, profile_key_ciphertext: profile_key_encryption::Ciphertext, @@ -815,10 +979,7 @@ impl ProfileKeyCredentialPresentationProof { W, x0, x1, - y1, - y2, - y3, - y4, + y: OneBased([y1, y2, y3, y4]), I, .. } = credentials_key_pair; @@ -846,18 +1007,248 @@ impl ProfileKeyCredentialPresentationProof { point_args.add("G_b2", profile_key_enc_system.G_b2); point_args.add("C_y2-E_A2", C_y2 - uid_ciphertext.E_A2); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y2", credentials_system.G_y[2]); point_args.add("-E_A1", -uid_ciphertext.E_A1); point_args.add("E_A1", uid_ciphertext.E_A1); point_args.add("C_y1", C_y1); - point_args.add("G_y1", credentials_system.G_y1); + point_args.add("G_y1", credentials_system.G_y[1]); point_args.add("C_y4-E_B2", C_y4 - profile_key_ciphertext.E_B2); - point_args.add("G_y4", credentials_system.G_y4); + point_args.add("G_y4", credentials_system.G_y[4]); point_args.add("-E_B1", -profile_key_ciphertext.E_B1); point_args.add("E_B1", profile_key_ciphertext.E_B1); point_args.add("C_y3", C_y3); - point_args.add("G_y3", credentials_system.G_y3); + point_args.add("G_y3", credentials_system.G_y[3]); + + match Self::get_poksho_statement().verify_proof(poksho_proof, &point_args, &[]) { + Err(_) => Err(ZkGroupError::ProofVerificationFailure), + Ok(_) => Ok(()), + } + } +} + +impl PniCredentialPresentationProof { + pub fn get_poksho_statement() -> poksho::Statement { + let mut st = poksho::Statement::new(); + st.add("C_z", &[("z", "G_z")]); + st.add("Z", &[("z", "I")]); + st.add("C_x1", &[("t", "C_x0"), ("z0", "G_x0"), ("z", "G_x1")]); + st.add("A", &[("a1", "G_a1"), ("a2", "G_a2")]); + st.add("B", &[("b1", "G_b1"), ("b2", "G_b2")]); + st.add("C_y2-E_A2", &[("z", "G_y2"), ("a2", "-E_A1")]); + st.add("E_A1", &[("a1", "C_y1"), ("z1", "G_y1")]); + st.add("C_y4-E_B2", &[("z", "G_y4"), ("b2", "-E_B1")]); + st.add("E_B1", &[("b1", "C_y3"), ("z2", "G_y3")]); + st.add("C_y6-E_C2", &[("z", "G_y6"), ("a2", "-E_C1")]); + st.add("E_C1", &[("a1", "C_y5"), ("z1", "G_y5")]); + st + } + + #[allow(clippy::too_many_arguments)] + pub fn new( + uid_enc_key_pair: uid_encryption::KeyPair, + profile_key_enc_key_pair: profile_key_encryption::KeyPair, + credentials_public_key: credentials::PublicKey, + credential: credentials::PniCredential, + uid_ciphertext: uid_encryption::Ciphertext, + pni_ciphertext: uid_encryption::Ciphertext, + profile_key_ciphertext: profile_key_encryption::Ciphertext, + uid_bytes: UidBytes, + pni_bytes: UidBytes, + profile_key_bytes: ProfileKeyBytes, + sho: &mut Sho, + ) -> Self { + let credentials_system = credentials::SystemParams::get_hardcoded(); + let uid_system = uid_encryption::SystemParams::get_hardcoded(); + let profile_key_system = profile_key_encryption::SystemParams::get_hardcoded(); + let uid = uid_struct::UidStruct::new(uid_bytes); + let profile_key = profile_key_struct::ProfileKeyStruct::new(profile_key_bytes, uid_bytes); + let pni = uid_struct::UidStruct::new(pni_bytes); + + let z = sho.get_scalar(); + + let C_y1 = z * credentials_system.G_y[1] + uid.M1; + let C_y2 = z * credentials_system.G_y[2] + uid.M2; + let C_y3 = z * credentials_system.G_y[3] + profile_key.M3; + let C_y4 = z * credentials_system.G_y[4] + profile_key.M4; + let C_y5 = z * credentials_system.G_y[5] + pni.M1; + let C_y6 = z * credentials_system.G_y[6] + pni.M2; + + let C_x0 = z * credentials_system.G_x0 + credential.U; + let C_V = z * credentials_system.G_V + credential.V; + let C_x1 = z * credentials_system.G_x1 + credential.t * credential.U; + let C_z = z * credentials_system.G_z; + + let z0 = -z * credential.t; + let z1 = -z * uid_enc_key_pair.a1; + let z2 = -z * profile_key_enc_key_pair.b1; + + let I = credentials_public_key.I; + let Z = z * I; + + // Scalars listed in order of stmts for debugging + let mut scalar_args = poksho::ScalarArgs::new(); + scalar_args.add("z", z); + scalar_args.add("t", credential.t); + scalar_args.add("z0", z0); + scalar_args.add("a1", uid_enc_key_pair.a1); + scalar_args.add("a2", uid_enc_key_pair.a2); + scalar_args.add("b1", profile_key_enc_key_pair.b1); + scalar_args.add("b2", profile_key_enc_key_pair.b2); + scalar_args.add("z1", z1); + scalar_args.add("z2", z2); + + // Points listed in order of stmts for debugging + let mut point_args = poksho::PointArgs::new(); + point_args.add("C_z", C_z); + point_args.add("G_z", credentials_system.G_z); + point_args.add("Z", Z); + point_args.add("I", I); + + point_args.add("C_x1", C_x1); + point_args.add("C_x0", C_x0); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + + point_args.add("A", uid_enc_key_pair.A); + point_args.add("G_a1", uid_system.G_a1); + point_args.add("G_a2", uid_system.G_a2); + + point_args.add("B", profile_key_enc_key_pair.B); + point_args.add("G_b1", profile_key_system.G_b1); + point_args.add("G_b2", profile_key_system.G_b2); + + point_args.add("C_y2-E_A2", C_y2 - uid_ciphertext.E_A2); + point_args.add("G_y2", credentials_system.G_y[2]); + point_args.add("-E_A1", -uid_ciphertext.E_A1); + point_args.add("E_A1", uid_ciphertext.E_A1); + point_args.add("C_y1", C_y1); + point_args.add("G_y1", credentials_system.G_y[1]); + + point_args.add("C_y4-E_B2", C_y4 - profile_key_ciphertext.E_B2); + point_args.add("G_y4", credentials_system.G_y[4]); + point_args.add("-E_B1", -profile_key_ciphertext.E_B1); + point_args.add("E_B1", profile_key_ciphertext.E_B1); + point_args.add("C_y3", C_y3); + point_args.add("G_y3", credentials_system.G_y[3]); + + point_args.add("C_y6-E_C2", C_y6 - pni_ciphertext.E_A2); + point_args.add("G_y6", credentials_system.G_y[6]); + point_args.add("-E_C1", -pni_ciphertext.E_A1); + point_args.add("E_C1", pni_ciphertext.E_A1); + point_args.add("C_y5", C_y5); + point_args.add("G_y5", credentials_system.G_y[5]); + + let poksho_proof = Self::get_poksho_statement() + .prove( + &scalar_args, + &point_args, + &[], + &sho.squeeze(RANDOMNESS_LEN)[..], + ) + .unwrap(); + + Self { + C_y1, + C_y2, + C_y3, + C_y4, + C_y5, + C_y6, + C_x0, + C_x1, + C_V, + C_z, + poksho_proof, + } + } + + pub fn verify( + &self, + credentials_key_pair: credentials::KeyPair, + uid_ciphertext: uid_encryption::Ciphertext, + uid_enc_public_key: uid_encryption::PublicKey, + profile_key_ciphertext: profile_key_encryption::Ciphertext, + profile_key_enc_public_key: profile_key_encryption::PublicKey, + pni_ciphertext: uid_encryption::Ciphertext, + ) -> Result<(), ZkGroupError> { + let uid_enc_system = uid_encryption::SystemParams::get_hardcoded(); + let profile_key_enc_system = profile_key_encryption::SystemParams::get_hardcoded(); + let credentials_system = credentials::SystemParams::get_hardcoded(); + + let Self { + C_x0, + C_x1, + C_y1, + C_y2, + C_y3, + C_y4, + C_y5, + C_y6, + C_V, + C_z, + poksho_proof, + } = self; + + let credentials::KeyPair { + W, + x0, + x1, + y: OneBased([y1, y2, y3, y4, y5, y6]), + I, + .. + } = credentials_key_pair; + + let Z = C_V + - W + - (x0 * C_x0) + - (x1 * C_x1) + - (y1 * C_y1) + - (y2 * C_y2) + - (y3 * C_y3) + - (y4 * C_y4) + - (y5 * C_y5) + - (y6 * C_y6); + + // Points listed in order of stmts for debugging + let mut point_args = poksho::PointArgs::new(); + point_args.add("C_z", *C_z); + point_args.add("G_z", credentials_system.G_z); + point_args.add("Z", Z); + point_args.add("I", I); + point_args.add("C_x1", *C_x1); + point_args.add("C_x0", *C_x0); + point_args.add("G_x0", credentials_system.G_x0); + point_args.add("G_x1", credentials_system.G_x1); + + point_args.add("A", uid_enc_public_key.A); + point_args.add("G_a1", uid_enc_system.G_a1); + point_args.add("G_a2", uid_enc_system.G_a2); + + point_args.add("B", profile_key_enc_public_key.B); + point_args.add("G_b1", profile_key_enc_system.G_b1); + point_args.add("G_b2", profile_key_enc_system.G_b2); + + point_args.add("C_y2-E_A2", C_y2 - uid_ciphertext.E_A2); + point_args.add("G_y2", credentials_system.G_y[2]); + point_args.add("-E_A1", -uid_ciphertext.E_A1); + point_args.add("E_A1", uid_ciphertext.E_A1); + point_args.add("C_y1", *C_y1); + point_args.add("G_y1", credentials_system.G_y[1]); + + point_args.add("C_y4-E_B2", C_y4 - profile_key_ciphertext.E_B2); + point_args.add("G_y4", credentials_system.G_y[4]); + point_args.add("-E_B1", -profile_key_ciphertext.E_B1); + point_args.add("E_B1", profile_key_ciphertext.E_B1); + point_args.add("C_y3", *C_y3); + point_args.add("G_y3", credentials_system.G_y[3]); + + point_args.add("C_y6-E_C2", C_y6 - pni_ciphertext.E_A2); + point_args.add("G_y6", credentials_system.G_y[6]); + point_args.add("-E_C1", -pni_ciphertext.E_A1); + point_args.add("E_C1", pni_ciphertext.E_A1); + point_args.add("C_y5", *C_y5); + point_args.add("G_y5", credentials_system.G_y[5]); match Self::get_poksho_statement().verify_proof(poksho_proof, &point_args, &[]) { Err(_) => Err(ZkGroupError::ProofVerificationFailure), @@ -886,8 +1277,8 @@ impl ReceiptCredentialPresentationProof { let z = sho.get_scalar(); - let C_y1 = z * credentials_system.G_y1; - let C_y2 = z * credentials_system.G_y2; + let C_y1 = z * credentials_system.G_y[1]; + let C_y2 = z * credentials_system.G_y[2]; let I = credentials_public_key.I; let Z = z * I; @@ -911,8 +1302,8 @@ impl ReceiptCredentialPresentationProof { point_args.add("C_y2", C_y2); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); - point_args.add("G_y1", credentials_system.G_y1); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); let poksho_proof = Self::get_poksho_statement() .prove( @@ -935,7 +1326,7 @@ impl ReceiptCredentialPresentationProof { pub fn verify( &self, - credentials_key_pair: credentials::KeyPair, + credentials_key_pair: credentials::KeyPair, receipt_struct: ReceiptStruct, ) -> Result<(), ZkGroupError> { let credentials_system = credentials::SystemParams::get_hardcoded(); @@ -955,8 +1346,7 @@ impl ReceiptCredentialPresentationProof { W, x0, x1, - y1, - y2, + y: OneBased([y1, y2, ..]), I, .. } = credentials_key_pair; @@ -973,8 +1363,8 @@ impl ReceiptCredentialPresentationProof { point_args.add("C_y2", C_y2); point_args.add("G_x0", credentials_system.G_x0); point_args.add("G_x1", credentials_system.G_x1); - point_args.add("G_y1", credentials_system.G_y1); - point_args.add("G_y2", credentials_system.G_y2); + point_args.add("G_y1", credentials_system.G_y[1]); + point_args.add("G_y2", credentials_system.G_y[2]); match Self::get_poksho_statement().verify_proof(poksho_proof, &point_args, &[]) { Err(_) => Err(ZkGroupError::ProofVerificationFailure), diff --git a/rust/tests/integration_tests.rs b/rust/tests/integration_tests.rs index c8632b9..80338a0 100644 --- a/rust/tests/integration_tests.rs +++ b/rust/tests/integration_tests.rs @@ -1,11 +1,10 @@ // -// Copyright (C) 2020 Signal Messenger, LLC. +// Copyright (C) 2020-2021 Signal Messenger, LLC. // All rights reserved. // // SPDX-License-Identifier: GPL-3.0-only // -#![allow(non_snake_case)] extern crate zkgroup; use curve25519_dalek::ristretto::RistrettoPoint; @@ -100,6 +99,62 @@ pub const PROFILE_KEY_CREDENTIAL_PRESENTATION_RESULT: [u8; 0xc5, 0x73, 0xf8, 0x3c, 0x33, 0xd3, 0xb9, 0xa7, 0x46, ]; +pub const PNI_CREDENTIAL_PRESENTATION_RESULT: [u8; zkgroup::PNI_CREDENTIAL_PRESENTATION_LEN] = [ + 0x00, 0xfe, 0xcc, 0x5f, 0x71, 0xd4, 0x0d, 0xbd, 0x45, 0x91, 0x2d, 0x0d, 0xe9, 0xc1, 0xed, 0x03, + 0x3c, 0x7e, 0xb1, 0xc4, 0x75, 0x5e, 0x19, 0xcb, 0x62, 0x41, 0xed, 0xe6, 0xa6, 0xa9, 0x9f, 0x65, + 0x54, 0x5e, 0x87, 0x0a, 0x80, 0x68, 0x54, 0xc5, 0x00, 0x0d, 0x43, 0x6d, 0xb6, 0x01, 0xa8, 0x9f, + 0x72, 0xb9, 0xb3, 0x99, 0xf0, 0xef, 0xa2, 0x77, 0x47, 0x37, 0x16, 0xe8, 0xbc, 0x20, 0xc9, 0x84, + 0x76, 0x62, 0x50, 0x93, 0x75, 0x55, 0x60, 0x4f, 0x2d, 0x2f, 0xcd, 0xd2, 0x63, 0xc6, 0x0f, 0x2f, + 0x72, 0xb5, 0xa0, 0x4d, 0x9b, 0xbb, 0xc6, 0xf9, 0x5c, 0x78, 0x08, 0x5f, 0x81, 0xaa, 0xf0, 0x7d, + 0x33, 0x16, 0xa2, 0xdb, 0xd1, 0xef, 0x85, 0xbb, 0x64, 0x2d, 0x5d, 0xa6, 0xd0, 0x0d, 0x03, 0xfe, + 0xd8, 0x09, 0x72, 0x76, 0xbf, 0x17, 0xa1, 0x13, 0xa4, 0x40, 0x18, 0xd7, 0x73, 0xc9, 0x11, 0x6c, + 0x33, 0xac, 0x86, 0x83, 0x7d, 0x4f, 0x5c, 0x41, 0xfb, 0x70, 0x15, 0x3f, 0x3d, 0x65, 0x5c, 0x0b, + 0x68, 0x98, 0x2f, 0xae, 0x01, 0x11, 0x34, 0x60, 0xdb, 0x75, 0xea, 0x70, 0x99, 0xef, 0x7e, 0x91, + 0x0c, 0xbe, 0x0b, 0xd6, 0x06, 0x87, 0x0d, 0xf5, 0x55, 0x22, 0xf9, 0xd0, 0xb1, 0xbe, 0xe1, 0xb1, + 0xab, 0x2f, 0x3b, 0x9c, 0xd3, 0x56, 0x3a, 0x42, 0x26, 0x84, 0xeb, 0xcf, 0xdb, 0x1f, 0xda, 0xda, + 0x27, 0xac, 0xb4, 0xd4, 0x8c, 0x7d, 0xb9, 0xc6, 0xb1, 0x38, 0x9c, 0x67, 0x42, 0xa8, 0xf8, 0x25, + 0x7b, 0xb7, 0x0f, 0x54, 0x30, 0xfe, 0xb4, 0xa4, 0x38, 0x00, 0x7f, 0xb3, 0x3e, 0x79, 0x10, 0xda, + 0x3b, 0x9a, 0x09, 0x97, 0xd7, 0xd3, 0x5c, 0x6c, 0x93, 0xa8, 0xd4, 0x59, 0x49, 0xd0, 0x1f, 0x88, + 0xb4, 0x97, 0xc8, 0x22, 0xb0, 0x12, 0x7b, 0x3f, 0xc5, 0x7c, 0xfa, 0xee, 0x90, 0xbc, 0xf7, 0xd4, + 0x19, 0x14, 0xf6, 0xf0, 0xf8, 0xfa, 0x0a, 0xcd, 0x82, 0xe0, 0x04, 0xca, 0xaa, 0xd1, 0xc9, 0xfe, + 0xec, 0x2f, 0xb6, 0x7f, 0x58, 0x93, 0x6a, 0xe7, 0xa9, 0x2a, 0x28, 0x5d, 0xc1, 0x5b, 0x23, 0x48, + 0x6a, 0x02, 0x72, 0xe8, 0x64, 0xf3, 0xae, 0x97, 0x69, 0xd6, 0x50, 0xfd, 0xd0, 0x89, 0x87, 0x39, + 0xad, 0x28, 0xe2, 0x59, 0xe8, 0xda, 0xe7, 0x39, 0x07, 0xca, 0xa8, 0xff, 0x69, 0xa5, 0x3a, 0x85, + 0x1e, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x6c, 0x70, 0x4b, 0x8d, 0xaf, 0x38, + 0xa4, 0x64, 0x81, 0x0e, 0xca, 0x85, 0x89, 0x54, 0x15, 0x21, 0xe0, 0x53, 0x22, 0x1d, 0xd8, 0x30, + 0x86, 0x6b, 0xf7, 0x7d, 0xa0, 0x25, 0xcd, 0xc2, 0x04, 0x1e, 0x33, 0xf7, 0x3e, 0x42, 0xc7, 0x03, + 0x87, 0x70, 0x9a, 0xcb, 0xac, 0x0d, 0xf4, 0x6d, 0x01, 0x55, 0xe6, 0xbf, 0x6f, 0x79, 0x52, 0xdd, + 0xc3, 0x28, 0x9a, 0x16, 0xca, 0x68, 0x2e, 0x74, 0x0d, 0xf7, 0x40, 0x3c, 0xc1, 0x2c, 0xbe, 0x0c, + 0xd5, 0x4a, 0x7b, 0x0d, 0xe0, 0x8e, 0xec, 0x4f, 0x7c, 0xdc, 0xe5, 0x29, 0x96, 0x88, 0x0e, 0xf5, + 0xdb, 0x74, 0xbc, 0xc4, 0xe8, 0xe7, 0x8d, 0x62, 0x0d, 0xa4, 0xd2, 0x1f, 0xf1, 0x37, 0xb2, 0x9d, + 0xf3, 0xa1, 0xa0, 0x8d, 0x14, 0xb9, 0x22, 0x4c, 0x91, 0xef, 0x05, 0xa1, 0xac, 0x0a, 0x7c, 0xfe, + 0x14, 0x2b, 0x22, 0x78, 0x53, 0xc9, 0x0b, 0xb9, 0x0d, 0xb0, 0xcf, 0x3d, 0x63, 0x11, 0x56, 0x0e, + 0x49, 0xca, 0x52, 0x98, 0x3f, 0x9e, 0xfc, 0x54, 0xec, 0xb6, 0x1f, 0x55, 0x2d, 0x6a, 0x85, 0x08, + 0x88, 0x71, 0xef, 0x4d, 0x0f, 0x58, 0x62, 0xdd, 0x04, 0xaf, 0xf9, 0x3f, 0xd9, 0x7b, 0x78, 0x16, + 0x18, 0x1d, 0x38, 0xbc, 0xb3, 0x0f, 0x71, 0xea, 0xeb, 0x9e, 0xff, 0x2b, 0xa6, 0x30, 0x91, 0x6e, + 0xac, 0x35, 0x5f, 0x45, 0x70, 0x3a, 0x8c, 0x78, 0x0e, 0x85, 0x79, 0xb2, 0x79, 0x3d, 0x4f, 0xb7, + 0x2e, 0x00, 0x1d, 0x15, 0xe2, 0x3b, 0xed, 0xcb, 0x3c, 0x82, 0x7f, 0xc5, 0x59, 0xef, 0x7a, 0xdb, + 0x6d, 0xa2, 0xec, 0x33, 0x29, 0x1b, 0x86, 0xbf, 0x0d, 0xb2, 0xad, 0x4a, 0x3a, 0x0c, 0xb9, 0x23, + 0x3d, 0x3a, 0xf9, 0x67, 0xd9, 0x30, 0x15, 0x05, 0xb8, 0x8d, 0x15, 0x7b, 0x34, 0x36, 0xae, 0x61, + 0x22, 0x69, 0x67, 0x18, 0xd8, 0x12, 0xb2, 0x70, 0x02, 0xcd, 0xce, 0x4c, 0x80, 0x76, 0x10, 0xf2, + 0xde, 0x7c, 0xec, 0x4a, 0x03, 0x93, 0x3d, 0xa6, 0x4a, 0x63, 0x19, 0xea, 0xb4, 0xac, 0x06, 0x30, + 0xc9, 0x9d, 0x0e, 0x62, 0x77, 0x99, 0x74, 0xe8, 0x03, 0x8f, 0xf5, 0x05, 0x32, 0x75, 0x37, 0x8c, + 0x1b, 0x41, 0xdd, 0x7b, 0xb5, 0xf8, 0xf4, 0xc1, 0x1d, 0xaa, 0x4c, 0xd1, 0x9f, 0xde, 0xc4, 0xd0, + 0x22, 0x28, 0x50, 0xc6, 0x06, 0x85, 0x7c, 0x99, 0x0e, 0x76, 0x5d, 0xe9, 0xdf, 0x4c, 0xfa, 0x54, + 0x87, 0xf3, 0x60, 0xe2, 0x9e, 0x99, 0x34, 0x3e, 0x91, 0x81, 0x1b, 0xae, 0xc3, 0x31, 0xc4, 0x68, + 0x09, 0x85, 0xe6, 0x08, 0xca, 0x5d, 0x40, 0x8e, 0x21, 0x72, 0x5c, 0x6a, 0xa1, 0xb6, 0x1d, 0x5a, + 0x8b, 0x48, 0xd7, 0x5f, 0x4a, 0xaa, 0x9a, 0x3c, 0xbe, 0x88, 0xd3, 0xe0, 0xf1, 0xa5, 0x43, 0x19, + 0x08, 0x1f, 0x77, 0xc7, 0x2c, 0x8f, 0x52, 0x54, 0x74, 0xfe, 0x74, 0x40, 0x90, 0x60, 0x61, 0x56, + 0x79, 0xfc, 0x11, 0x54, 0x73, 0x68, 0x3d, 0x63, 0xab, 0xd9, 0xce, 0xd4, 0x6c, 0x7f, 0x2a, 0xd7, + 0x36, 0x04, 0x6d, 0xe5, 0xa2, 0xc7, 0xd2, 0x52, 0x2f, 0x12, 0x28, 0x95, 0x59, 0x70, 0x49, 0xcf, + 0xd7, 0xcc, 0x5b, 0xeb, 0x6d, 0xc7, 0x2a, 0xa9, 0x90, 0xae, 0x9a, 0x62, 0xec, 0x8e, 0x25, 0x6a, + 0x1c, 0xbf, 0x5f, 0x3f, 0x28, 0x42, 0x33, 0xbb, 0x07, 0x48, 0xc0, 0x3a, 0xb4, 0xaf, 0xbf, 0x6b, + 0x8f, 0xb0, 0xe1, 0x26, 0xc0, 0x37, 0xa0, 0xad, 0x40, 0x94, 0x60, 0x0d, 0xd0, 0xe0, 0x63, 0x4d, + 0x76, 0xf8, 0x8c, 0x21, 0x08, 0x7f, 0x3c, 0xfb, 0x48, 0x5a, 0x89, 0xbc, 0x1e, 0x3a, 0xbc, 0x4c, + 0x95, 0x04, 0x1d, 0x1d, 0x17, 0x0e, 0xcc, 0xf0, 0x29, 0x33, 0xec, 0x53, 0x93, 0xd4, 0xbe, 0x1d, + 0xc5, 0x73, 0xf8, 0x3c, 0x33, 0xd3, 0xb9, 0xa7, 0x46, +]; + #[test] fn test_integration_auth() { let server_secret_params = zkgroup::ServerSecretParams::generate(zkgroup::TEST_ARRAY_32); @@ -185,9 +240,6 @@ fn test_integration_auth() { #[test] fn test_integration_profile() { - // Random UID and issueTime - let _uid = zkgroup::TEST_ARRAY_16; - // SERVER let server_secret_params = zkgroup::ServerSecretParams::generate(zkgroup::TEST_ARRAY_32); let server_public_params = server_secret_params.get_public_params(); @@ -287,6 +339,86 @@ fn test_integration_profile() { profile_key_credential_response_bytes.copy_from_slice(&bincode::serialize(&response).unwrap()); } +#[test] +fn test_integration_pni() { + // SERVER + let server_secret_params = zkgroup::ServerSecretParams::generate(zkgroup::TEST_ARRAY_32); + let server_public_params = server_secret_params.get_public_params(); + + // CLIENT + let master_key = zkgroup::groups::GroupMasterKey::new(zkgroup::TEST_ARRAY_32_1); + let group_secret_params = + zkgroup::groups::GroupSecretParams::derive_from_master_key(master_key); + let group_public_params = group_secret_params.get_public_params(); + + let aci = zkgroup::TEST_ARRAY_16; + let pni = zkgroup::TEST_ARRAY_16_1; + let profile_key = + zkgroup::profiles::ProfileKey::create(zkgroup::common::constants::TEST_ARRAY_32_1); + let profile_key_commitment = profile_key.get_commitment(aci); + + // Create context and request + let randomness = zkgroup::TEST_ARRAY_32_3; + + let context = server_public_params.create_pni_credential_request_context( + randomness, + aci, + pni, + profile_key, + ); + let request = context.get_request(); + + // SERVER + + let randomness = zkgroup::TEST_ARRAY_32_4; + let response = server_secret_params + .issue_pni_credential(randomness, &request, aci, pni, profile_key_commitment) + .unwrap(); + + // CLIENT + // Gets stored profile credential + let pni_credential = server_public_params + .receive_pni_credential(&context, &response) + .unwrap(); + + // Create presentation + let randomness = zkgroup::TEST_ARRAY_32_5; + + let presentation = server_public_params.create_pni_credential_presentation( + randomness, + group_secret_params, + pni_credential, + ); + + let presentation_bytes = &bincode::serialize(&presentation).unwrap(); + // for b in presentation_bytes.iter() { + // print!("0x{:02x}, ", b); + // } + assert!(PNI_CREDENTIAL_PRESENTATION_RESULT[..] == presentation_bytes[..]); + + // SERVER + server_secret_params + .verify_pni_credential_presentation(group_public_params, &presentation) + .unwrap(); + + // test encoding + // these tests will also discover if the serialized sizes change, + // necessitating an update to the LEN constants + + let mut pni_credential_bytes = [0u8; zkgroup::common::constants::PNI_CREDENTIAL_LEN]; + let mut pni_credential_presentation_bytes = + [0u8; zkgroup::common::constants::PNI_CREDENTIAL_PRESENTATION_LEN]; + let mut pni_credential_request_context_bytes = + [0u8; zkgroup::common::constants::PNI_CREDENTIAL_REQUEST_CONTEXT_LEN]; + let mut pni_credential_response_bytes = + [0u8; zkgroup::common::constants::PNI_CREDENTIAL_RESPONSE_LEN]; + + pni_credential_bytes.copy_from_slice(&bincode::serialize(&pni_credential).unwrap()); + pni_credential_presentation_bytes.copy_from_slice(&bincode::serialize(&presentation).unwrap()); + pni_credential_request_context_bytes.copy_from_slice(&bincode::serialize(&context).unwrap()); + pni_credential_response_bytes.copy_from_slice(&bincode::serialize(&response).unwrap()); +} + #[test] fn test_server_sigs() { let server_secret_params = diff --git a/rust/tests/receipt_flow.rs b/rust/tests/receipt_flow.rs index 6eb1e01..e8f5988 100644 --- a/rust/tests/receipt_flow.rs +++ b/rust/tests/receipt_flow.rs @@ -13,7 +13,7 @@ use zkgroup::crypto::receipt_credential_request; use zkgroup::crypto::receipt_struct::ReceiptStruct; use zkgroup::{ RandomnessBytes, ReceiptExpirationTime, ReceiptLevel, ReceiptSerialBytes, ServerSecretParams, - NUM_RECEIPT_CRED_ATTRIBUTES, RANDOMNESS_LEN, RECEIPT_SERIAL_LEN, + RANDOMNESS_LEN, RECEIPT_SERIAL_LEN, }; #[test] @@ -37,7 +37,8 @@ fn test_request_response() { let given_to_server_public_key = client_key_pair.get_public_key(); // server generated materials; issuance request -> issuance response - let server_key_pair = credentials::KeyPair::generate(&mut sho, NUM_RECEIPT_CRED_ATTRIBUTES); + let server_key_pair = + credentials::KeyPair::::generate(&mut sho); let blinded_receipt_credential = server_key_pair.create_blinded_receipt_credential( given_to_server_public_key, given_to_server_ciphertext, From 80cd4709ee2d349b6727b7a48b2cdea18127cce6 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 16 Nov 2021 16:39:00 -0800 Subject: [PATCH 68/69] Expose PniCredential to Java/Node/Swift This required a tweak to the codegen to accept UUID parameters not named 'uuid'. --- codegen/codegen.py | 55 ++- codegen/codegen_simpleapi.py | 2 + ffi/c/zkgroup.h | 99 +++- .../signal/zkgroup/ServerPublicParams.java | 2 +- .../signal/zkgroup/ServerSecretParams.java | 2 +- .../org/signal/zkgroup/internal/Native.java | 13 + .../profiles/ClientZkProfileOperations.java | 68 +++ .../zkgroup/profiles/PniCredential.java | 39 ++ .../profiles/PniCredentialPresentation.java | 92 ++++ .../profiles/PniCredentialRequestContext.java | 56 +++ .../profiles/PniCredentialResponse.java | 39 ++ .../profiles/ServerZkProfileOperations.java | 38 ++ .../zkgroup/integrationtests/ZkGroupTest.java | 60 +++ ffi/node/test/ZKGroup-test.ts | 86 ++++ ffi/node/zkgroup/ServerPublicParams.ts | 2 +- ffi/node/zkgroup/ServerSecretParams.ts | 2 +- ffi/node/zkgroup/internal/Native.ts | 26 + .../profiles/ClientZkProfileOperations.ts | 67 +++ ffi/node/zkgroup/profiles/PniCredential.ts | 26 + .../profiles/PniCredentialPresentation.ts | 66 +++ .../profiles/PniCredentialRequestContext.ts | 41 ++ .../zkgroup/profiles/PniCredentialResponse.ts | 27 ++ .../profiles/ServerZkProfileOperations.ts | 44 ++ .../ZKGroup/ClientZkProfileOperations.swift | 74 +++ ffi/swift/Sources/ZKGroup/PniCredential.swift | 35 ++ .../ZKGroup/PniCredentialPresentation.swift | 86 ++++ .../ZKGroup/PniCredentialRequestContext.swift | 52 ++ .../ZKGroup/PniCredentialResponse.swift | 35 ++ .../Sources/ZKGroup/ServerPublicParams.swift | 2 +- .../Sources/ZKGroup/ServerSecretParams.swift | 2 +- .../ZKGroup/ServerZkProfileOperations.swift | 41 ++ ffi/swift/Sources/libzkgroup/zkgroup.h | 99 +++- ffi/swift/Tests/ZKGroupTests.swift | 105 ++++ rust/src/ffi/ffiapi.rs | 421 ++++++++++++++++ rust/src/ffi/ffiapijava.rs | 448 ++++++++++++++++++ rust/src/ffi/simpleapi.rs | 294 ++++++++++++ 36 files changed, 2633 insertions(+), 13 deletions(-) create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredential.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialPresentation.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialRequestContext.java create mode 100644 ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialResponse.java create mode 100644 ffi/node/zkgroup/profiles/PniCredential.ts create mode 100644 ffi/node/zkgroup/profiles/PniCredentialPresentation.ts create mode 100644 ffi/node/zkgroup/profiles/PniCredentialRequestContext.ts create mode 100644 ffi/node/zkgroup/profiles/PniCredentialResponse.ts create mode 100644 ffi/swift/Sources/ZKGroup/PniCredential.swift create mode 100644 ffi/swift/Sources/ZKGroup/PniCredentialPresentation.swift create mode 100644 ffi/swift/Sources/ZKGroup/PniCredentialRequestContext.swift create mode 100644 ffi/swift/Sources/ZKGroup/PniCredentialResponse.swift diff --git a/codegen/codegen.py b/codegen/codegen.py index 238bf86..067dc1a 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -176,7 +176,7 @@ def define_classes(): classes.append(c) - c = ClassDescriptor("server_secret_params", "", "api::ServerSecretParams", 1121, runtime_error_on_serialize=True) + c = ClassDescriptor("server_secret_params", "", "api::ServerSecretParams", 1537, runtime_error_on_serialize=True) c.add_static_method("generate_deterministic", "class", "server_secret_params", [("class", "randomness")], """ let server_secret_params = api::ServerSecretParams::generate(randomness);""") @@ -209,15 +209,27 @@ def define_classes(): c.add_method("create_profile_key_credential_request_context_deterministic", "class", "profile_key_credential_request_context", [("class", "randomness"), ("UUID", "uuid"), ("class", "profile_key")], """ let profile_key_credential_request_context = server_public_params.create_profile_key_credential_request_context(randomness, uuid, profile_key);""", runtime_error=True) - c.add_method("receive_profile_key_credential", "class", "profile_key_credential", [("class", "profile_key_credential_request_context"), ("class", "profile_key_credential_response")], + c.add_method("create_pni_credential_request_context_deterministic", "class", "pni_credential_request_context", [("class", "randomness"), ("UUID", "aci"), ("UUID", "pni"), ("class", "profile_key")], + """ let pni_credential_request_context = server_public_params.create_pni_credential_request_context(randomness, aci, pni, profile_key);""", runtime_error=True) + + c.add_method("receive_profile_key_credential", "class", "profile_key_credential", [("class", "profile_key_credential_request_context"), ("class", "profile_key_credential_response")], """ let profile_key_credential = match server_public_params.receive_profile_key_credential(&profile_key_credential_request_context, &profile_key_credential_response) { Ok(result) => result, Err(_) => return FFI_RETURN_INPUT_ERROR, };""") + c.add_method("receive_pni_credential", "class", "pni_credential", [("class", "pni_credential_request_context"), ("class", "pni_credential_response")], + """ let pni_credential = match server_public_params.receive_pni_credential(&pni_credential_request_context, &pni_credential_response) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + };""") + c.add_method("create_profile_key_credential_presentation_deterministic", "class", "profile_key_credential_presentation", [("class", "randomness"), ("class", "group_secret_params"), ("class", "profile_key_credential") ], """ let profile_key_credential_presentation = server_public_params.create_profile_key_credential_presentation(randomness, group_secret_params, profile_key_credential);""", runtime_error=True) + c.add_method("create_pni_credential_presentation_deterministic", "class", "pni_credential_presentation", [("class", "randomness"), ("class", "group_secret_params"), ("class", "pni_credential") ], + """ let pni_credential_presentation = server_public_params.create_pni_credential_presentation(randomness, group_secret_params, pni_credential);""", runtime_error=True) + classes.append(c) c = ClassDescriptor("client_zk_receipt_operations", "receipts", "api::receipts::ClientZkReceiptOperations", 256, wrap_class="server_public_params") @@ -262,12 +274,30 @@ def define_classes(): Err(_) => return FFI_RETURN_INPUT_ERROR, };""") + c.add_method("issue_pni_credential_deterministic", "class", "pni_credential_response", [("class", "randomness"), ("class", "profile_key_credential_request"), ("UUID", "aci"), ("UUID", "pni"), ("class", "profile_key_commitment")], + """ let pni_credential_response = match server_secret_params.issue_pni_credential( + randomness, + &profile_key_credential_request, + aci, + pni, + profile_key_commitment, + ) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + };""") + c.add_method("verify_profile_key_credential_presentation", "boolean", "None", [("class", "group_public_params"), ("class", "profile_key_credential_presentation") ], """ match server_secret_params.verify_profile_key_credential_presentation(group_public_params, &profile_key_credential_presentation) { Ok(_) => (), Err(_) => return FFI_RETURN_INPUT_ERROR, }""") + c.add_method("verify_pni_credential_presentation", "boolean", "None", [("class", "group_public_params"), ("class", "pni_credential_presentation") ], + """ match server_secret_params.verify_pni_credential_presentation(group_public_params, &pni_credential_presentation) { + Ok(_) => (), + Err(_) => return FFI_RETURN_INPUT_ERROR, + }""") + classes.append(c) c = ClassDescriptor("server_zk_receipt_operations", "receipts", "api::receipts::ServerZkReceiptOperations", 544, wrap_class="server_secret_params") @@ -294,7 +324,7 @@ def define_classes(): classes.append(c) - c = ClassDescriptor("server_public_params", "", "api::ServerPublicParams", 225, runtime_error_on_serialize=True) + c = ClassDescriptor("server_public_params", "", "api::ServerPublicParams", 289, runtime_error_on_serialize=True) c.add_method("verify_signature", "boolean", "None", [("byte[]", "message"), ("class", "notary_signature")], """ match server_public_params.verify_signature(message, notary_signature) { @@ -320,23 +350,42 @@ def define_classes(): c = ClassDescriptor("profile_key_credential_request_context", "profiles", "api::profiles::ProfileKeyCredentialRequestContext", 473) c.add_method("get_request", "class", "profile_key_credential_request", [], """ let profile_key_credential_request = profile_key_credential_request_context.get_request();""" ) + classes.append(c) + c = ClassDescriptor("pni_credential_request_context", "profiles", "api::profiles::PniCredentialRequestContext", 489) + c.add_method("get_request", "class", "profile_key_credential_request", [], + """ let profile_key_credential_request = pni_credential_request_context.get_request();""" ) classes.append(c) + c = ClassDescriptor("profile_key_credential_request", "profiles", "api::profiles::ProfileKeyCredentialRequest", 329) classes.append(c) c = ClassDescriptor("profile_key_credential_response", "profiles", "api::profiles::ProfileKeyCredentialResponse", 457) classes.append(c) + c = ClassDescriptor("pni_credential_response", "profiles", "api::profiles::PniCredentialResponse", 521) + classes.append(c) + c = ClassDescriptor("profile_key_credential", "profiles", "api::profiles::ProfileKeyCredential", 145) classes.append(c) + c = ClassDescriptor("pni_credential", "profiles", "api::profiles::PniCredential", 161) + classes.append(c) + c = ClassDescriptor("profile_key_credential_presentation", "profiles", "api::profiles::ProfileKeyCredentialPresentation", 713) c.add_method("get_uuid_ciphertext", "class", "uuid_ciphertext", [], """ let uuid_ciphertext = profile_key_credential_presentation.get_uuid_ciphertext();"""); c.add_method("get_profile_key_ciphertext", "class", "profile_key_ciphertext", [], """ let profile_key_ciphertext = profile_key_credential_presentation.get_profile_key_ciphertext();"""); + classes.append(c) + c = ClassDescriptor("pni_credential_presentation", "profiles", "api::profiles::PniCredentialPresentation", 841) + c.add_method("get_aci_ciphertext", "class", "uuid_ciphertext", [], + """ let uuid_ciphertext = pni_credential_presentation.get_aci_ciphertext();"""); + c.add_method("get_pni_ciphertext", "class", "uuid_ciphertext", [], + """ let uuid_ciphertext = pni_credential_presentation.get_pni_ciphertext();"""); + c.add_method("get_profile_key_ciphertext", "class", "profile_key_ciphertext", [], + """ let profile_key_ciphertext = pni_credential_presentation.get_profile_key_ciphertext();"""); classes.append(c) c = ClassDescriptor("receipt_credential_request_context", "receipts", "api::receipts::ReceiptCredentialRequestContext", 177) diff --git a/codegen/codegen_simpleapi.py b/codegen/codegen_simpleapi.py index 39a065b..7edaf3a 100644 --- a/codegen/codegen_simpleapi.py +++ b/codegen/codegen_simpleapi.py @@ -100,6 +100,8 @@ def print_method(c, m, rustClasses, static): for param in m.params: if param[0] == "int" or param[0] == "long" or param[0] == "byte[]": s += " let %s = %sIn;\n" % (param[1].snake(), param[1].lower_camel()) + elif param[0] == "UUID": + s += template_load % (param[1].snake(), rustClasses['uuid'], param[1].lower_camel(), error_name) elif param[1].snake() == "notary_signature": s += """ let mut notary_signature: simple_types::NotarySignatureBytes = [0u8; SIGNATURE_LEN]; notary_signature.copy_from_slice(notarySignatureIn);\n"""; diff --git a/ffi/c/zkgroup.h b/ffi/c/zkgroup.h index d93e53d..f2331d6 100644 --- a/ffi/c/zkgroup.h +++ b/ffi/c/zkgroup.h @@ -29,6 +29,14 @@ #define AUTH_CREDENTIAL_RESPONSE_LEN 361 +#define PNI_CREDENTIAL_LEN 161 + +#define PNI_CREDENTIAL_PRESENTATION_LEN 841 + +#define PNI_CREDENTIAL_REQUEST_CONTEXT_LEN 489 + +#define PNI_CREDENTIAL_RESPONSE_LEN 521 + #define PROFILE_KEY_LEN 32 #define PROFILE_KEY_CIPHERTEXT_LEN 65 @@ -63,9 +71,9 @@ #define RESERVED_LEN 1 -#define SERVER_SECRET_PARAMS_LEN 1121 +#define SERVER_SECRET_PARAMS_LEN 1537 -#define SERVER_PUBLIC_PARAMS_LEN 225 +#define SERVER_PUBLIC_PARAMS_LEN 289 #define UUID_CIPHERTEXT_LEN 65 @@ -223,6 +231,19 @@ int32_t FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDetermini uint8_t *profileKeyCredentialRequestContextOut, uint32_t profileKeyCredentialRequestContextLen); +int32_t FFI_ServerPublicParams_createPniCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *aci, + uint32_t aciLen, + const uint8_t *pni, + uint32_t pniLen, + const uint8_t *profileKey, + uint32_t profileKeyLen, + uint8_t *pniCredentialRequestContextOut, + uint32_t pniCredentialRequestContextLen); + int32_t FFI_ServerPublicParams_receiveProfileKeyCredential(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *profileKeyCredentialRequestContext, @@ -232,6 +253,15 @@ int32_t FFI_ServerPublicParams_receiveProfileKeyCredential(const uint8_t *server uint8_t *profileKeyCredentialOut, uint32_t profileKeyCredentialLen); +int32_t FFI_ServerPublicParams_receivePniCredential(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *pniCredentialRequestContext, + uint32_t pniCredentialRequestContextLen, + const uint8_t *pniCredentialResponse, + uint32_t pniCredentialResponseLen, + uint8_t *pniCredentialOut, + uint32_t pniCredentialLen); + int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *randomness, @@ -243,6 +273,17 @@ int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterminist uint8_t *profileKeyCredentialPresentationOut, uint32_t profileKeyCredentialPresentationLen); +int32_t FFI_ServerPublicParams_createPniCredentialPresentationDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *pniCredential, + uint32_t pniCredentialLen, + uint8_t *pniCredentialPresentationOut, + uint32_t pniCredentialPresentationLen); + int32_t FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *randomness, @@ -300,6 +341,21 @@ int32_t FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic(const uint uint8_t *profileKeyCredentialResponseOut, uint32_t profileKeyCredentialResponseLen); +int32_t FFI_ServerSecretParams_issuePniCredentialDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *profileKeyCredentialRequest, + uint32_t profileKeyCredentialRequestLen, + const uint8_t *aci, + uint32_t aciLen, + const uint8_t *pni, + uint32_t pniLen, + const uint8_t *profileKeyCommitment, + uint32_t profileKeyCommitmentLen, + uint8_t *pniCredentialResponseOut, + uint32_t pniCredentialResponseLen); + int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, const uint8_t *groupPublicParams, @@ -307,6 +363,13 @@ int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint const uint8_t *profileKeyCredentialPresentation, uint32_t profileKeyCredentialPresentationLen); +int32_t FFI_ServerSecretParams_verifyPniCredentialPresentation(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen, + const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen); + int32_t FFI_ServerSecretParams_issueReceiptCredentialDeterministic(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, const uint8_t *randomness, @@ -368,15 +431,29 @@ int32_t FFI_ProfileKeyCredentialRequestContext_getRequest(const uint8_t *profile uint8_t *profileKeyCredentialRequestOut, uint32_t profileKeyCredentialRequestLen); +int32_t FFI_PniCredentialRequestContext_checkValidContents(const uint8_t *pniCredentialRequestContext, + uint32_t pniCredentialRequestContextLen); + +int32_t FFI_PniCredentialRequestContext_getRequest(const uint8_t *pniCredentialRequestContext, + uint32_t pniCredentialRequestContextLen, + uint8_t *profileKeyCredentialRequestOut, + uint32_t profileKeyCredentialRequestLen); + int32_t FFI_ProfileKeyCredentialRequest_checkValidContents(const uint8_t *profileKeyCredentialRequest, uint32_t profileKeyCredentialRequestLen); int32_t FFI_ProfileKeyCredentialResponse_checkValidContents(const uint8_t *profileKeyCredentialResponse, uint32_t profileKeyCredentialResponseLen); +int32_t FFI_PniCredentialResponse_checkValidContents(const uint8_t *pniCredentialResponse, + uint32_t pniCredentialResponseLen); + int32_t FFI_ProfileKeyCredential_checkValidContents(const uint8_t *profileKeyCredential, uint32_t profileKeyCredentialLen); +int32_t FFI_PniCredential_checkValidContents(const uint8_t *pniCredential, + uint32_t pniCredentialLen); + int32_t FFI_ProfileKeyCredentialPresentation_checkValidContents(const uint8_t *profileKeyCredentialPresentation, uint32_t profileKeyCredentialPresentationLen); @@ -390,6 +467,24 @@ int32_t FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext(const uint8 uint8_t *profileKeyCiphertextOut, uint32_t profileKeyCiphertextLen); +int32_t FFI_PniCredentialPresentation_checkValidContents(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen); + +int32_t FFI_PniCredentialPresentation_getAciCiphertext(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_PniCredentialPresentation_getPniCiphertext(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_PniCredentialPresentation_getProfileKeyCiphertext(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen, + uint8_t *profileKeyCiphertextOut, + uint32_t profileKeyCiphertextLen); + int32_t FFI_ReceiptCredentialRequestContext_checkValidContents(const uint8_t *receiptCredentialRequestContext, uint32_t receiptCredentialRequestContextLen); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java b/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java index 17d39c0..a86a1a2 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/ServerPublicParams.java @@ -14,7 +14,7 @@ public final class ServerPublicParams extends ByteArray { - public static final int SIZE = 225; + public static final int SIZE = 289; public ServerPublicParams(byte[] contents) { super(contents, SIZE, true); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java b/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java index a06ba1e..d4e72ab 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/ServerSecretParams.java @@ -16,7 +16,7 @@ public final class ServerSecretParams extends ByteArray { - public static final int SIZE = 1121; + public static final int SIZE = 1537; public static ServerSecretParams generate() { return generate(new SecureRandom()); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java index f7d7b77..0169969 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/internal/Native.java @@ -77,15 +77,20 @@ private static void copyToTempFileAndLoad(InputStream in, String extension) thro public static native int serverPublicParamsReceiveAuthCredentialJNI(byte[] self, byte[] uuid, int redemptionTime, byte[] authCredentialResponse, byte[] output); public static native int serverPublicParamsCreateAuthCredentialPresentationDeterministicJNI(byte[] self, byte[] randomness, byte[] groupSecretParams, byte[] authCredential, byte[] output); public static native int serverPublicParamsCreateProfileKeyCredentialRequestContextDeterministicJNI(byte[] self, byte[] randomness, byte[] uuid, byte[] profileKey, byte[] output); + public static native int serverPublicParamsCreatePniCredentialRequestContextDeterministicJNI(byte[] self, byte[] randomness, byte[] aci, byte[] pni, byte[] profileKey, byte[] output); public static native int serverPublicParamsReceiveProfileKeyCredentialJNI(byte[] self, byte[] profileKeyCredentialRequestContext, byte[] profileKeyCredentialResponse, byte[] output); + public static native int serverPublicParamsReceivePniCredentialJNI(byte[] self, byte[] pniCredentialRequestContext, byte[] pniCredentialResponse, byte[] output); public static native int serverPublicParamsCreateProfileKeyCredentialPresentationDeterministicJNI(byte[] self, byte[] randomness, byte[] groupSecretParams, byte[] profileKeyCredential, byte[] output); + public static native int serverPublicParamsCreatePniCredentialPresentationDeterministicJNI(byte[] self, byte[] randomness, byte[] groupSecretParams, byte[] pniCredential, byte[] output); public static native int serverPublicParamsCreateReceiptCredentialRequestContextDeterministicJNI(byte[] self, byte[] randomness, byte[] receiptSerial, byte[] output); public static native int serverPublicParamsReceiveReceiptCredentialJNI(byte[] self, byte[] receiptCredentialRequestContext, byte[] receiptCredentialResponse, byte[] output); public static native int serverPublicParamsCreateReceiptCredentialPresentationDeterministicJNI(byte[] self, byte[] randomness, byte[] receiptCredential, byte[] output); public static native int serverSecretParamsIssueAuthCredentialDeterministicJNI(byte[] self, byte[] randomness, byte[] uuid, int redemptionTime, byte[] output); public static native int serverSecretParamsVerifyAuthCredentialPresentationJNI(byte[] self, byte[] groupPublicParams, byte[] authCredentialPresentation); public static native int serverSecretParamsIssueProfileKeyCredentialDeterministicJNI(byte[] self, byte[] randomness, byte[] profileKeyCredentialRequest, byte[] uuid, byte[] profileKeyCommitment, byte[] output); + public static native int serverSecretParamsIssuePniCredentialDeterministicJNI(byte[] self, byte[] randomness, byte[] profileKeyCredentialRequest, byte[] aci, byte[] pni, byte[] profileKeyCommitment, byte[] output); public static native int serverSecretParamsVerifyProfileKeyCredentialPresentationJNI(byte[] self, byte[] groupPublicParams, byte[] profileKeyCredentialPresentation); + public static native int serverSecretParamsVerifyPniCredentialPresentationJNI(byte[] self, byte[] groupPublicParams, byte[] pniCredentialPresentation); public static native int serverSecretParamsIssueReceiptCredentialDeterministicJNI(byte[] self, byte[] randomness, byte[] receiptCredentialRequest, long receiptExpirationTime, long receiptLevel, byte[] output); public static native int serverSecretParamsVerifyReceiptCredentialPresentationJNI(byte[] self, byte[] receiptCredentialPresentation); public static native int groupPublicParamsGetGroupIdentifierJNI(byte[] self, byte[] output); @@ -99,12 +104,20 @@ private static void copyToTempFileAndLoad(InputStream in, String extension) thro public static native int authCredentialPresentationCheckValidContentsJNI(byte[] self); public static native int profileKeyCredentialRequestContextGetRequestJNI(byte[] self, byte[] output); public static native int profileKeyCredentialRequestContextCheckValidContentsJNI(byte[] self); + public static native int pniCredentialRequestContextGetRequestJNI(byte[] self, byte[] output); + public static native int pniCredentialRequestContextCheckValidContentsJNI(byte[] self); public static native int profileKeyCredentialRequestCheckValidContentsJNI(byte[] self); public static native int profileKeyCredentialResponseCheckValidContentsJNI(byte[] self); + public static native int pniCredentialResponseCheckValidContentsJNI(byte[] self); public static native int profileKeyCredentialCheckValidContentsJNI(byte[] self); + public static native int pniCredentialCheckValidContentsJNI(byte[] self); public static native int profileKeyCredentialPresentationGetUuidCiphertextJNI(byte[] self, byte[] output); public static native int profileKeyCredentialPresentationGetProfileKeyCiphertextJNI(byte[] self, byte[] output); public static native int profileKeyCredentialPresentationCheckValidContentsJNI(byte[] self); + public static native int pniCredentialPresentationGetAciCiphertextJNI(byte[] self, byte[] output); + public static native int pniCredentialPresentationGetPniCiphertextJNI(byte[] self, byte[] output); + public static native int pniCredentialPresentationGetProfileKeyCiphertextJNI(byte[] self, byte[] output); + public static native int pniCredentialPresentationCheckValidContentsJNI(byte[] self); public static native int receiptCredentialRequestContextGetRequestJNI(byte[] self, byte[] output); public static native int receiptCredentialRequestContextCheckValidContentsJNI(byte[] self); public static native int receiptCredentialRequestCheckValidContentsJNI(byte[] self); diff --git a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java index 65566a5..faacf31 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ClientZkProfileOperations.java @@ -51,6 +51,30 @@ public ProfileKeyCredentialRequestContext createProfileKeyCredentialRequestConte } + public PniCredentialRequestContext createPniCredentialRequestContext(UUID aci, UUID pni, ProfileKey profileKey) { + return createPniCredentialRequestContext(new SecureRandom(), aci, pni, profileKey); + } + + public PniCredentialRequestContext createPniCredentialRequestContext(SecureRandom secureRandom, UUID aci, UUID pni, ProfileKey profileKey) { + byte[] newContents = new byte[PniCredentialRequestContext.SIZE]; + byte[] random = new byte[Native.RANDOM_LENGTH]; + + secureRandom.nextBytes(random); + + int ffi_return = Native.serverPublicParamsCreatePniCredentialRequestContextDeterministicJNI(serverPublicParams.getInternalContentsForJNI(), random, UUIDUtil.serialize(aci), UUIDUtil.serialize(pni), profileKey.getInternalContentsForJNI(), newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new PniCredentialRequestContext(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + public ProfileKeyCredential receiveProfileKeyCredential(ProfileKeyCredentialRequestContext profileKeyCredentialRequestContext, ProfileKeyCredentialResponse profileKeyCredentialResponse) throws VerificationFailedException { if (profileKeyCredentialResponse == null) { throw new VerificationFailedException(); @@ -75,6 +99,26 @@ public ProfileKeyCredential receiveProfileKeyCredential(ProfileKeyCredentialRequ } + public PniCredential receivePniCredential(PniCredentialRequestContext pniCredentialRequestContext, PniCredentialResponse pniCredentialResponse) throws VerificationFailedException { + byte[] newContents = new byte[PniCredential.SIZE]; + + int ffi_return = Native.serverPublicParamsReceivePniCredentialJNI(serverPublicParams.getInternalContentsForJNI(), pniCredentialRequestContext.getInternalContentsForJNI(), pniCredentialResponse.getInternalContentsForJNI(), newContents); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new PniCredential(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + public ProfileKeyCredentialPresentation createProfileKeyCredentialPresentation(GroupSecretParams groupSecretParams, ProfileKeyCredential profileKeyCredential) { return createProfileKeyCredentialPresentation(new SecureRandom(), groupSecretParams, profileKeyCredential); } @@ -99,4 +143,28 @@ public ProfileKeyCredentialPresentation createProfileKeyCredentialPresentation(S } + public PniCredentialPresentation createPniCredentialPresentation(GroupSecretParams groupSecretParams, PniCredential pniCredential) { + return createPniCredentialPresentation(new SecureRandom(), groupSecretParams, pniCredential); + } + + public PniCredentialPresentation createPniCredentialPresentation(SecureRandom secureRandom, GroupSecretParams groupSecretParams, PniCredential pniCredential) { + byte[] newContents = new byte[PniCredentialPresentation.SIZE]; + byte[] random = new byte[Native.RANDOM_LENGTH]; + + secureRandom.nextBytes(random); + + int ffi_return = Native.serverPublicParamsCreatePniCredentialPresentationDeterministicJNI(serverPublicParams.getInternalContentsForJNI(), random, groupSecretParams.getInternalContentsForJNI(), pniCredential.getInternalContentsForJNI(), newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new PniCredentialPresentation(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + } diff --git a/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredential.java b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredential.java new file mode 100644 index 0000000..fe31b52 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredential.java @@ -0,0 +1,39 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.profiles; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class PniCredential extends ByteArray { + + public static final int SIZE = 161; + + public PniCredential(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.pniCredentialCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialPresentation.java b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialPresentation.java new file mode 100644 index 0000000..2fc15d0 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialPresentation.java @@ -0,0 +1,92 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.profiles; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.groups.ProfileKeyCiphertext; +import org.signal.zkgroup.groups.UuidCiphertext; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class PniCredentialPresentation extends ByteArray { + + public static final int SIZE = 841; + + public PniCredentialPresentation(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.pniCredentialPresentationCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public UuidCiphertext getAciCiphertext() { + byte[] newContents = new byte[UuidCiphertext.SIZE]; + + int ffi_return = Native.pniCredentialPresentationGetAciCiphertextJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new UuidCiphertext(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public UuidCiphertext getPniCiphertext() { + byte[] newContents = new byte[UuidCiphertext.SIZE]; + + int ffi_return = Native.pniCredentialPresentationGetPniCiphertextJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new UuidCiphertext(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public ProfileKeyCiphertext getProfileKeyCiphertext() { + byte[] newContents = new byte[ProfileKeyCiphertext.SIZE]; + + int ffi_return = Native.pniCredentialPresentationGetProfileKeyCiphertextJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ProfileKeyCiphertext(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialRequestContext.java b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialRequestContext.java new file mode 100644 index 0000000..f351429 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialRequestContext.java @@ -0,0 +1,56 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.profiles; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class PniCredentialRequestContext extends ByteArray { + + public static final int SIZE = 489; + + public PniCredentialRequestContext(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.pniCredentialRequestContextCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public ProfileKeyCredentialRequest getRequest() { + byte[] newContents = new byte[ProfileKeyCredentialRequest.SIZE]; + + int ffi_return = Native.pniCredentialRequestContextGetRequestJNI(contents, newContents); + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new ProfileKeyCredentialRequest(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialResponse.java b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialResponse.java new file mode 100644 index 0000000..224b667 --- /dev/null +++ b/ffi/java/src/main/java/org/signal/zkgroup/profiles/PniCredentialResponse.java @@ -0,0 +1,39 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// + +// Generated by zkgroup/codegen/codegen.py - do not edit + +package org.signal.zkgroup.profiles; + +import org.signal.zkgroup.InvalidInputException; +import org.signal.zkgroup.ZkGroupError; +import org.signal.zkgroup.internal.ByteArray; +import org.signal.zkgroup.internal.Native; + +public final class PniCredentialResponse extends ByteArray { + + public static final int SIZE = 521; + + public PniCredentialResponse(byte[] contents) throws InvalidInputException { + super(contents, SIZE); + + int ffi_return = Native.pniCredentialResponseCheckValidContentsJNI(contents); + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException("FFI_RETURN_INPUT_ERROR"); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + + public byte[] serialize() { + return contents.clone(); + } + +} diff --git a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ServerZkProfileOperations.java b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ServerZkProfileOperations.java index e02e727..40bcacd 100644 --- a/ffi/java/src/main/java/org/signal/zkgroup/profiles/ServerZkProfileOperations.java +++ b/ffi/java/src/main/java/org/signal/zkgroup/profiles/ServerZkProfileOperations.java @@ -54,6 +54,33 @@ public ProfileKeyCredentialResponse issueProfileKeyCredential(SecureRandom secur } + public PniCredentialResponse issuePniCredential(ProfileKeyCredentialRequest profileKeyCredentialRequest, UUID aci, UUID pni, ProfileKeyCommitment profileKeyCommitment) throws VerificationFailedException { + return issuePniCredential(new SecureRandom(), profileKeyCredentialRequest, aci, pni, profileKeyCommitment); + } + + public PniCredentialResponse issuePniCredential(SecureRandom secureRandom, ProfileKeyCredentialRequest profileKeyCredentialRequest, UUID aci, UUID pni, ProfileKeyCommitment profileKeyCommitment) throws VerificationFailedException { + byte[] newContents = new byte[PniCredentialResponse.SIZE]; + byte[] random = new byte[Native.RANDOM_LENGTH]; + + secureRandom.nextBytes(random); + + int ffi_return = Native.serverSecretParamsIssuePniCredentialDeterministicJNI(serverSecretParams.getInternalContentsForJNI(), random, profileKeyCredentialRequest.getInternalContentsForJNI(), UUIDUtil.serialize(aci), UUIDUtil.serialize(pni), profileKeyCommitment.getInternalContentsForJNI(), newContents); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + try { + return new PniCredentialResponse(newContents); + } catch (InvalidInputException e) { + throw new AssertionError(e); + } + + } + public void verifyProfileKeyCredentialPresentation(GroupPublicParams groupPublicParams, ProfileKeyCredentialPresentation profileKeyCredentialPresentation) throws VerificationFailedException { int ffi_return = Native.serverSecretParamsVerifyProfileKeyCredentialPresentationJNI(serverSecretParams.getInternalContentsForJNI(), groupPublicParams.getInternalContentsForJNI(), profileKeyCredentialPresentation.getInternalContentsForJNI()); if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { @@ -65,4 +92,15 @@ public void verifyProfileKeyCredentialPresentation(GroupPublicParams groupPublic } } + public void verifyPniCredentialPresentation(GroupPublicParams groupPublicParams, PniCredentialPresentation pniCredentialPresentation) throws VerificationFailedException { + int ffi_return = Native.serverSecretParamsVerifyPniCredentialPresentationJNI(serverSecretParams.getInternalContentsForJNI(), groupPublicParams.getInternalContentsForJNI(), pniCredentialPresentation.getInternalContentsForJNI()); + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException(); + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + } + } diff --git a/ffi/java/src/test/java/org/signal/zkgroup/integrationtests/ZkGroupTest.java b/ffi/java/src/test/java/org/signal/zkgroup/integrationtests/ZkGroupTest.java index 4e2180b..3183bea 100644 --- a/ffi/java/src/test/java/org/signal/zkgroup/integrationtests/ZkGroupTest.java +++ b/ffi/java/src/test/java/org/signal/zkgroup/integrationtests/ZkGroupTest.java @@ -30,6 +30,10 @@ import org.signal.zkgroup.groups.ProfileKeyCiphertext; import org.signal.zkgroup.groups.UuidCiphertext; import org.signal.zkgroup.profiles.ClientZkProfileOperations; +import org.signal.zkgroup.profiles.PniCredential; +import org.signal.zkgroup.profiles.PniCredentialPresentation; +import org.signal.zkgroup.profiles.PniCredentialRequestContext; +import org.signal.zkgroup.profiles.PniCredentialResponse; import org.signal.zkgroup.profiles.ProfileKey; import org.signal.zkgroup.profiles.ProfileKeyCommitment; import org.signal.zkgroup.profiles.ProfileKeyCredential; @@ -52,6 +56,8 @@ public final class ZkGroupTest extends SecureRandomTest { private static final byte[] TEST_ARRAY_16 = Hex.fromStringCondensedAssert("000102030405060708090a0b0c0d0e0f"); + private static final byte[] TEST_ARRAY_16_1 = Hex.fromStringCondensedAssert("6465666768696a6b6c6d6e6f70717273"); + private static final byte[] TEST_ARRAY_32 = Hex.fromStringCondensedAssert("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"); private static final byte[] TEST_ARRAY_32_1 = Hex.fromStringCondensedAssert("6465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f80818283"); @@ -75,6 +81,9 @@ public final class ZkGroupTest extends SecureRandomTest { private static final byte[] profileKeyPresentationResult = Hex.fromStringCondensedAssert( "00c4d19bca1ae844585168869da4133e0e0bb59f2ce17b7ac65bff5da9610eca103429d8022a94bae2b5b1057b5595b8ad70bfc2d0e1ad662cb75e6bae0782be6f00e3db793bc28561f0196c2e74da6f303fa8bcb70c94096671b73f7b3a95fb002200d5b9180fa0ef7d3014d01344145b4d38480d72ff25c24294e305e5705072e0d32cc4e84f5caf31486089a4b934c80c92eba43472ff23a5af93c397535d33801f0e6fc6eb2ee0d117f03bb4fd38a8b9c88d94708131f38742ca804a3cfc4f9476bc2d03f53d17001c36478afbe9cc535a224b2df6b2b08bef06cbc7d4dc42ccfc3459f7ac5c4419ae9f3c8a161d554d047778943216240858da3b1101984c40010000000000007a01eea6b2adad14d71ab8b8e411bef3c596e954b70e4031570cb1abd7e932083241f1caca3116708fa4319fbbdfe351376c23644ae09a42f0155db4996c9d0c7ffc8521c1914c0e1a20ae51e65df64dd5e6e5985b3d9d31732046d2d77f9c08aaccf056b84026073976eec6164cbdaee5d9e76e497f0c290af681cabd5c5101282abb26c3680d6087ce053310fe8a94f59d8ae23caac5fc0ed0c379888abf028a6f29f89d4fe2acc1706341b2245ba1885bca57e1e27ccf7ed79371500965009f960c2ba00fad3e93383b87ce119cac0b3360eb99284ce78e2cbed680f7960373e0ab75c190254160c2353614109489e653c9b2e1c93f92c7c5ad583d987a04bd3541b24485c33ea49bac43c87c4ab3efde2e2d7ec10a40be544199f925b20b2c55542bc56410571e41cd8e0286f609a66768b5061ccb4777af32309928dd09765de9df4cfa5487f360e29e99343e91811baec331c4680985e608ca5d408e21725c6aa1b61d5a8b48d75f4aaa9a3cbe88d3e0f1a54319081f77c72c8f52547448c03ab4afbf6b8fb0e126c037a0ad4094600dd0e0634d76f88c21087f3cfb485a89bc1e3abc4c95041d1d170eccf02933ec5393d4be1dc573f83c33d3b9a746"); +private static final byte[] pniPresentationResult = Hex.fromStringCondensedAssert( +"00fecc5f71d40dbd45912d0de9c1ed033c7eb1c4755e19cb6241ede6a6a99f65545e870a806854c5000d436db601a89f72b9b399f0efa277473716e8bc20c984766250937555604f2d2fcdd263c60f2f72b5a04d9bbbc6f95c78085f81aaf07d3316a2dbd1ef85bb642d5da6d00d03fed8097276bf17a113a44018d773c9116c33ac86837d4f5c41fb70153f3d655c0b68982fae01113460db75ea7099ef7e910cbe0bd606870df55522f9d0b1bee1b1ab2f3b9cd3563a422684ebcfdb1fdada27acb4d48c7db9c6b1389c6742a8f8257bb70f5430feb4a438007fb33e7910da3b9a0997d7d35c6c93a8d45949d01f88b497c822b0127b3fc57cfaee90bcf7d41914f6f0f8fa0acd82e004caaad1c9feec2fb67f58936ae7a92a285dc15b23486a0272e864f3ae9769d650fdd0898739ad28e259e8dae73907caa8ff69a53a851e4001000000000000f26c704b8daf38a464810eca8589541521e053221dd830866bf77da025cdc2041e33f73e42c70387709acbac0df46d0155e6bf6f7952ddc3289a16ca682e740df7403cc12cbe0cd54a7b0de08eec4f7cdce52996880ef5db74bcc4e8e78d620da4d21ff137b29df3a1a08d14b9224c91ef05a1ac0a7cfe142b227853c90bb90db0cf3d6311560e49ca52983f9efc54ecb61f552d6a85088871ef4d0f5862dd04aff93fd97b7816181d38bcb30f71eaeb9eff2ba630916eac355f45703a8c780e8579b2793d4fb72e001d15e23bedcb3c827fc559ef7adb6da2ec33291b86bf0db2ad4a3a0cb9233d3af967d9301505b88d157b3436ae6122696718d812b27002cdce4c807610f2de7cec4a03933da64a6319eab4ac0630c99d0e62779974e8038ff5053275378c1b41dd7bb5f8f4c11daa4cd19fdec4d0222850c606857c990e765de9df4cfa5487f360e29e99343e91811baec331c4680985e608ca5d408e21725c6aa1b61d5a8b48d75f4aaa9a3cbe88d3e0f1a54319081f77c72c8f525474fe74409060615679fc115473683d63abd9ced46c7f2ad736046de5a2c7d2522f122895597049cfd7cc5beb6dc72aa990ae9a62ec8e256a1cbf5f3f284233bb0748c03ab4afbf6b8fb0e126c037a0ad4094600dd0e0634d76f88c21087f3cfb485a89bc1e3abc4c95041d1d170eccf02933ec5393d4be1dc573f83c33d3b9a746"); + @Test public void testAuthIntegration() throws VerificationFailedException, InvalidInputException, InvalidRedemptionTimeException { @@ -275,6 +284,57 @@ public void testProfileKeyIntegration() throws VerificationFailedException, Inva throw new AssertionError(); } + + @Test + public void testPniIntegration() throws VerificationFailedException, InvalidInputException, UnsupportedEncodingException { + + UUID aci = UUIDUtil.deserialize(TEST_ARRAY_16); + UUID pni = UUIDUtil.deserialize(TEST_ARRAY_16_1); + + // Generate keys (client's are per-group, server's are not) + // --- + + // SERVER + ServerSecretParams serverSecretParams = ServerSecretParams.generate(createSecureRandom(TEST_ARRAY_32)); + ServerPublicParams serverPublicParams = serverSecretParams.getPublicParams(); + ServerZkProfileOperations serverZkProfile = new ServerZkProfileOperations(serverSecretParams); + + // CLIENT + GroupMasterKey masterKey = new GroupMasterKey(TEST_ARRAY_32_1); + GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(masterKey); + + assertArrayEquals(groupSecretParams.getMasterKey().serialize(), masterKey.serialize()); + + GroupPublicParams groupPublicParams = groupSecretParams.getPublicParams(); + ClientZkProfileOperations clientZkProfileCipher = new ClientZkProfileOperations(serverPublicParams); + + ProfileKey profileKey = new ProfileKey(TEST_ARRAY_32_1); + ProfileKeyCommitment profileKeyCommitment = profileKey.getCommitment(aci); + + // Create context and request + PniCredentialRequestContext context = clientZkProfileCipher.createPniCredentialRequestContext(createSecureRandom(TEST_ARRAY_32_3), aci, pni, profileKey); + ProfileKeyCredentialRequest request = context.getRequest(); + + // SERVER + PniCredentialResponse response = serverZkProfile.issuePniCredential(createSecureRandom(TEST_ARRAY_32_4), request, aci, pni, profileKeyCommitment); + + // CLIENT + // Gets stored profile credential + ClientZkGroupCipher clientZkGroupCipher = new ClientZkGroupCipher(groupSecretParams); + PniCredential pniCredential = clientZkProfileCipher.receivePniCredential(context, response); + + PniCredentialPresentation presentation = clientZkProfileCipher.createPniCredentialPresentation(createSecureRandom(TEST_ARRAY_32_5), groupSecretParams, pniCredential); + + assertArrayEquals(presentation.serialize(), pniPresentationResult); + + // Verify presentation + serverZkProfile.verifyPniCredentialPresentation(groupPublicParams, presentation); + UuidCiphertext aciCiphertextRecv = presentation.getAciCiphertext(); + assertArrayEquals(clientZkGroupCipher.encryptUuid(aci).serialize(), aciCiphertextRecv.serialize()); + UuidCiphertext pniCiphertextRecv = presentation.getPniCiphertext(); + assertArrayEquals(clientZkGroupCipher.encryptUuid(pni).serialize(), pniCiphertextRecv.serialize()); + } + @Test public void testServerSignatures() throws VerificationFailedException { ServerSecretParams serverSecretParams = ServerSecretParams.generate(createSecureRandom(TEST_ARRAY_32)); diff --git a/ffi/node/test/ZKGroup-test.ts b/ffi/node/test/ZKGroup-test.ts index a4e1f44..090b58e 100644 --- a/ffi/node/test/ZKGroup-test.ts +++ b/ffi/node/test/ZKGroup-test.ts @@ -53,6 +53,7 @@ function clone(data: FFICompatArrayType) { describe('ZKGroup', () => { const TEST_ARRAY_16 = hexToCompatArray('000102030405060708090a0b0c0d0e0f'); + const TEST_ARRAY_16_1 = hexToCompatArray('6465666768696a6b6c6d6e6f70717273'); const TEST_ARRAY_32 = hexToCompatArray('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'); const TEST_ARRAY_32_1 = hexToCompatArray('6465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f80818283'); const TEST_ARRAY_32_2 = hexToCompatArray('c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7'); @@ -65,6 +66,9 @@ describe('ZKGroup', () => { const profileKeyPresentationResult = hexToCompatArray( '00c4d19bca1ae844585168869da4133e0e0bb59f2ce17b7ac65bff5da9610eca103429d8022a94bae2b5b1057b5595b8ad70bfc2d0e1ad662cb75e6bae0782be6f00e3db793bc28561f0196c2e74da6f303fa8bcb70c94096671b73f7b3a95fb002200d5b9180fa0ef7d3014d01344145b4d38480d72ff25c24294e305e5705072e0d32cc4e84f5caf31486089a4b934c80c92eba43472ff23a5af93c397535d33801f0e6fc6eb2ee0d117f03bb4fd38a8b9c88d94708131f38742ca804a3cfc4f9476bc2d03f53d17001c36478afbe9cc535a224b2df6b2b08bef06cbc7d4dc42ccfc3459f7ac5c4419ae9f3c8a161d554d047778943216240858da3b1101984c40010000000000007a01eea6b2adad14d71ab8b8e411bef3c596e954b70e4031570cb1abd7e932083241f1caca3116708fa4319fbbdfe351376c23644ae09a42f0155db4996c9d0c7ffc8521c1914c0e1a20ae51e65df64dd5e6e5985b3d9d31732046d2d77f9c08aaccf056b84026073976eec6164cbdaee5d9e76e497f0c290af681cabd5c5101282abb26c3680d6087ce053310fe8a94f59d8ae23caac5fc0ed0c379888abf028a6f29f89d4fe2acc1706341b2245ba1885bca57e1e27ccf7ed79371500965009f960c2ba00fad3e93383b87ce119cac0b3360eb99284ce78e2cbed680f7960373e0ab75c190254160c2353614109489e653c9b2e1c93f92c7c5ad583d987a04bd3541b24485c33ea49bac43c87c4ab3efde2e2d7ec10a40be544199f925b20b2c55542bc56410571e41cd8e0286f609a66768b5061ccb4777af32309928dd09765de9df4cfa5487f360e29e99343e91811baec331c4680985e608ca5d408e21725c6aa1b61d5a8b48d75f4aaa9a3cbe88d3e0f1a54319081f77c72c8f52547448c03ab4afbf6b8fb0e126c037a0ad4094600dd0e0634d76f88c21087f3cfb485a89bc1e3abc4c95041d1d170eccf02933ec5393d4be1dc573f83c33d3b9a746'); + const pniPresentationResult = hexToCompatArray( +'00fecc5f71d40dbd45912d0de9c1ed033c7eb1c4755e19cb6241ede6a6a99f65545e870a806854c5000d436db601a89f72b9b399f0efa277473716e8bc20c984766250937555604f2d2fcdd263c60f2f72b5a04d9bbbc6f95c78085f81aaf07d3316a2dbd1ef85bb642d5da6d00d03fed8097276bf17a113a44018d773c9116c33ac86837d4f5c41fb70153f3d655c0b68982fae01113460db75ea7099ef7e910cbe0bd606870df55522f9d0b1bee1b1ab2f3b9cd3563a422684ebcfdb1fdada27acb4d48c7db9c6b1389c6742a8f8257bb70f5430feb4a438007fb33e7910da3b9a0997d7d35c6c93a8d45949d01f88b497c822b0127b3fc57cfaee90bcf7d41914f6f0f8fa0acd82e004caaad1c9feec2fb67f58936ae7a92a285dc15b23486a0272e864f3ae9769d650fdd0898739ad28e259e8dae73907caa8ff69a53a851e4001000000000000f26c704b8daf38a464810eca8589541521e053221dd830866bf77da025cdc2041e33f73e42c70387709acbac0df46d0155e6bf6f7952ddc3289a16ca682e740df7403cc12cbe0cd54a7b0de08eec4f7cdce52996880ef5db74bcc4e8e78d620da4d21ff137b29df3a1a08d14b9224c91ef05a1ac0a7cfe142b227853c90bb90db0cf3d6311560e49ca52983f9efc54ecb61f552d6a85088871ef4d0f5862dd04aff93fd97b7816181d38bcb30f71eaeb9eff2ba630916eac355f45703a8c780e8579b2793d4fb72e001d15e23bedcb3c827fc559ef7adb6da2ec33291b86bf0db2ad4a3a0cb9233d3af967d9301505b88d157b3436ae6122696718d812b27002cdce4c807610f2de7cec4a03933da64a6319eab4ac0630c99d0e62779974e8038ff5053275378c1b41dd7bb5f8f4c11daa4cd19fdec4d0222850c606857c990e765de9df4cfa5487f360e29e99343e91811baec331c4680985e608ca5d408e21725c6aa1b61d5a8b48d75f4aaa9a3cbe88d3e0f1a54319081f77c72c8f525474fe74409060615679fc115473683d63abd9ced46c7f2ad736046de5a2c7d2522f122895597049cfd7cc5beb6dc72aa990ae9a62ec8e256a1cbf5f3f284233bb0748c03ab4afbf6b8fb0e126c037a0ad4094600dd0e0634d76f88c21087f3cfb485a89bc1e3abc4c95041d1d170eccf02933ec5393d4be1dc573f83c33d3b9a746'); + it('testAuthIntegration', () => { const uuid = toUUID(TEST_ARRAY_16); const redemptionTime = 123456; @@ -172,6 +176,88 @@ describe('ZKGroup', () => { assertArrayEquals(pkvB.serialize(), pkvC.serialize()); }); + it('testPniIntegration', () => { + const aci = toUUID(TEST_ARRAY_16); + const pni = toUUID(TEST_ARRAY_16_1); + + // Generate keys (client's are per-group, server's are not) + // --- + + // SERVER + const serverSecretParams = ServerSecretParams.generateWithRandom( + TEST_ARRAY_32 + ); + const serverPublicParams = serverSecretParams.getPublicParams(); + const serverZkProfile = new ServerZkProfileOperations(serverSecretParams); + + // CLIENT + const masterKey = new GroupMasterKey(TEST_ARRAY_32_1); + const groupSecretParams = GroupSecretParams.deriveFromMasterKey(masterKey); + + assertArrayEquals( + groupSecretParams.getMasterKey().serialize(), + masterKey.serialize() + ); + + const groupPublicParams = groupSecretParams.getPublicParams(); + const clientZkProfileCipher = new ClientZkProfileOperations( + serverPublicParams + ); + + const profileKey = new ProfileKey(TEST_ARRAY_32_1); + const profileKeyCommitment = profileKey.getCommitment(aci); + + // Create context and request + const context = clientZkProfileCipher.createPniCredentialRequestContextWithRandom( + TEST_ARRAY_32_3, + aci, + pni, + profileKey + ); + const request = context.getRequest(); + + // SERVER + const response = serverZkProfile.issuePniCredentialWithRandom( + TEST_ARRAY_32_4, + request, + aci, + pni, + profileKeyCommitment + ); + + // CLIENT + // Gets stored profile credential + const clientZkGroupCipher = new ClientZkGroupCipher(groupSecretParams); + const pniCredential = clientZkProfileCipher.receivePniCredential( + context, + response + ); + + const presentation = clientZkProfileCipher.createPniCredentialPresentationWithRandom( + TEST_ARRAY_32_5, + groupSecretParams, + pniCredential + ); + + assertArrayEquals(presentation.serialize(), pniPresentationResult); + + // Verify presentation + serverZkProfile.verifyPniCredentialPresentation( + groupPublicParams, + presentation + ); + const aciCiphertextRecv = presentation.getAciCiphertext(); + assertArrayEquals( + clientZkGroupCipher.encryptUuid(aci).serialize(), + aciCiphertextRecv.serialize() + ); + const pniCiphertextRecv = presentation.getPniCiphertext(); + assertArrayEquals( + clientZkGroupCipher.encryptUuid(pni).serialize(), + pniCiphertextRecv.serialize() + ); + }); + it('testServerSignatures', () => { const serverSecretParams = ServerSecretParams.generateWithRandom(TEST_ARRAY_32); const serverPublicParams = serverSecretParams.getPublicParams(); diff --git a/ffi/node/zkgroup/ServerPublicParams.ts b/ffi/node/zkgroup/ServerPublicParams.ts index e4817fc..b56daed 100644 --- a/ffi/node/zkgroup/ServerPublicParams.ts +++ b/ffi/node/zkgroup/ServerPublicParams.ts @@ -11,7 +11,7 @@ import FFICompatArray, { FFICompatArrayType } from './internal/FFICompatArray' export default class ServerPublicParams extends ByteArray { - static SIZE = 225; + static SIZE = 289; constructor (contents: FFICompatArrayType) { super(contents, ServerPublicParams.SIZE, true); diff --git a/ffi/node/zkgroup/ServerSecretParams.ts b/ffi/node/zkgroup/ServerSecretParams.ts index 4ee8a05..23c666e 100644 --- a/ffi/node/zkgroup/ServerSecretParams.ts +++ b/ffi/node/zkgroup/ServerSecretParams.ts @@ -12,7 +12,7 @@ import NotarySignature from './NotarySignature'; export default class ServerSecretParams extends ByteArray { - static SIZE = 1121; + static SIZE = 1537; static generate(): ServerSecretParams { const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); diff --git a/ffi/node/zkgroup/internal/Native.ts b/ffi/node/zkgroup/internal/Native.ts index a893915..f37ef44 100644 --- a/ffi/node/zkgroup/internal/Native.ts +++ b/ffi/node/zkgroup/internal/Native.ts @@ -44,12 +44,17 @@ interface NativeCalls { FFI_ServerPublicParams_receiveAuthCredential: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: IntType, param6: FFICompatArrayType, param7: UInt32Type, param8: FFICompatArrayType, param9: UInt32Type) => IntType; FFI_ServerPublicParams_createAuthCredentialPresentationDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type) => IntType, FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type) => IntType, + FFI_ServerPublicParams_createPniCredentialRequestContextDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type, param11: FFICompatArrayType, param12: UInt32Type) => IntType, FFI_ServerPublicParams_receiveProfileKeyCredential: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, + FFI_ServerPublicParams_receivePniCredential: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type) => IntType, + FFI_ServerPublicParams_createPniCredentialPresentationDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type) => IntType, FFI_ServerSecretParams_issueAuthCredentialDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: IntType, param8: FFICompatArrayType, param9: UInt32Type) => IntType, FFI_ServerSecretParams_verifyAuthCredentialPresentation: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type) => IntType, FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type, param11: FFICompatArrayType, param12: UInt32Type) => IntType, + FFI_ServerSecretParams_issuePniCredentialDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type, param9: FFICompatArrayType, param10: UInt32Type, param11: FFICompatArrayType, param12: UInt32Type, param13: FFICompatArrayType, param14: UInt32Type) => IntType, FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type) => IntType, + FFI_ServerSecretParams_verifyPniCredentialPresentation: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type) => IntType, FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, FFI_ServerPublicParams_receiveReceiptCredential: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type, param5: FFICompatArrayType, param6: UInt32Type, param7: FFICompatArrayType, param8: UInt32Type) => IntType, @@ -64,12 +69,20 @@ interface NativeCalls { FFI_AuthCredentialPresentation_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCredentialRequestContext_getRequest: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ProfileKeyCredentialRequestContext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, + FFI_PniCredentialRequestContext_getRequest: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_PniCredentialRequestContext_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCredentialRequest_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCredentialResponse_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, + FFI_PniCredentialResponse_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCredential_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, + FFI_PniCredential_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ProfileKeyCredentialPresentation_getUuidCiphertext: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ProfileKeyCredentialPresentation_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, + FFI_PniCredentialPresentation_getAciCiphertext: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_PniCredentialPresentation_getPniCiphertext: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_PniCredentialPresentation_getProfileKeyCiphertext: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, + FFI_PniCredentialPresentation_checkValidContents: (param2: FFICompatArrayType, param3: UInt32Type) => IntType, FFI_ReceiptCredentialRequestContext_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, FFI_ReceiptCredentialRequestContext_getRequest: (param1: FFICompatArrayType, param2: UInt32Type, param3: FFICompatArrayType, param4: UInt32Type) => IntType, FFI_ReceiptCredentialRequest_checkValidContents: (param1: FFICompatArrayType, param2: UInt32Type) => IntType, @@ -109,15 +122,20 @@ const library: NativeCalls = Library(libraryPath, { 'FFI_ServerPublicParams_receiveAuthCredential': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', 'int', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createAuthCredentialPresentationDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ServerPublicParams_createPniCredentialRequestContextDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_receiveProfileKeyCredential': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ServerPublicParams_receivePniCredential': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ServerPublicParams_createPniCredentialPresentationDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_receiveReceiptCredential': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerPublicParams_createReceiptCredentialPresentationDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerSecretParams_issueAuthCredentialDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', 'int', FFICompatArray, 'uint32', ] ], 'FFI_ServerSecretParams_verifyAuthCredentialPresentation': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], 'FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_ServerSecretParams_issuePniCredentialDeterministic': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], + 'FFI_ServerSecretParams_verifyPniCredentialPresentation': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], 'FFI_GroupPublicParams_getGroupIdentifier': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_GroupPublicParams_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ServerPublicParams_verifySignature': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], @@ -129,14 +147,22 @@ const library: NativeCalls = Library(libraryPath, { 'FFI_AuthCredentialPresentation_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredentialRequestContext_getRequest': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ProfileKeyCredentialRequestContext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], + 'FFI_PniCredentialRequestContext_getRequest': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_PniCredentialRequestContext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredentialRequest_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredentialResponse_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], + 'FFI_PniCredentialResponse_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredential_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], + 'FFI_PniCredential_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ReceiptCredential_getReceiptExpirationTime': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], 'FFI_ReceiptCredential_getReceiptLevel': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32' ] ], 'FFI_ProfileKeyCredentialPresentation_getUuidCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ProfileKeyCredentialPresentation_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], + 'FFI_PniCredentialPresentation_getAciCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_PniCredentialPresentation_getPniCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_PniCredentialPresentation_getProfileKeyCiphertext': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], + 'FFI_PniCredentialPresentation_checkValidContents': [ 'int', [ FFICompatArray, 'uint32' ] ], 'FFI_ReceiptCredentialRequestContext_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], 'FFI_ReceiptCredentialRequestContext_getRequest': [ 'int', [ FFICompatArray, 'uint32', FFICompatArray, 'uint32', ] ], 'FFI_ReceiptCredentialRequest_checkValidContents': [ 'int', [ FFICompatArray, 'uint32', ] ], diff --git a/ffi/node/zkgroup/profiles/ClientZkProfileOperations.ts b/ffi/node/zkgroup/profiles/ClientZkProfileOperations.ts index 58aea56..fbb2bbf 100644 --- a/ffi/node/zkgroup/profiles/ClientZkProfileOperations.ts +++ b/ffi/node/zkgroup/profiles/ClientZkProfileOperations.ts @@ -19,6 +19,10 @@ import ProfileKeyCredential from './ProfileKeyCredential'; import ProfileKeyCredentialPresentation from './ProfileKeyCredentialPresentation'; import GroupSecretParams from '../groups/GroupSecretParams'; import ProfileKeyCredentialResponse from './ProfileKeyCredentialResponse'; +import PniCredentialRequestContext from './PniCredentialRequestContext'; +import PniCredentialResponse from './PniCredentialResponse'; +import PniCredential from './PniCredential'; +import PniCredentialPresentation from './PniCredentialPresentation'; import { UUID_LENGTH, UUIDType, fromUUID, toUUID } from '../internal/UUIDUtil'; @@ -52,6 +56,29 @@ export default class ClientZkProfileOperations { return new ProfileKeyCredentialRequestContext(newContents); } + createPniCredentialRequestContext(aci: UUIDType, pni: UUIDType, profileKey: ProfileKey): PniCredentialRequestContext { + const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); + + return this.createPniCredentialRequestContextWithRandom(random, aci, pni, profileKey); + } + + createPniCredentialRequestContextWithRandom(random: FFICompatArrayType, aci: UUIDType, pni: UUIDType, profileKey: ProfileKey): PniCredentialRequestContext { + const newContents = new FFICompatArray(PniCredentialRequestContext.SIZE); + + const serverPublicParamsContents = this.serverPublicParams.getContents(); + const aciContents = fromUUID(aci); + const pniContents = fromUUID(pni); + const profileKeyContents = profileKey.getContents(); + + const ffi_return = Native.FFI_ServerPublicParams_createPniCredentialRequestContextDeterministic(serverPublicParamsContents, serverPublicParamsContents.length, random, random.length, aciContents, aciContents.length, pniContents, pniContents.length, profileKeyContents, profileKeyContents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return new PniCredentialRequestContext(newContents); + } + receiveProfileKeyCredential(profileKeyCredentialRequestContext: ProfileKeyCredentialRequestContext, profileKeyCredentialResponse: ProfileKeyCredentialResponse): ProfileKeyCredential { const newContents = new FFICompatArray(ProfileKeyCredential.SIZE); @@ -71,6 +98,25 @@ export default class ClientZkProfileOperations { return new ProfileKeyCredential(newContents); } + receivePniCredential(pniCredentialRequestContext: PniCredentialRequestContext, pniCredentialResponse: PniCredentialResponse): PniCredential { + const newContents = new FFICompatArray(PniCredential.SIZE); + + const serverPublicParamsContents = this.serverPublicParams.getContents(); + const pniCredentialRequestContextContents = pniCredentialRequestContext.getContents(); + const pniCredentialResponseContents = pniCredentialResponse.getContents(); + + const ffi_return = Native.FFI_ServerPublicParams_receivePniCredential(serverPublicParamsContents, serverPublicParamsContents.length, pniCredentialRequestContextContents, pniCredentialRequestContextContents.length, pniCredentialResponseContents, pniCredentialResponseContents.length, newContents, newContents.length); + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return new PniCredential(newContents); + } + createProfileKeyCredentialPresentation(groupSecretParams: GroupSecretParams, profileKeyCredential: ProfileKeyCredential): ProfileKeyCredentialPresentation { const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); @@ -93,4 +139,25 @@ export default class ClientZkProfileOperations { return new ProfileKeyCredentialPresentation(newContents); } + createPniCredentialPresentation(groupSecretParams: GroupSecretParams, pniCredential: PniCredential): PniCredentialPresentation { + const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); + + return this.createPniCredentialPresentationWithRandom(random, groupSecretParams, pniCredential); + } + + createPniCredentialPresentationWithRandom(random: FFICompatArrayType, groupSecretParams: GroupSecretParams, pniCredential: PniCredential): PniCredentialPresentation { + const newContents = new FFICompatArray(PniCredentialPresentation.SIZE); + + const serverPublicParamsContents = this.serverPublicParams.getContents(); + const groupSecretParamsContents = groupSecretParams.getContents(); + const pniCredentialContents = pniCredential.getContents(); + + const ffi_return = Native.FFI_ServerPublicParams_createPniCredentialPresentationDeterministic(serverPublicParamsContents, serverPublicParamsContents.length, random, random.length, groupSecretParamsContents, groupSecretParamsContents.length, pniCredentialContents, pniCredentialContents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError("FFI_RETURN!=OK"); + } + + return new PniCredentialPresentation(newContents); + } } diff --git a/ffi/node/zkgroup/profiles/PniCredential.ts b/ffi/node/zkgroup/profiles/PniCredential.ts new file mode 100644 index 0000000..fbeac48 --- /dev/null +++ b/ffi/node/zkgroup/profiles/PniCredential.ts @@ -0,0 +1,26 @@ +import ByteArray from '../internal/ByteArray'; +import FFICompatArray, { FFICompatArrayType } from '../internal/FFICompatArray'; + +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; + +import Native, { FFI_RETURN_OK, FFI_RETURN_INPUT_ERROR } from '../internal/Native'; + +export default class PniCredential extends ByteArray { + + static SIZE = 161; + + constructor(contents: FFICompatArrayType) { + super(contents, PniCredential.SIZE, true); + + const ffi_return = Native.FFI_PniCredential_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } +} diff --git a/ffi/node/zkgroup/profiles/PniCredentialPresentation.ts b/ffi/node/zkgroup/profiles/PniCredentialPresentation.ts new file mode 100644 index 0000000..f777d35 --- /dev/null +++ b/ffi/node/zkgroup/profiles/PniCredentialPresentation.ts @@ -0,0 +1,66 @@ +import ByteArray from '../internal/ByteArray'; +import FFICompatArray, { FFICompatArrayType } from '../internal/FFICompatArray'; + +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; + +import Native, { FFI_RETURN_OK, FFI_RETURN_INPUT_ERROR } from '../internal/Native'; + +import UuidCiphertext from '../groups/UuidCiphertext'; +import ProfileKeyCiphertext from '../groups/ProfileKeyCiphertext'; + +export default class PniCredentialPresentation extends ByteArray { + + static SIZE = 841; + + constructor(contents: FFICompatArrayType) { + super(contents, PniCredentialPresentation.SIZE, true); + + const ffi_return = Native.FFI_PniCredentialPresentation_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } + + getAciCiphertext(): UuidCiphertext { + const newContents = new FFICompatArray(UuidCiphertext.SIZE); + + const ffi_return = Native.FFI_PniCredentialPresentation_getAciCiphertext(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + + return new UuidCiphertext(newContents); + } + + getPniCiphertext(): UuidCiphertext { + const newContents = new FFICompatArray(UuidCiphertext.SIZE); + + const ffi_return = Native.FFI_PniCredentialPresentation_getPniCiphertext(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + + return new UuidCiphertext(newContents); + } + + getProfileKeyCiphertext(): ProfileKeyCiphertext { + const newContents = new FFICompatArray(ProfileKeyCiphertext.SIZE); + + const ffi_return = Native.FFI_PniCredentialPresentation_getProfileKeyCiphertext(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + + return new ProfileKeyCiphertext(newContents); + } + +} diff --git a/ffi/node/zkgroup/profiles/PniCredentialRequestContext.ts b/ffi/node/zkgroup/profiles/PniCredentialRequestContext.ts new file mode 100644 index 0000000..358b36c --- /dev/null +++ b/ffi/node/zkgroup/profiles/PniCredentialRequestContext.ts @@ -0,0 +1,41 @@ +import ByteArray from '../internal/ByteArray'; +import FFICompatArray, { FFICompatArrayType } from '../internal/FFICompatArray'; + +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; + +import Native, { FFI_RETURN_OK, FFI_RETURN_INPUT_ERROR } from '../internal/Native'; + +import ProfileKeyCredentialRequest from './ProfileKeyCredentialRequest'; + + +export default class PniCredentialRequestContext extends ByteArray { + + static SIZE = 489; + + constructor(contents: FFICompatArrayType) { + super(contents, PniCredentialRequestContext.SIZE, true); + + const ffi_return = Native.FFI_PniCredentialRequestContext_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } + + getRequest(): ProfileKeyCredentialRequest { + const newContents = new FFICompatArray(ProfileKeyCredentialRequest.SIZE); + + const ffi_return = Native.FFI_PniCredentialRequestContext_getRequest(this.contents, this.contents.length, newContents, newContents.length); + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + + return new ProfileKeyCredentialRequest(newContents); + } +} diff --git a/ffi/node/zkgroup/profiles/PniCredentialResponse.ts b/ffi/node/zkgroup/profiles/PniCredentialResponse.ts new file mode 100644 index 0000000..51e867c --- /dev/null +++ b/ffi/node/zkgroup/profiles/PniCredentialResponse.ts @@ -0,0 +1,27 @@ +import ByteArray from '../internal/ByteArray'; +import FFICompatArray, { FFICompatArrayType } from '../internal/FFICompatArray'; + +import InvalidInputException from '../errors/InvalidInputException'; +import ZkGroupError from '../errors/ZkGroupError'; + +import Native, { FFI_RETURN_OK, FFI_RETURN_INPUT_ERROR } from '../internal/Native'; + +export default class PniCredentialResponse extends ByteArray { + + static SIZE = 521; + + constructor(contents: FFICompatArrayType) { + super(contents, PniCredentialResponse.SIZE, true); + + const ffi_return = Native.FFI_PniCredentialResponse_checkValidContents(this.contents, this.contents.length); + + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new InvalidInputException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } + +} diff --git a/ffi/node/zkgroup/profiles/ServerZkProfileOperations.ts b/ffi/node/zkgroup/profiles/ServerZkProfileOperations.ts index ee78106..5b1a259 100644 --- a/ffi/node/zkgroup/profiles/ServerZkProfileOperations.ts +++ b/ffi/node/zkgroup/profiles/ServerZkProfileOperations.ts @@ -16,8 +16,10 @@ import ProfileKeyCredentialRequest from './ProfileKeyCredentialRequest'; import ProfileKeyCommitment from './ProfileKeyCommitment'; import GroupPublicParams from '../groups/GroupPublicParams'; import ProfileKeyCredentialPresentation from './ProfileKeyCredentialPresentation'; +import PniCredentialResponse from './PniCredentialResponse'; import { UUID_LENGTH, UUIDType, fromUUID, toUUID } from '../internal/UUIDUtil'; +import PniCredentialPresentation from './PniCredentialPresentation'; export default class ServerZkProfileOperations { @@ -53,6 +55,33 @@ export default class ServerZkProfileOperations { return new ProfileKeyCredentialResponse(newContents); } + issuePniCredential(pniCredentialRequest: ProfileKeyCredentialRequest, aci: UUIDType, pni: UUIDType, profileKeyCommitment: ProfileKeyCommitment): PniCredentialResponse{ + const random = new FFICompatArray(randomBytes(RANDOM_LENGTH)); + + return this.issuePniCredentialWithRandom(random, pniCredentialRequest, aci, pni, profileKeyCommitment); + } + + issuePniCredentialWithRandom(random: FFICompatArrayType, pniCredentialRequest: ProfileKeyCredentialRequest, aci: UUIDType, pni: UUIDType, profileKeyCommitment: ProfileKeyCommitment): PniCredentialResponse { + const newContents = new FFICompatArray(PniCredentialResponse.SIZE); + + const serverSecretParamsContents = this.serverSecretParams.getContents(); + const pniCredentialRequestContents = pniCredentialRequest.getContents() + const aciContents = fromUUID(aci); + const pniContents = fromUUID(pni); + const profileKeyCommitmentContents = profileKeyCommitment.getContents() + + const ffi_return = Native.FFI_ServerSecretParams_issuePniCredentialDeterministic(serverSecretParamsContents, serverSecretParamsContents.length, random, random.length, pniCredentialRequestContents, pniCredentialRequestContents.length, aciContents, aciContents.length, pniContents, pniContents.length, profileKeyCommitmentContents, profileKeyCommitmentContents.length, newContents, newContents.length); + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + + return new PniCredentialResponse(newContents); + } + verifyProfileKeyCredentialPresentation(groupPublicParams: GroupPublicParams, profileKeyCredentialPresentation: ProfileKeyCredentialPresentation ) { const serverSecretParamsContents = this.serverSecretParams.getContents() const groupPublicParamsContents = groupPublicParams.getContents() @@ -68,4 +97,19 @@ export default class ServerZkProfileOperations { } } + verifyPniCredentialPresentation(groupPublicParams: GroupPublicParams, pniCredentialPresentation: PniCredentialPresentation ) { + const serverSecretParamsContents = this.serverSecretParams.getContents() + const groupPublicParamsContents = groupPublicParams.getContents() + const pniCredentialPresentationContents = pniCredentialPresentation.getContents(); + + const ffi_return = Native.FFI_ServerSecretParams_verifyPniCredentialPresentation(serverSecretParamsContents, serverSecretParamsContents.length, groupPublicParamsContents, groupPublicParamsContents.length, pniCredentialPresentationContents, pniCredentialPresentationContents.length); + if (ffi_return == FFI_RETURN_INPUT_ERROR) { + throw new VerificationFailedException('FFI_RETURN_INPUT_ERROR'); + } + + if (ffi_return != FFI_RETURN_OK) { + throw new ZkGroupError('FFI_RETURN!=OK'); + } + } + } diff --git a/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift b/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift index 40ae47e..943ffa7 100644 --- a/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ClientZkProfileOperations.swift @@ -44,6 +44,33 @@ public class ClientZkProfileOperations { } + public func createPniCredentialRequestContext(aci: ZKGUuid, pni: ZKGUuid, profileKey: ProfileKey) throws -> PniCredentialRequestContext { + var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) + let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) + guard result == errSecSuccess else { + throw ZkGroupException.AssertionError + } + + return try createPniCredentialRequestContext(randomness: randomness, aci: aci, pni: pni, profileKey: profileKey) + } + + public func createPniCredentialRequestContext(randomness: [UInt8], aci: ZKGUuid, pni: ZKGUuid, profileKey: ProfileKey) throws -> PniCredentialRequestContext { + var newContents: [UInt8] = Array(repeating: 0, count: PniCredentialRequestContext.SIZE) + + let ffi_return = FFI_ServerPublicParams_createPniCredentialRequestContextDeterministic(serverPublicParams.getInternalContentsForFFI(), UInt32(serverPublicParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), aci.getInternalContentsForFFI(), UInt32(aci.getInternalContentsForFFI().count), pni.getInternalContentsForFFI(), UInt32(pni.getInternalContentsForFFI().count), profileKey.getInternalContentsForFFI(), UInt32(profileKey.getInternalContentsForFFI().count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try PniCredentialRequestContext(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + public func receiveProfileKeyCredential(profileKeyCredentialRequestContext: ProfileKeyCredentialRequestContext, profileKeyCredentialResponse: ProfileKeyCredentialResponse) throws -> ProfileKeyCredential { var newContents: [UInt8] = Array(repeating: 0, count: ProfileKeyCredential.SIZE) @@ -64,6 +91,26 @@ public class ClientZkProfileOperations { } + public func receivePniCredential(pniCredentialRequestContext: PniCredentialRequestContext, pniCredentialResponse: PniCredentialResponse) throws -> PniCredential { + var newContents: [UInt8] = Array(repeating: 0, count: PniCredential.SIZE) + + let ffi_return = FFI_ServerPublicParams_receivePniCredential(serverPublicParams.getInternalContentsForFFI(), UInt32(serverPublicParams.getInternalContentsForFFI().count), pniCredentialRequestContext.getInternalContentsForFFI(), UInt32(pniCredentialRequestContext.getInternalContentsForFFI().count), pniCredentialResponse.getInternalContentsForFFI(), UInt32(pniCredentialResponse.getInternalContentsForFFI().count), &newContents, UInt32(newContents.count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try PniCredential(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + public func createProfileKeyCredentialPresentation(groupSecretParams: GroupSecretParams, profileKeyCredential: ProfileKeyCredential) throws -> ProfileKeyCredentialPresentation { var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) @@ -91,4 +138,31 @@ public class ClientZkProfileOperations { } + public func createPniCredentialPresentation(groupSecretParams: GroupSecretParams, pniCredential: PniCredential) throws -> PniCredentialPresentation { + var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) + let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) + guard result == errSecSuccess else { + throw ZkGroupException.AssertionError + } + + return try createPniCredentialPresentation(randomness: randomness, groupSecretParams: groupSecretParams, pniCredential: pniCredential) + } + + public func createPniCredentialPresentation(randomness: [UInt8], groupSecretParams: GroupSecretParams, pniCredential: PniCredential) throws -> PniCredentialPresentation { + var newContents: [UInt8] = Array(repeating: 0, count: PniCredentialPresentation.SIZE) + + let ffi_return = FFI_ServerPublicParams_createPniCredentialPresentationDeterministic(serverPublicParams.getInternalContentsForFFI(), UInt32(serverPublicParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), groupSecretParams.getInternalContentsForFFI(), UInt32(groupSecretParams.getInternalContentsForFFI().count), pniCredential.getInternalContentsForFFI(), UInt32(pniCredential.getInternalContentsForFFI().count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try PniCredentialPresentation(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + } diff --git a/ffi/swift/Sources/ZKGroup/PniCredential.swift b/ffi/swift/Sources/ZKGroup/PniCredential.swift new file mode 100644 index 0000000..c47b723 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/PniCredential.swift @@ -0,0 +1,35 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class PniCredential : ByteArray { + + public static let SIZE: Int = 161 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: PniCredential.SIZE) + + + let ffi_return = FFI_PniCredential_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/PniCredentialPresentation.swift b/ffi/swift/Sources/ZKGroup/PniCredentialPresentation.swift new file mode 100644 index 0000000..36863b4 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/PniCredentialPresentation.swift @@ -0,0 +1,86 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class PniCredentialPresentation : ByteArray { + + public static let SIZE: Int = 841 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: PniCredentialPresentation.SIZE) + + + let ffi_return = FFI_PniCredentialPresentation_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func getAciCiphertext() throws -> UuidCiphertext { + var newContents: [UInt8] = Array(repeating: 0, count: UuidCiphertext.SIZE) + + let ffi_return = FFI_PniCredentialPresentation_getAciCiphertext(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try UuidCiphertext(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func getPniCiphertext() throws -> UuidCiphertext { + var newContents: [UInt8] = Array(repeating: 0, count: UuidCiphertext.SIZE) + + let ffi_return = FFI_PniCredentialPresentation_getPniCiphertext(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try UuidCiphertext(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func getProfileKeyCiphertext() throws -> ProfileKeyCiphertext { + var newContents: [UInt8] = Array(repeating: 0, count: ProfileKeyCiphertext.SIZE) + + let ffi_return = FFI_PniCredentialPresentation_getProfileKeyCiphertext(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ProfileKeyCiphertext(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/PniCredentialRequestContext.swift b/ffi/swift/Sources/ZKGroup/PniCredentialRequestContext.swift new file mode 100644 index 0000000..cbaf929 --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/PniCredentialRequestContext.swift @@ -0,0 +1,52 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class PniCredentialRequestContext : ByteArray { + + public static let SIZE: Int = 489 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: PniCredentialRequestContext.SIZE) + + + let ffi_return = FFI_PniCredentialRequestContext_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func getRequest() throws -> ProfileKeyCredentialRequest { + var newContents: [UInt8] = Array(repeating: 0, count: ProfileKeyCredentialRequest.SIZE) + + let ffi_return = FFI_PniCredentialRequestContext_getRequest(self.contents, UInt32(self.contents.count), &newContents, UInt32(newContents.count)) + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try ProfileKeyCredentialRequest(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/PniCredentialResponse.swift b/ffi/swift/Sources/ZKGroup/PniCredentialResponse.swift new file mode 100644 index 0000000..6e9101c --- /dev/null +++ b/ffi/swift/Sources/ZKGroup/PniCredentialResponse.swift @@ -0,0 +1,35 @@ +// +// Copyright (C) 2020 Signal Messenger, LLC. +// All rights reserved. +// +// SPDX-License-Identifier: GPL-3.0-only +// +// Generated by zkgroup/codegen/codegen.py - do not edit + +import Foundation +import libzkgroup + +public class PniCredentialResponse : ByteArray { + + public static let SIZE: Int = 521 + + public init(contents: [UInt8]) throws { + try super.init(newContents: contents, expectedLength: PniCredentialResponse.SIZE) + + + let ffi_return = FFI_PniCredentialResponse_checkValidContents(self.contents, UInt32(self.contents.count)) + + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.InvalidInput + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + + public func serialize() -> [UInt8] { + return contents + } + +} diff --git a/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift b/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift index 81a294a..bad3098 100644 --- a/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift +++ b/ffi/swift/Sources/ZKGroup/ServerPublicParams.swift @@ -11,7 +11,7 @@ import libzkgroup public class ServerPublicParams : ByteArray { - public static let SIZE: Int = 225 + public static let SIZE: Int = 289 public init(contents: [UInt8]) throws { try super.init(newContents: contents, expectedLength: ServerPublicParams.SIZE, unrecoverable: true) diff --git a/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift b/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift index 34a5e6d..6a34c3d 100644 --- a/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift +++ b/ffi/swift/Sources/ZKGroup/ServerSecretParams.swift @@ -11,7 +11,7 @@ import libzkgroup public class ServerSecretParams : ByteArray { - public static let SIZE: Int = 1121 + public static let SIZE: Int = 1537 public static func generate() throws -> ServerSecretParams { var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) diff --git a/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift b/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift index ef976a5..9fc7173 100644 --- a/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift +++ b/ffi/swift/Sources/ZKGroup/ServerZkProfileOperations.swift @@ -47,6 +47,36 @@ public class ServerZkProfileOperations { } + public func issuePniCredential(profileKeyCredentialRequest: ProfileKeyCredentialRequest, aci: ZKGUuid, pni: ZKGUuid, profileKeyCommitment: ProfileKeyCommitment) throws -> PniCredentialResponse { + var randomness: [UInt8] = Array(repeating: 0, count: Int(32)) + let result = SecRandomCopyBytes(kSecRandomDefault, randomness.count, &randomness) + guard result == errSecSuccess else { + throw ZkGroupException.AssertionError + } + + return try issuePniCredential(randomness: randomness, profileKeyCredentialRequest: profileKeyCredentialRequest, aci: aci, pni: pni, profileKeyCommitment: profileKeyCommitment) + } + + public func issuePniCredential(randomness: [UInt8], profileKeyCredentialRequest: ProfileKeyCredentialRequest, aci: ZKGUuid, pni: ZKGUuid, profileKeyCommitment: ProfileKeyCommitment) throws -> PniCredentialResponse { + var newContents: [UInt8] = Array(repeating: 0, count: PniCredentialResponse.SIZE) + + let ffi_return = FFI_ServerSecretParams_issuePniCredentialDeterministic(serverSecretParams.getInternalContentsForFFI(), UInt32(serverSecretParams.getInternalContentsForFFI().count), randomness, UInt32(randomness.count), profileKeyCredentialRequest.getInternalContentsForFFI(), UInt32(profileKeyCredentialRequest.getInternalContentsForFFI().count), aci.getInternalContentsForFFI(), UInt32(aci.getInternalContentsForFFI().count), pni.getInternalContentsForFFI(), UInt32(pni.getInternalContentsForFFI().count), profileKeyCommitment.getInternalContentsForFFI(), UInt32(profileKeyCommitment.getInternalContentsForFFI().count), &newContents, UInt32(newContents.count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + + do { + return try PniCredentialResponse(contents: newContents) + } catch ZkGroupException.InvalidInput { + throw ZkGroupException.AssertionError + } + + } + public func verifyProfileKeyCredentialPresentation(groupPublicParams: GroupPublicParams, profileKeyCredentialPresentation: ProfileKeyCredentialPresentation) throws { let ffi_return = FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(serverSecretParams.getInternalContentsForFFI(), UInt32(serverSecretParams.getInternalContentsForFFI().count), groupPublicParams.getInternalContentsForFFI(), UInt32(groupPublicParams.getInternalContentsForFFI().count), profileKeyCredentialPresentation.getInternalContentsForFFI(), UInt32(profileKeyCredentialPresentation.getInternalContentsForFFI().count)) if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { @@ -58,4 +88,15 @@ public class ServerZkProfileOperations { } } + public func verifyPniCredentialPresentation(groupPublicParams: GroupPublicParams, pniCredentialPresentation: PniCredentialPresentation) throws { + let ffi_return = FFI_ServerSecretParams_verifyPniCredentialPresentation(serverSecretParams.getInternalContentsForFFI(), UInt32(serverSecretParams.getInternalContentsForFFI().count), groupPublicParams.getInternalContentsForFFI(), UInt32(groupPublicParams.getInternalContentsForFFI().count), pniCredentialPresentation.getInternalContentsForFFI(), UInt32(pniCredentialPresentation.getInternalContentsForFFI().count)) + if (ffi_return == Native.FFI_RETURN_INPUT_ERROR) { + throw ZkGroupException.VerificationFailed + } + + if (ffi_return != Native.FFI_RETURN_OK) { + throw ZkGroupException.ZkGroupError + } + } + } diff --git a/ffi/swift/Sources/libzkgroup/zkgroup.h b/ffi/swift/Sources/libzkgroup/zkgroup.h index d93e53d..f2331d6 100644 --- a/ffi/swift/Sources/libzkgroup/zkgroup.h +++ b/ffi/swift/Sources/libzkgroup/zkgroup.h @@ -29,6 +29,14 @@ #define AUTH_CREDENTIAL_RESPONSE_LEN 361 +#define PNI_CREDENTIAL_LEN 161 + +#define PNI_CREDENTIAL_PRESENTATION_LEN 841 + +#define PNI_CREDENTIAL_REQUEST_CONTEXT_LEN 489 + +#define PNI_CREDENTIAL_RESPONSE_LEN 521 + #define PROFILE_KEY_LEN 32 #define PROFILE_KEY_CIPHERTEXT_LEN 65 @@ -63,9 +71,9 @@ #define RESERVED_LEN 1 -#define SERVER_SECRET_PARAMS_LEN 1121 +#define SERVER_SECRET_PARAMS_LEN 1537 -#define SERVER_PUBLIC_PARAMS_LEN 225 +#define SERVER_PUBLIC_PARAMS_LEN 289 #define UUID_CIPHERTEXT_LEN 65 @@ -223,6 +231,19 @@ int32_t FFI_ServerPublicParams_createProfileKeyCredentialRequestContextDetermini uint8_t *profileKeyCredentialRequestContextOut, uint32_t profileKeyCredentialRequestContextLen); +int32_t FFI_ServerPublicParams_createPniCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *aci, + uint32_t aciLen, + const uint8_t *pni, + uint32_t pniLen, + const uint8_t *profileKey, + uint32_t profileKeyLen, + uint8_t *pniCredentialRequestContextOut, + uint32_t pniCredentialRequestContextLen); + int32_t FFI_ServerPublicParams_receiveProfileKeyCredential(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *profileKeyCredentialRequestContext, @@ -232,6 +253,15 @@ int32_t FFI_ServerPublicParams_receiveProfileKeyCredential(const uint8_t *server uint8_t *profileKeyCredentialOut, uint32_t profileKeyCredentialLen); +int32_t FFI_ServerPublicParams_receivePniCredential(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *pniCredentialRequestContext, + uint32_t pniCredentialRequestContextLen, + const uint8_t *pniCredentialResponse, + uint32_t pniCredentialResponseLen, + uint8_t *pniCredentialOut, + uint32_t pniCredentialLen); + int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *randomness, @@ -243,6 +273,17 @@ int32_t FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterminist uint8_t *profileKeyCredentialPresentationOut, uint32_t profileKeyCredentialPresentationLen); +int32_t FFI_ServerPublicParams_createPniCredentialPresentationDeterministic(const uint8_t *serverPublicParams, + uint32_t serverPublicParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *groupSecretParams, + uint32_t groupSecretParamsLen, + const uint8_t *pniCredential, + uint32_t pniCredentialLen, + uint8_t *pniCredentialPresentationOut, + uint32_t pniCredentialPresentationLen); + int32_t FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic(const uint8_t *serverPublicParams, uint32_t serverPublicParamsLen, const uint8_t *randomness, @@ -300,6 +341,21 @@ int32_t FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic(const uint uint8_t *profileKeyCredentialResponseOut, uint32_t profileKeyCredentialResponseLen); +int32_t FFI_ServerSecretParams_issuePniCredentialDeterministic(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *randomness, + uint32_t randomnessLen, + const uint8_t *profileKeyCredentialRequest, + uint32_t profileKeyCredentialRequestLen, + const uint8_t *aci, + uint32_t aciLen, + const uint8_t *pni, + uint32_t pniLen, + const uint8_t *profileKeyCommitment, + uint32_t profileKeyCommitmentLen, + uint8_t *pniCredentialResponseOut, + uint32_t pniCredentialResponseLen); + int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, const uint8_t *groupPublicParams, @@ -307,6 +363,13 @@ int32_t FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation(const uint const uint8_t *profileKeyCredentialPresentation, uint32_t profileKeyCredentialPresentationLen); +int32_t FFI_ServerSecretParams_verifyPniCredentialPresentation(const uint8_t *serverSecretParams, + uint32_t serverSecretParamsLen, + const uint8_t *groupPublicParams, + uint32_t groupPublicParamsLen, + const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen); + int32_t FFI_ServerSecretParams_issueReceiptCredentialDeterministic(const uint8_t *serverSecretParams, uint32_t serverSecretParamsLen, const uint8_t *randomness, @@ -368,15 +431,29 @@ int32_t FFI_ProfileKeyCredentialRequestContext_getRequest(const uint8_t *profile uint8_t *profileKeyCredentialRequestOut, uint32_t profileKeyCredentialRequestLen); +int32_t FFI_PniCredentialRequestContext_checkValidContents(const uint8_t *pniCredentialRequestContext, + uint32_t pniCredentialRequestContextLen); + +int32_t FFI_PniCredentialRequestContext_getRequest(const uint8_t *pniCredentialRequestContext, + uint32_t pniCredentialRequestContextLen, + uint8_t *profileKeyCredentialRequestOut, + uint32_t profileKeyCredentialRequestLen); + int32_t FFI_ProfileKeyCredentialRequest_checkValidContents(const uint8_t *profileKeyCredentialRequest, uint32_t profileKeyCredentialRequestLen); int32_t FFI_ProfileKeyCredentialResponse_checkValidContents(const uint8_t *profileKeyCredentialResponse, uint32_t profileKeyCredentialResponseLen); +int32_t FFI_PniCredentialResponse_checkValidContents(const uint8_t *pniCredentialResponse, + uint32_t pniCredentialResponseLen); + int32_t FFI_ProfileKeyCredential_checkValidContents(const uint8_t *profileKeyCredential, uint32_t profileKeyCredentialLen); +int32_t FFI_PniCredential_checkValidContents(const uint8_t *pniCredential, + uint32_t pniCredentialLen); + int32_t FFI_ProfileKeyCredentialPresentation_checkValidContents(const uint8_t *profileKeyCredentialPresentation, uint32_t profileKeyCredentialPresentationLen); @@ -390,6 +467,24 @@ int32_t FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext(const uint8 uint8_t *profileKeyCiphertextOut, uint32_t profileKeyCiphertextLen); +int32_t FFI_PniCredentialPresentation_checkValidContents(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen); + +int32_t FFI_PniCredentialPresentation_getAciCiphertext(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_PniCredentialPresentation_getPniCiphertext(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen, + uint8_t *uuidCiphertextOut, + uint32_t uuidCiphertextLen); + +int32_t FFI_PniCredentialPresentation_getProfileKeyCiphertext(const uint8_t *pniCredentialPresentation, + uint32_t pniCredentialPresentationLen, + uint8_t *profileKeyCiphertextOut, + uint32_t profileKeyCiphertextLen); + int32_t FFI_ReceiptCredentialRequestContext_checkValidContents(const uint8_t *receiptCredentialRequestContext, uint32_t receiptCredentialRequestContextLen); diff --git a/ffi/swift/Tests/ZKGroupTests.swift b/ffi/swift/Tests/ZKGroupTests.swift index 2ae3909..a5ce632 100644 --- a/ffi/swift/Tests/ZKGroupTests.swift +++ b/ffi/swift/Tests/ZKGroupTests.swift @@ -9,6 +9,8 @@ class ZKGroupTests: XCTestCase { let TEST_ARRAY_16: [UInt8] = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f] + let TEST_ARRAY_16_1: [UInt8] = [0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73] + let TEST_ARRAY_32: [UInt8] = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f] @@ -116,6 +118,61 @@ class ZKGroupTests: XCTestCase { 0x95, 0x04, 0x1d, 0x1d, 0x17, 0x0e, 0xcc, 0xf0, 0x29, 0x33, 0xec, 0x53, 0x93, 0xd4, 0xbe, 0x1d, 0xc5, 0x73, 0xf8, 0x3c, 0x33, 0xd3, 0xb9, 0xa7, 0x46] + let pniPresentationResult: [UInt8] = [ + 0x00, 0xfe, 0xcc, 0x5f, 0x71, 0xd4, 0x0d, 0xbd, 0x45, 0x91, 0x2d, 0x0d, 0xe9, 0xc1, 0xed, 0x03, + 0x3c, 0x7e, 0xb1, 0xc4, 0x75, 0x5e, 0x19, 0xcb, 0x62, 0x41, 0xed, 0xe6, 0xa6, 0xa9, 0x9f, 0x65, + 0x54, 0x5e, 0x87, 0x0a, 0x80, 0x68, 0x54, 0xc5, 0x00, 0x0d, 0x43, 0x6d, 0xb6, 0x01, 0xa8, 0x9f, + 0x72, 0xb9, 0xb3, 0x99, 0xf0, 0xef, 0xa2, 0x77, 0x47, 0x37, 0x16, 0xe8, 0xbc, 0x20, 0xc9, 0x84, + 0x76, 0x62, 0x50, 0x93, 0x75, 0x55, 0x60, 0x4f, 0x2d, 0x2f, 0xcd, 0xd2, 0x63, 0xc6, 0x0f, 0x2f, + 0x72, 0xb5, 0xa0, 0x4d, 0x9b, 0xbb, 0xc6, 0xf9, 0x5c, 0x78, 0x08, 0x5f, 0x81, 0xaa, 0xf0, 0x7d, + 0x33, 0x16, 0xa2, 0xdb, 0xd1, 0xef, 0x85, 0xbb, 0x64, 0x2d, 0x5d, 0xa6, 0xd0, 0x0d, 0x03, 0xfe, + 0xd8, 0x09, 0x72, 0x76, 0xbf, 0x17, 0xa1, 0x13, 0xa4, 0x40, 0x18, 0xd7, 0x73, 0xc9, 0x11, 0x6c, + 0x33, 0xac, 0x86, 0x83, 0x7d, 0x4f, 0x5c, 0x41, 0xfb, 0x70, 0x15, 0x3f, 0x3d, 0x65, 0x5c, 0x0b, + 0x68, 0x98, 0x2f, 0xae, 0x01, 0x11, 0x34, 0x60, 0xdb, 0x75, 0xea, 0x70, 0x99, 0xef, 0x7e, 0x91, + 0x0c, 0xbe, 0x0b, 0xd6, 0x06, 0x87, 0x0d, 0xf5, 0x55, 0x22, 0xf9, 0xd0, 0xb1, 0xbe, 0xe1, 0xb1, + 0xab, 0x2f, 0x3b, 0x9c, 0xd3, 0x56, 0x3a, 0x42, 0x26, 0x84, 0xeb, 0xcf, 0xdb, 0x1f, 0xda, 0xda, + 0x27, 0xac, 0xb4, 0xd4, 0x8c, 0x7d, 0xb9, 0xc6, 0xb1, 0x38, 0x9c, 0x67, 0x42, 0xa8, 0xf8, 0x25, + 0x7b, 0xb7, 0x0f, 0x54, 0x30, 0xfe, 0xb4, 0xa4, 0x38, 0x00, 0x7f, 0xb3, 0x3e, 0x79, 0x10, 0xda, + 0x3b, 0x9a, 0x09, 0x97, 0xd7, 0xd3, 0x5c, 0x6c, 0x93, 0xa8, 0xd4, 0x59, 0x49, 0xd0, 0x1f, 0x88, + 0xb4, 0x97, 0xc8, 0x22, 0xb0, 0x12, 0x7b, 0x3f, 0xc5, 0x7c, 0xfa, 0xee, 0x90, 0xbc, 0xf7, 0xd4, + 0x19, 0x14, 0xf6, 0xf0, 0xf8, 0xfa, 0x0a, 0xcd, 0x82, 0xe0, 0x04, 0xca, 0xaa, 0xd1, 0xc9, 0xfe, + 0xec, 0x2f, 0xb6, 0x7f, 0x58, 0x93, 0x6a, 0xe7, 0xa9, 0x2a, 0x28, 0x5d, 0xc1, 0x5b, 0x23, 0x48, + 0x6a, 0x02, 0x72, 0xe8, 0x64, 0xf3, 0xae, 0x97, 0x69, 0xd6, 0x50, 0xfd, 0xd0, 0x89, 0x87, 0x39, + 0xad, 0x28, 0xe2, 0x59, 0xe8, 0xda, 0xe7, 0x39, 0x07, 0xca, 0xa8, 0xff, 0x69, 0xa5, 0x3a, 0x85, + 0x1e, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x6c, 0x70, 0x4b, 0x8d, 0xaf, 0x38, + 0xa4, 0x64, 0x81, 0x0e, 0xca, 0x85, 0x89, 0x54, 0x15, 0x21, 0xe0, 0x53, 0x22, 0x1d, 0xd8, 0x30, + 0x86, 0x6b, 0xf7, 0x7d, 0xa0, 0x25, 0xcd, 0xc2, 0x04, 0x1e, 0x33, 0xf7, 0x3e, 0x42, 0xc7, 0x03, + 0x87, 0x70, 0x9a, 0xcb, 0xac, 0x0d, 0xf4, 0x6d, 0x01, 0x55, 0xe6, 0xbf, 0x6f, 0x79, 0x52, 0xdd, + 0xc3, 0x28, 0x9a, 0x16, 0xca, 0x68, 0x2e, 0x74, 0x0d, 0xf7, 0x40, 0x3c, 0xc1, 0x2c, 0xbe, 0x0c, + 0xd5, 0x4a, 0x7b, 0x0d, 0xe0, 0x8e, 0xec, 0x4f, 0x7c, 0xdc, 0xe5, 0x29, 0x96, 0x88, 0x0e, 0xf5, + 0xdb, 0x74, 0xbc, 0xc4, 0xe8, 0xe7, 0x8d, 0x62, 0x0d, 0xa4, 0xd2, 0x1f, 0xf1, 0x37, 0xb2, 0x9d, + 0xf3, 0xa1, 0xa0, 0x8d, 0x14, 0xb9, 0x22, 0x4c, 0x91, 0xef, 0x05, 0xa1, 0xac, 0x0a, 0x7c, 0xfe, + 0x14, 0x2b, 0x22, 0x78, 0x53, 0xc9, 0x0b, 0xb9, 0x0d, 0xb0, 0xcf, 0x3d, 0x63, 0x11, 0x56, 0x0e, + 0x49, 0xca, 0x52, 0x98, 0x3f, 0x9e, 0xfc, 0x54, 0xec, 0xb6, 0x1f, 0x55, 0x2d, 0x6a, 0x85, 0x08, + 0x88, 0x71, 0xef, 0x4d, 0x0f, 0x58, 0x62, 0xdd, 0x04, 0xaf, 0xf9, 0x3f, 0xd9, 0x7b, 0x78, 0x16, + 0x18, 0x1d, 0x38, 0xbc, 0xb3, 0x0f, 0x71, 0xea, 0xeb, 0x9e, 0xff, 0x2b, 0xa6, 0x30, 0x91, 0x6e, + 0xac, 0x35, 0x5f, 0x45, 0x70, 0x3a, 0x8c, 0x78, 0x0e, 0x85, 0x79, 0xb2, 0x79, 0x3d, 0x4f, 0xb7, + 0x2e, 0x00, 0x1d, 0x15, 0xe2, 0x3b, 0xed, 0xcb, 0x3c, 0x82, 0x7f, 0xc5, 0x59, 0xef, 0x7a, 0xdb, + 0x6d, 0xa2, 0xec, 0x33, 0x29, 0x1b, 0x86, 0xbf, 0x0d, 0xb2, 0xad, 0x4a, 0x3a, 0x0c, 0xb9, 0x23, + 0x3d, 0x3a, 0xf9, 0x67, 0xd9, 0x30, 0x15, 0x05, 0xb8, 0x8d, 0x15, 0x7b, 0x34, 0x36, 0xae, 0x61, + 0x22, 0x69, 0x67, 0x18, 0xd8, 0x12, 0xb2, 0x70, 0x02, 0xcd, 0xce, 0x4c, 0x80, 0x76, 0x10, 0xf2, + 0xde, 0x7c, 0xec, 0x4a, 0x03, 0x93, 0x3d, 0xa6, 0x4a, 0x63, 0x19, 0xea, 0xb4, 0xac, 0x06, 0x30, + 0xc9, 0x9d, 0x0e, 0x62, 0x77, 0x99, 0x74, 0xe8, 0x03, 0x8f, 0xf5, 0x05, 0x32, 0x75, 0x37, 0x8c, + 0x1b, 0x41, 0xdd, 0x7b, 0xb5, 0xf8, 0xf4, 0xc1, 0x1d, 0xaa, 0x4c, 0xd1, 0x9f, 0xde, 0xc4, 0xd0, + 0x22, 0x28, 0x50, 0xc6, 0x06, 0x85, 0x7c, 0x99, 0x0e, 0x76, 0x5d, 0xe9, 0xdf, 0x4c, 0xfa, 0x54, + 0x87, 0xf3, 0x60, 0xe2, 0x9e, 0x99, 0x34, 0x3e, 0x91, 0x81, 0x1b, 0xae, 0xc3, 0x31, 0xc4, 0x68, + 0x09, 0x85, 0xe6, 0x08, 0xca, 0x5d, 0x40, 0x8e, 0x21, 0x72, 0x5c, 0x6a, 0xa1, 0xb6, 0x1d, 0x5a, + 0x8b, 0x48, 0xd7, 0x5f, 0x4a, 0xaa, 0x9a, 0x3c, 0xbe, 0x88, 0xd3, 0xe0, 0xf1, 0xa5, 0x43, 0x19, + 0x08, 0x1f, 0x77, 0xc7, 0x2c, 0x8f, 0x52, 0x54, 0x74, 0xfe, 0x74, 0x40, 0x90, 0x60, 0x61, 0x56, + 0x79, 0xfc, 0x11, 0x54, 0x73, 0x68, 0x3d, 0x63, 0xab, 0xd9, 0xce, 0xd4, 0x6c, 0x7f, 0x2a, 0xd7, + 0x36, 0x04, 0x6d, 0xe5, 0xa2, 0xc7, 0xd2, 0x52, 0x2f, 0x12, 0x28, 0x95, 0x59, 0x70, 0x49, 0xcf, + 0xd7, 0xcc, 0x5b, 0xeb, 0x6d, 0xc7, 0x2a, 0xa9, 0x90, 0xae, 0x9a, 0x62, 0xec, 0x8e, 0x25, 0x6a, + 0x1c, 0xbf, 0x5f, 0x3f, 0x28, 0x42, 0x33, 0xbb, 0x07, 0x48, 0xc0, 0x3a, 0xb4, 0xaf, 0xbf, 0x6b, + 0x8f, 0xb0, 0xe1, 0x26, 0xc0, 0x37, 0xa0, 0xad, 0x40, 0x94, 0x60, 0x0d, 0xd0, 0xe0, 0x63, 0x4d, + 0x76, 0xf8, 0x8c, 0x21, 0x08, 0x7f, 0x3c, 0xfb, 0x48, 0x5a, 0x89, 0xbc, 0x1e, 0x3a, 0xbc, 0x4c, + 0x95, 0x04, 0x1d, 0x1d, 0x17, 0x0e, 0xcc, 0xf0, 0x29, 0x33, 0xec, 0x53, 0x93, 0xd4, 0xbe, 0x1d, + 0xc5, 0x73, 0xf8, 0x3c, 0x33, 0xd3, 0xb9, 0xa7, 0x46] + let serverSignatureResult: [UInt8] = [ 0x87, 0xd3, 0x54, 0x56, 0x4d, 0x35, 0xef, 0x91, 0xed, 0xba, 0x85, 0x1e, 0x08, 0x15, 0x61, 0x2e, 0x86, 0x4c, 0x22, 0x7a, 0x04, 0x71, 0xd5, 0x0c, 0x27, 0x06, 0x98, 0x60, 0x44, 0x06, 0xd0, 0x03, @@ -231,6 +288,54 @@ class ZKGroupTests: XCTestCase { XCTAssertEqual(pkvB.serialize(), pkvC.serialize()) } + func testPniIntegration() throws { + let aci: ZKGUuid = try ZKGUuid(contents: TEST_ARRAY_16) + let pni: ZKGUuid = try ZKGUuid(contents: TEST_ARRAY_16_1) + + // Generate keys (client's are per-group, server's are not) + // --- + + // SERVER + let serverSecretParams = try ServerSecretParams.generate(randomness: TEST_ARRAY_32) + let serverPublicParams = try serverSecretParams.getPublicParams() + let serverZkProfile = ServerZkProfileOperations(serverSecretParams: serverSecretParams) + + // CLIENT + let masterKey = try GroupMasterKey(contents: TEST_ARRAY_32_1) + let groupSecretParams = try GroupSecretParams.deriveFromMasterKey(groupMasterKey: masterKey) + + XCTAssertEqual(try groupSecretParams.getMasterKey().serialize(), masterKey.serialize()) + + let groupPublicParams = try groupSecretParams.getPublicParams() + let clientZkProfileCipher = ClientZkProfileOperations(serverPublicParams: serverPublicParams) + + let profileKey = try ProfileKey(contents: TEST_ARRAY_32_1) + let profileKeyCommitment = try profileKey.getCommitment(uuid: aci) + + // Create context and request + let context = try clientZkProfileCipher.createPniCredentialRequestContext(randomness: TEST_ARRAY_32_3, aci: aci, pni: pni, profileKey: profileKey) + let request = try context.getRequest() + + // SERVER + let response = try serverZkProfile.issuePniCredential(randomness: TEST_ARRAY_32_4, profileKeyCredentialRequest: request, aci: aci, pni: pni, profileKeyCommitment: profileKeyCommitment) + + // CLIENT + // Gets stored profile credential + let clientZkGroupCipher = ClientZkGroupCipher(groupSecretParams: groupSecretParams) + let pniCredential = try clientZkProfileCipher.receivePniCredential(pniCredentialRequestContext: context, pniCredentialResponse: response) + + let presentation = try clientZkProfileCipher.createPniCredentialPresentation(randomness: TEST_ARRAY_32_5, groupSecretParams: groupSecretParams, pniCredential: pniCredential) + + XCTAssertEqual(presentation.serialize(), pniPresentationResult) + + // Verify presentation + try serverZkProfile.verifyPniCredentialPresentation(groupPublicParams: groupPublicParams, pniCredentialPresentation: presentation) + let aciCiphertextRecv = try presentation.getAciCiphertext() + XCTAssertEqual(try clientZkGroupCipher.encryptUuid(uuid: aci).serialize(), aciCiphertextRecv.serialize()) + let pniCiphertextRecv = try presentation.getPniCiphertext() + XCTAssertEqual(try clientZkGroupCipher.encryptUuid(uuid: pni).serialize(), pniCiphertextRecv.serialize()) + } + func testServerSignatures() throws { let serverSecretParams = try ServerSecretParams.generate(randomness: TEST_ARRAY_32) let serverPublicParams = try serverSecretParams.getPublicParams() diff --git a/rust/src/ffi/ffiapi.rs b/rust/src/ffi/ffiapi.rs index 3b36bac..5096b2b 100644 --- a/rust/src/ffi/ffiapi.rs +++ b/rust/src/ffi/ffiapi.rs @@ -596,6 +596,53 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialRequestContex } } +#[no_mangle] +pub extern "C" fn FFI_ServerPublicParams_createPniCredentialRequestContextDeterministic( + serverPublicParams: *const u8, + serverPublicParamsLen: u32, + randomness: *const u8, + randomnessLen: u32, + aci: *const u8, + aciLen: u32, + pni: *const u8, + pniLen: u32, + profileKey: *const u8, + profileKeyLen: u32, + pniCredentialRequestContextOut: *mut u8, + pniCredentialRequestContextLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params: &[u8] = + unsafe { slice::from_raw_parts(serverPublicParams, serverPublicParamsLen as usize) }; + let randomness: &[u8] = + unsafe { slice::from_raw_parts(randomness, randomnessLen as usize) }; + let aci: &[u8] = unsafe { slice::from_raw_parts(aci, aciLen as usize) }; + let pni: &[u8] = unsafe { slice::from_raw_parts(pni, pniLen as usize) }; + let profile_key: &[u8] = + unsafe { slice::from_raw_parts(profileKey, profileKeyLen as usize) }; + let pni_credential_request_context: &mut [u8] = unsafe { + slice::from_raw_parts_mut( + pniCredentialRequestContextOut, + pniCredentialRequestContextLen as usize, + ) + }; + + simpleapi::ServerPublicParams_createPniCredentialRequestContextDeterministic( + server_public_params, + randomness, + aci, + pni, + profile_key, + pni_credential_request_context, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ServerPublicParams_receiveProfileKeyCredential( serverPublicParams: *const u8, @@ -640,6 +687,46 @@ pub extern "C" fn FFI_ServerPublicParams_receiveProfileKeyCredential( } } +#[no_mangle] +pub extern "C" fn FFI_ServerPublicParams_receivePniCredential( + serverPublicParams: *const u8, + serverPublicParamsLen: u32, + pniCredentialRequestContext: *const u8, + pniCredentialRequestContextLen: u32, + pniCredentialResponse: *const u8, + pniCredentialResponseLen: u32, + pniCredentialOut: *mut u8, + pniCredentialLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params: &[u8] = + unsafe { slice::from_raw_parts(serverPublicParams, serverPublicParamsLen as usize) }; + let pni_credential_request_context: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialRequestContext, + pniCredentialRequestContextLen as usize, + ) + }; + let pni_credential_response: &[u8] = unsafe { + slice::from_raw_parts(pniCredentialResponse, pniCredentialResponseLen as usize) + }; + let pni_credential: &mut [u8] = + unsafe { slice::from_raw_parts_mut(pniCredentialOut, pniCredentialLen as usize) }; + + simpleapi::ServerPublicParams_receivePniCredential( + server_public_params, + pni_credential_request_context, + pni_credential_response, + pni_credential, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialPresentationDeterministic( serverPublicParams: *const u8, @@ -685,6 +772,50 @@ pub extern "C" fn FFI_ServerPublicParams_createProfileKeyCredentialPresentationD } } +#[no_mangle] +pub extern "C" fn FFI_ServerPublicParams_createPniCredentialPresentationDeterministic( + serverPublicParams: *const u8, + serverPublicParamsLen: u32, + randomness: *const u8, + randomnessLen: u32, + groupSecretParams: *const u8, + groupSecretParamsLen: u32, + pniCredential: *const u8, + pniCredentialLen: u32, + pniCredentialPresentationOut: *mut u8, + pniCredentialPresentationLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params: &[u8] = + unsafe { slice::from_raw_parts(serverPublicParams, serverPublicParamsLen as usize) }; + let randomness: &[u8] = + unsafe { slice::from_raw_parts(randomness, randomnessLen as usize) }; + let group_secret_params: &[u8] = + unsafe { slice::from_raw_parts(groupSecretParams, groupSecretParamsLen as usize) }; + let pni_credential: &[u8] = + unsafe { slice::from_raw_parts(pniCredential, pniCredentialLen as usize) }; + let pni_credential_presentation: &mut [u8] = unsafe { + slice::from_raw_parts_mut( + pniCredentialPresentationOut, + pniCredentialPresentationLen as usize, + ) + }; + + simpleapi::ServerPublicParams_createPniCredentialPresentationDeterministic( + server_public_params, + randomness, + group_secret_params, + pni_credential, + pni_credential_presentation, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ServerPublicParams_createReceiptCredentialRequestContextDeterministic( serverPublicParams: *const u8, @@ -935,6 +1066,60 @@ pub extern "C" fn FFI_ServerSecretParams_issueProfileKeyCredentialDeterministic( } } +#[no_mangle] +pub extern "C" fn FFI_ServerSecretParams_issuePniCredentialDeterministic( + serverSecretParams: *const u8, + serverSecretParamsLen: u32, + randomness: *const u8, + randomnessLen: u32, + profileKeyCredentialRequest: *const u8, + profileKeyCredentialRequestLen: u32, + aci: *const u8, + aciLen: u32, + pni: *const u8, + pniLen: u32, + profileKeyCommitment: *const u8, + profileKeyCommitmentLen: u32, + pniCredentialResponseOut: *mut u8, + pniCredentialResponseLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params: &[u8] = + unsafe { slice::from_raw_parts(serverSecretParams, serverSecretParamsLen as usize) }; + let randomness: &[u8] = + unsafe { slice::from_raw_parts(randomness, randomnessLen as usize) }; + let profile_key_credential_request: &[u8] = unsafe { + slice::from_raw_parts( + profileKeyCredentialRequest, + profileKeyCredentialRequestLen as usize, + ) + }; + let aci: &[u8] = unsafe { slice::from_raw_parts(aci, aciLen as usize) }; + let pni: &[u8] = unsafe { slice::from_raw_parts(pni, pniLen as usize) }; + let profile_key_commitment: &[u8] = unsafe { + slice::from_raw_parts(profileKeyCommitment, profileKeyCommitmentLen as usize) + }; + let pni_credential_response: &mut [u8] = unsafe { + slice::from_raw_parts_mut(pniCredentialResponseOut, pniCredentialResponseLen as usize) + }; + + simpleapi::ServerSecretParams_issuePniCredentialDeterministic( + server_secret_params, + randomness, + profile_key_credential_request, + aci, + pni, + profile_key_commitment, + pni_credential_response, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation( serverSecretParams: *const u8, @@ -969,6 +1154,40 @@ pub extern "C" fn FFI_ServerSecretParams_verifyProfileKeyCredentialPresentation( } } +#[no_mangle] +pub extern "C" fn FFI_ServerSecretParams_verifyPniCredentialPresentation( + serverSecretParams: *const u8, + serverSecretParamsLen: u32, + groupPublicParams: *const u8, + groupPublicParamsLen: u32, + pniCredentialPresentation: *const u8, + pniCredentialPresentationLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params: &[u8] = + unsafe { slice::from_raw_parts(serverSecretParams, serverSecretParamsLen as usize) }; + let group_public_params: &[u8] = + unsafe { slice::from_raw_parts(groupPublicParams, groupPublicParamsLen as usize) }; + let pni_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialPresentation, + pniCredentialPresentationLen as usize, + ) + }; + + simpleapi::ServerSecretParams_verifyPniCredentialPresentation( + server_secret_params, + group_public_params, + pni_credential_presentation, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ServerSecretParams_issueReceiptCredentialDeterministic( serverSecretParams: *const u8, @@ -1308,6 +1527,61 @@ pub extern "C" fn FFI_ProfileKeyCredentialRequestContext_getRequest( } } +#[no_mangle] +pub extern "C" fn FFI_PniCredentialRequestContext_checkValidContents( + pniCredentialRequestContext: *const u8, + pniCredentialRequestContextLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_request_context: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialRequestContext, + pniCredentialRequestContextLen as usize, + ) + }; + + simpleapi::PniCredentialRequestContext_checkValidContents(pni_credential_request_context) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_PniCredentialRequestContext_getRequest( + pniCredentialRequestContext: *const u8, + pniCredentialRequestContextLen: u32, + profileKeyCredentialRequestOut: *mut u8, + profileKeyCredentialRequestLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_request_context: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialRequestContext, + pniCredentialRequestContextLen as usize, + ) + }; + let profile_key_credential_request: &mut [u8] = unsafe { + slice::from_raw_parts_mut( + profileKeyCredentialRequestOut, + profileKeyCredentialRequestLen as usize, + ) + }; + + simpleapi::PniCredentialRequestContext_getRequest( + pni_credential_request_context, + profile_key_credential_request, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ProfileKeyCredentialRequest_checkValidContents( profileKeyCredentialRequest: *const u8, @@ -1352,6 +1626,25 @@ pub extern "C" fn FFI_ProfileKeyCredentialResponse_checkValidContents( } } +#[no_mangle] +pub extern "C" fn FFI_PniCredentialResponse_checkValidContents( + pniCredentialResponse: *const u8, + pniCredentialResponseLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_response: &[u8] = unsafe { + slice::from_raw_parts(pniCredentialResponse, pniCredentialResponseLen as usize) + }; + + simpleapi::PniCredentialResponse_checkValidContents(pni_credential_response) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ProfileKeyCredential_checkValidContents( profileKeyCredential: *const u8, @@ -1371,6 +1664,24 @@ pub extern "C" fn FFI_ProfileKeyCredential_checkValidContents( } } +#[no_mangle] +pub extern "C" fn FFI_PniCredential_checkValidContents( + pniCredential: *const u8, + pniCredentialLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential: &[u8] = + unsafe { slice::from_raw_parts(pniCredential, pniCredentialLen as usize) }; + + simpleapi::PniCredential_checkValidContents(pni_credential) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ProfileKeyCredentialPresentation_checkValidContents( profileKeyCredentialPresentation: *const u8, @@ -1454,6 +1765,116 @@ pub extern "C" fn FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext( } } +#[no_mangle] +pub extern "C" fn FFI_PniCredentialPresentation_checkValidContents( + pniCredentialPresentation: *const u8, + pniCredentialPresentationLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialPresentation, + pniCredentialPresentationLen as usize, + ) + }; + + simpleapi::PniCredentialPresentation_checkValidContents(pni_credential_presentation) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_PniCredentialPresentation_getAciCiphertext( + pniCredentialPresentation: *const u8, + pniCredentialPresentationLen: u32, + uuidCiphertextOut: *mut u8, + uuidCiphertextLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialPresentation, + pniCredentialPresentationLen as usize, + ) + }; + let uuid_ciphertext: &mut [u8] = + unsafe { slice::from_raw_parts_mut(uuidCiphertextOut, uuidCiphertextLen as usize) }; + + simpleapi::PniCredentialPresentation_getAciCiphertext( + pni_credential_presentation, + uuid_ciphertext, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_PniCredentialPresentation_getPniCiphertext( + pniCredentialPresentation: *const u8, + pniCredentialPresentationLen: u32, + uuidCiphertextOut: *mut u8, + uuidCiphertextLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialPresentation, + pniCredentialPresentationLen as usize, + ) + }; + let uuid_ciphertext: &mut [u8] = + unsafe { slice::from_raw_parts_mut(uuidCiphertextOut, uuidCiphertextLen as usize) }; + + simpleapi::PniCredentialPresentation_getPniCiphertext( + pni_credential_presentation, + uuid_ciphertext, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "C" fn FFI_PniCredentialPresentation_getProfileKeyCiphertext( + pniCredentialPresentation: *const u8, + pniCredentialPresentationLen: u32, + profileKeyCiphertextOut: *mut u8, + profileKeyCiphertextLen: u32, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation: &[u8] = unsafe { + slice::from_raw_parts( + pniCredentialPresentation, + pniCredentialPresentationLen as usize, + ) + }; + let profile_key_ciphertext: &mut [u8] = unsafe { + slice::from_raw_parts_mut(profileKeyCiphertextOut, profileKeyCiphertextLen as usize) + }; + + simpleapi::PniCredentialPresentation_getProfileKeyCiphertext( + pni_credential_presentation, + profile_key_ciphertext, + ) + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "C" fn FFI_ReceiptCredentialRequestContext_checkValidContents( receiptCredentialRequestContext: *const u8, diff --git a/rust/src/ffi/ffiapijava.rs b/rust/src/ffi/ffiapijava.rs index f466246..109b894 100644 --- a/rust/src/ffi/ffiapijava.rs +++ b/rust/src/ffi/ffiapijava.rs @@ -748,6 +748,57 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParam } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsCreatePniCredentialRequestContextDeterministicJNI( + env: JNIEnv, + _class: JClass, + serverPublicParams: jbyteArray, + randomness: jbyteArray, + aci: jbyteArray, + pni: jbyteArray, + profileKey: jbyteArray, + pniCredentialRequestContextOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params = env.convert_byte_array(serverPublicParams).unwrap(); + let randomness = env.convert_byte_array(randomness).unwrap(); + let aci = env.convert_byte_array(aci).unwrap(); + let pni = env.convert_byte_array(pni).unwrap(); + let profile_key = env.convert_byte_array(profileKey).unwrap(); + let mut pni_credential_request_context: Vec = vec![ + 0; + env.get_array_length(pniCredentialRequestContextOut) + .unwrap() as usize + ]; + + let ffi_return = + simpleapi::ServerPublicParams_createPniCredentialRequestContextDeterministic( + &server_public_params, + &randomness, + &aci, + &pni, + &profile_key, + &mut pni_credential_request_context, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + pniCredentialRequestContextOut, + 0, + &u8toi8(pni_credential_request_context)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsReceiveProfileKeyCredentialJNI( env: JNIEnv, @@ -793,6 +844,44 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParam } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsReceivePniCredentialJNI( + env: JNIEnv, + _class: JClass, + serverPublicParams: jbyteArray, + pniCredentialRequestContext: jbyteArray, + pniCredentialResponse: jbyteArray, + pniCredentialOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params = env.convert_byte_array(serverPublicParams).unwrap(); + let pni_credential_request_context = + env.convert_byte_array(pniCredentialRequestContext).unwrap(); + let pni_credential_response = env.convert_byte_array(pniCredentialResponse).unwrap(); + let mut pni_credential: Vec = + vec![0; env.get_array_length(pniCredentialOut).unwrap() as usize]; + + let ffi_return = simpleapi::ServerPublicParams_receivePniCredential( + &server_public_params, + &pni_credential_request_context, + &pni_credential_response, + &mut pni_credential, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region(pniCredentialOut, 0, &u8toi8(pni_credential)[..]) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsCreateProfileKeyCredentialPresentationDeterministicJNI( env: JNIEnv, @@ -842,6 +931,50 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParam } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsCreatePniCredentialPresentationDeterministicJNI( + env: JNIEnv, + _class: JClass, + serverPublicParams: jbyteArray, + randomness: jbyteArray, + groupSecretParams: jbyteArray, + pniCredential: jbyteArray, + pniCredentialPresentationOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_public_params = env.convert_byte_array(serverPublicParams).unwrap(); + let randomness = env.convert_byte_array(randomness).unwrap(); + let group_secret_params = env.convert_byte_array(groupSecretParams).unwrap(); + let pni_credential = env.convert_byte_array(pniCredential).unwrap(); + let mut pni_credential_presentation: Vec = + vec![0; env.get_array_length(pniCredentialPresentationOut).unwrap() as usize]; + + let ffi_return = simpleapi::ServerPublicParams_createPniCredentialPresentationDeterministic( + &server_public_params, + &randomness, + &group_secret_params, + &pni_credential, + &mut pni_credential_presentation, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + pniCredentialPresentationOut, + 0, + &u8toi8(pni_credential_presentation)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverPublicParamsCreateReceiptCredentialRequestContextDeterministicJNI( env: JNIEnv, @@ -1099,6 +1232,57 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParam } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParamsIssuePniCredentialDeterministicJNI( + env: JNIEnv, + _class: JClass, + serverSecretParams: jbyteArray, + randomness: jbyteArray, + profileKeyCredentialRequest: jbyteArray, + aci: jbyteArray, + pni: jbyteArray, + profileKeyCommitment: jbyteArray, + pniCredentialResponseOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params = env.convert_byte_array(serverSecretParams).unwrap(); + let randomness = env.convert_byte_array(randomness).unwrap(); + let profile_key_credential_request = + env.convert_byte_array(profileKeyCredentialRequest).unwrap(); + let aci = env.convert_byte_array(aci).unwrap(); + let pni = env.convert_byte_array(pni).unwrap(); + let profile_key_commitment = env.convert_byte_array(profileKeyCommitment).unwrap(); + let mut pni_credential_response: Vec = + vec![0; env.get_array_length(pniCredentialResponseOut).unwrap() as usize]; + + let ffi_return = simpleapi::ServerSecretParams_issuePniCredentialDeterministic( + &server_secret_params, + &randomness, + &profile_key_credential_request, + &aci, + &pni, + &profile_key_commitment, + &mut pni_credential_response, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + pniCredentialResponseOut, + 0, + &u8toi8(pni_credential_response)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParamsVerifyProfileKeyCredentialPresentationJNI( env: JNIEnv, @@ -1131,6 +1315,37 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParam } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParamsVerifyPniCredentialPresentationJNI( + env: JNIEnv, + _class: JClass, + serverSecretParams: jbyteArray, + groupPublicParams: jbyteArray, + pniCredentialPresentation: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let server_secret_params = env.convert_byte_array(serverSecretParams).unwrap(); + let group_public_params = env.convert_byte_array(groupPublicParams).unwrap(); + let pni_credential_presentation = + env.convert_byte_array(pniCredentialPresentation).unwrap(); + + let ffi_return = simpleapi::ServerSecretParams_verifyPniCredentialPresentation( + &server_secret_params, + &group_public_params, + &pni_credential_presentation, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_serverSecretParamsIssueReceiptCredentialDeterministicJNI( env: JNIEnv, @@ -1511,6 +1726,70 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredent } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialRequestContextCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + pniCredentialRequestContext: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_request_context = + env.convert_byte_array(pniCredentialRequestContext).unwrap(); + + let ffi_return = simpleapi::PniCredentialRequestContext_checkValidContents( + &pni_credential_request_context, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialRequestContextGetRequestJNI( + env: JNIEnv, + _class: JClass, + pniCredentialRequestContext: jbyteArray, + profileKeyCredentialRequestOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_request_context = + env.convert_byte_array(pniCredentialRequestContext).unwrap(); + let mut profile_key_credential_request: Vec = vec![ + 0; + env.get_array_length(profileKeyCredentialRequestOut) + .unwrap() as usize + ]; + + let ffi_return = simpleapi::PniCredentialRequestContext_getRequest( + &pni_credential_request_context, + &mut profile_key_credential_request, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + profileKeyCredentialRequestOut, + 0, + &u8toi8(profile_key_credential_request)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredentialRequestCheckValidContentsJNI( env: JNIEnv, @@ -1562,6 +1841,29 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredent } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialResponseCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + pniCredentialResponse: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_response = env.convert_byte_array(pniCredentialResponse).unwrap(); + + let ffi_return = + simpleapi::PniCredentialResponse_checkValidContents(&pni_credential_response); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredentialCheckValidContentsJNI( env: JNIEnv, @@ -1585,6 +1887,28 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredent } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + pniCredential: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential = env.convert_byte_array(pniCredential).unwrap(); + + let ffi_return = simpleapi::PniCredential_checkValidContents(&pni_credential); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredentialPresentationCheckValidContentsJNI( env: JNIEnv, @@ -1681,6 +2005,130 @@ pub extern "system" fn Java_org_signal_zkgroup_internal_Native_profileKeyCredent } } +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialPresentationCheckValidContentsJNI( + env: JNIEnv, + _class: JClass, + pniCredentialPresentation: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation = + env.convert_byte_array(pniCredentialPresentation).unwrap(); + + let ffi_return = + simpleapi::PniCredentialPresentation_checkValidContents(&pni_credential_presentation); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialPresentationGetAciCiphertextJNI( + env: JNIEnv, + _class: JClass, + pniCredentialPresentation: jbyteArray, + uuidCiphertextOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation = + env.convert_byte_array(pniCredentialPresentation).unwrap(); + let mut uuid_ciphertext: Vec = + vec![0; env.get_array_length(uuidCiphertextOut).unwrap() as usize]; + + let ffi_return = simpleapi::PniCredentialPresentation_getAciCiphertext( + &pni_credential_presentation, + &mut uuid_ciphertext, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region(uuidCiphertextOut, 0, &u8toi8(uuid_ciphertext)[..]) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialPresentationGetPniCiphertextJNI( + env: JNIEnv, + _class: JClass, + pniCredentialPresentation: jbyteArray, + uuidCiphertextOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation = + env.convert_byte_array(pniCredentialPresentation).unwrap(); + let mut uuid_ciphertext: Vec = + vec![0; env.get_array_length(uuidCiphertextOut).unwrap() as usize]; + + let ffi_return = simpleapi::PniCredentialPresentation_getPniCiphertext( + &pni_credential_presentation, + &mut uuid_ciphertext, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region(uuidCiphertextOut, 0, &u8toi8(uuid_ciphertext)[..]) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + +#[no_mangle] +pub extern "system" fn Java_org_signal_zkgroup_internal_Native_pniCredentialPresentationGetProfileKeyCiphertextJNI( + env: JNIEnv, + _class: JClass, + pniCredentialPresentation: jbyteArray, + profileKeyCiphertextOut: jbyteArray, +) -> i32 { + let result = panic::catch_unwind(|| { + let pni_credential_presentation = + env.convert_byte_array(pniCredentialPresentation).unwrap(); + let mut profile_key_ciphertext: Vec = + vec![0; env.get_array_length(profileKeyCiphertextOut).unwrap() as usize]; + + let ffi_return = simpleapi::PniCredentialPresentation_getProfileKeyCiphertext( + &pni_credential_presentation, + &mut profile_key_ciphertext, + ); + if ffi_return != FFI_RETURN_OK { + return ffi_return; + } + + env.set_byte_array_region( + profileKeyCiphertextOut, + 0, + &u8toi8(profile_key_ciphertext)[..], + ) + .unwrap(); + FFI_RETURN_OK + }); + + match result { + Ok(result) => result, + Err(_) => FFI_RETURN_INTERNAL_ERROR, + } +} + #[no_mangle] pub extern "system" fn Java_org_signal_zkgroup_internal_Native_receiptCredentialRequestContextCheckValidContentsJNI( env: JNIEnv, diff --git a/rust/src/ffi/simpleapi.rs b/rust/src/ffi/simpleapi.rs index 1cafea4..9595182 100644 --- a/rust/src/ffi/simpleapi.rs +++ b/rust/src/ffi/simpleapi.rs @@ -440,6 +440,46 @@ pub fn ServerPublicParams_createProfileKeyCredentialRequestContextDeterministic( FFI_RETURN_OK } +pub fn ServerPublicParams_createPniCredentialRequestContextDeterministic( + serverPublicParamsIn: &[u8], + randomnessIn: &[u8], + aciIn: &[u8], + pniIn: &[u8], + profileKeyIn: &[u8], + pniCredentialRequestContextOut: &mut [u8], +) -> i32 { + let server_public_params: api::ServerPublicParams = + match bincode::deserialize(serverPublicParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let randomness: simple_types::RandomnessBytes = match bincode::deserialize(randomnessIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let aci: simple_types::UidBytes = match bincode::deserialize(aciIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let pni: simple_types::UidBytes = match bincode::deserialize(pniIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let profile_key: api::profiles::ProfileKey = match bincode::deserialize(profileKeyIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let pni_credential_request_context = server_public_params + .create_pni_credential_request_context(randomness, aci, pni, profile_key); + pniCredentialRequestContextOut + .copy_from_slice(&bincode::serialize(&pni_credential_request_context).unwrap()); + FFI_RETURN_OK +} + pub fn ServerPublicParams_receiveProfileKeyCredential( serverPublicParamsIn: &[u8], profileKeyCredentialRequestContextIn: &[u8], @@ -474,6 +514,39 @@ pub fn ServerPublicParams_receiveProfileKeyCredential( FFI_RETURN_OK } +pub fn ServerPublicParams_receivePniCredential( + serverPublicParamsIn: &[u8], + pniCredentialRequestContextIn: &[u8], + pniCredentialResponseIn: &[u8], + pniCredentialOut: &mut [u8], +) -> i32 { + let server_public_params: api::ServerPublicParams = + match bincode::deserialize(serverPublicParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let pni_credential_request_context: api::profiles::PniCredentialRequestContext = + match bincode::deserialize(pniCredentialRequestContextIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let pni_credential_response: api::profiles::PniCredentialResponse = + match bincode::deserialize(pniCredentialResponseIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let pni_credential = match server_public_params + .receive_pni_credential(&pni_credential_request_context, &pni_credential_response) + { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + pniCredentialOut.copy_from_slice(&bincode::serialize(&pni_credential).unwrap()); + FFI_RETURN_OK +} + pub fn ServerPublicParams_createProfileKeyCredentialPresentationDeterministic( serverPublicParamsIn: &[u8], randomnessIn: &[u8], @@ -514,6 +587,44 @@ pub fn ServerPublicParams_createProfileKeyCredentialPresentationDeterministic( FFI_RETURN_OK } +pub fn ServerPublicParams_createPniCredentialPresentationDeterministic( + serverPublicParamsIn: &[u8], + randomnessIn: &[u8], + groupSecretParamsIn: &[u8], + pniCredentialIn: &[u8], + pniCredentialPresentationOut: &mut [u8], +) -> i32 { + let server_public_params: api::ServerPublicParams = + match bincode::deserialize(serverPublicParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let randomness: simple_types::RandomnessBytes = match bincode::deserialize(randomnessIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let group_secret_params: api::groups::GroupSecretParams = + match bincode::deserialize(groupSecretParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let pni_credential: api::profiles::PniCredential = match bincode::deserialize(pniCredentialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let pni_credential_presentation = server_public_params.create_pni_credential_presentation( + randomness, + group_secret_params, + pni_credential, + ); + pniCredentialPresentationOut + .copy_from_slice(&bincode::serialize(&pni_credential_presentation).unwrap()); + FFI_RETURN_OK +} + pub fn ServerPublicParams_createReceiptCredentialRequestContextDeterministic( serverPublicParamsIn: &[u8], randomnessIn: &[u8], @@ -716,6 +827,62 @@ pub fn ServerSecretParams_issueProfileKeyCredentialDeterministic( FFI_RETURN_OK } +pub fn ServerSecretParams_issuePniCredentialDeterministic( + serverSecretParamsIn: &[u8], + randomnessIn: &[u8], + profileKeyCredentialRequestIn: &[u8], + aciIn: &[u8], + pniIn: &[u8], + profileKeyCommitmentIn: &[u8], + pniCredentialResponseOut: &mut [u8], +) -> i32 { + let server_secret_params: api::ServerSecretParams = + match bincode::deserialize(serverSecretParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let randomness: simple_types::RandomnessBytes = match bincode::deserialize(randomnessIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let profile_key_credential_request: api::profiles::ProfileKeyCredentialRequest = + match bincode::deserialize(profileKeyCredentialRequestIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let aci: simple_types::UidBytes = match bincode::deserialize(aciIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let pni: simple_types::UidBytes = match bincode::deserialize(pniIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let profile_key_commitment: api::profiles::ProfileKeyCommitment = + match bincode::deserialize(profileKeyCommitmentIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + let pni_credential_response = match server_secret_params.issue_pni_credential( + randomness, + &profile_key_credential_request, + aci, + pni, + profile_key_commitment, + ) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + pniCredentialResponseOut + .copy_from_slice(&bincode::serialize(&pni_credential_response).unwrap()); + FFI_RETURN_OK +} + pub fn ServerSecretParams_verifyProfileKeyCredentialPresentation( serverSecretParamsIn: &[u8], groupPublicParamsIn: &[u8], @@ -748,6 +915,37 @@ pub fn ServerSecretParams_verifyProfileKeyCredentialPresentation( FFI_RETURN_OK } +pub fn ServerSecretParams_verifyPniCredentialPresentation( + serverSecretParamsIn: &[u8], + groupPublicParamsIn: &[u8], + pniCredentialPresentationIn: &[u8], +) -> i32 { + let server_secret_params: api::ServerSecretParams = + match bincode::deserialize(serverSecretParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + + let group_public_params: api::groups::GroupPublicParams = + match bincode::deserialize(groupPublicParamsIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + let pni_credential_presentation: api::profiles::PniCredentialPresentation = + match bincode::deserialize(pniCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + match server_secret_params + .verify_pni_credential_presentation(group_public_params, &pni_credential_presentation) + { + Ok(_) => (), + Err(_) => return FFI_RETURN_INPUT_ERROR, + } + FFI_RETURN_OK +} + pub fn ServerSecretParams_issueReceiptCredentialDeterministic( serverSecretParamsIn: &[u8], randomnessIn: &[u8], @@ -945,6 +1143,31 @@ pub fn ProfileKeyCredentialRequestContext_getRequest( FFI_RETURN_OK } +pub fn PniCredentialRequestContext_checkValidContents(pniCredentialRequestContextIn: &[u8]) -> i32 { + let _: api::profiles::PniCredentialRequestContext = + match bincode::deserialize(pniCredentialRequestContextIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + +pub fn PniCredentialRequestContext_getRequest( + pniCredentialRequestContextIn: &[u8], + profileKeyCredentialRequestOut: &mut [u8], +) -> i32 { + let pni_credential_request_context: api::profiles::PniCredentialRequestContext = + match bincode::deserialize(pniCredentialRequestContextIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let profile_key_credential_request = pni_credential_request_context.get_request(); + profileKeyCredentialRequestOut + .copy_from_slice(&bincode::serialize(&profile_key_credential_request).unwrap()); + FFI_RETURN_OK +} + pub fn ProfileKeyCredentialRequest_checkValidContents(profileKeyCredentialRequestIn: &[u8]) -> i32 { let _: api::profiles::ProfileKeyCredentialRequest = match bincode::deserialize(profileKeyCredentialRequestIn) { @@ -967,6 +1190,16 @@ pub fn ProfileKeyCredentialResponse_checkValidContents( FFI_RETURN_OK } +pub fn PniCredentialResponse_checkValidContents(pniCredentialResponseIn: &[u8]) -> i32 { + let _: api::profiles::PniCredentialResponse = + match bincode::deserialize(pniCredentialResponseIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + pub fn ProfileKeyCredential_checkValidContents(profileKeyCredentialIn: &[u8]) -> i32 { let _: api::profiles::ProfileKeyCredential = match bincode::deserialize(profileKeyCredentialIn) { @@ -977,6 +1210,15 @@ pub fn ProfileKeyCredential_checkValidContents(profileKeyCredentialIn: &[u8]) -> FFI_RETURN_OK } +pub fn PniCredential_checkValidContents(pniCredentialIn: &[u8]) -> i32 { + let _: api::profiles::PniCredential = match bincode::deserialize(pniCredentialIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + pub fn ProfileKeyCredentialPresentation_checkValidContents( profileKeyCredentialPresentationIn: &[u8], ) -> i32 { @@ -1017,6 +1259,58 @@ pub fn ProfileKeyCredentialPresentation_getProfileKeyCiphertext( FFI_RETURN_OK } +pub fn PniCredentialPresentation_checkValidContents(pniCredentialPresentationIn: &[u8]) -> i32 { + let _: api::profiles::PniCredentialPresentation = + match bincode::deserialize(pniCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INPUT_ERROR, + }; + + FFI_RETURN_OK +} + +pub fn PniCredentialPresentation_getAciCiphertext( + pniCredentialPresentationIn: &[u8], + uuidCiphertextOut: &mut [u8], +) -> i32 { + let pni_credential_presentation: api::profiles::PniCredentialPresentation = + match bincode::deserialize(pniCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let uuid_ciphertext = pni_credential_presentation.get_aci_ciphertext(); + uuidCiphertextOut.copy_from_slice(&bincode::serialize(&uuid_ciphertext).unwrap()); + FFI_RETURN_OK +} + +pub fn PniCredentialPresentation_getPniCiphertext( + pniCredentialPresentationIn: &[u8], + uuidCiphertextOut: &mut [u8], +) -> i32 { + let pni_credential_presentation: api::profiles::PniCredentialPresentation = + match bincode::deserialize(pniCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let uuid_ciphertext = pni_credential_presentation.get_pni_ciphertext(); + uuidCiphertextOut.copy_from_slice(&bincode::serialize(&uuid_ciphertext).unwrap()); + FFI_RETURN_OK +} + +pub fn PniCredentialPresentation_getProfileKeyCiphertext( + pniCredentialPresentationIn: &[u8], + profileKeyCiphertextOut: &mut [u8], +) -> i32 { + let pni_credential_presentation: api::profiles::PniCredentialPresentation = + match bincode::deserialize(pniCredentialPresentationIn) { + Ok(result) => result, + Err(_) => return FFI_RETURN_INTERNAL_ERROR, + }; + let profile_key_ciphertext = pni_credential_presentation.get_profile_key_ciphertext(); + profileKeyCiphertextOut.copy_from_slice(&bincode::serialize(&profile_key_ciphertext).unwrap()); + FFI_RETURN_OK +} + pub fn ReceiptCredentialRequestContext_checkValidContents( receiptCredentialRequestContextIn: &[u8], ) -> i32 { From e6e53bf6796297b21fa5d8ca00996fff81a5881d Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 17 Nov 2021 10:11:52 -0800 Subject: [PATCH 69/69] Bump version to 0.9.0 --- Cargo.lock | 2 +- ZKGroup.podspec | 2 +- deploy.gradle | 2 +- ffi/node/package-lock.json | 4 ++-- ffi/node/package.json | 2 +- rust/Cargo.toml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ae6a61..5fc1b52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1007,7 +1007,7 @@ checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" [[package]] name = "zkgroup" -version = "0.8.2" +version = "0.9.0" dependencies = [ "aead", "aes-gcm-siv", diff --git a/ZKGroup.podspec b/ZKGroup.podspec index 3a4b1ab..530d7a7 100644 --- a/ZKGroup.podspec +++ b/ZKGroup.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "ZKGroup" - s.version = "0.8.2" + s.version = "0.9.0" s.summary = "Swift API for the Rust zkgroup crate." s.homepage = "https://signal.org/" s.license = { :type => "GPLv3", :file => "LICENSE" } diff --git a/deploy.gradle b/deploy.gradle index b2ce322..347fe2b 100644 --- a/deploy.gradle +++ b/deploy.gradle @@ -1,7 +1,7 @@ apply plugin: 'maven' apply plugin: 'signing' -version = '0.8.2' +version = '0.9.0' group = 'org.signal' def isReleaseBuild() { diff --git a/ffi/node/package-lock.json b/ffi/node/package-lock.json index 6c8f409..1c531b3 100644 --- a/ffi/node/package-lock.json +++ b/ffi/node/package-lock.json @@ -1,12 +1,12 @@ { "name": "zkgroup", - "version": "0.8.2", + "version": "0.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "zkgroup", - "version": "0.8.2", + "version": "0.9.0", "license": "ISC", "dependencies": { "@types/ffi-napi": "^4.0.1", diff --git a/ffi/node/package.json b/ffi/node/package.json index e8c6114..666ab43 100644 --- a/ffi/node/package.json +++ b/ffi/node/package.json @@ -1,6 +1,6 @@ { "name": "zkgroup", - "version": "0.8.2", + "version": "0.9.0", "description": "zero-knowledge group functionality", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index f6478b2..dd13d8e 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "zkgroup" -version = "0.8.2" +version = "0.9.0" authors = ["Trevor Perrin "] edition = "2018" description = "A zero-knowledge group library"