@@ -4,6 +4,8 @@ import com.google.common.primitives.{Bytes, Ints}
44import scorex .crypto .authds .avltree .batch .{BatchAVLProver , InternalProverNode , ProverLeaf , ProverNodes }
55import scorex .crypto .authds .{ADKey , ADValue , Balance }
66import scorex .crypto .hash .{CryptographicHash , Digest }
7+ import scorex .util .encode .Base16
8+ import scorex .utils .ByteArray
79
810import scala .util .Try
911
@@ -128,8 +130,11 @@ class BatchAVLProverSerializer[D <: Digest, HF <: CryptographicHash[D]](implicit
128130 val rightBytes = bytes.slice(keyLength + 6 + leftLength, bytes.length)
129131 val left = loop(leftBytes)
130132 val right = loop(rightBytes)
131- val keyAsNum = BigInt (1 , key)
132- require(BigInt (1 , left.key) < keyAsNum && keyAsNum <= BigInt (1 , right.key), s " key check fail " )
133+
134+ // check that left.key < key <= right.key
135+ val leftComparison = ByteArray .compare(left.key, key)
136+ val rightComparison = ByteArray .compare(key, right.key)
137+ require(leftComparison < 0 && rightComparison <= 0 , s " key check fail for key ${Base16 .encode(key)}" )
133138 new InternalProverNode [D ](key, left, right, balance)
134139 case 2 =>
135140 val balance = Balance @@ bytes.slice(1 , 2 ).head
0 commit comments