File tree Expand file tree Collapse file tree 4 files changed +28
-9
lines changed
batcher/aligned-sdk/src/sdk Expand file tree Collapse file tree 4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -42,9 +42,13 @@ impl IsMerkleTreeBackend for Risc0ImageIdAndPubInputs {
4242
4343 fn hash_new_parent ( child_1 : & Self :: Node , child_2 : & Self :: Node ) -> Self :: Node {
4444 let mut hasher = Keccak :: v256 ( ) ;
45- hasher. update ( child_1) ;
46- hasher. update ( child_2) ;
47-
45+ if child_1 < child_2 {
46+ hasher. update ( child_1) ;
47+ hasher. update ( child_2) ;
48+ } else {
49+ hasher. update ( child_2) ;
50+ hasher. update ( child_1) ;
51+ }
4852 let mut hash = [ 0u8 ; 32 ] ;
4953 hasher. finalize ( & mut hash) ;
5054 hash
Original file line number Diff line number Diff line change @@ -39,8 +39,13 @@ impl IsMerkleTreeBackend for SP1VkAndPubInputs {
3939
4040 fn hash_new_parent ( child_1 : & Self :: Node , child_2 : & Self :: Node ) -> Self :: Node {
4141 let mut hasher = Keccak256 :: new ( ) ;
42- hasher. update ( child_1) ;
43- hasher. update ( child_2) ;
42+ if child_1 < child_2 {
43+ hasher. update ( child_1) ;
44+ hasher. update ( child_2) ;
45+ } else {
46+ hasher. update ( child_2) ;
47+ hasher. update ( child_1) ;
48+ }
4449 hasher. finalize ( ) . into ( )
4550 }
4651}
Original file line number Diff line number Diff line change @@ -152,8 +152,13 @@ impl IsMerkleTreeBackend for AlignedProof {
152152
153153 fn hash_new_parent ( child_1 : & Self :: Node , child_2 : & Self :: Node ) -> Self :: Node {
154154 let mut hasher = Keccak256 :: new ( ) ;
155- hasher. update ( child_1) ;
156- hasher. update ( child_2) ;
155+ if child_1 < child_2 {
156+ hasher. update ( child_1) ;
157+ hasher. update ( child_2) ;
158+ } else {
159+ hasher. update ( child_2) ;
160+ hasher. update ( child_1) ;
161+ }
157162 hasher. finalize ( ) . into ( )
158163 }
159164}
Original file line number Diff line number Diff line change @@ -72,8 +72,13 @@ impl IsMerkleTreeBackend for Hash32 {
7272
7373 fn hash_new_parent ( child_1 : & Self :: Node , child_2 : & Self :: Node ) -> Self :: Node {
7474 let mut hasher = Keccak256 :: new ( ) ;
75- hasher. update ( child_1) ;
76- hasher. update ( child_2) ;
75+ if child_1 < child_2 {
76+ hasher. update ( child_1) ;
77+ hasher. update ( child_2) ;
78+ } else {
79+ hasher. update ( child_2) ;
80+ hasher. update ( child_1) ;
81+ }
7782 hasher. finalize ( ) . into ( )
7883 }
7984}
You can’t perform that action at this time.
0 commit comments