Skip to content

Commit

Permalink
Proving key bundle (#261)
Browse files Browse the repository at this point in the history
* proving dir

Signed-off-by: Apokalip <simeon@manta.network>

* Fixing proving paths

Signed-off-by: Apokalip <simeon@manta.network>

* Fixing Mac Installation

Signed-off-by: Apokalip <simeon@manta.network>

* fmt

Signed-off-by: Apokalip <simeon@manta.network>

* fmt

Signed-off-by: Apokalip <simeon@manta.network>

* fmt

Signed-off-by: Apokalip <simeon@manta.network>

* Fixing proving keys for test server runs

Signed-off-by: Apokalip <simeon@manta.network>

* println removal

Signed-off-by: Apokalip <simeon@manta.network>

Signed-off-by: Apokalip <simeon@manta.network>
  • Loading branch information
Apokalip authored Jan 23, 2023
1 parent 9f709e6 commit dcb3c0e
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 20 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ derivative = { version = "2.2.0", default-features = false, features = ["use_cor
dirs-next = { version = "2.0.0", default-features = false }
futures = { version = "0.3.17", default-features = false, features = ["alloc"] }
http-types = { version = "2.12.0", default-features = false }
manta-accounting = { git = "https://github.com/manta-network/manta-rs", default-features = false, features = ["cocoon-fs"] }
manta-crypto = { git = "https://github.com/manta-network/manta-rs", default-features = false, features = ["getrandom"] }
manta-parameters = { git = "https://github.com/manta-network/manta-rs", default-features = false, features = ["download"] }
manta-pay = { git = "https://github.com/manta-network/manta-rs", default-features = false, features = ["bs58", "groth16", "serde", "wallet", "network", "parameters"] }
manta-util = { git = "https://github.com/manta-network/manta-rs", default-features = false }
manta-accounting = { git = "https://github.com/manta-network/manta-rs", rev = "c3a9c7472021bfc5d46bea75b03a38aa2da4c41d", default-features = false, features = ["cocoon-fs"] }
manta-crypto = { git = "https://github.com/manta-network/manta-rs", rev = "c3a9c7472021bfc5d46bea75b03a38aa2da4c41d", default-features = false, features = ["getrandom"] }
manta-parameters = { git = "https://github.com/manta-network/manta-rs", rev = "c3a9c7472021bfc5d46bea75b03a38aa2da4c41d", default-features = false, features = ["download"] }
manta-pay = { git = "https://github.com/manta-network/manta-rs", rev = "c3a9c7472021bfc5d46bea75b03a38aa2da4c41d", default-features = false, features = ["bs58", "groth16", "serde", "wallet", "network", "parameters"] }
manta-util = { git = "https://github.com/manta-network/manta-rs", rev = "c3a9c7472021bfc5d46bea75b03a38aa2da4c41d", default-features = false }
parking_lot = { version = "0.12.1", default-features = false }
password-hash = { version = "0.4.2", default-features = false, features = ["alloc"] }
reqwest = { version = "0.11.11", default-features = false, features = ["json"] }
Expand Down
50 changes: 36 additions & 14 deletions src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

// TODO: Report a more informative error.

use manta_parameters::{Download, Get};
use manta_parameters::Get;
use manta_pay::{config, parameters::load_transfer_parameters, signer::base::SignerParameters};
use manta_util::codec::{Decode, IoReader};
use std::{
fs::{self, File},
path::Path,
path::{Path, PathBuf},
};

/// Loads the [`SignerParameters`] from the Manta SDK.
Expand All @@ -39,24 +39,46 @@ where
directory.push("testnet");
directory.push("proving");
fs::create_dir_all(&directory).ok()?;
let mint = directory.join("to-private.dat");
manta_parameters::pay::testnet::proving::ToPrivate::download_if_invalid(&mint).ok()?;
let private_transfer = directory.join("private-transfer.dat");
manta_parameters::pay::testnet::proving::PrivateTransfer::download_if_invalid(
&private_transfer,
)
.ok()?;
let reclaim = directory.join("to-public.dat");
manta_parameters::pay::testnet::proving::ToPublic::download_if_invalid(&reclaim).ok()?;
let parameters = load_transfer_parameters();
let mut exec_dir =
std::env::current_exe().expect("Could not get Manta Signer executable file directory");
exec_dir.pop();

// MacOs installation puts assets in another folder "Resources" compared to Win/Linux Installations
let mut directory_check = PathBuf::from(&exec_dir).join("proving");
// check for test server and MacOs installation folder hierachy discrepancy relative to Win/Ubuntu
if !directory_check.is_dir() {
exec_dir.pop();
directory_check = PathBuf::from(&exec_dir).join("proving");

if !directory_check.is_dir() {
exec_dir.push("Resources");
}
}
// use absolute paths for release
let mut to_private = PathBuf::from(&exec_dir);
to_private.push("proving/to-private.lfs");

let mut private_transfer = PathBuf::from(&exec_dir);
private_transfer.push("proving/private-transfer.lfs");

let mut to_public = PathBuf::from(&exec_dir);
to_public.push("proving/to-public.lfs");

Some(SignerParameters {
proving_context: config::MultiProvingContext {
to_private: config::ProvingContext::decode(IoReader(File::open(mint).ok()?)).ok()?,
to_private: config::ProvingContext::decode(IoReader(
File::open(to_private).expect("Could not read to_private.lfs"),
))
.ok()?,
private_transfer: config::ProvingContext::decode(IoReader(
File::open(private_transfer).ok()?,
File::open(private_transfer).expect("Could not read private_transfer.lfs"),
))
.ok()?,
to_public: config::ProvingContext::decode(IoReader(
File::open(to_public).expect("Could not read to_public.lfs"),
))
.ok()?,
to_public: config::ProvingContext::decode(IoReader(File::open(reclaim).ok()?)).ok()?,
},
parameters,
})
Expand Down
Binary file added ui/src-tauri/proving/private-transfer.lfs
Binary file not shown.
Binary file added ui/src-tauri/proving/to-private.lfs
Binary file not shown.
Binary file added ui/src-tauri/proving/to-public.lfs
Binary file not shown.
4 changes: 3 additions & 1 deletion ui/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"icons/128x128@2x.png",
"icons/icon.ico"
],
"resources": [],
"resources": [
"proving/*"
],
"externalBin": [],
"copyright": "Copyright 2019-2022 Manta Network",
"category": "DeveloperTool",
Expand Down

1 comment on commit dcb3c0e

@vercel
Copy link

@vercel vercel bot commented on dcb3c0e Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.