Skip to content

Commit

Permalink
Build sapling parameters into zebrad
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Oct 23, 2023
1 parent b04cca9 commit 7af3701
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 8 deletions.
51 changes: 51 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4916,6 +4916,56 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"

[[package]]
name = "wagyu-zcash-parameters"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955763984e7d1e7bfb1d796c6ec303913a288c138774fa67a86cdf4f2adad08b"
dependencies = [
"wagyu-zcash-parameters-1",
"wagyu-zcash-parameters-2",
"wagyu-zcash-parameters-3",
"wagyu-zcash-parameters-4",
"wagyu-zcash-parameters-5",
"wagyu-zcash-parameters-6",
]

[[package]]
name = "wagyu-zcash-parameters-1"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30f179c3951340a68e6ae2d00add39ed72263fd99f6693b399b1ae0ea4dca6f1"

[[package]]
name = "wagyu-zcash-parameters-2"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e08a39cf68902082af6fb8129cbfe5f100c731cf1e4c49a81e456146249fb21"

[[package]]
name = "wagyu-zcash-parameters-3"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f1ae3f133131bfb34ee27c0749fe79c310a766a3370ce676908a7e3d3987512"

[[package]]
name = "wagyu-zcash-parameters-4"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "049f697efaa5fcded7e43f8095c359325b7f92371e147530397917dd6d32b23c"

[[package]]
name = "wagyu-zcash-parameters-5"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80adeea7cd72a33e72e4093f17c211df54b221cc047ad6c3a64ac3a8542617a8"

[[package]]
name = "wagyu-zcash-parameters-6"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ad468482ce2ea9fc0bbe80c729f628b2f729fa2ec10c7d95b0b60fd7f4658c9"

[[package]]
name = "wait-timeout"
version = "0.2.0"
Expand Down Expand Up @@ -5516,6 +5566,7 @@ dependencies = [
"tracing-error",
"tracing-futures",
"tracing-subscriber",
"wagyu-zcash-parameters",
"zcash_proofs",
"zebra-chain",
"zebra-node-services",
Expand Down
2 changes: 2 additions & 0 deletions zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ tracing-futures = "0.2.5"

orchard = "0.6.0"

# TODO: remove local-prover and download-params when sprout is built into the binary
zcash_proofs = { version = "0.13.0-rc.1", features = ["local-prover", "multicore", "download-params"] }
wagyu-zcash-parameters = "0.1.0"

tower-fallback = { path = "../tower-fallback/", version = "0.2.41-beta.6" }
tower-batch-control = { path = "../tower-batch-control/", version = "0.2.41-beta.6" }
Expand Down
28 changes: 20 additions & 8 deletions zebra-consensus/src/primitives/groth16/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,43 @@ impl Groth16Parameters {
let sapling_output_path = params_directory.join(zcash_proofs::SAPLING_OUTPUT_NAME);
let sprout_path = params_directory.join(zcash_proofs::SPROUT_NAME);

// TODO: remove sapling download when sprout is also built into the binary.
Groth16Parameters::download_sapling_parameters(&sapling_spend_path, &sapling_output_path);
Groth16Parameters::download_sprout_parameters(&sprout_path);

// TODO: if loading fails, log a message including `failure_hint`
// TODO: remove file load when sprout is also built into the binary.
tracing::info!("checking and loading Zcash Sapling and Sprout parameters");
let parameters = zcash_proofs::load_parameters(
let file_parameters = zcash_proofs::load_parameters(
&sapling_spend_path,
&sapling_output_path,
Some(&sprout_path),
);

let (sapling_spend_bytes, sapling_output_bytes) =
wagyu_zcash_parameters::load_sapling_parameters();

// TODO: add sprout bytes here
let bin_parameters = zcash_proofs::parse_parameters(
sapling_spend_bytes.as_slice(),
sapling_output_bytes.as_slice(),
None,
);

let sapling = SaplingParameters {
spend: parameters.spend_params,
spend_prepared_verifying_key: parameters.spend_vk,
output: parameters.output_params,
output_prepared_verifying_key: parameters.output_vk,
spend: bin_parameters.spend_params,
spend_prepared_verifying_key: bin_parameters.spend_vk,
output: bin_parameters.output_params,
output_prepared_verifying_key: bin_parameters.output_vk,
};

// TODO: remove sprout extract when sprout is also built into the binary.
let sprout = SproutParameters {
joinsplit_prepared_verifying_key: parameters
joinsplit_prepared_verifying_key: file_parameters
.sprout_vk
.expect("unreachable code: sprout loader panics on failure"),
};

tracing::info!("Zcash Sapling and Sprout parameters downloaded and/or verified");
tracing::info!("Zcash Sapling and Sprout parameters loaded and verified");

Groth16Parameters { sapling, sprout }
}
Expand Down

0 comments on commit 7af3701

Please sign in to comment.