MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / compress

Function compress

bitcoin/core/contrib/ripemd160.py:73–93  ·  view source on GitHub ↗

Compress state (h0, h1, h2, h3, h4) with block.

(h0, h1, h2, h3, h4, block)

Source from the content-addressed store, hash-verified

71
72
73def compress(h0, h1, h2, h3, h4, block):
74 """Compress state (h0, h1, h2, h3, h4) with block."""
75 # Left path variables.
76 al, bl, cl, dl, el = h0, h1, h2, h3, h4
77 # Right path variables.
78 ar, br, cr, dr, er = h0, h1, h2, h3, h4
79 # Message variables.
80 x = [int.from_bytes(block[4*i:4*(i+1)], 'little') for i in range(16)]
81
82 # Iterate over the 80 rounds of the compression.
83 for j in range(80):
84 rnd = j >> 4
85 # Perform left side of the transformation.
86 al = rol(al + fi(bl, cl, dl, rnd) + x[ML[j]] + KL[rnd], RL[j]) + el
87 al, bl, cl, dl, el = el, al, bl, rol(cl, 10), dl
88 # Perform right side of the transformation.
89 ar = rol(ar + fi(br, cr, dr, 4 - rnd) + x[MR[j]] + KR[rnd], RR[j]) + er
90 ar, br, cr, dr, er = er, ar, br, rol(cr, 10), dr
91
92 # Compose old state, left transform, and right transform into new state.
93 return h1 + cl + dr, h2 + dl + er, h3 + el + ar, h4 + al + br, h0 + bl + cr
94
95
96def ripemd160(data):

Callers 1

ripemd160Function · 0.85

Calls 3

rolFunction · 0.85
fiFunction · 0.85
from_bytesMethod · 0.45

Tested by

no test coverage detected