def mask_last

bend-collections-laws-crypto@1.0.0.0 · spec/crypto/curve25519/x25519.bend:40

import bend-collections-laws-crypto@1.0.0.0/spec/crypto/curve25519/x25519.bend as X25519
import Base

40# decodeUCoordinate: the last byte's top bit masked (bits = 255)
41def mask_last(xs: List<&2, U32>) -> List<&2, U32>:
42  match xs:
43    case Nil{}:
44      Nil{}
45    case Con{x, xt}:
46      match xt:
47        case Nil{}:
48          Con{U32.and(x, 127), Nil{}}
49        case Con{y, yt}:
50          Con{x, mask_last(Con{y, yt})}

Uses (3)

Used by (5)