def bytes_ok

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/curve25519/field.bend:41

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/curve25519/field.bend as Field
import Base

41# n values, each below 2^8
42def bytes_ok(n: Nat, xs: List<&2, U32>) -> Bool:
43  match n:
44    case 0n:
45      match xs:
46        case Nil{}:
47          True{}
48        case Con{x, xt}:
49          False{}
50    case 1n+m:
51      match xs:
52        case Nil{}:
53          False{}
54        case Con{x, xt}:
55          Bool.and(Nat.is_lt(U32.to_nat(x), 256n), bytes_ok(m, xt))

Uses (7)

Used by (18)