diff --git a/zcash_primitives/src/transaction/mod.rs b/zcash_primitives/src/transaction/mod.rs index 05bababd3..cf2eade5c 100644 --- a/zcash_primitives/src/transaction/mod.rs +++ b/zcash_primitives/src/transaction/mod.rs @@ -993,8 +993,8 @@ impl Transaction { } // TODO: should this be moved to `from_data` and stored? - pub fn auth_commitment(&self) -> Result { - Ok(self.data.digest(BlockTxCommitmentDigester)) + pub fn auth_commitment(&self) -> Blake2bHash { + self.data.digest(BlockTxCommitmentDigester) } } diff --git a/zcash_primitives/src/transaction/tests.rs b/zcash_primitives/src/transaction/tests.rs index 932b5a532..f5533213f 100644 --- a/zcash_primitives/src/transaction/tests.rs +++ b/zcash_primitives/src/transaction/tests.rs @@ -160,6 +160,7 @@ fn zip_0244() { for tv in self::data::zip_0244::make_test_vectors() { let tx = Transaction::read(&tv.tx[..], BranchId::Nu5).unwrap(); assert_eq!(tx.txid.as_ref(), &tv.txid); + assert_eq!(tx.auth_commitment().as_ref(), &tv.auth_digest); let txid_parts = tx.deref().digest(TxIdDigester); match tv.transparent_input { diff --git a/zcash_primitives/src/transaction/tests/data.rs b/zcash_primitives/src/transaction/tests/data.rs index b949a87cd..227158e30 100644 --- a/zcash_primitives/src/transaction/tests/data.rs +++ b/zcash_primitives/src/transaction/tests/data.rs @@ -5689,6 +5689,7 @@ pub mod zip_0244 { pub struct TestVector { pub tx: Vec, pub txid: [u8; 32], + pub auth_digest: [u8; 32], pub transparent_input: Option, pub script_code: Option>, pub amount: Option, @@ -5979,6 +5980,11 @@ pub mod zip_0244 { 0x69, 0x8b, 0x3c, 0x87, 0xc7, 0x4a, 0x2a, 0x63, 0xa2, 0x89, 0xd3, 0x00, 0x05, 0xda, 0xd6, 0x98, 0x3d, 0x95, 0x44, ], + auth_digest: [ + 0x1c, 0xbb, 0xe0, 0xd7, 0x25, 0x4c, 0xa6, 0x52, 0xcd, 0xda, 0xa7, 0xa9, 0xd2, + 0x91, 0x5a, 0x60, 0x9e, 0x35, 0x73, 0xc0, 0x3d, 0x27, 0x05, 0xe9, 0xad, 0xd4, + 0xe3, 0x2e, 0xec, 0x0d, 0x76, 0x9e, + ], transparent_input: Some(0), script_code: Some(vec![0x65, 0x00, 0x51]), amount: Some(570688904498311), @@ -6160,6 +6166,11 @@ pub mod zip_0244 { 0xf8, 0xa5, 0xe4, 0xfc, 0xb7, 0xbf, 0xa7, 0xda, 0x79, 0x29, 0xbf, 0xb7, 0x31, 0xac, 0x10, 0xa5, 0x8a, 0xb0, 0x03, ], + auth_digest: [ + 0x64, 0xed, 0x51, 0x50, 0x16, 0x96, 0xf1, 0x14, 0x32, 0xb8, 0xa1, 0xe2, 0xe6, + 0x87, 0xb8, 0x9e, 0x61, 0x25, 0x97, 0xfd, 0x47, 0x49, 0xf9, 0x2c, 0x0f, 0x5f, + 0x51, 0x71, 0xfc, 0xad, 0x78, 0xbe, + ], transparent_input: None, script_code: None, amount: None, @@ -6184,6 +6195,11 @@ pub mod zip_0244 { 0xcb, 0xf9, 0x57, 0x6a, 0xb7, 0x6b, 0xff, 0xc7, 0x1b, 0xcd, 0x98, 0x5b, 0x62, 0xdd, 0xd6, 0x9d, 0x29, 0x97, 0xcd, ], + auth_digest: [ + 0x04, 0xda, 0x78, 0xb6, 0x64, 0x11, 0x1d, 0xe8, 0xe4, 0xfc, 0xfc, 0x14, 0x93, + 0x3d, 0x79, 0xf6, 0xd9, 0x60, 0xda, 0xd8, 0xf1, 0x08, 0xf1, 0xe0, 0xb4, 0x26, + 0xcc, 0x20, 0x36, 0x29, 0x22, 0xed, + ], transparent_input: None, script_code: None, amount: None, @@ -6209,6 +6225,11 @@ pub mod zip_0244 { 0xa1, 0xe3, 0x4f, 0xd5, 0xf9, 0xc7, 0x9c, 0x9f, 0x78, 0xdc, 0x65, 0x05, 0x1a, 0x9a, 0x14, 0xca, 0xc2, 0xb1, 0xbf, ], + auth_digest: [ + 0x04, 0xda, 0x78, 0xb6, 0x64, 0x11, 0x1d, 0xe8, 0xe4, 0xfc, 0xfc, 0x14, 0x93, + 0x3d, 0x79, 0xf6, 0xd9, 0x60, 0xda, 0xd8, 0xf1, 0x08, 0xf1, 0xe0, 0xb4, 0x26, + 0xcc, 0x20, 0x36, 0x29, 0x22, 0xed, + ], transparent_input: None, script_code: None, amount: None, @@ -6247,6 +6268,11 @@ pub mod zip_0244 { 0xf5, 0x90, 0x93, 0x03, 0xd4, 0x58, 0x0e, 0x72, 0x3a, 0xd3, 0x16, 0x2c, 0x06, 0x09, 0x66, 0x48, 0xa2, 0x5b, 0x1e, ], + auth_digest: [ + 0x9e, 0x7c, 0x68, 0x39, 0xb3, 0x1f, 0xb3, 0xe9, 0x12, 0xb6, 0x93, 0xd1, 0x87, + 0x9f, 0xbb, 0xad, 0xdb, 0xe7, 0xa7, 0x4a, 0x50, 0x8e, 0x7b, 0x6d, 0x1f, 0xe1, + 0x93, 0x82, 0x68, 0xc0, 0x4a, 0xb3, + ], transparent_input: Some(1), script_code: Some(vec![0xac, 0x00, 0x00]), amount: Some(693972628630138), @@ -6520,6 +6546,11 @@ pub mod zip_0244 { 0x87, 0x1f, 0x14, 0x12, 0xe3, 0x8f, 0x89, 0x13, 0x07, 0x52, 0x80, 0xcd, 0x2b, 0x38, 0x02, 0xf5, 0xb2, 0x70, 0x4e, ], + auth_digest: [ + 0xee, 0x3a, 0x4a, 0x6d, 0xd3, 0x89, 0xf2, 0x81, 0xb6, 0xd6, 0xe3, 0xd8, 0xe0, + 0xf7, 0x97, 0xa3, 0xd4, 0xfa, 0x01, 0x4e, 0x3f, 0x41, 0x6a, 0x0e, 0x47, 0x68, + 0x4f, 0x76, 0x02, 0x15, 0x44, 0x58, + ], transparent_input: None, script_code: None, amount: None, @@ -6551,6 +6582,11 @@ pub mod zip_0244 { 0x6d, 0xbc, 0xdf, 0x2d, 0x35, 0xd0, 0x13, 0x55, 0x80, 0x4b, 0xf0, 0xe3, 0xee, 0x1b, 0x17, 0xde, 0x9e, 0x46, 0xcd, ], + auth_digest: [ + 0x2c, 0xbe, 0xf7, 0x5b, 0x3e, 0x2c, 0xff, 0x88, 0xb6, 0xf1, 0x20, 0xbf, 0x70, + 0xcb, 0x3e, 0xc7, 0x57, 0xec, 0x25, 0xd3, 0x11, 0xfa, 0xca, 0xfd, 0xfe, 0x2d, + 0xb4, 0x2e, 0xd3, 0x42, 0x04, 0x0f, + ], transparent_input: Some(0), script_code: Some(vec![0x63, 0x52, 0x51, 0x63, 0x53]), amount: Some(107504874564564), @@ -6829,6 +6865,11 @@ pub mod zip_0244 { 0x51, 0x2a, 0xd9, 0x06, 0x50, 0x34, 0x22, 0x5d, 0xad, 0x9c, 0x89, 0xbf, 0xcb, 0x73, 0x32, 0x8d, 0x3d, 0x4f, 0xe6, ], + auth_digest: [ + 0xbb, 0x48, 0xcf, 0x27, 0x71, 0x54, 0x6c, 0x2c, 0x15, 0x57, 0x7d, 0xb2, 0x0d, + 0x04, 0x86, 0x5a, 0x8c, 0xc0, 0x0c, 0x9c, 0x02, 0xec, 0xb3, 0x10, 0x24, 0x94, + 0x31, 0x0f, 0x18, 0x68, 0x50, 0xcf, + ], transparent_input: None, script_code: None, amount: None, @@ -6943,6 +6984,11 @@ pub mod zip_0244 { 0x49, 0x01, 0x54, 0xeb, 0x2d, 0xeb, 0x76, 0x78, 0x74, 0xa3, 0x1b, 0x5d, 0x10, 0xaa, 0xf7, 0x6b, 0xa8, 0x4f, 0xae, ], + auth_digest: [ + 0xf1, 0x58, 0x29, 0x64, 0xb8, 0xc9, 0xec, 0x20, 0x29, 0xab, 0x97, 0xa2, 0x55, + 0x98, 0xdb, 0xff, 0x28, 0x35, 0x23, 0xe6, 0xf3, 0x7a, 0xdb, 0x19, 0xcc, 0x57, + 0x69, 0xb5, 0x13, 0xc7, 0x33, 0xc0, + ], transparent_input: None, script_code: None, amount: None, @@ -7261,6 +7307,11 @@ pub mod zip_0244 { 0x77, 0xde, 0x07, 0x15, 0x27, 0x5d, 0x15, 0x6c, 0xda, 0xb9, 0x6f, 0x68, 0xdc, 0x70, 0x10, 0x58, 0x3b, 0x02, 0xaa, ], + auth_digest: [ + 0x87, 0x46, 0xc9, 0x9d, 0x98, 0x57, 0x86, 0xb1, 0xb7, 0x7c, 0x40, 0x5f, 0x6e, + 0xe8, 0x31, 0xe2, 0x98, 0x71, 0xca, 0x9d, 0x68, 0xe7, 0x72, 0x4f, 0xb7, 0xf8, + 0x78, 0x6f, 0x28, 0x18, 0x42, 0xa6, + ], transparent_input: Some(0), script_code: Some(vec![]), amount: Some(1405243945822387),