def bytes_length_limit.go
qasim-bend-kit@0.1.0.2 · libs/AES256GCM.bend:40
import qasim-bend-kit@0.1.0.2/libs/AES256GCM.bend as AES256GCM
import Base
40def bytes_length_limit.go(fuel: Nat, bytes: List<&2, U32>,
41 low: U32, +high: U32, +max_low: U32, +max_high: U32,
42 within: Bool) -> Bool:
43 match fuel bytes within:
44 case 0n Nil{} _: within
45 case 0n _ <> _ _: False{}
46 case 1n+p Nil{} _: False{}
47 case 1n+p _ <> _ False{}: False{}
48 case 1n+p _ <> tail True{}:
49 +next_low = U32.add(low, 1)
50 +next_high = Bool.pick(U32, U32.is_eq(next_low, 0), U32.add(high, 1), high)
51 bytes_length_limit.go(p, tail, next_low, next_high,
52 max_low, max_high,
53 length_pair_within(next_low, next_high, max_low, max_high))