def mask_top

bend-collections@1.0.0.0 · src/crypto/curve25519/field.bend:275

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

275# the last byte with its top bit cleared (RFC 7748 decodeUCoordinate)
276def mask_top(xs: List<&2, U32>) -> List<&2, U32>:
277  match xs:
278    case Nil{}:
279      Nil{}
280    case Con{x, xt}:
281      match xt:
282        case Nil{}:
283          Con{U32.and(x, 127), Nil{}}
284        case Con{y, yt}:
285          Con{x, mask_top(Con{y, yt})}

Uses (3)

Used by (1)