diff --git a/rust/apps/zcash/src/pczt/parse.rs b/rust/apps/zcash/src/pczt/parse.rs index 7e75bc5c0..233c767bd 100644 --- a/rust/apps/zcash/src/pczt/parse.rs +++ b/rust/apps/zcash/src/pczt/parse.rs @@ -5,6 +5,7 @@ use alloc::{ }; use zcash_vendor::{ orchard::{ + self, keys::{EphemeralKeyBytes, FullViewingKey, OutgoingViewingKey}, note::{Memo, Note, Nullifier, Rho}, note_encryption::OrchardDomain, @@ -74,13 +75,7 @@ pub fn parse_pczt( ufvk: &UnifiedFullViewingKey, pczt: &Pczt, ) -> Result { - let parsed_orchard = parse_orchard( - seed_fingerprint, - ufvk.orchard().ok_or(ZcashError::InvalidDataError( - "orchard is not present in ufvk".to_string(), - ))?, - &pczt.orchard(), - )?; + let parsed_orchard = parse_orchard(seed_fingerprint, ufvk, &pczt.orchard())?; let parsed_transparent = parse_transparent(seed_fingerprint, &pczt.transparent())?; @@ -217,7 +212,7 @@ fn parse_transparent_output( fn parse_orchard( seed_fingerprint: &[u8; 32], - fvk: &FullViewingKey, + ufvk: &UnifiedFullViewingKey, orchard: &pczt::orchard::Bundle, ) -> Result, ZcashError> { let mut parsed_orchard = ParsedOrchard::new(vec![], vec![]); @@ -231,7 +226,7 @@ fn parse_orchard( parsed_orchard.add_from(parsed_from); } } - let parsed_to = parse_orchard_output(fvk, &action)?; + let parsed_to = parse_orchard_output(ufvk, &action)?; //none dummy output: not my output or the amount it not 0 if !parsed_to.get_visible() || parsed_to.get_amount() != 0 { @@ -274,7 +269,7 @@ fn parse_orchard_spend( } fn parse_orchard_output( - fvk: &FullViewingKey, + ufvk: &UnifiedFullViewingKey, action: &pczt::orchard::Action, ) -> Result { let output = action.output().clone(); @@ -287,63 +282,74 @@ fn parse_orchard_output( let cv = action.cv_net().clone(); let enc_ciphertext = output.enc_ciphertext().clone().try_into().unwrap(); let out_ciphertext = output.out_ciphertext().clone().try_into().unwrap(); + let fvk = ufvk.orchard().ok_or(ZcashError::InvalidDataError( + "orchard is not present in ufvk".to_string(), + ))?; + let external_ovk = fvk.to_ovk(zcash_vendor::zip32::Scope::External).clone(); let internal_ovk = fvk.to_ovk(zcash_vendor::zip32::Scope::Internal).clone(); - //it is external output - if let Some((note, address, memo)) = decode_output_enc_ciphertext( - &external_ovk, - &rho, - &epk, - &cmx, - &cv, - &enc_ciphertext, - &out_ciphertext, - )? { - let zec_value = format_zec_value(note.value().inner() as f64); - let ua = unified::Address(vec![Receiver::Orchard(address.to_raw_address_bytes())]) + let transparent_internal_ovk = ufvk + .transparent() + .map(|k| orchard::keys::OutgoingViewingKey::from(k.internal_ovk().as_bytes())); + + let decode_output = |vk: OutgoingViewingKey| { + if let Ok(Some((note, address, memo))) = decode_output_enc_ciphertext( + &vk, + &rho, + &epk, + &cmx, + &cv, + &enc_ciphertext, + &out_ciphertext, + ) { + let zec_value = format_zec_value(note.value().inner() as f64); + let ua = unified::Address::try_from_items(vec![Receiver::Orchard( + address.to_raw_address_bytes(), + )]) + .unwrap() .encode(&NetworkType::Main); - let memo = decode_memo(memo); - Ok(ParsedTo::new( - ua, - zec_value, - note.value().inner(), - false, - true, - memo, - )) - } else if let Some((note, address, memo)) = decode_output_enc_ciphertext( - &internal_ovk, - &rho, - &epk, - &cmx, - &cv, - &enc_ciphertext, - &out_ciphertext, - )? { - let zec_value = format_zec_value(note.value().inner() as f64); - let ua = unified::Address(vec![Receiver::Orchard(address.to_raw_address_bytes())]) - .encode(&NetworkType::Main); - let memo = decode_memo(memo); - Ok(ParsedTo::new( - ua, - zec_value, - note.value().inner(), - true, - true, - memo, - )) - } else { - Ok(ParsedTo::new( - "Unknown Address".to_string(), - "Unknown Value".to_string(), - 0, - false, - false, - None, - )) + let memo = decode_memo(memo); + Some(ParsedTo::new( + ua, + zec_value, + note.value().inner(), + false, + true, + memo, + )) + } else { + None + } + }; + + let mut keys = vec![external_ovk, internal_ovk]; + + if let Some(ovk) = transparent_internal_ovk { + keys.push(ovk); } -} + let mut parsed_to = None; + + for key in keys { + let output = decode_output(key.clone()); + match output { + Some(output) => { + parsed_to = Some(output); + break; + } + None => continue, + } + } + + Ok(parsed_to.unwrap_or(ParsedTo::new( + "Unknown Address".to_string(), + "Unknown Value".to_string(), + 0, + false, + false, + None, + ))) +} fn decode_memo(memo_bytes: [u8; 512]) -> Option { let first = memo_bytes[0]; @@ -424,7 +430,7 @@ mod tests { #[test] fn test_decode_pczt_2() { - let hex_str = "50435a5401000000058ace9cb502d5a09cc70c0100eae5a70185010001227a636173685f636c69656e745f6261636b656e643a70726f706f73616c5f696e666f148c3b8fdb49a840dbade76e60189071b1c2e5a701019a03f6b13fb77ed0555fe488da3699921bac7e03d21b461169e0e6cf8fba9d330000000000e091431976a914ef2c6cc589f3ad61071f6ea56736831faf06e16c88ac0000010102b96236741e1bba262a0a052335f4b131f2d6fa241592f0e48551dd2fa5b722d81b290d0b4449383e1f899dab47bfa689794f15673c4bba95eed10e14ca5aa95305ac80808008858180800880808080080000000000000000000000fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e0100000000000000000000000000000000000000000000000000000000000000000258d9709079df9e036e6a34c66c2308ec2a7ae8ae062b966285268c29ec88eeb11b0063aeef9143d3e5c3d1a80b7b59c6732c750dc96539e794e36bc779b86a29c168b1777845e05cf141d25191532e9170105b396a8f989d90601c2615252f8c01ac9ee8f91404fad8a5d58396537511bb88263f922bd8d850929621339c04c594f0c280bf665161d2b97b118f711688d49e2c447d5a00df9c6d3890823061351001e0c3163c6b21a98c0bbe65c57696965cda66fac4198cb3c6dae64432f23b1764657d6d2da0a2cbfaf89c930100018df94357b3886c5b95a00c2c95defb13af982b9c1919979a947be6512009731b019871da2ff5c38b8d7fa97712fbe30b519cd5da9693e05b4522540659f1ce69ef01008dd48ae6bf31b1d26f9c72c17dbaa0bea35af1effd7ad55bf85b69a578e91832ce0310a818a46f3f97ac73230b43a52e52db1e7209a9202c222501e5887d346b94101e390e327350124bce2fdd7dc11fef667c38ec0c1be6fa2b3d64b84112018ce0ed880a8963057601ed691f863510ecf483c583d6ee2cc34f88bfff3680af4585f572319007aced6fb162a7651ff3f70c9493cbc704814174846a7478fdbb6577656e3b5806b22a3d28fdd9d41997e199ecbbe8318e408afa4f5a5afcedd3372155bf3d1760cd6a42bc78426842572737fc1baffcf43ab16a66af31c44c3ed957011a19d97c43ba6fc433709cd762bb70ac9fa71e9300c29c84ae8bbb718f420f8fe919589f9c84f4e0343bb76c3d539025873839627a9e16c27bdd5b15bb411e8c8b2e1a0a587a704e471780d547ce3785afdb86a747a26ab18093220f88571d043637cd2d26f79ce358a0a95444e3f9668bf94f51edd9ed6e6814f9fea61bbe5e443746a2fa632fb33a6a6f6209bceb200db848d97621407169d55a1f7bd7284f26316c345900cb15410cd068ae0c11063d8024c17431e09b3ce2666357865904752f8300a2ec40d930b054fca369b802fd3dd9cf6a7db8bfa52ff455e4ce6cf20a2abb0bebf9fdb3aeeeeae45d0b7b41b68491b0f7c75a11f74af7600191d093823ba2e8939b3dc05ce7973d923c39541bade04ae8fdbd1708fa60652cc43d34f52483b02edb9d3c5f4d3af6080987fa8f1f08f54f243b29c92496576035c96f1a23fc9ba38e3f19194a2b854e310f49289340d27c404367ee3184f76d7b74f9600a363f1de5a375728a1199569c78852b1e1e3dea47d7d58d2d5a2fb7940d055709823ca9edbef7e9ff18e6afa5a074bef578312a7366cd6f185644f86b2619190d5fe5a9c38988892bb8df8b27ce3a8c52737856eceff5bc9205522388715eac0d29b6f25771a38f2fd6c35292df760d8b674faa519407ae3d2c3ec3b8e10654336b56884bcec86f65358f52e715946abc6147aad7875834d2ff3e35740d7ce62acd084aea23065cb74c9db4a3440b8e51b6956cf0360e43e8b73a760d31216d3f4954f4ae50d5b51fb9a9144ed95599012af253f82229d1d27b3bbaa7c448b916517f9377084985101f79dedee7933ab783a271f31e9439e4ac827854065d3032b93f115b1c88ee2591283edfa11b6284104e7307ff036c0a5417c7f57dd5682683fc6ab0b92ac30989cadc01fa74dffe632c22e108b5f7f23906eb9e62b9bf046be8613ce57f14cf2d488724e8fd8c804e0b7b7b46537f18d061fb6b986a241b4f7975673dfeadc48c357771fec7377b1e760c5a1e430ff28a3f86440e97d52dfd6c1a35e45ee8b3ba36abd928c6a082ce014b1aa8674503e499008535992926fb111c2f5a7ad6b25cf2e8d89700606eaf97616a95ea1ba16282ff374447f41fc4fd745ecb7513fda1e43bff4206f1cff72418314c92a806eb179389c7994834c9b29a16b0b59577358fffd72281adaef823e7cfdf4e86597b0cccba6495f13e78bcfc39bec4bd79ce9cd4797b40ec43e4616c8b535528241e55eda9ccd32722013b85bc9cc5ef0efd694f3ba9312ef14f5058062bed5efea32c01005085da023e0000001a223282647ce65868668f2fec970a918cb2a09031ef3b396724b7fa868ee01dfe866f4ba1dbe4ca87c97ad544d0221ee155b3529684806e44db6fd118c7b0b7c4042b6b9aa254a8cb9cdf4f346a6576b45a724829e93eb56ded7c6b201ab285cd4d03fbff8717d58865b3918737f2dd15ed621b9fd1e11367e285e95565eb3eefb01aa6b22e0dc722da4230b5dd1f08ff5bdc5b8b9187121117925e1ddf33eebc1327bfc8945133b5a3fa7f692137665e109d9513dddd08369cf0cd8b4af2b829c89de5d5794a628e4544460751fcc3e2c996cf3dd82bf7c9b50062c28ee8143328bb9a452626fb4cdbc1aa714f4cab7e217b73df02ecc5d1326d5516eaa0d688c60f415eff55a9aa5ed80e4b7feb138dcd62edb3fe9ed945cfb910ce08ebf0f6278d5da4e020c18b1d1e6dbadf255e192d0589bf7f7ec005420454b4a5c635aa7d32e0f46393d53b9a288f437f986914b0510a7ecd3c5617da11db57d34b891ab40f791c373c2a083ad5ed8b3d494f6c2fe7b5ea5b5bb4c6f0c7296386130a2584bf4ce7aedb1d41625a30fac3ace085355cdf0071fc542e2f73e9cf054521d8578b2c8a3a3806b182fdb6053a8a523cd4da561783d725e6244ea7aa99d4acd8d03ea5e9dcf2fcdbbea1ead681bb5b6d2fec606b392b3021f93b60b1722c7b9ffddce1a529187a1cd0b339be1d01de9535fdfb584d79523491310b648ad9c1188807f8313f6d49d3eb5a48cc4adbc6f31453ad1d7f45e08f7bacc8b2621d4602de45340d31b4b70923f5dd03e26ef6dc3fd1e5bbbd03a9f5e34cdb06650cfe21b4c3abc20db26c87805f8f877bfdcbe16b2a03ec72ace7a03163024c88058bbd0cd927c254e769071c6a5f2b0b2519532a811be033ef972e5c98780ba450e2fab3decc170250a5adeffd2c5f3f65a20d084e7347e8ad436409decfcc139602f2c977ff2f644eebecd2f456f0ae106514da38dcb7be70110e4765e4dbc957095ac60c6bd33db5ae9025500a357008e4310e0c87a40fde0118fb9315a97e2d4b6997f5b5dc702cd62033cb91f8a163a140aaef1eafe78640d52e841d99a0bf42a0872a010001e127c18fed42f37fd3fb23cd195ce275526ef50302b966b8a433db30abc6e51c00000001e48493f14723aa75ec32c8c13bb29454ab3c618d6575d55a7ab6bfc3dcfc273db0047fdf10e31858f636e034465958172a08936adc9be1e2fa28e8df8f0ae08dc53848c4f52c0773327dd97a2ce283cdde231abb2c58aab3097f733ce4fb8f340ca67db74731f466eba77d7d2ac537fb1fd3ac798f529f727e924bc31a51821701f937a200856fa5fa542e2f88d468be18cf8305af26f9a48d0e2305ac778a98be8a71eb9373fb8b9020f79aad548ccd60fdc2ff00fc460aeba30160dfec81480c01eef2be08fbd3e1e8a64068dfe795f2bc465b73ccb60b0e390dcc3a5f9fcab1d68675386ca795bfd6d6d28c0100011f3458af949a563b37b5af4de816156a2946644a6bdfffc53b1dda56dc34352f016d578975fd6af35c1e4e76dafb44d588eb59fcfab93a727f50e281ba95e27a4c01b777182305401beaf4719a50aeced58ebf6588c5436be4e98cfb247ca9b4670fa8ab53104256a644d5d5db5f24daa3ce579f1605ca57e8a69956229d9c73b40fc8097d4c5d2c5a810ec0baf6ec0ff48fac85a44310230759af10d1dda3b5ad3901b6c6af91049db394ebcb43a6470d3a228a49a57cb200a027432fb93ac148cad35d14afbd000de73bf27e12e6914acd86dfc958960de72e4000c956a326065783be51fa1c15aa45414f1d97146f8862dccedab3101a755616360bbab987bb73f4385c906c13ec01c3b9ba117c8489e1516202a2d779e9544718fbd304cce37b8f0e8057ce3d31a6c63cb79646cf1af3b93bee2324bed20b142b830e63f4e409fb9b8bc55a1d700d8f8fcf7b10dbabb671bb74e93e765aa56ca4fd1b5ccf7a54432490219b181415169765204828293278a32c84fb4d917b3cfe1d0c31cc5af44b0c05b8890e3893c6d3f8209ed42aba86b0343bd95fdfc69db115ad3bfeac2a396c8e9d250206ceec434a48eefbca667d873bb5e3633754d876f206495d4309428afcc5fd0cd73f862fcd0b7c0ba1a057c4d67ed76a7f51bc19d8ed246b05dec4b3b5127c22d0497f822906f26ba1f8f0255d82f0850b5cebbe7fbe13fbd482bcaf5791b104d907bee83b878bbd7dd3b17dc4e01e86feb687866570054b7843a8fdfdc3a6316f9738fd7702d2cab555b5432e2b2f04ca2126cc233ebbf59985651c0bc6b00eca3160e4e1b2a969671c90e446d31919ec78782dd7f10a1464a473b4bf4a8030c9a686adc4f7c4f220486e2f66f382b8b3cd24ef57f2abf82e1225369ff45b33221a006f551b3f4a42c18d4c2d1de58986dd495acb708768f361173021d20d068efdfd4c2ad2f987c1f25deb9352aaa2f01bb29e3cf59d8e032e898cdff68e0ed3dd7d2f940cbdeeccebce860829eba0b5c6497563c09b87acf070ceedca900cc3b929ac75697918446b25fe968c3b83269b9f4a10cd50756a77c98ccee4f90d8245539d0f277b1db49559a428988bbb8a95eb3ae4d167c6030db1063f7ca612276d1782c3259421986323caaca7448138bf887a4a31d9ddab2787f8c8a89139840b0ebecfa0cae07654a8219b4ea9a78030f30760e6b1429790b3024b7e243db83e3b1849523eee31660d2c49dd1e9d579717b5115c88edd726308d7ef94c3863531e1f2aadf9b0fc60d57e5c916dea8568addcb13df2b0e9a0b93598e517209b9b80e250b0a8945de8b7a1a5a68bc552b3e3016ab7ae7432b1995e22db86247371b558986b05b6238dc011be5876db1ebb09031e235c8ce53073633018dc37e7d34c5277150bf1e3d7c1287a8c3d3a94a58d84514071b1ec250a971f5e3b0437fd07a3b492f78d13aceaa0049e7354979b14c2226fc58f633e1e4312607d3137ba5d5c603482ac4ec04730ebd2a09fae15a142c5e425a5edb263dd76097b1ea345408b665ce1cc1c2b1ef7e27f2f005fc1e8c17268a29e50698e4776c9bd29917c8575af618181289a8f74e51d7fcae9b9c424a9c7536e923a656ef1db18084d540a419fc2bdad282e759f1919bc9f173d40fb5451f8c15d84a29e2ae3a42c017cee774d3e533b5269b35b274a24acc91e1e787778c2759bbc11fdaa5dc99a3d000000395dd461f8cdd44264e834175a5b1a0e5d23edb93c6e400dfc520b27a1b12f1434a95976168b7e3e3e76409a44ab98fb2e754b9fdfb88a7eb8a1be4a0c14fb83c4042e8400d46d582f83ebf1cc30622efe09702c3a58b00e60466a3808ba5e9990d78851d654168296ecedbc8b7b37df78b0aa9b2c08b9decbae868c082b002aef73ac73640a842e095baa7d58e2745e665c37d33d82b8e765603023458cccf4fa523d71941144be0cd9626caf057a2c83036f35f9b013028371fd9139fb4a5c7f156e35e1dad67b93b3aa2762d1e55687c6d7b38464628ce2d0a932d254d0c6d00bb4e859cc0b38f70946e51725daeff7d86fe3d058382f9c514891cb9470355f16bc5c9b4ba94ee071b6bc7a46c850c2b1120aa18d9527493716940ca9baff82bad3fe0d81a3e0bad63e5dccfb57b9e20a461fcf5a0cfbb4ff9575ac0d3c23124d239198a3105d5f897def65f584e1b1e7cb96703a242a1cf51839a60ffe738bd11f7930bbbef4fb5a1480db00812067063a8545dfd78d5c1943d45d6665458411d350b24cbc85f4e9a3b140a344ae0e14787838547b3ecde886ef470c4d12561e1ca8e6e9a24cb7353dc3055eba608528b012d04828f5e38a25ab478842f2b081bd4236de5f4a7d1332968589a72092193cae569ffb56a0e5f4c3bedf60caf4665f3dfc67bed7db9f8976b9ba75a818bf28eb00a1b220fdcadb4ddda8dc39b40ceb9ad2df37c52981433ab159da901d5eb3239d159cff393e931a2c82bd572da4ebfddfe6f9a7ba56e9be62da08d0fca327d40f8d2791c9dc3594ac941889180cb9cf7058aaa8d4f4f5bec3135920117773719cad754d326bce0cf1346351d0c426fdce833b16fb8b900f0bab684ff69b95fc0ea3995b46ec59f657a37b17a3613b60aa7c5069c40c79a74a6bdeb9d7bc3f0a51d49214a37e88a69fe44edbeac917e8e2805f43c6b07f9694bec6fc60ecd9d0f02b368642f8d325782e9f7a7e0b8ccb8c065d021419a59f6f30fbe614cdbdc6bf046e01a6e4300a17750f9a93b123a762950633fe0e507065c3443b147b14642b21823b57f468fc7d7579fe8bf68401c89c4201655e49b76964cf785f1dd759e877a2c178e0fe44c4a5b91688a88b0fae3d2a63000001207a636173685f636c69656e745f6261636b656e643a6f75747075745f696e666f12028c3b8fdb49a840dbade76e60189071b10001b70676bb468a16b2afaefc8e0833a0bea250e7516b2bb00c56238ced8f937e3103c89c4201ae2935f1dfd8a24aed7c70df7de3a668eb7a49b1319880dde2bbd9031ae5d82f00019a8b09ad6dc2799bbe383047484ceef04d8d48dfd0a08567d0d94bb16c90a62e"; + let hex_str = "50435a5401000000058ace9cb502d5a09cc70c0100c6eea70185010001227a636173685f636c69656e745f6261636b656e643a70726f706f73616c5f696e666f140cd612b51afd462f8b19e3edcaf791579eeea70101cc5a56912078cf9352b33c84818d1c78f23ea6b3f7119c2756fa52ccfdf28ac30000000000c0c393071976a9149517c77b7fcc08e66122dccb6ee6713eb7712d2b88ac000001010325d5b38ff44c279744d83c97f139878dc6837a9df74604982f326e87840898422fac20755b7bb7c99d302b782ea36f62a1b0cfe8d7d4d09a58e8ba5da26f457805ac80808008858180800880808080080000000000000000000000fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e0100000000000000000000000000000000000000000000000000000000000000000250d6b6180802fad46b531a41f8048a995dbdf97777e2bd9edfc2b9aeda6c07a9d8e871bdd1bd33d6156adfc6ba0e2dcf1b708c66ef342a181de1f2e47da4771a0a6dc894a6c882180a27f825febded2c33a12127935079e1989a9d087726823c016bf171d0ccb2dffc3c3b5deca68d85c69d1556894f04d639c21f0e95a8a0ce3385cf3636669f4fcf486cf5ec2b8d373ab2160652104721fa38ac23317d17160801abb7447651a41c23da5886b2472cd66b264f0f3c7b871a2f8a8940112abe039c3d4b9136bda4c9f56be72d010001ac75582207c74bbfa4923d1bf6b9be9e7d0930f15bd6bd3b5c274e01aef2493901320ca25f660cd8863e145fbbf6fd6e4b250ecf49df120f2aabaaa2105df1783701282e3514b060ab4ceba6058c47881907be43cd729177e53a21027e8860d55d334094e241d50c2ffabc846aa6300bc5d67ba26cbb3dc3f6d7affebdb3ff108b3d5660e985bcecfa5b79ec1c228b526bccc38906dd9b9275c30bacce17405ed62d01e2c8dac1035209145fd84981f6411055ab6fb767187d3c2e7d83f685880089cecf027a701f27da26e9626199889f332d235ba402ab59e6510aa8a11b9dd62262d08f9be800256ffbbf22544e0324c409f23cfae76dc04d15df6a8c580d539de3e7e0f13a17d37030072c68113e8a27c8feeb378a58aa846857c76cd108730414515ae58b3d39ec7f007641a577401873759d486071360cc0cfa13b399a7c1fa64516ada52f52d4c19905141f06a99eb61945ad498c1169c6302af0bd1b139fa4ea74f6243269fcf7aa3b01db4386071b151db4d2823787a0916d50b1aa63b2c816c85ebe397b4b9e67ea106e3fc1bfc2af656afcb596f9564cea2f72c9e7099554f629f10f8ede89681458684ddcb7eb2fd577ff3b4b7149c1e56f09189c32f5e93b46bf1fec65ac69cde16fd3d3aa64ac0013f01f654ecd8c60e585aa3fc7a50e39242823fe8abe83fdc86d39d32eae90e886f49eae8a02a9e42f3cca7e152e3a830dfa23ddea3b651ac7bfdac6e1f6994a5935d4ca3c703587d64dd3741abb5e2534493da90cfb207b642029301fc7de44b7f9fe9683144b575031237c6a85a883224d224af772686e90ae5718cabdc772c1a68a4efcc4eb3e866b4c071b90ab4865ae24d516b60cf06f3bab40795768bc59d9a9b13766b0ae3432cce7a1cfccd21ab702354f60e074a1506837d9d1d95df0ec9decd30d046591ec62d29436964508421c4e4df7039bc0b6507d8b35a9ee65aa0c2eebf0972f6ef54d4e50bb50512de2177d5802f37181fa553d46bc12cb173ef9f6729e7201f5012aa48d26b6628cb303d13ebba5563024bfcd5681581c48fb0ee8845a4ec8a1f2658b1260b63e9024025cff1da124bb641f2abe20fb7b8b00d946fd76025afbdb88e94516276ca4a30f2f212ec4c9ade8a5e26d8ec5d877b5c2cd21d814970140efcbd3eae570f9b6031241cb3af089f3822bce5facfb2ee41c159ff0c01325580a79d4755aba69c43a7e114d25b3f4c5acc400106ed5e4171260a43acb4d68784a2832689db227d6159129d5492deb33ffabb3d5c2302dcf0274805709d93b9684fa8e29f25a336b1053faea9b0c23959d8a0b7b663d0a64012f135ba18548540ec382e6bedc654c309e9ef791b8824c3f7a37f106e48be64acda154a7abd4e3d08987ac13a5bab41e8adb5405a6dec45a6abc98624fe92b6cf7ce9129e88e54a60c27ee9af76da21af0ac2989724bbfb368193c49dec64575d3016cf3e4a23017c14c75f6b526070e3b36384df1484c2e7f49d1e6e3b7080a35951df2d1d82acc19fc5c2874519820e26e6ca6975103e2248314b62cdb13e114f02568cff9f9d0dbbe0445c9391b210978416a06b847fb1c0afaebd3709fa3f587b51450641f9ec73ebda35040d01f24a55606420a5b89ca8bff7d990f83376cfffc75e561d6fa845b584852e631220117338761887479770d185e5bdc1076f8f24debbaa903a2097b0eacb18b123a00000000c4c3b827f46d95cac08efed6230bcb9d1934c9510a3849fbb246796f46301928bb373a65866878a40848d2151397078b1b307891a0480f0ea0af7c5d26d8132bc4040f4a736b4e631c3ce945e6ac1eaddfbb52007b29edac1c8a54289d7ade61fcd32cf4ab1baa7a0c759fda36c3caae7685a83c9e6e6feee53c8697a57df335e9239f6265bc2934667122a891468208211904444182140c1947c7b26cb8799445f63bf12608ff15349c3f4b90622f37821ae17784f53eb2287592ca40e1e3f19370a67b5e81a6c36a636681f50b1f6cec77dc3f3f0a2b129c3c79b4b88ccd22da870c1f7907a908036a3238e893a26a0448408c2deac7eb024cadb8098d7946d7b838f4225894603b6134dfec4393d30d7df04c319bf8a22b8ed4174d08eb39716fe994662251599d4ceddc10526540a5226c0d921e333002ade4102156164d897ee560447c63f572979d18daba882dd524ef358606f3b6cebd25939dcfb636e7cbf0a587f26a6922f491f73ed3bd33a6d31a96ee41d6566df473df6d4b915fdf30fac9ed50c3a109a228e8e11203368fb860ee365c6cb1f3d454ede35e4fb91c86d19b74eb47e5833c6ded6541b371d05e8e3a0744f28cf2223a06d119a68f8da2e914c71fa4042e1b2dc42318f18d7d2e4223ea8bffb17f0754e1c2fa3e0fbd8b181891e6338000ee9945b7c18438190146df465cd68d16ebb294b6dd58a4281ce4a466c6623d39b492c5a1a0d1d87f5cb2c07a28954852dcdc6721be4de9d79cd46cb1f626b7fa01e1d88a3a2bf89bd5f555ec877a39268156b2d915cb138d958de54287ceeeaab8d727031273785e4e45c964fe8a022b3829fe315ef5ecfabc35542c6fc1888701cb8d4f44eb235fcbf03abb7a743aa942daedc4bfe2eb2eb59c9d6a265042bb916da786457fae6b491ed5c2c364ebf8b7e58706be1816bf7ecabd056cf7a087cb49c6df364bdb380e3bf1cbd55f367089b953d1a781ac045883d0738ec9dc3d814af06e1c2aabea3cfec3dde9da0114b0cac3e14c4e1a4a4fd22c98563b9cbe859c67768a39f67abd5dbe55d3d16ff58e5c45b21d8c573f54b901a8ce92070184bfac62deb42faa0d8aae4312f6e5bb87d3fbf7f41e3ae973102911b15cdf18000001207a636173685f636c69656e745f6261636b656e643a6f75747075745f696e666f12020cd612b51afd462f8b19e3edcaf791570001e5d7d2a541e8a9dbd65430262fcbc3670b8e62bfc371cdbbb03aec8a56202812656652e733b4666631d0ac1863e1914ebfa94027390bf458fd5d4a0300dd9c03eafcb8deb7d8cb6395c581911b9289bc4401f3f76795d107ec8b30254f5527208d81eb51e9a8d9f5e81ed2112c9ae3420bb7057c57f0771b1a8b6af19fca848501181ae892cf374e2592ee04264ed88380162e5af0643f7ab3a74737423c06ff962df9a52b7af937d74f8223f0acf064d7b48799dfdf4973974b645bfc2bf4612f0173753e2dd70394bdd5ecaae04a88ce265a12b17136f31c9d79e33ed256020b26de133790bf8ae697d13d020100014f255bd407e80920d3bf46e4eb44f062bb4dca10053cb4fac2ed5a07b4f085370127f80f55bb75f8e36bea1672ee4e036fa92f93dd78c67d920b567b929295b23c01dca3fd69b33c66202184abb20819ad94b9fe65c07a9c8ec0a6a0cc80f9db0427aa298514d043a8cec61d3680986198df7f44935cfe8ffdb6ecdf782f2efce23c745a7545168a5d5593b4cb6141400706ebbab9e797a9fa9ce8faa0203c328e1401b6f389ff07c9b9554fc680e4553fca4f3c2b62d9a175b36458f54dcbd995d14246efaa5f115681ff4c53a1435fd7815ef46517389b046639b3158500b38deb057c9a4ac111b6b98075f84d4bb4c027ccbb2033728294767f8c3c242354b63064cd886cf20e60fe817b9a66d952bf6eb5a997cc23d79e9b6b93867edb5a9e69f6fac20b9d0c70c68497569ea7b8227df0a5ba6e68874ae2e9df5c2fec6ddea243478c98b60a86a344a09d02367d0ae4b3d49535c094f4245975dbd7542787601c97982564325c4a5bb4332fa79a976e71a1706bb0b0f59559ba55be2bab9386cda943c0d735d9ebcef6998d175ac66c4ab8fe9d2a1c0de31137d91568e13a54ac53d3e62e2c005a3c70c031308cdc233c624366b56e3d8407df2890e6083a30fc8224e25a1aa649784acd4cf525f564b87186eeb1359820b99c4b2bab239a6c79e82cf44c386fee4bf719a8c56a1df1bf028c52e1590a5e76e5bbcc435f7b71ca4726237c14c94ffc8a4a19d41798ee851cccf94b4e2a271dac766f51f10adc8abd343abf2793ef25180bcddda6c3ac63d22183805d97a8dfc7b9432e8a7a00220609b96d0ad8adf4bb6b07616239b530f9e384b15407b8d9d36f671aaddff6da610632df26175224cf0a55a0a543175884c37251c6fa82f9b974ca0fafcf0531b1e67e283eff4ab04652717cbf8c3fb5a205317090e6f687c51d7dc3b5bac8022ccfccc62a6ad2d713f459976ddcc620461bf25445da2e5611253ff575fa96df147506c33c9b5a97fcbf51d54b333430c61720cf720ef57094802dfb6304d8f98ca47b5a2aff93bcab58ee5d5e6c063ceb6faa12c7015d1fbfd084f9de3025ef87c14ee100ef093931e1d4bcc636909a557c472fde2d6568cc1698faeb95afa982b25de03317e88d60edc54a98c1e28f57f1f0bc41b29085d6ef4d44a5da8dfbc20a14881ea6c4e77e6eb9c4031753d201f610c395f070037b74c6ec6af37db29a53484c131fbe21e7acf5fb62009b6bbaccd7a99fc86782b8c0870ac3d421f9e4d16d6b275a38deb8873954197344926db5d131f7a8982e12bda39b082457992398bc063620b189d5479436a31d3bd693ae160a8448455a98e732a1b70325bbc74aca4a389dadff81a9466a90aecf4be59650b6291da62d6862adb94169d874c8a07c0d22137306eadc45a734195d2928291618778d06fd30c41de76cba30b3af42b42d0782638a9d801582bcd1964de6f5ad8aa4e4e770621995fb95932517204cdb5518bb5cd1fc51218c548d7f007b96e66148729eedf33783170de66b24184cef61180c5f04cc4a32a330f46383c1535089894abe84e742e99ee30746218f431683081fa5ad6c05fe91c3415a466c1008423572ab53f3f4bc71dd4ba4b4020b49993a37e4287b30b64069937d12502089dc08aa2936ead0b9700579eeae610906fb2d011fafcbe9f9662612883cfc9482ec528efcfe8599ad804b4d92e2df63ac61ae19000000e43a1fa07ee130fdcbe71433d461500caa3c5353eb8dd328f7ae59cc47efb70b52bf497498f1be83d007fcee95f16c67dbf2158646471f797b2ef14a33ed670cc404fcf32b8638f93c13d65d32b5c2c6ad095ed997c001ef9437b0d25a042e479fd3e61d7ba6f8764d1754ba6855586aeb831210e9997a5a7c2b257b86c5c9d8c347a27e21be3235c35716ebe211ff56f5eac5fa8b6e4e2dab0b4f97918defea11ee692ac74d4077e7c91bcdb054b7f3786d9a569fcb5a70b7e6e2bc11e37583bc7e0a72e64c4501b8815db1285fc2bef2f38d08c63607db80996a468df7ee3429ee80c220798485dcdd681a66c415fca444099390bd0f71c472a6df571d09e75bb9395827b818f12e34a44ad7acfbbb2b99a732acae7cf5918715e6619353d24ca3b4820d282b517d0f55252341aa5ad16b8b76ca599e587366cce9fe6a8c862b30f8cec40c9bd289fdef187cd6421e0a4af9eeba5c35e6bfb18b968926398bf3fb0d33e930729cc4ac892511c94ad95f8df860957f074730b766d716e4d1c63c83de642a0efbf52bfa2d8114a4aa1335d8412c57c3ddd700f857c9a8ebd4d3b88328eae7a51478c73b4bd1a7207b7b3bcfd1540ba1ecb10d65567b987ff43329cd6c4b41cdee30b5f5986e993d4c9120494e506ca17c53f85d2ae77db8ec105902b6ba004fca7cef3cd8ce4458c042581a39e4dea6e68fb259f4d8c4f3261eeeb76a943d790b2e1f1dd163a4f3028b086a4e42a361290aea1f2cc8858928aba8d02c5776075b07a953d848d598445a67351c5a54ccfa36d3c869ec06ec43c53dcd58c570dff6d309133953c72e4893f8ec8ea29b1dd59cad43a477fc779887d2a8871496a4ae8df4469c020eebd281572dbecd98a7c478e525ca372fb13b182da6ec7d924f50d63f042c577e19780ed86da60bccc72edab3a7d4ad2a79484122e11fa0342d70679b3e5cd92edfc3253816433d1d73474a22e6b68100ece18ca0a75c0e9c38e1197ef900fcb2ce21a8a6248e3c9950ae015f88e5c18bbbdc99944c4b28638b0584295e4ca72ac8d87ee2165602bf8dafdc16210bfbbe15797d63f53e01000104a46d0e52c6ec386e384dfb13470bf81d5d4b01abe8fead0821c6c796af6cbf0000000162189c40473eb519fb9b4c4566180a587312b3d9f22722c0f204c90c4873843903a8ce920701ae2935f1dfd8a24aed7c70df7de3a668eb7a49b1319880dde2bbd9031ae5d82f000146f06ee6673b1869f447e861994a879d7ea01599b699ef7ba33fb5979e93ac0b"; let pczt_hex = hex::decode(hex_str).unwrap(); let pczt = Pczt::parse(&pczt_hex).unwrap(); let fingerprint = diff --git a/rust/apps/zcash/src/pczt/sign.rs b/rust/apps/zcash/src/pczt/sign.rs index 6fe88e9a5..805d4a6b5 100644 --- a/rust/apps/zcash/src/pczt/sign.rs +++ b/rust/apps/zcash/src/pczt/sign.rs @@ -82,6 +82,7 @@ impl<'a> PcztSigner for SeedSigner<'a> { pub fn sign_pczt(pczt: &Pczt, seed: &[u8]) -> crate::Result> { pczt.sign(&SeedSigner { seed }) .map(|pczt| { + rust_tools::debug!(format!("pczt: {:?}", hex::encode(pczt.serialize()))); pczt.serialize() }) .map_err(|e| ZcashError::SigningError(e.to_string())) @@ -107,9 +108,9 @@ mod tests { #[test] fn test_sign_pczt() { - let pczt = "50435a5401000000058ace9cb502d5a09cc70c010092dda70185010001227a636173685f636c69656e745f6261636b656e643a70726f706f73616c5f696e666f140cd612b51afd462f8b19e3edcaf79157eadca7010000000000fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e0100000000000000000000000000000000000000000000000000000000000000000248f5fbabcfab48f0f81f210e7b6bc4e9bdb3a9be5ff0018f9e190f7072e78d3bb6dc07e492c92d702a85fac123a1847a6f651e00f8905d0e437ed33fa9def418e7b457e8a6b65862a31d56434817f451ebab580bc2fe374fa96f01cc0c3adf37000114b0cac3e14c4e1a4a4fd22c98563b9cbe859c67768a39f67abd5dbe55d3d16ff58e5c45b21d8c573f54b901e0f5f201012e37833cbe331fe961f4adccead166294519a354f2ee72022fbffafd660424000126639c70fd66ea727c38e7bbcbc185f69eab410d41c2cf1ffa799deeb0cae9ce017d6d7535f6e3eade13042662d05eefa91d1f4757fcd0b4b844554e77366f4b36a7068e15c2f06aaa11f6bcfd2e9e36231530069f7fb99a2771050689f24f332b427fdd05d1d5f3219230a1406f0955e3ddc0ef5ce2c7f160d797f3e54ef5782001d9a3ab170d54720a916ed11694a363087edd33e80c4fba5b99ab4e268844c626e095c6147f90aa00e564894d523d591803c3f70e5f3cf0b78df11c30c692eb53b61d570fc4e15c65718ddb408e62add513bf87284e72c4142fbe75e92e18d344fb61b11769c751e83f12141f7ba68eb0c19844adfaacccf642609a1f2773cce422f7c31f04e8bd109baefd7739b9c48a570c5e4d613d9f2b5a0621b61a4e7eda788c1b1bf44905b00a67e2474ffdf203cc9bd32e593a741ed1dadf5e0a2c3cf02a9d82393100c0297533ab75c22b113db4693d8cf61b21570c1f21edf89477a2e7bf740cb1e779f3088da9819a590c5474384ed04d724606a76ddf80036e2ac52a8fa7057aa0667da7c4ef890f2eab3c5892e39be29b020793a5d3f0f6f3942981c26a38007ab14443f4b375536142b59f222f5337bf4c671bd6f57aa3fd5e050726dc3c53fd99c2e7156a1092c95bce18d9e2a5cc568a96556430c1785958b26fb22b12eec609dbfb205dd0c6675c576ea301bf0aa397c4cd383f6ace064434e405b5093c1d81175c618596a01ecadad95d75fee2eb4390fef14a084ac781b79e487f0f1dbb6c1523d9a86316044757219311a23d5ad6e71d34b8f6a2832494d2b98d3d7597692c9b1a0b7d4bc8e93db1c90c8331e9709ac9973ca3fbf38b2aa955382b0c104faa2b1148b1b627090aa939e321b82edcb0ce70aa4eee298997556b4f358449e7d9f0bcb971dcd97024ace98fe01e7c6d96d6fb235fcbcfef949d71f12912278dfeae9949f887b70ae81e084f8897a5054627acef3efd01c8b29793d522ca2ced953b7fb95e3ba986333da9e69cd355223c929731094b6c2174c7638d2e60040850b766b126a2b4843fcdfdffa5d5cab3f53bc860a3bef68958b5f066177097b04c2aa045a0deffcaca41c5ac92e694466578f5909e72bb78d33310f705cc2dcaa338b312112db04b435a706d63244dd435238f0aa1e9e1598d354708102dcc4273c8a0ed2337ecf7879380a07e7d427c7f9d82e538002bd1442978402cdaf63debf5b40df902dae98dadc029f281474d190cddecef1b10653248a234151f91982912012669f74d0cfa1030ff37b152324e5b8346b3335a0aaeb63a0a2de2bca6a8d987d668defba89dc082196a922634ed88e065c669e526bb8815ee1be8ae2ad91d463bab75ee941d33cc5817b613c63cda943a4c07f600591b088a25d53fdee371cef596766823f4a518a583b1158243afe89700f0da76da46d0060f15d2444cefe7914c9a61e829c730eceb216288fee825f6b3b6298f6f6b6bd62e4c57a617a0aa10ea7a83aa6b6b0ed685b6a3d9e5b8fd14f56cdc18021b12253f3fd4915c19bd831a7920be55d969b2ac23359e2559da77de2373f06ca014ba2787d063cd07ee4944222b7762840eb94c688bec743fa8bdf7715c8fe29f104c2a01422e35d9895d15c28e4f72c0e664a3619d181e2a6e49a06a01eaea82d8c5fe19012fac20755b7bb7c99d302b782ea36f62a1b0cfe8d7d4d09a58e8ba5da26f457803a080808008858180800880808080080000d7c7a57b6e269cf6cd8779d931b0a65483d6277b5904f346516eb847cda0f41ef2d0853dd79541a3f47e437de217c05a1bc6878794441d49c0ae29c43a1f49a5c404f19d637f63c1ca41a49da057411bce72ec26103743c1610e3ac2a2d03ff9c7905336bb908d18188538675704fbcf1ede853596846bd86411411d4c227c29174ada099d9a7758d1119e4afe3eb33e4ecd85c8f2704dbbdef80a4cddb9db92e2b513bbd576c61733425278813a904a515e655586fcc72a73c7b104917ab2e0fb2f706451ebb1847eef52b954af6a61e581757550cdf558e9505fefb91f107bc4cc97101b71880364f57dde3002db3b10a6f5b13d9b350fa2f7b6c01dc2ff8446b20fc6d81b76295f6eca4d4df43a10008251031725ce8182ce9f7dd8870ff86857d528c78cd76b10913196b1a8c1cdf1bd432323c3d92124c0a947a419f133d1df6a3d7ca7cb45ece70374cbee975dbfe2c489e01f568d9308cf52fb1ead544c4339079f32dd58bdcc610974e8cf482c65244f0d292053ad6e3ec5470653384624420e06c007f6d1c07cb9f48d8dc6d6059fe6bf958d2ceb1581b8b5e443742d6757de3f2cc744d57e6e6a49daf16fb296cf4f1b0a92a560ffddce81aa407753210512aad107bbc0d5d0c9fe09470f92acdb3291af21c34f541546f5de2ae09b8b3fe645605665d00467f540c7fb4bdd7fffb8a7f1a1dd0f7e0e23b9244b4fd9a554707673d31c67c9558a7bacd532585640b0d0e9aa8717e4519bce5c42c4c0f5ba41b66c49e4f17245e38062d1414969961dbc1180ce84f3bfd4d54cb73e0c0d44cadad0f5815654b3c596ca2ba9885b915adc55f4e8800c73f5cf23f07977d8fca50fc2c458fc7ca185ab2281e727eba6e4c3b712c12040f861cad1e8002828c0bdcd0d50a5efc317a42fbdff314681dbaee8f323eebcd3eb7147a57d2d61119d7c42cc1050d38bc6b631f6924c80cd7dfa47117f788fdbcc398fbfb3b03450f475bedb7d2eba077b59b3cc9a21d417526d43c1e30114b0cac3e14c4e1a4a4fd22c98563b9cbe859c67768a39f67abd5dbe55d3d16ff58e5c45b21d8c573f54b901c0d9f1010103031340066f28afc325e52e4fda0f3374c56d79c78c722ba40f674a691ad274000001207a636173685f636c69656e745f6261636b656e643a6f75747075745f696e666f12020cd612b51afd462f8b19e3edcaf791570001b77a4338d47b31f9417cdcff3b64cd5b56ac29a1c8fccf88196e5cac18c4950fa575f542f2e258a2afb3be0a6d09762db5621be58132de59f239e4ce1c3f7fb98e8021c39a7fe35e4f7e0fd8ef2705ac9450e519ed583d8898a1bfa133c95d3d06c3d40a98f865ccb24e622f3084891f59c8cd61476794b210effd7dc0d399ac01d045bccb48fd21e4d059d296ad228e8f02c5fa1586e8ccbb0dcd158fc9faa291b8041d6d388f256329e3f52784a85a6501a179cf2c844d10461b30becb2db90e0195676e6987be5dd1f0766b98ffdb212e2cc81d7cc9cac00fd72ca94c1dc95b4bf94e6ed40dad44aaf961170100011f5a262c895dc5ebe44c979755cab722a6bd9f9df0b330215dd1e156e73d412001ed6b3033bb57e2b56f8de4c795e9f17f4a84b8662b6a0d8b2f0c7e4686305593016c215f6e30d62fd4cf948303c0ff45d849167b3c0ec10200e5bbf3cd92533734e4bb8056307ad10d2ed368dc582bdabe318d5bcade1bb2c5bdec667f7b676632e143078f0205b7cfd2666ac62d55d629364bd885e4deb3b53e6f522030571e06019af38db8054d2c7ac8284cb9b1f640b971d1985b4df06e562e56e3507692204402d215bb38b8b3922497a5d25674bab58dbac39ce22e9da3401fe22dddb4df2b66b941683bd94403214032a67899b2188e3606b210f30da22134824daf6d3eaea26ea48313cfbb5c9202071fedfe67ea5459d9b64e289e114286aeaafdc925b6f0e3e22d04c3e44961598644b2c1823cc10a88ceeaa9e0baaca6a88781d07c4c44e215a3188421c3f3e98870feaeb644289806cc0dcc614b5807bb250b6b77dc7541f4e61b2740bd9d4553fe455a63d952ef933202777ac84817d9037b94994bc73bd0a53070fad69c2192e7c9fd420d5d76ef381b10cfd5ad9cf7266d33b617b8a27b8d05fe2f5aded2047645608a668adb5e99afd1287d3a541b63ae3034d97dc354a0110d58817a633ea5dcd91c79ead3dd8686ea1e32d73883b03871134e34de11f92f952139b5708555318e1799cf16882180b13996b529a50da7ac0c74847f9d160983ae377789e1f8e7a4455ef31552ea3eb8fbb1d104ebc75afd10a9cef5f0f12a3a908ffe2b7495fff8912428bbcfa1fb2f5efe9444503b4a78326262e32bdd1f166b41a8b0015d87aa777a506e93dfe5597917c1a5ccdb0d13f1e3ccd491431e2691c8ab5baa24a430d3becbdc7171d026ddf8a6a4357fd5508995d36e033b3d3a5ff7ec5c680599dc339ab5fd20842e391404934a615cb4416e22f37bb97b2ffc5470259a80d9f4ee26410c6b164a71bff1b3e9731d3e08d09e2ad47b190311819099d92403ec77099025a85da9eb09224146b111c9bbeaf879f84370f53b3b6bee68b017e414b1cf8b5c07a6855e35ec48d2f93e632645633a63e5d3b6291af483b62e859d541aef33a71196b5934fff89d9f05b3eb06e27fbcc2b239dcd1e0635ea1ac5eb429dda2846fccb2114b635dca74ca2934a54a6f73b7ce0a9930686ada39ea0958ecccb0f4179e0618ef3fa83b1136328fd56d0967a9a287abf0605930cb48c7d9553a59538da183cc28adc3be32a875ce86d2d806875d69b511fb5da89e1f82453edb15f4f9ab90dcb40b0846c3085d1984a40cb96491dbf4e08cb03540f9a00eafb3177daac3bcb6c675da4eba12afe6b88944e56df1bb5a52489ea4e66ee092f1c120a9d06b98e007459ef6170f857ee838e15ff995d13ae2098565744ae8b8f8854287fdc7f65d80b0d49a4229a341f2fc16d0a7dbc4213097e06e17cde24b0b05e5bb615da1069d8fe5468d674049ebf71d8905fc8e2332fc02d7883fe82b2b115375340d38d26f0bd72b29e10167022afd121aa836e2e0f7ee6f02d8722f2e908b65e62ab60ec4ec6a2e413931e57386241ece6e4d8202a96e12a4d6ac6d09ca68bb41c88f2d3089e485fb09555c542a47166fbd3b91d17f517c06997065c85e2b108740c0d8eb24a72928e13227b4239ee2a380286081901c2ca4cd85d8df2749700103665ba4d3821d535e4c0473b5574f163d66f3cb92f012fac20755b7bb7c99d302b782ea36f62a1b0cfe8d7d4d09a58e8ba5da26f457803a0808080088581808008808080800800005716212c0a7d26f17c87169cb4f183c87442246685bf85eeeb24e1ab77e8d01877714e36f47b331940ced47aa97e745f3258a535daeaa01191c0ceb7e7e8d9b5c40490d135d8df82e20561ab5d69fd3b0a2afb462df8092b9176b6ce9d2cfeb7ddce2879d36181128f182cb636ca25835be79c86af90569c77254a094271ace1c8cfff4af4cf4f381c1c293abe2dda35965a59f981de14506350bc8381ab776cc1275146bb5bbfc5fd648d5e148a0554f8a556e6cf5651a0367e65c1a265b8105e048a07381e195fd470a5d73706f3f0d9f8579c47eac3cde9eaef7208555bd9ba87431805c831142ae5cc895ff59b4970f76b8c725f81a47d4ef54ba8301a9502cf231e25d24c473ea5313c6d989e54728f66246b4375936d5475e3aeb9d94a9972e84c0eeae11cbf5d491430f2a42ec4ccc0fb8d44c905e3851b82f31f8347b8deaad9f331fd3892b77e7aa58f7bc97671e6ff2a3cbd95d9eea4a6b3720a7228159feba56e434c02ad8ef4ddac023170a96eee1801e403f858cc2beaf3f55500bc1b9787ff519a8fff8efa8293c90d5d5425eb678fd8d9815beff8070a014648bdaf65c65717babde51c26577d9e95e249f58d1a0fa8af650a80572fb38990bf40cd7445f980f6cc4a0e4de0c0cf220da4d9d6860ffd063fa102797062d63730eda932d961c8f786e73023d7fa46d653977ecf71b9b24ee54ec2a07883e3c5f454bc74322bcde660d9613c8122e2b39e09a152bdc8a5baaba655d1817a7273feaba854706fa5629142f221056a3cc8fa9bae98ce69f77c5425edae55eb5d5e8b33de7b63becb4896de2fbf9da6e1a43c91e8311419b17752efa129cf3514d4e1dda9697e454b486449e2755dd494c0a12f6481ad3ff4ff7baa9900d121b4afbfb724a673cb501d222ecf6d439f8ddb1aa4643d0cd90e4c873fdafbcb31300f0d11a3674dec4672f3779c205ec2a46912a3fb67a547a3b8ab43ba0ce3f6bb0f276ea61306d1e4e73bdf5703fd221923ef76a9cc49f2aa0199a66f4d2212d15f6b9ddf1d738b41226e3954130fee9e1654409d3eb52a82e0e18f62bb13bab4f37db92901904e012d4e2731af2c3b64f3aaf85866655d7d1a1817ab46125a4f8c56faa8231c31ee000001207a636173685f636c69656e745f6261636b656e643a6f75747075745f696e666fd80100d50175316677787573387a63687136343772346a61717833327537736a32777479706c7376756e336a6563613272633477353575387572736e337132773438377634756d6b686738776c727465726e686e3064776761707471683537327566306b357078736d717a75726633336671677868353375616a6b7472683377733735677766786c65677537686e676839726c6c743635636e7568393675766d65336366346b663366357938737936396a39356e6c7370726176396d3977336d7a6c336b757663306d6874716d3074746c71716a6d786735357501bdcd4e998f0a8b7670e3a9e8b8dd6f86607a8404e47d7bf03c8c42991a37c20e03904e00a5352047e2bbef44cefe58d8b14b140dbd8ea88bf69c0c1d19fe7dec221984130001744892d16386bc6fb25f86e8f4413de2b626aea5ac7a4b7956fa9e4533fb571e"; + let pczt = "50435a5401000000058ace9cb502d5a09cc70c0100c6fea70185010001227a636173685f636c69656e745f6261636b656e643a70726f706f73616c5f696e666f140cd612b51afd462f8b19e3edcaf791579efea7010000000000fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e01000000000000000000000000000000000000000000000000000000000000000002605d24c9243562806a1b7503c8ea3d0eb3f4396295315248d88140517dd8773fea6ca8372648dc6c1e05b4fdeea0dcfe3b0193e3c77c8e585c948a72e84f6824f86a91ce32399e91ad444507833972e17cbef20d76d988c196d69a920db49886000114b0cac3e14c4e1a4a4fd22c98563b9cbe859c67768a39f67abd5dbe55d3d16ff58e5c45b21d8c573f54b901d0ad73013590ab44ccbc82f402d607793b1ac222fbfcb592460160cf775e7b469a2ae12901b227285b222e468c8330b7ed6f74728973ebe1a66299f8290690ba906b45eb1d017d6d7535f6e3eade13042662d05eefa91d1f4757fcd0b4b844554e77366f4b36a7068e15c2f06aaa11f6bcfd2e9e36231530069f7fb99a2771050689f24f332b427fdd05d1d5f3219230a1406f0955e3ddc0ef5ce2c7f160d797f3e54ef578200198d4ac17681ab42419ea525c66c4bb2e41463f8b5857ec3e8ffc5859ee86cf0620fbf703ff5732f7e6d0d059f8ec4bb809e8d53f182c0830653ebb25df34d2fce5be6903c769f954c98dbbe8b1eb3f44881b7f1d5d02897ad06be32319ffe3ad955e0027e52a543e27c712aa52157eeae9fe778f66a568915c834bcc182607b57a4e142d667653bda46ff77b414ae5d454a90766517bff58a2c068ea679e1e0125379b18f82523c38db1b57890808fffc45986802010b5d6e56d97a1b6a5e3dbb29dfc27a51047ac3c6f2af836bf2462c4e93770be38490306226b406a878cab85af9c171ac00ceff27fe9c721ba04188dfae2faece945130d039c4f89285d6c76413623c8ec46a78434d9a59d709e6de2892afa1bf826a35848afe9dd99e36457e569304d2d6852d19bd214f7729644b2b68e9956ad31be510ca7d5329b7d647d341010e41966f7aaac3b5788e072daec0e6437eddb94a1a31ab496c3c0c7ec64fa9404fd8d40ccb9fb2e104aa0357a122141052c9a741c4c2c736b6dd0363ddbf27e2922ae2800cb93abe63b70c172de70362d9830e53800398884a7a64ff68ed99e0b9d2e26bdef115ced7bd36305a54386996133c4e65759f3731637a40eba67da103f98adbe364f148b0cc2042cafc6be1166fae39090ab4b354bfb6217b964453b63f8dbd10df936f1734973e0b3bd25f4ed440566c923085903f696bc6347ec0f6f3f63aab58e63b6449583df5658a91972a20291c6311b5b3e5240aff8d7d00212278dfeae9949f887b70ae81e084f8897a5054627acef3efd01c8b29793d522ca2ced953b7fb95e3ba986333da9e69cd355223c929731094b6c2174c7638d2e60040850b766b126a2b4843fcdfdffa5d5cab3f53bc860a3bef68958b5f066177097b04c2aa045a0deffcaca41c5ac92e694466578f5909e72bb78d33310f705cc2dcaa338b312112db04b435a706d63244dd435238f0aa1e9e1598d354708102dcc4273c8a0ed2337ecf7879380a07e7d427c7f9d82e538002bd1442978402cdaf63debf5b40df902dae98dadc029f281474d190cddecef1b10653248a234151f91982912012669f74d0cfa1030ff37b152324e5b8346b3335a0aaeb63a0a2de2bca6a8d987d668defba89dc082196a922634ed88e065c669e526bb8815ee1be8ae2ad91d463bab75ee941d33cc5817b613c63cda943a4c07f600591b088a25d53fdee371cef596766823f4a518a583b1158243afe89700f0da76da46d0060f15d2444cefe7914c9a61e829c730eceb216288fee825f6b3b6298f6f6b6bd62e4c57a617a0aa10ea7a83aa6b6b0ed685b6a3d9e5b8fd14f56cdc18021b12253f3fd4915c19bd831a7920be55d969b2ac23359e2559da77de2373f06ca014ba2787d063cd07ee4944222b7762840eb94c688bec743fa8bdf7715c8fe29f104c2a0105f3600ab15c6f1c087eaf89f57e650b1e7a603d5414de3a81af8292a2af183b012fac20755b7bb7c99d302b782ea36f62a1b0cfe8d7d4d09a58e8ba5da26f457803a08080800885818080088080808008000080bcba8fd36661ebe7b37230e7f3e04c48542cf1a0c3388ff0873c5faa5a992651270a6151797049162f9be38403e86480188acfd569daf4f9c537c29add78afc404520d3c23751e0450890c02250cc144c0dad537b464f0f85034a5b730ba70c6d81ae4261a29937aba79fa72f9eb404d07238e84f21fbfe64e3d2d7b65f934253e1b97bfe8f67c31725ea8527110038cc9b1ed922cb9c23638f2972bd6b04c4a376bbed6d24fb51abbdbc498d5a114e8664bf11296751218c2696b2606093de8bdb94972edf34a3c59b8f18210651233ed0d92014c81782cee5e06540c2cc05580e41ec72e3523c2654ccad3c73c8ada5b2498011365d83475058ff82f1fad89b445075f512b08a57ca977e490cc033e91e27e42f20009af72b6d53855681b671d5662783f5440aaa08fd69821d826b180ac2a728e7d8c364614eedfce34bef6280141783ead439d162218e0872c9514ebd6b19e723e2324b2021f871ce5459b7a1267828b3c00c7dd7ecf6c08e37e717588b42e18efc7a14a72e105843f051bfddb1bd4f0e9dd4f59bc7809a546dbd1d5269ab64486f85ca80a6e0a7a88c0c6bd18654bde21e964cec1331a68006c5ede67c92831ceaf192b9e44f07e62f8156ecc2d8bf07b4b552db9e7f3e5648a662b5165282ee27640ea7f6019336ff50713eaad3f511cb6f950148e58ea1f353833a6fccaff3c895f294ae5f636245853d991d442ca02589ae90d44c4683bc12391ce555d319bd3a6c614d3d71bbcb1f9b3ad3107e5f93ca35f718ec89fed151624c38bef99c7bdd83eee9aa96d92d645c4b23b65fb79a995df9948a64df883b1f3a807b938f61afee72656592ac8ae3e4170ab64de085b4c300f1dabef73c21a649ca373f70ba0d53ea0cf26c793e9a2d0ae3c2fbd50d21d1b14c3387d528299c9d37e269a7516a5a9ab9bce7e7b6e709aa58db1677647b17d3b2946a0e57de3dc5ece4917679cbeb2d586bfa7d169995524de21a86d60efa9903fde28b999a16b698fa989330199a66f4d2212d15f6b9ddf1d738b41226e3954130fee9e1654409d3eb52a82e0e18f62bb13bab4f37db92901a08d0601e052bb9fdbf4f233adc2221f19fb24637494f466108a5329370dd30c1341a3c6000001207a636173685f636c69656e745f6261636b656e643a6f75747075745f696e666fd80100d50175316677787573387a63687136343772346a61717833327537736a32777479706c7376756e336a6563613272633477353575387572736e337132773438377634756d6b686738776c727465726e686e3064776761707471683537327566306b357078736d717a75726633336671677868353375616a6b7472683377733735677766786c65677537686e676839726c6c743635636e7568393675766d65336366346b663366357938737936396a39356e6c7370726176396d3977336d7a6c336b757663306d6874716d3074746c71716a6d786735357501d381b40829d450b45b41844f3a018bf3c8605285baf8a484ed92e58bafc241219789437d1286951ebaa210cb384a658bca1ecae2429174c0c9f354804802818efbd865eb0609f8d779f06086d7a0ce6a2203fd074dd7fd1e7239c6d145f8113a22252861231b3a40d74ff3b23bfbda0a865fdaf8efbdc0e09edaa096b13df08c017890ba7b365f5837585fa213c580bc75e88bbccaf301bd4f88046f12681f17b3128b4270f06ab727bc9c0a53192fac26d277b1589ac141c35245aa5dd5586e26010d79aa242f3ee18cedd2f8bf9e43675a1a0e856d454a1e1371b87c20278f20db4381faa08495c348f08336010001f13726573dbb1cfd6384e47fcc8678ab7e56ab8abfd872b267bea799cc78602c0169b9da089a769593b63fdb5abb883c5c20e69ce5c05a74999e25338cded3920101dbdf8a657607f449b9f88c32bdfd4d73e97cd523f4d317c1a769eb69373cb93da8d91a6391b6914c17bd05b2fe808b73e48fde3360032163c6573235c3dd703bb7e66d8fc5544a369142c98948ccde9f17c21a0381c42bb2e9187e51ac8e613d01e09efcb90d9300f2ada3b85a1eeac5437c3659bacf88d33a2f9f87265b87e9c6061c7b3c27b0abf551c81061d942051009f6decb8e0118effd4316c2696a240ff3f55f483a79ebe0861cfd7d8b4afac6d8e6e7b78de86f2afd72a9bbc63be9f0083e6b0306baefa79b7e1e35f3a63d83b7d06ae43faa8d4456ab494599ff05adfe9f80a40a66c65fd35630b8fb51a5245f48062fa340567f5ab6df5a602de02f433cf4ab3dcaa7b975f57ee389352efbb1633961520338091b699a4dd8c0adb2550309ca3788b928ae68362cde34c2ebef5201d91bae878fa2c37833d163e8e7cd05dd5d3f05f83215fea674601ba60175c45b391df8afe9c9c827dde5832475ea4413fd1628870c039f1527e78a5368455004f648a8f9479345aeaa2b60e066832bb44334be4e530721a57d9ae64e2507a81b840f8a750b6c19ad9dc32d69b0838a256f2501d4e2c9c7458b3d32fa546e9fad489a4382009060123032ccdec3ba3961880946e5290f799f657d13e0d48899a33cfaacff3a80f398695590806486a20a6c35e3e8a721b58a3b7adce18a505b7a2a1e11d75b150d108ea196476eea4aeefb2b12d27e209ff9f6b1837e403bec3a2e402b1a68ac03210724261a326eebec782bc047b8b6e796354d422972657290f2564c3e90c8b36460ab0c51eb9fbd1a0630e2e123ec45325cc934f3344f002e0791c752d355a2e5d5fdccce5e3abe130a09cb318eb7a3da6f460b6ed4f8d364f52b85eda97f93294cb449914d9207e443328482e5f86f3bb4ca72e03398c5a4e393ad39492920213db32ebee184095350321ae14e3be3671e6d07cc0ad640d2db978b25b6bc04a0d68516fe558619c12815646f53055672996e1334428388b8f5a30d6cef40ff1f05198cbee2deb3608c0f67e9750d1a6289440a916f9689722683d873c0efd256f701c98ad499402e91094e6f4e74aac11863018f7d19054a34b183485c3d369b95f5792c2f5d50a8a904ea891c0ed9b5a973918342c2696de2013fa26872fa5fd817717664383248651fe354b9bb91472cddad11ad596b577363d620cf13ff8a9b3d5ef97a31ccead80e705f89ea60dd32bf1135301d42e86f185daa22339bb7e6d1d3e06af075012a27992b3f1f879a952eb6e268f488c01cdebb9bd62358eef30e9a111cdbe6bbdb15859ba98994f91c0bde9dba3893024c7ea02344631ffcfe43e7949811f8fda71e23357f09ac6b6714c0b3fd54abbfe57f7cacbbd130366caf02aea81d04286b3fda4a367fdd570d5386db0c00d2233c56fbd843a574f28ac892e7be90d8b27b28d00e653e22daa40ccd4fc7232587bcc0153d970d8babacf6c9ad7e909c1608099246d50c0b0aad8cad51de4d80f17eb5b242ebe3a000ffd6eccbf5c0bb217d3a872c8b13a6cdde0dc5cf5b4482224c8b3a525cd220763b48058aa3f923be77260113ccd027c9462d45a7c115af3c2c1ff7afb33104cb6127ac3e4517ab00209e040000007c555a81595ae184b8904d286ff94325561f525db19ccf836663d1532b06a712d5ec7de472661db5c089560e95397ba36d68e27fe1327d9771a3b0fe814a231ec404e63e87fa1d7757b1bc89d74d08116434710eea9cd052ba91d0dd030c397f390dbc3ac7e81f616443f9fcc7e5165629c3ed1793dd8102e88de6f9f511dcd5fb6b829774da28cdc7c712896dac62672c9fa019f8ef45ea3a532a815dc8e3c4377437202d2cf146b419eeb4907cd45b7b7c33940ca9aee99df5dbebb98b2b7efc38c8454c77f012651bbb1937098ff6396b2b0315172b3098fa8d7bda0c420a4b6d7b2aab7eb3f17e70e0f34ab2454922a4b39c88a23b2b510c09c0ed5d37f468db5594e07be50a7f84bd08cae1936bf42a4a2a58ccb6e0b665ca12682b5595804b4e9ba01865c1d4996191445af6ca392c2c60a64166b6d7ca8509b689bec123cbc1de6a3653623c29a9fff626147546068f7ab5f3dd5bdac6e25124b1b3a000b21c68ee5090475f327359ffbd7866c85780c663787f963a301ec1eb67d618fa47b1a624de3535579c59f2dc6e86e0ee3967c0ac3bf03bd45479e3d392c4df3688a3e7830ebdb14d16793e543dc6267cd0fc0c8919fae1e0f60d5c554396801032e413572c9f2d8c253b219bddeae1ef9fad78d84573d666fc6a274f049cb58f060ec897cb5e1ba3bef50035d6edb094eafec35af418007650dbe0956972476ea3ca5b668b5386c770e0d44f798dc734fc116784cf429fcc11da7bca16b8bcc16fc4fc25207fb22fe67d82973c8218e151d9abb2385ec9a9d9c29fdf38772646b9b5965773f4c7d9e4e5cf3556fc666f8db1d2db0a816d235c04c06799f3127cc1afcfed39d8e4335678335df5147db11f38ab6dd9e4947cb8d46f28c05253312e0707095a50ff586c7187a4da407f5f7c00469ab40b292ca7b2750924ee64c0dd5687454c643b3cd09de529e85aef0c43ebee5191b4d0ed49c33e58345933cfab3153f7b5e867b0b415d22b6950fc846246f4be91c80114b0cac3e14c4e1a4a4fd22c98563b9cbe859c67768a39f67abd5dbe55d3d16ff58e5c45b21d8c573f54b901a0d26c01ce735088089ccc3d9aba0f224b8dcb8073ed9bea70ba1f8ad83ae66b5635c9ad000001207a636173685f636c69656e745f6261636b656e643a6f75747075745f696e666f12020cd612b51afd462f8b19e3edcaf7915700011e967b51143ea4006830fd2d55801278cce4c6838916506e43a2095107c5103203904e005c6640f7ca57dd7a466a291f1806be6fd0daac702b3162000abc03b05521da3e0001f017305a1c27ae28e6c8ec7393e8564995451909440ff5f23035efdcb6875213"; - let seed = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + let seed = "5d741f330207d529ff7af106616bbffa15c1cf3bf9778830e003a17787926c0bd77261f91a4a3e2e52b8f96f35bdadc94187bef0f53c449a3802b4e7332cfedd"; let seed = hex::decode(seed).unwrap(); @@ -124,8 +125,8 @@ mod tests { // //6122d6b5ddcc9eb600a4cedb98932b3a7edf6e8b51bc4478b296450bda68c506 // println!("alpha: {:?}", hex::encode(pczt.orchard().actions()[0].spend().alpha().unwrap())); - let result = sign_pczt(&pczt, &seed); + let result = sign_pczt(&pczt, &seed).unwrap(); - // println!("result: {:?}", result.map(|pczt| hex::encode(pczt))); + println!("result: {:?}", hex::encode(result)); } } diff --git a/rust/zcash_vendor/src/pczt/pczt_ext.rs b/rust/zcash_vendor/src/pczt/pczt_ext.rs index 5231d8244..56d2513fe 100644 --- a/rust/zcash_vendor/src/pczt/pczt_ext.rs +++ b/rust/zcash_vendor/src/pczt/pczt_ext.rs @@ -62,6 +62,11 @@ pub const SIGHASH_SINGLE: u8 = 0x03; pub const SIGHASH_MASK: u8 = 0x1f; pub const SIGHASH_ANYONECANPAY: u8 = 0x80; +pub(crate) const FLAG_TRANSPARENT_INPUTS_MODIFIABLE: u8 = 0b0000_0001; +pub(crate) const FLAG_TRANSPARENT_OUTPUTS_MODIFIABLE: u8 = 0b0000_0010; +pub(crate) const FLAG_HAS_SIGHASH_SINGLE: u8 = 0b0000_0100; +pub(crate) const FLAG_SHIELDED_MODIFIABLE: u8 = 0b1000_0000; + fn hasher(personal: &[u8; 16]) -> State { Params::new().hash_length(32).personal(personal).to_state() } @@ -450,7 +455,20 @@ impl Pczt { }) .collect(), ); - //TODO: modify signing flags for transparent inputs + + if input.sighash_type & SIGHASH_ANYONECANPAY == 0 { + pczt.global.tx_modifiable &= !FLAG_TRANSPARENT_INPUTS_MODIFIABLE; + } + + if (input.sighash_type & !SIGHASH_ANYONECANPAY) != SIGHASH_NONE { + pczt.global.tx_modifiable &= !FLAG_TRANSPARENT_OUTPUTS_MODIFIABLE; + } + + if (input.sighash_type & !SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE { + pczt.global.tx_modifiable |= FLAG_HAS_SIGHASH_SINGLE; + } + + pczt.global.tx_modifiable &= !FLAG_SHIELDED_MODIFIABLE; Ok(()) })?; pczt.sapling.spends.iter_mut().try_for_each(|spend| { @@ -461,6 +479,9 @@ impl Pczt { d.clone(), )?; spend.spend_auth_sig = signature; + pczt.global.tx_modifiable &= !(FLAG_TRANSPARENT_INPUTS_MODIFIABLE + | FLAG_TRANSPARENT_OUTPUTS_MODIFIABLE + | FLAG_SHIELDED_MODIFIABLE); } Ok(()) })?; @@ -478,6 +499,9 @@ impl Pczt { d.clone(), )?; action.spend.spend_auth_sig = signature; + pczt.global.tx_modifiable &= !(FLAG_TRANSPARENT_INPUTS_MODIFIABLE + | FLAG_TRANSPARENT_OUTPUTS_MODIFIABLE + | FLAG_SHIELDED_MODIFIABLE); } } }