Skip to content

Commit b904de3

Browse files
committed
Merge rust-bitcoin#2877: hashes: remove all_zeros and constify constructors
4652ce2 API changes for "delete `all_zeros`" (Andrew Poelstra) 8869f35 hashes: drop the `all_zeros` method on arbitrary hashes (Andrew Poelstra) 9f8797f API changes for constification of hash constructors (Andrew Poelstra) 154e91a hashes: constify a bunch of constructors (Andrew Poelstra) c155cbf hashes: use workaround to get constfns on tagged hashes with MSRV (Andrew Poelstra) Pull request description: I think these changes are both uncontroversial but they have fairly large diffs so I am PRing them together before making more invasive changes. ACKs for top commit: tcharding: ACK 4652ce2 Tree-SHA512: 4560fa397deab50448598894b9364f9d8f8b48169901a84db6a44168cdba795ab69b48ad2cac61caebcee5e227a03271335b405cf5514265290a4d1f2fdf52a2
2 parents 4a1d81c + 4652ce2 commit b904de3

File tree

18 files changed

+435
-533
lines changed

18 files changed

+435
-533
lines changed

api/bitcoin/all-features.txt

Lines changed: 114 additions & 130 deletions
Large diffs are not rendered by default.

api/bitcoin/default-features.txt

Lines changed: 114 additions & 130 deletions
Large diffs are not rendered by default.

api/bitcoin/no-features.txt

Lines changed: 114 additions & 130 deletions
Large diffs are not rendered by default.

api/hashes/all-features.txt

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#[repr(transparent)] pub struct bitcoin_hashes::sha1::Hash(_)
66
#[repr(transparent)] pub struct bitcoin_hashes::sha256::Hash(_)
77
#[repr(transparent)] pub struct bitcoin_hashes::sha256d::Hash(_)
8-
#[repr(transparent)] pub struct bitcoin_hashes::sha256t::Hash<T: bitcoin_hashes::sha256t::Tag>(_, _)
8+
#[repr(transparent)] pub struct bitcoin_hashes::sha256t::Hash<T>(_, _)
99
#[repr(transparent)] pub struct bitcoin_hashes::sha384::Hash(_)
1010
#[repr(transparent)] pub struct bitcoin_hashes::sha512::Hash(_)
1111
#[repr(transparent)] pub struct bitcoin_hashes::sha512_256::Hash(_)
@@ -431,7 +431,6 @@ impl<T: bitcoin_hashes::Hash> core::marker::StructuralPartialEq for bitcoin_hash
431431
impl<T: bitcoin_hashes::Hash> std::io::Write for bitcoin_hashes::hmac::HmacEngine<T>
432432
impl<T: bitcoin_hashes::sha256t::Tag> bitcoin_hashes::Hash for bitcoin_hashes::sha256t::Hash<T>
433433
impl<T: bitcoin_hashes::sha256t::Tag> bitcoin_hashes::serde_macros::serde_details::SerdeHash for bitcoin_hashes::sha256t::Hash<T>
434-
impl<T: bitcoin_hashes::sha256t::Tag> bitcoin_hashes::sha256t::Hash<T>
435434
impl<T: bitcoin_hashes::sha256t::Tag> core::borrow::Borrow<[u8]> for bitcoin_hashes::sha256t::Hash<T>
436435
impl<T: bitcoin_hashes::sha256t::Tag> core::clone::Clone for bitcoin_hashes::sha256t::Hash<T>
437436
impl<T: bitcoin_hashes::sha256t::Tag> core::cmp::Eq for bitcoin_hashes::sha256t::Hash<T>
@@ -458,6 +457,8 @@ impl<T: core::cmp::PartialEq + bitcoin_hashes::Hash> core::cmp::PartialEq for bi
458457
impl<T: core::cmp::PartialOrd + bitcoin_hashes::Hash> core::cmp::PartialOrd for bitcoin_hashes::hmac::Hmac<T>
459458
impl<T: core::hash::Hash + bitcoin_hashes::Hash> core::hash::Hash for bitcoin_hashes::hmac::Hmac<T>
460459
impl<T: core::marker::Copy + bitcoin_hashes::Hash> core::marker::Copy for bitcoin_hashes::hmac::Hmac<T>
460+
impl<T> bitcoin_hashes::sha256t::Hash<T> where (T): bitcoin_hashes::sha256t::Tag
461+
impl<T> bitcoin_hashes::sha256t::Tag for (T) where T: bitcoin_hashes::sha256t::Tag
461462
impl<T> core::marker::Freeze for bitcoin_hashes::hkdf::Hkdf<T> where T: core::marker::Freeze
462463
impl<T> core::marker::Freeze for bitcoin_hashes::hmac::Hmac<T> where T: core::marker::Freeze
463464
impl<T> core::marker::Freeze for bitcoin_hashes::hmac::HmacEngine<T> where <T as bitcoin_hashes::Hash>::Engine: core::marker::Freeze
@@ -534,56 +535,50 @@ pub const bitcoin_hashes::siphash24::Hash::DISPLAY_BACKWARD: bool
534535
pub const bitcoin_hashes::siphash24::Hash::LEN: usize
535536
pub const bitcoin_hashes::siphash24::Hash::N: usize
536537
pub const bitcoin_hashes::siphash24::HashEngine::BLOCK_SIZE: usize
537-
pub const fn bitcoin_hashes::hash160::Hash::all_zeros() -> Self
538538
pub const fn bitcoin_hashes::hash160::Hash::as_byte_array(&self) -> &[u8; 20]
539539
pub const fn bitcoin_hashes::hash160::Hash::from_byte_array(bytes: [u8; 20]) -> Self
540540
pub const fn bitcoin_hashes::hash160::Hash::to_byte_array(self) -> [u8; 20]
541-
pub const fn bitcoin_hashes::ripemd160::Hash::all_zeros() -> Self
542541
pub const fn bitcoin_hashes::ripemd160::Hash::as_byte_array(&self) -> &[u8; 20]
543542
pub const fn bitcoin_hashes::ripemd160::Hash::from_byte_array(bytes: [u8; 20]) -> Self
544543
pub const fn bitcoin_hashes::ripemd160::Hash::to_byte_array(self) -> [u8; 20]
545-
pub const fn bitcoin_hashes::sha1::Hash::all_zeros() -> Self
546544
pub const fn bitcoin_hashes::sha1::Hash::as_byte_array(&self) -> &[u8; 20]
547545
pub const fn bitcoin_hashes::sha1::Hash::from_byte_array(bytes: [u8; 20]) -> Self
548546
pub const fn bitcoin_hashes::sha1::Hash::to_byte_array(self) -> [u8; 20]
549-
pub const fn bitcoin_hashes::sha256::Hash::all_zeros() -> Self
550547
pub const fn bitcoin_hashes::sha256::Hash::as_byte_array(&self) -> &[u8; 32]
551548
pub const fn bitcoin_hashes::sha256::Hash::const_hash(bytes: &[u8]) -> Self
552549
pub const fn bitcoin_hashes::sha256::Hash::from_byte_array(bytes: [u8; 32]) -> Self
553550
pub const fn bitcoin_hashes::sha256::Hash::to_byte_array(self) -> [u8; 32]
554551
pub const fn bitcoin_hashes::sha256::Midstate::from_byte_array(inner: [u8; 32]) -> Self
555552
pub const fn bitcoin_hashes::sha256::Midstate::hash_tag(tag: &[u8]) -> Self
556553
pub const fn bitcoin_hashes::sha256::Midstate::to_byte_array(self) -> [u8; 32]
557-
pub const fn bitcoin_hashes::sha256d::Hash::all_zeros() -> Self
558554
pub const fn bitcoin_hashes::sha256d::Hash::as_byte_array(&self) -> &[u8; 32]
559555
pub const fn bitcoin_hashes::sha256d::Hash::from_byte_array(bytes: [u8; 32]) -> Self
560556
pub const fn bitcoin_hashes::sha256d::Hash::to_byte_array(self) -> [u8; 32]
561-
pub const fn bitcoin_hashes::sha384::Hash::all_zeros() -> Self
557+
pub const fn bitcoin_hashes::sha256t::Hash<T>::as_byte_array(&self) -> &[u8; 32]
558+
pub const fn bitcoin_hashes::sha256t::Hash<T>::from_byte_array(bytes: [u8; 32]) -> Self
559+
pub const fn bitcoin_hashes::sha256t::Hash<T>::to_byte_array(self) -> [u8; 32]
562560
pub const fn bitcoin_hashes::sha384::Hash::as_byte_array(&self) -> &[u8; 48]
563561
pub const fn bitcoin_hashes::sha384::Hash::from_byte_array(bytes: [u8; 48]) -> Self
564562
pub const fn bitcoin_hashes::sha384::Hash::to_byte_array(self) -> [u8; 48]
565-
pub const fn bitcoin_hashes::sha512::Hash::all_zeros() -> Self
566563
pub const fn bitcoin_hashes::sha512::Hash::as_byte_array(&self) -> &[u8; 64]
567564
pub const fn bitcoin_hashes::sha512::Hash::from_byte_array(bytes: [u8; 64]) -> Self
568565
pub const fn bitcoin_hashes::sha512::Hash::to_byte_array(self) -> [u8; 64]
569-
pub const fn bitcoin_hashes::sha512_256::Hash::all_zeros() -> Self
570566
pub const fn bitcoin_hashes::sha512_256::Hash::as_byte_array(&self) -> &[u8; 32]
571567
pub const fn bitcoin_hashes::sha512_256::Hash::from_byte_array(bytes: [u8; 32]) -> Self
572568
pub const fn bitcoin_hashes::sha512_256::Hash::to_byte_array(self) -> [u8; 32]
573-
pub const fn bitcoin_hashes::siphash24::Hash::all_zeros() -> Self
574569
pub const fn bitcoin_hashes::siphash24::Hash::as_byte_array(&self) -> &[u8; 8]
575570
pub const fn bitcoin_hashes::siphash24::Hash::from_byte_array(bytes: [u8; 8]) -> Self
576571
pub const fn bitcoin_hashes::siphash24::Hash::to_byte_array(self) -> [u8; 8]
577572
pub const fn bitcoin_hashes::siphash24::HashEngine::new() -> bitcoin_hashes::siphash24::HashEngine
578573
pub const fn bitcoin_hashes::siphash24::HashEngine::with_keys(k0: u64, k1: u64) -> bitcoin_hashes::siphash24::HashEngine
579574
pub extern crate bitcoin_hashes::hex
580575
pub extern crate bitcoin_hashes::serde
576+
pub fn (T)::engine() -> bitcoin_hashes::sha256::HashEngine
581577
pub fn bitcoin_hashes::FromSliceError::clone(&self) -> bitcoin_hashes::FromSliceError
582578
pub fn bitcoin_hashes::FromSliceError::eq(&self, other: &bitcoin_hashes::FromSliceError) -> bool
583579
pub fn bitcoin_hashes::FromSliceError::expected_length(&self) -> usize
584580
pub fn bitcoin_hashes::FromSliceError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
585581
pub fn bitcoin_hashes::FromSliceError::invalid_length(&self) -> usize
586-
pub fn bitcoin_hashes::Hash::all_zeros() -> Self
587582
pub fn bitcoin_hashes::Hash::as_byte_array(&self) -> &Self::Bytes
588583
pub fn bitcoin_hashes::Hash::engine() -> Self::Engine
589584
pub fn bitcoin_hashes::Hash::from_byte_array(bytes: Self::Bytes) -> Self
@@ -596,7 +591,6 @@ pub fn bitcoin_hashes::HashEngine::input(&mut self, data: &[u8])
596591
pub fn bitcoin_hashes::HashEngine::midstate(&self) -> Self::MidState
597592
pub fn bitcoin_hashes::HashEngine::n_bytes_hashed(&self) -> usize
598593
pub fn bitcoin_hashes::cmp::fixed_time_eq(a: &[u8], b: &[u8]) -> bool
599-
pub fn bitcoin_hashes::hash160::Hash::all_zeros() -> Self
600594
pub fn bitcoin_hashes::hash160::Hash::as_byte_array(&self) -> &Self::Bytes
601595
pub fn bitcoin_hashes::hash160::Hash::as_ref(&self) -> &[u8; 20]
602596
pub fn bitcoin_hashes::hash160::Hash::as_ref(&self) -> &[u8]
@@ -629,7 +623,6 @@ pub fn bitcoin_hashes::hkdf::Hkdf<T>::new(salt: &[u8], ikm: &[u8]) -> Self
629623
pub fn bitcoin_hashes::hkdf::MaxLengthError::clone(&self) -> bitcoin_hashes::hkdf::MaxLengthError
630624
pub fn bitcoin_hashes::hkdf::MaxLengthError::eq(&self, other: &bitcoin_hashes::hkdf::MaxLengthError) -> bool
631625
pub fn bitcoin_hashes::hkdf::MaxLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
632-
pub fn bitcoin_hashes::hmac::Hmac<T>::all_zeros() -> Self
633626
pub fn bitcoin_hashes::hmac::Hmac<T>::as_byte_array(&self) -> &Self::Bytes
634627
pub fn bitcoin_hashes::hmac::Hmac<T>::as_ref(&self) -> &[u8]
635628
pub fn bitcoin_hashes::hmac::Hmac<T>::clone(&self) -> bitcoin_hashes::hmac::Hmac<T>
@@ -659,7 +652,6 @@ pub fn bitcoin_hashes::hmac::HmacEngine<T>::n_bytes_hashed(&self) -> usize
659652
pub fn bitcoin_hashes::hmac::HmacEngine<T>::new(key: &[u8]) -> bitcoin_hashes::hmac::HmacEngine<T>
660653
pub fn bitcoin_hashes::hmac::HmacEngine<T>::write(&mut self, buf: &[u8]) -> bitcoin_io::Result<usize>
661654
pub fn bitcoin_hashes::hmac::HmacEngine<T>::write(&mut self, buf: &[u8]) -> std::io::error::Result<usize>
662-
pub fn bitcoin_hashes::ripemd160::Hash::all_zeros() -> Self
663655
pub fn bitcoin_hashes::ripemd160::Hash::as_byte_array(&self) -> &Self::Bytes
664656
pub fn bitcoin_hashes::ripemd160::Hash::as_ref(&self) -> &[u8; 20]
665657
pub fn bitcoin_hashes::ripemd160::Hash::as_ref(&self) -> &[u8]
@@ -698,7 +690,6 @@ pub fn bitcoin_hashes::ripemd160::HashEngine::write(&mut self, buf: &[u8]) -> st
698690
pub fn bitcoin_hashes::serde_macros::serde_details::SerdeHash::deserialize<'de, D: serde::de::Deserializer<'de>>(d: D) -> core::result::Result<Self, <D as serde::de::Deserializer>::Error>
699691
pub fn bitcoin_hashes::serde_macros::serde_details::SerdeHash::from_slice_delegated(sl: &[u8]) -> core::result::Result<Self, bitcoin_hashes::FromSliceError>
700692
pub fn bitcoin_hashes::serde_macros::serde_details::SerdeHash::serialize<S: serde::ser::Serializer>(&self, s: S) -> core::result::Result<<S as serde::ser::Serializer>::Ok, <S as serde::ser::Serializer>::Error>
701-
pub fn bitcoin_hashes::sha1::Hash::all_zeros() -> Self
702693
pub fn bitcoin_hashes::sha1::Hash::as_byte_array(&self) -> &Self::Bytes
703694
pub fn bitcoin_hashes::sha1::Hash::as_ref(&self) -> &[u8; 20]
704695
pub fn bitcoin_hashes::sha1::Hash::as_ref(&self) -> &[u8]
@@ -734,7 +725,6 @@ pub fn bitcoin_hashes::sha1::HashEngine::midstate(&self) -> [u8; 20]
734725
pub fn bitcoin_hashes::sha1::HashEngine::n_bytes_hashed(&self) -> usize
735726
pub fn bitcoin_hashes::sha1::HashEngine::write(&mut self, buf: &[u8]) -> bitcoin_io::Result<usize>
736727
pub fn bitcoin_hashes::sha1::HashEngine::write(&mut self, buf: &[u8]) -> std::io::error::Result<usize>
737-
pub fn bitcoin_hashes::sha256::Hash::all_zeros() -> Self
738728
pub fn bitcoin_hashes::sha256::Hash::as_byte_array(&self) -> &Self::Bytes
739729
pub fn bitcoin_hashes::sha256::Hash::as_ref(&self) -> &[u8; 32]
740730
pub fn bitcoin_hashes::sha256::Hash::as_ref(&self) -> &[u8]
@@ -788,7 +778,6 @@ pub fn bitcoin_hashes::sha256::Midstate::hash<__H: core::hash::Hasher>(&self, st
788778
pub fn bitcoin_hashes::sha256::Midstate::index(&self, index: I) -> &Self::Output
789779
pub fn bitcoin_hashes::sha256::Midstate::partial_cmp(&self, other: &bitcoin_hashes::sha256::Midstate) -> core::option::Option<core::cmp::Ordering>
790780
pub fn bitcoin_hashes::sha256::Midstate::serialize<S: serde::ser::Serializer>(&self, s: S) -> core::result::Result<<S as serde::ser::Serializer>::Ok, <S as serde::ser::Serializer>::Error>
791-
pub fn bitcoin_hashes::sha256d::Hash::all_zeros() -> Self
792781
pub fn bitcoin_hashes::sha256d::Hash::as_byte_array(&self) -> &Self::Bytes
793782
pub fn bitcoin_hashes::sha256d::Hash::as_ref(&self) -> &[u8; 32]
794783
pub fn bitcoin_hashes::sha256d::Hash::as_ref(&self) -> &[u8]
@@ -815,9 +804,7 @@ pub fn bitcoin_hashes::sha256d::Hash::partial_cmp(&self, other: &bitcoin_hashes:
815804
pub fn bitcoin_hashes::sha256d::Hash::schema_name() -> alloc::string::String
816805
pub fn bitcoin_hashes::sha256d::Hash::serialize<S: serde::ser::Serializer>(&self, s: S) -> core::result::Result<<S as serde::ser::Serializer>::Ok, <S as serde::ser::Serializer>::Error>
817806
pub fn bitcoin_hashes::sha256d::Hash::to_byte_array(self) -> Self::Bytes
818-
pub fn bitcoin_hashes::sha256t::Hash<T>::all_zeros() -> Self
819807
pub fn bitcoin_hashes::sha256t::Hash<T>::as_byte_array(&self) -> &Self::Bytes
820-
pub fn bitcoin_hashes::sha256t::Hash<T>::as_byte_array(&self) -> &[u8; 32]
821808
pub fn bitcoin_hashes::sha256t::Hash<T>::as_ref(&self) -> &[u8; 32]
822809
pub fn bitcoin_hashes::sha256t::Hash<T>::as_ref(&self) -> &[u8]
823810
pub fn bitcoin_hashes::sha256t::Hash<T>::borrow(&self) -> &[u8]
@@ -829,7 +816,6 @@ pub fn bitcoin_hashes::sha256t::Hash<T>::engine() -> bitcoin_hashes::sha256::Has
829816
pub fn bitcoin_hashes::sha256t::Hash<T>::eq(&self, other: &bitcoin_hashes::sha256t::Hash<T>) -> bool
830817
pub fn bitcoin_hashes::sha256t::Hash<T>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
831818
pub fn bitcoin_hashes::sha256t::Hash<T>::from_byte_array(bytes: Self::Bytes) -> Self
832-
pub fn bitcoin_hashes::sha256t::Hash<T>::from_byte_array(bytes: [u8; 32]) -> Self
833819
pub fn bitcoin_hashes::sha256t::Hash<T>::from_bytes_mut(bytes: &mut [u8; 32]) -> &mut Self
834820
pub fn bitcoin_hashes::sha256t::Hash<T>::from_bytes_ref(bytes: &[u8; 32]) -> &Self
835821
pub fn bitcoin_hashes::sha256t::Hash<T>::from_engine(e: bitcoin_hashes::sha256::HashEngine) -> bitcoin_hashes::sha256t::Hash<T>
@@ -845,9 +831,7 @@ pub fn bitcoin_hashes::sha256t::Hash<T>::partial_cmp(&self, other: &bitcoin_hash
845831
pub fn bitcoin_hashes::sha256t::Hash<T>::schema_name() -> alloc::string::String
846832
pub fn bitcoin_hashes::sha256t::Hash<T>::serialize<S: serde::ser::Serializer>(&self, s: S) -> core::result::Result<<S as serde::ser::Serializer>::Ok, <S as serde::ser::Serializer>::Error>
847833
pub fn bitcoin_hashes::sha256t::Hash<T>::to_byte_array(self) -> Self::Bytes
848-
pub fn bitcoin_hashes::sha256t::Hash<T>::to_byte_array(self) -> [u8; 32]
849834
pub fn bitcoin_hashes::sha256t::Tag::engine() -> bitcoin_hashes::sha256::HashEngine
850-
pub fn bitcoin_hashes::sha384::Hash::all_zeros() -> Self
851835
pub fn bitcoin_hashes::sha384::Hash::as_byte_array(&self) -> &Self::Bytes
852836
pub fn bitcoin_hashes::sha384::Hash::as_ref(&self) -> &[u8; 48]
853837
pub fn bitcoin_hashes::sha384::Hash::as_ref(&self) -> &[u8]
@@ -879,7 +863,6 @@ pub fn bitcoin_hashes::sha384::HashEngine::default() -> Self
879863
pub fn bitcoin_hashes::sha384::HashEngine::input(&mut self, inp: &[u8])
880864
pub fn bitcoin_hashes::sha384::HashEngine::midstate(&self) -> [u8; 64]
881865
pub fn bitcoin_hashes::sha384::HashEngine::n_bytes_hashed(&self) -> usize
882-
pub fn bitcoin_hashes::sha512::Hash::all_zeros() -> Self
883866
pub fn bitcoin_hashes::sha512::Hash::as_byte_array(&self) -> &Self::Bytes
884867
pub fn bitcoin_hashes::sha512::Hash::as_ref(&self) -> &[u8; 64]
885868
pub fn bitcoin_hashes::sha512::Hash::as_ref(&self) -> &[u8]
@@ -915,7 +898,6 @@ pub fn bitcoin_hashes::sha512::HashEngine::midstate(&self) -> [u8; 64]
915898
pub fn bitcoin_hashes::sha512::HashEngine::n_bytes_hashed(&self) -> usize
916899
pub fn bitcoin_hashes::sha512::HashEngine::write(&mut self, buf: &[u8]) -> bitcoin_io::Result<usize>
917900
pub fn bitcoin_hashes::sha512::HashEngine::write(&mut self, buf: &[u8]) -> std::io::error::Result<usize>
918-
pub fn bitcoin_hashes::sha512_256::Hash::all_zeros() -> Self
919901
pub fn bitcoin_hashes::sha512_256::Hash::as_byte_array(&self) -> &Self::Bytes
920902
pub fn bitcoin_hashes::sha512_256::Hash::as_ref(&self) -> &[u8; 32]
921903
pub fn bitcoin_hashes::sha512_256::Hash::as_ref(&self) -> &[u8]
@@ -947,7 +929,6 @@ pub fn bitcoin_hashes::sha512_256::HashEngine::default() -> Self
947929
pub fn bitcoin_hashes::sha512_256::HashEngine::input(&mut self, inp: &[u8])
948930
pub fn bitcoin_hashes::sha512_256::HashEngine::midstate(&self) -> [u8; 64]
949931
pub fn bitcoin_hashes::sha512_256::HashEngine::n_bytes_hashed(&self) -> usize
950-
pub fn bitcoin_hashes::siphash24::Hash::all_zeros() -> Self
951932
pub fn bitcoin_hashes::siphash24::Hash::as_byte_array(&self) -> &Self::Bytes
952933
pub fn bitcoin_hashes::siphash24::Hash::as_ref(&self) -> &[u8; 8]
953934
pub fn bitcoin_hashes::siphash24::Hash::as_ref(&self) -> &[u8]

0 commit comments

Comments
 (0)