38
38
ErrExclusionProofUnexpectedValue = errors .New ("exclusion proof's value should be empty" )
39
39
ErrExclusionProofInvalidNode = errors .New ("invalid node for exclusion proof" )
40
40
ErrProofValueDoesntMatch = errors .New ("the provided value does not match the proof node for the provided key's value" )
41
+ ErrProofKeyPartialByte = errors .New ("the provided key has partial byte length" )
41
42
ErrProofNodeHasUnincludedValue = errors .New ("the provided proof has a value for a key within the range that is not present in the provided key/values" )
42
43
ErrInvalidMaybe = errors .New ("maybe is nothing but has value" )
43
44
ErrNilProofNode = errors .New ("proof node is nil" )
@@ -124,6 +125,7 @@ type Proof struct {
124
125
// Always contains at least the root.
125
126
Path []ProofNode
126
127
// This is a proof that [key] exists/doesn't exist.
128
+ // Must not have any partial bytes.
127
129
Key Key
128
130
129
131
// Nothing if [Key] isn't in the trie.
@@ -145,6 +147,10 @@ func (proof *Proof) Verify(
145
147
return ErrEmptyProof
146
148
}
147
149
150
+ if proof .Key .hasPartialByte () {
151
+ return ErrProofKeyPartialByte
152
+ }
153
+
148
154
lastNode := proof .Path [len (proof .Path )- 1 ]
149
155
inclusionProof := lastNode .Key .Compare (proof .Key ) == 0
150
156
@@ -258,6 +264,7 @@ type RangeProof struct {
258
264
// Each key is in the requested range (inclusive).
259
265
// The first key-value is the first key-value at/after the range start.
260
266
// The key-value pairs are consecutive.
267
+ // Must not have any partial bytes.
261
268
// Sorted by increasing key and with no duplicate keys.
262
269
KeyValues []KeyValue
263
270
}
@@ -352,6 +359,9 @@ func (proof *RangeProof) Verify(
352
359
keys := make ([]Key , len (proof .KeyValues ))
353
360
for i , keyValue := range proof .KeyValues {
354
361
k := ToKey (keyValue .Key )
362
+ if k .hasPartialByte () {
363
+ return ErrProofKeyPartialByte
364
+ }
355
365
356
366
keyValues [k ] = keyValue .Value
357
367
keys [i ] = k
@@ -580,6 +590,7 @@ type ChangeProof struct {
580
590
// end roots such that k1 < k3 < k2.
581
591
// This is a subset of the requested key-value range, rather than the entire
582
592
// range, because otherwise the proof may be too large.
593
+ // Must not have any partial bytes.
583
594
// Sorted by increasing key and with no duplicate keys.
584
595
//
585
596
// Example: Suppose that between the start root and the end root, the following
0 commit comments