Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
pacu committed Jan 6, 2025
1 parent 045fc9f commit a38cc14
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 97 deletions.
55 changes: 20 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ tokio-util = { version = "0.7", optional = true }
tui-logger = { version = "0.14", optional = true, features = ["tracing-support"] }

# Ledger Support
ledger-zcash = { git = "https://github.com/zecdev/ledger-zcash-rs.git", rev = "a37982096abade5adf0151d92ee1879ca053c085", optional = true }
ledger-zcash = { git = "https://github.com/zecdev/ledger-zcash-rs.git", rev = "d12c85b7b2d12bd860cee55fc79cb46330259c56", optional = true }
zx-bip44 = { version = "0.1.0", optional = true }
redjubjub = { version = "0.7", optional = true }
ledger-transport = { version = "0.11", optional = true }
Expand Down Expand Up @@ -116,4 +116,20 @@ ledger-support = [
]

[patch.crates-io]
sapling-crypto = { git = "https://github.com/pacu/sapling-crypto.git", rev = "cca6c3ccdadd3ed14ed4900aa50d350e9bcac300" }
sapling-crypto = { git = "https://github.com/pacu/sapling-crypto.git", rev = "09320f2fb1d058185d5a739325e4b893b0012955" }
redjubjub = { git = "https://github.com/ZcashFoundation/redjubjub", rev = "1cf76ae8c02ec0b2627e20b60df526641d40c942" }

equihash = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
orchard = { git = "https://github.com/zcash/orchard.git", rev = "4fa6d3b549f8803016a309281404eab095d04de8" }
pczt = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }

transparent = { package = "zcash_transparent", git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_address = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_client_backend = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_client_sqlite = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_encoding = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_keys = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_primitives = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_proofs = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zcash_protocol = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
zip321 = { git = "https://github.com/zcash/librustzcash.git", rev = "9c6d1b958bd015f3fc3f8d5e5815b2bfc54e484b" }
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "stable"
components = [ "clippy", "rustfmt" ]
channel = "1.81"
components = [ "clippy", "rustfmt", "rust-src" ]
65 changes: 7 additions & 58 deletions src/commands/wallet/init_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,69 +106,18 @@ impl Command {

println!("Device ID {:?}", ledger_id);

println!("get FullViewingKey ");
// get FVK
let mut fvk_bytes = app.get_fvk(0x8000_0000)
println!("get UnifiedFullViewingKey ");
// get UFVK
let mut ufvk_raw = app.get_ufvk(0)
.await
.map_err(anyhow::Error::new)?;

let mut dk_bytes = app.get_dk(0x8000_0000)
.await
.map_err(anyhow::Error::new)?;
// // get parts according to https://github.com/Zondax/ledger-zcash/blob/main/docs/APDUSPEC.md
// // let mut ak_bytes = [0u8; AK_SIZE];
// // ak_bytes.copy_from_slice(&fvk_bytes[0..AK_SIZE]);

// // let mut nk_bytes = [0u8; NSK_SIZE];
// // nk_bytes.copy_from_slice(&ak_bytes[AK_SIZE..(AK_SIZE + NSK_SIZE)]);

// // let mut ovk_bytes = [0u8; NSK_SIZE];
// // ovk_bytes.copy_from_slice(&fvk_bytes[(AK_SIZE + NSK_SIZE)..(AK_SIZE + NSK_SIZE + OVK_SIZE)]);


// // let ak = match SpendValidatingKey::from_bytes(&ak_bytes) {
// // Some(s) => s,
// // None => return Err(anyhow!("Failed to parse SpendValidatingKey from bytes")),
// // };

// // let nk = NullifierDerivingKey::from_bytes(nk_bytes);

// let vk = ViewingKey { ak, nk };
println!("Create FVK from bytes");
let mut buffer = &fvk_bytes[..];
let fvk = FullViewingKey::read(buffer)
.map_err(anyhow::Error::new)?;


println!("FVK {:?}",fvk_bytes);
println!("FVK {:?}",fvk);

println!("Get Diverisifier Key");
let dk = DiversifierKey::from_bytes(dk_bytes);
println!("DK {:?}",dk_bytes);

// Create a slice that contains the FVK + DK so we can create a Diversifiable FVK
// from bytes
let mut dfvk_bytes = [0u8; FVK_SIZE + DK_SIZE];

dfvk_bytes[..FVK_SIZE].copy_from_slice(&fvk_bytes);
dfvk_bytes[FVK_SIZE..FVK_SIZE + DK_SIZE].copy_from_slice(&dk_bytes);


let dfvk = DiversifiableFullViewingKey::from_bytes(&dfvk_bytes)
.expect("Unable to create Sapling Diversifiable Full Viewing Key");


let path = BIP44Path::from_string("m/44'/133'/0'/0/0")
.map_err(|_|anyhow!("Error mapping path m/44'/133'/0/0"))?;

// Obtain Transparent PubKey
let t_pubkey = app.get_address_unshielded(&path, false)
.await
.map_err(anyhow::Error::new)?;
let dfvk = DiversifiableFullViewingKey::from_bytes(&ufvk_raw.dfvk)
.expect("Unable to create Sapling Diversifiable Full Viewing Key");

println!("got transparent address {:?}", t_pubkey.address);
let pub_key_bytes = PublicKeyBytes::from(t_pubkey.public_key);

let pub_key_bytes = PublicKeyBytes::from(ufvk_raw.transparent);

let mut account_pub_key_bytes = [0u8; 65];

Expand Down

0 comments on commit a38cc14

Please sign in to comment.