entropy.bend
1# W3C Trace Context Level 2 propagation, with its rules proved as laws. Source: https://github.com/LucasGois1/bend-trace-context
2#
3# Host entropy
4# ============
5#
6# The first line is the package's description on BendHub, which describes a
7# package by the first line of its first .bend file in path order: this one.
8#
9# The package's only host binding for randomness: entropy/native.c natively and
10# entropy/webcrypto.js in JavaScript. generation.bend reads source words from
11# it; trace_context.bend never does.
12
13import Base
14
15# One word from the host's cryptographic source: WebCrypto in JavaScript and
16# the operating system's generator natively. Fail code 1 means unavailable and
17# code 2 means source-failure in JavaScript; natively the code is the host
18# errno with its strerror text. The pure codec never calls it implicitly.
19def read_u32() -> IO(Result<&1, &1, U32 & String, U32>):
20 import "./entropy/native.c"
21 import "./entropy/webcrypto.js"