FormatHashBlocks: blocks = 1 + ((len + 8) / 64); // should be len + 9 #599

issue dmgores opened this issue on October 29, 2011
  1. dmgores commented at 8:49 PM on October 29, 2011: none

    FormatHashBlocks: int blocks = 1 + ((len + 8) / 64);

    I think this should be len+9, because 64 bits are used for the bit count, and then assuming the input's length is in whole bytes, you will need one more byte in front of the length bytes to place the 0x80. Note this does not effect current versions of bitcoin, but maybe in the future if the length of the block's hash input changed, this could be a problem.

    Cheers, Dean

  2. sipa referenced this in commit 4947e1e208 on Feb 19, 2012
  3. sipa commented at 6:29 PM on February 19, 2012: member

    This is correct; SHA256 can hash up to 55 bytes in one block, not 56.

  4. sipa commented at 6:55 PM on February 20, 2012: member

    Actually... that means the formula is correct; closing...

  5. sipa closed this on Feb 20, 2012

  6. ptschip referenced this in commit 01580001f7 on May 19, 2017
  7. sipa referenced this in commit cc05fa919a on Mar 30, 2019
  8. sipa referenced this in commit 1e32413e52 on Mar 30, 2019
  9. sipa referenced this in commit 54245985fb on Mar 31, 2019
  10. sipa referenced this in commit 3fe71bbd95 on Apr 2, 2019
  11. LongShao007 referenced this in commit 3d9a3d2063 on Jul 15, 2019
  12. LongShao007 referenced this in commit 8af66f3427 on Jul 15, 2019
  13. LongShao007 referenced this in commit 807f206f73 on Jul 15, 2019
  14. fjahr referenced this in commit ee99f12f3d on Jul 24, 2019
  15. kallewoof referenced this in commit c866f52e2a on Oct 4, 2019
  16. backpacker69 referenced this in commit ef89673ace on Mar 28, 2021
  17. rajarshimaitra referenced this in commit 9af2827ba6 on Aug 5, 2021
  18. DrahtBot locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 06:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me