diff --git a/Cargo.lock b/Cargo.lock index 1b0d5e6d55282a..f407a61d234406 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3626,6 +3626,61 @@ dependencies = [ "ascii_utils", ] +[[package]] +name = "fastcrypto" +version = "0.1.6" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5#4e7debce78340848f0009b648f56d912d6bd02d5" +dependencies = [ + "aes", + "aes-gcm", + "ark-ec", + "ark-ff", + "ark-secp256r1", + "ark-serialize", + "auto_ops", + "base64ct", + "bincode", + "blake2", + "blake3", + "blst", + "bs58", + "bulletproofs", + "cbc", + "ctr", + "curve25519-dalek-ng", + "derive_more", + "digest 0.10.6", + "ecdsa 0.16.6", + "ed25519-consensus", + "elliptic-curve 0.13.4", + "eyre", + "fastcrypto-derive 0.1.3 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "generic-array", + "hex", + "hkdf", + "lazy_static", + "merlin", + "once_cell", + "p256", + "rand 0.8.5", + "readonly", + "rfc6979 0.4.0", + "rsa", + "schemars", + "secp256k1", + "serde", + "serde_bytes", + "serde_with", + "sha2 0.10.6", + "sha3 0.10.6", + "signature 2.0.0", + "static_assertions", + "thiserror", + "tokio", + "typenum", + "zeroize", +] + [[package]] name = "fastcrypto" version = "0.1.6" @@ -3654,7 +3709,7 @@ dependencies = [ "ed25519-consensus", "elliptic-curve 0.13.4", "eyre", - "fastcrypto-derive", + "fastcrypto-derive 0.1.3 (git+https://github.com/MystenLabs/fastcrypto?rev=6c17d6e5efb0a4d8c1b1b909ef38ee0b09eafa8b)", "generic-array", "hex", "hkdf", @@ -3681,6 +3736,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "fastcrypto-derive" +version = "0.1.3" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5#4e7debce78340848f0009b648f56d912d6bd02d5" +dependencies = [ + "convert_case 0.6.0", + "proc-macro2 1.0.58", + "quote 1.0.26", + "syn 1.0.107", +] + [[package]] name = "fastcrypto-derive" version = "0.1.3" @@ -3692,6 +3758,35 @@ dependencies = [ "syn 1.0.107", ] +[[package]] +name = "fastcrypto-zkp" +version = "0.1.1" +source = "git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5#4e7debce78340848f0009b648f56d912d6bd02d5" +dependencies = [ + "ark-bls12-381", + "ark-bn254", + "ark-crypto-primitives", + "ark-ec", + "ark-ff", + "ark-groth16", + "ark-relations", + "ark-serialize", + "bcs", + "blst", + "byte-slice-cast", + "derive_more", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "im", + "num-bigint", + "once_cell", + "poseidon-ark", + "regex", + "reqwest", + "schemars", + "serde", + "serde_json", +] + [[package]] name = "fastcrypto-zkp" version = "0.1.1" @@ -3709,7 +3804,7 @@ dependencies = [ "blst", "byte-slice-cast", "derive_more", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=6c17d6e5efb0a4d8c1b1b909ef38ee0b09eafa8b)", "im", "num-bigint", "once_cell", @@ -6290,7 +6385,7 @@ version = "0.11.0" dependencies = [ "cfg-if", "ed25519-consensus", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "hashbrown 0.12.3", "impl-trait-for-tuples", "indexmap", @@ -6336,7 +6431,7 @@ dependencies = [ name = "narwhal-config" version = "0.1.0" dependencies = [ - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "insta", "match_opt", "mysten-network", @@ -6362,7 +6457,7 @@ dependencies = [ "bincode", "cfg-if", "criterion", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "indexmap", "match_opt", @@ -6392,7 +6487,7 @@ dependencies = [ "bcs", "bincode", "criterion", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "hex-literal", "proptest", "proptest-derive", @@ -6413,7 +6508,7 @@ dependencies = [ "bcs", "bincode", "bytes", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "indexmap", "itertools", @@ -6485,7 +6580,7 @@ dependencies = [ "cfg-if", "clap 2.34.0", "eyre", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "mysten-metrics", "mysten-network", @@ -6534,7 +6629,7 @@ dependencies = [ "bincode", "bytes", "dashmap", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "governor", "indexmap", @@ -6578,7 +6673,7 @@ name = "narwhal-storage" version = "0.1.0" dependencies = [ "dashmap", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "lru", "mysten-common", @@ -6602,7 +6697,7 @@ name = "narwhal-test-utils" version = "0.1.0" dependencies = [ "anemo", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "fdlimit", "indexmap", "itertools", @@ -6644,7 +6739,7 @@ dependencies = [ "criterion", "derive_builder", "enum_dispatch", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "indexmap", "mockall", @@ -6690,7 +6785,7 @@ dependencies = [ "byteorder", "bytes", "eyre", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "governor", "itertools", @@ -9207,7 +9302,7 @@ version = "0.0.0" dependencies = [ "bcs", "eyre", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "serde", "serde_repr", "workspace-hack", @@ -9570,8 +9665,8 @@ dependencies = [ "const-str", "csv", "expect-test", - "fastcrypto", - "fastcrypto-zkp", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "fastcrypto-zkp 0.1.1 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "fs_extra", "git-version", "inquire", @@ -9702,7 +9797,7 @@ dependencies = [ "byteorder", "bytes", "ed25519-consensus", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "indicatif", "integer-encoding", @@ -9743,7 +9838,7 @@ dependencies = [ "clap 3.2.23", "comfy-table", "duration-str", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "hdrhistogram", "indicatif", @@ -9795,7 +9890,7 @@ dependencies = [ "async-trait", "bcs", "clap 3.2.23", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "jsonrpsee", "move-core-types", @@ -9837,7 +9932,7 @@ dependencies = [ "bcs", "csv", "dirs", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "insta", "move-binary-format", "move-core-types", @@ -9876,8 +9971,8 @@ dependencies = [ "enum_dispatch", "expect-test", "eyre", - "fastcrypto", - "fastcrypto-zkp", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "fastcrypto-zkp 0.1.1 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "fs_extra", "futures", "im", @@ -9981,7 +10076,7 @@ dependencies = [ "bcs", "clap 3.2.23", "expect-test", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "fs_extra", "futures", "indexmap", @@ -10172,7 +10267,7 @@ dependencies = [ "camino", "csv", "dirs", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "insta", "move-binary-format", "move-core-types", @@ -10208,7 +10303,7 @@ dependencies = [ "bcs", "clap 3.2.23", "expect-test", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "hex", "hyper", "insta", @@ -10239,7 +10334,7 @@ dependencies = [ "diesel", "diesel-derive-enum", "diesel_migrations", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "itertools", "jsonrpsee", @@ -10281,7 +10376,7 @@ version = "0.0.0" dependencies = [ "anyhow", "bcs", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "move-binary-format", "move-bytecode-utils", "move-core-types", @@ -10310,7 +10405,7 @@ dependencies = [ "cached", "expect-test", "eyre", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "hyper", "itertools", @@ -10394,7 +10489,7 @@ dependencies = [ "bcs", "colored", "enum_dispatch", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "itertools", "move-binary-format", "move-bytecode-utils", @@ -10419,7 +10514,7 @@ version = "0.0.0" dependencies = [ "anyhow", "bip32", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "rand 0.8.5", "serde", "serde_json", @@ -10499,7 +10594,7 @@ dependencies = [ "clap 3.2.23", "colored", "const-str", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "git-version", "jemalloc-ctl", @@ -10540,7 +10635,7 @@ version = "0.0.0" dependencies = [ "anyhow", "datatest-stable", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "move-binary-format", "move-bytecode-utils", "move-bytecode-verifier", @@ -10565,8 +10660,8 @@ version = "0.1.0" dependencies = [ "bcs", "better_any", - "fastcrypto", - "fastcrypto-zkp", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "fastcrypto-zkp 0.1.1 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "linked-hash-map", "move-binary-format", "move-core-types", @@ -10585,8 +10680,8 @@ version = "0.1.0" dependencies = [ "bcs", "better_any", - "fastcrypto", - "fastcrypto-zkp", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "fastcrypto-zkp 0.1.1 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "linked-hash-map", "move-binary-format", "move-core-types", @@ -10609,7 +10704,7 @@ dependencies = [ "anyhow", "dashmap", "ed25519-consensus", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "governor", "mysten-metrics", @@ -10645,8 +10740,8 @@ dependencies = [ "axum", "clap 3.2.23", "const-str", - "fastcrypto", - "fastcrypto-zkp", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "fastcrypto-zkp 0.1.1 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "git-version", "mysten-common", @@ -10690,7 +10785,7 @@ dependencies = [ "anyhow", "bcs", "clap 3.2.23", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "move-core-types", "pretty_assertions", "rand 0.8.5", @@ -10798,7 +10893,7 @@ dependencies = [ "bytes", "clap 3.2.23", "const-str", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "git-version", "http-body", "hyper", @@ -10905,7 +11000,7 @@ dependencies = [ "chrono", "clap 3.2.23", "eyre", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "hyper", "move-bytecode-utils", @@ -11000,7 +11095,7 @@ dependencies = [ "clap 3.2.23", "colored", "dirs", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "futures-core", "jsonrpsee", @@ -11030,7 +11125,7 @@ version = "0.7.0" dependencies = [ "anemo", "anemo-tower", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "lru", "move-package", "msim", @@ -11056,7 +11151,7 @@ dependencies = [ "bcs", "byteorder", "bytes", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "integer-encoding", "num_enum", @@ -11153,7 +11248,7 @@ dependencies = [ "clap 4.3.3", "criterion", "eyre", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "hyper", "hyper-rustls 0.24.0", @@ -11257,7 +11352,7 @@ dependencies = [ "camino", "csv", "dirs", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "insta", "move-binary-format", "move-core-types", @@ -11287,7 +11382,7 @@ dependencies = [ name = "sui-telemetry" version = "0.1.0" dependencies = [ - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "reqwest", "serde", "sui-core", @@ -11335,7 +11430,7 @@ dependencies = [ "axum", "axum-server", "ed25519", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "pkcs8 0.9.0", "rand 0.8.5", "rcgen", @@ -11361,7 +11456,7 @@ dependencies = [ "colored", "comfy-table", "eyre", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "futures", "hex", "indicatif", @@ -11427,7 +11522,7 @@ dependencies = [ "bcs", "bimap", "clap 3.2.23", - "fastcrypto", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "move-binary-format", "move-bytecode-utils", "move-command-line-common", @@ -11470,8 +11565,8 @@ dependencies = [ "derive_more", "enum_dispatch", "eyre", - "fastcrypto", - "fastcrypto-zkp", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", + "fastcrypto-zkp 0.1.1 (git+https://github.com/MystenLabs/fastcrypto?rev=4e7debce78340848f0009b648f56d912d6bd02d5)", "im", "indexmap", "itertools", @@ -13591,9 +13686,9 @@ dependencies = [ "eyre", "fail", "fast_chemail", - "fastcrypto", - "fastcrypto-derive", - "fastcrypto-zkp", + "fastcrypto 0.1.6 (git+https://github.com/MystenLabs/fastcrypto?rev=6c17d6e5efb0a4d8c1b1b909ef38ee0b09eafa8b)", + "fastcrypto-derive 0.1.3 (git+https://github.com/MystenLabs/fastcrypto?rev=6c17d6e5efb0a4d8c1b1b909ef38ee0b09eafa8b)", + "fastcrypto-zkp 0.1.1 (git+https://github.com/MystenLabs/fastcrypto?rev=6c17d6e5efb0a4d8c1b1b909ef38ee0b09eafa8b)", "fastrand", "fd-lock", "fdlimit", diff --git a/Cargo.toml b/Cargo.toml index 2414e6d1f91e56..ffce23f5969a01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -413,8 +413,8 @@ move-stackless-bytecode = { path = "external-crates/move/move-prover/bytecode" } move-symbol-pool = { path = "external-crates/move/move-symbol-pool" } move-abstract-stack = { path = "external-crates/move/move-abstract-stack" } -fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "6c17d6e5efb0a4d8c1b1b909ef38ee0b09eafa8b" } -fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "6c17d6e5efb0a4d8c1b1b909ef38ee0b09eafa8b", package = "fastcrypto-zkp" } +fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "4e7debce78340848f0009b648f56d912d6bd02d5" } +fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "4e7debce78340848f0009b648f56d912d6bd02d5", package = "fastcrypto-zkp" } # anemo dependencies anemo = { git = "https://github.com/mystenlabs/anemo.git", rev = "0f0ae8d8f222820a20b586088ea7a2941478a159" } diff --git a/crates/sui-core/src/signature_verifier.rs b/crates/sui-core/src/signature_verifier.rs index 24374643abaffd..b4cc392b125096 100644 --- a/crates/sui-core/src/signature_verifier.rs +++ b/crates/sui-core/src/signature_verifier.rs @@ -99,8 +99,8 @@ pub struct SignatureVerifier { /// very cheaply. oauth_provider_jwk: RwLock>, - /// A list of supported providers for ZKLogin and the environment (prod/test) the code runs in. - zk_login_params: RwLock, + /// Params that contains a list of supported providers for ZKLogin and the environment (prod/test) the code runs in. + zk_login_params: ZkLoginParams, queue: Mutex, pub metrics: Arc, @@ -136,10 +136,10 @@ impl SignatureVerifier { oauth_provider_jwk: Default::default(), queue: Mutex::new(CertBuffer::new(batch_size)), metrics, - zk_login_params: RwLock::new(ZkLoginParams { + zk_login_params: ZkLoginParams { supported_providers, env, - }), + }, } } @@ -320,11 +320,10 @@ impl SignatureVerifier { .is_verified(signed_tx.full_message_digest(), || { signed_tx.verify_epoch(self.committee.epoch())?; let oauth_provider_jwk = self.oauth_provider_jwk.read().clone(); - let zklogin_params = self.zk_login_params.read().clone(); let aux_data = VerifyParams::new( oauth_provider_jwk, - zklogin_params.supported_providers, - zklogin_params.env, + self.zk_login_params.supported_providers.clone(), + self.zk_login_params.env.clone(), ); signed_tx.verify_message_signature(&aux_data) }) diff --git a/crates/sui/src/keytool.rs b/crates/sui/src/keytool.rs index f7ee259e40c7c9..b2ed1f3297ece4 100644 --- a/crates/sui/src/keytool.rs +++ b/crates/sui/src/keytool.rs @@ -11,7 +11,7 @@ use fastcrypto::traits::{KeyPair, ToFromBytes}; use fastcrypto_zkp::bn254::utils::get_oidc_url; use fastcrypto_zkp::bn254::zk_login::{AddressParams, OIDCProvider}; use json_to_table::{json_to_table, Orientation}; -use num_bigint::{BigInt, Sign}; +use num_bigint::BigUint; use rand::rngs::StdRng; use rand::SeedableRng; use rusoto_core::Region; @@ -179,7 +179,7 @@ pub enum KeyToolCommand { Unpack { keypair: SuiKeyPair }, /// Given the max_epoch, generate an OAuth url, ask user to paste the redirect with id_token, call salt server, then call the prover server, - /// create a test transaction, use the ephemeral key to sign and execute it with a serialized zklogin signature. + /// create a test transaction, use the ephemeral key to sign and execute it by assembling to a serialized zkLogin signature. ZkLoginSignAndExecuteTx { #[clap(long)] max_epoch: EpochId, @@ -712,14 +712,14 @@ impl KeyToolCommand { let mut eph_pk_bytes = vec![pk.flag()]; eph_pk_bytes.extend(pk.as_ref()); - let kp_bigint = BigInt::from_bytes_be(Sign::Plus, &eph_pk_bytes); + let kp_bigint = BigUint::from_bytes_be(&eph_pk_bytes); println!("Ephemeral pubkey (BigInt): {:?}", kp_bigint); let jwt_randomness = if fixed { "100681567828351849884072155819400689117".to_string() } else { let random_bytes = rand::thread_rng().gen::<[u8; 16]>(); - let jwt_random_bytes = BigInt::from_bytes_be(Sign::Plus, &random_bytes); + let jwt_random_bytes = BigUint::from_bytes_be(&random_bytes); jwt_random_bytes.to_string() }; println!("Jwt randomness: {jwt_randomness}"); diff --git a/crates/sui/src/zklogin_commands_util.rs b/crates/sui/src/zklogin_commands_util.rs index 5d34c7a2b19363..915878fccf307f 100644 --- a/crates/sui/src/zklogin_commands_util.rs +++ b/crates/sui/src/zklogin_commands_util.rs @@ -1,12 +1,12 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 +use anyhow::anyhow; use fastcrypto::traits::EncodeDecodeBase64; use fastcrypto_zkp::bn254::utils::get_enoki_address; -use fastcrypto_zkp::bn254::zk_login::ZkLoginInputs; +use fastcrypto_zkp::bn254::utils::{get_proof, get_salt}; use regex::Regex; use reqwest::Client; -use serde::Deserialize; use serde_json::json; use shared_crypto::intent::Intent; use std::io; @@ -21,8 +21,6 @@ use sui_types::transaction::Transaction; use sui_types::zk_login_authenticator::ZkLoginAuthenticator; const GAS_URL: &str = "http://127.0.0.1:9123/gas"; -const SALT_SERVER_URL: &str = "http://salt.api-devnet.mystenlabs.com/get_salt"; -const PROVER_SERVER_URL: &str = "http://185.209.177.123:8000/test/zkp"; /// Read a line from stdin, parse the id_token field and return. pub fn read_cli_line() -> Result { @@ -56,55 +54,6 @@ pub(crate) async fn request_tokens_from_faucet(address: SuiAddress) -> Result<() Ok(()) } -/// Call the salt server to get the salt based on the given JWT token. -pub async fn get_salt(jwt_token: &str) -> Result { - let client = Client::new(); - let body = json!({ "token": jwt_token }); - let response = client - .post(SALT_SERVER_URL) - .json(&body) - .header("Content-Type", "application/json") - .send() - .await?; - let full_bytes = response.bytes().await?; - let res: GetSaltResponse = serde_json::from_slice(&full_bytes)?; - Ok(res.salt) -} - -/// Call the prover backend to get the zklogin inputs based on jwt_token, max_epoch, jwt_randomness, eph_pubkey and salt. -pub async fn get_proof( - jwt_token: &str, - max_epoch: EpochId, - jwt_randomness: &str, - eph_pubkey: &str, - salt: &str, -) -> Result { - let client = Client::new(); - let body = json!({ - "jwt": jwt_token, - "eph_public_key": eph_pubkey, - "max_epoch": max_epoch, - "jwt_randomness": jwt_randomness, - "subject_pin": salt, - "key_claim_name": "sub" - }); - let response = client - .post(PROVER_SERVER_URL.to_string()) - .header("Content-Type", "application/json") - .json(&body) - .send() - .await?; - let full_bytes = response.bytes().await?; - let get_proof_response: ZkLoginInputs = serde_json::from_slice(&full_bytes) - .map_err(|e| anyhow::anyhow!("json deser failed with bytes {:?}: {e}", full_bytes))?; - Ok(get_proof_response) -} - -#[derive(Deserialize)] -struct GetSaltResponse { - salt: String, -} - /// A helper function that performs a zklogin test transaction based on the provided parameters. pub async fn perform_zk_login_test_tx( parsed_token: &str, @@ -114,7 +63,9 @@ pub async fn perform_zk_login_test_tx( ephemeral_key_identifier: SuiAddress, keystore: &mut Keystore, ) -> Result { - let user_salt = get_salt(parsed_token).await?; + let user_salt = get_salt(parsed_token) + .await + .map_err(|_| anyhow!("Failed to get salt"))?; println!("User salt: {user_salt}"); let mut zk_login_inputs = get_proof( parsed_token, @@ -123,7 +74,8 @@ pub async fn perform_zk_login_test_tx( kp_bigint, &user_salt, ) - .await?; + .await + .map_err(|_| anyhow!("Failed to get salt"))?; println!("ZkLogin inputs:"); println!("{:?}", serde_json::to_string(&zk_login_inputs).unwrap()); zk_login_inputs.init()?;