Home / Docs / Diagnostics

U4004: policy outside a trusted module

Release v0.4.0

A module whose header does not say trusted declares a policy.

Why Una rejects it

A policy lowers labels, so it is part of the trusted computing base. It is allowed only in a module whose header says trusted module and that una.toml lists under [trusted] modules, or from edition 0.4 the trusted section of ita.una (spec/07 §5, §6).

U4004 reports a policy in a module whose header does not say trusted. A header that says trusted without the listing is U7005.

How to fix it

The repair at a glance

src/keys.unadiff
  trusted module keys

  pub pepper() -> Int = 7
+
+ pub policy reveal
+   from secret Text
+   to Text
+   via shown
+   purpose "show a digest"
+   owner privacy
+
+ shown(t: secret Text) -> Text = t
src/demo.unadiff
  module demo

- pub policy reveal
-   from secret Text
-   to Text
-   via shown
-   purpose "show a digest"
-   owner privacy
-
- shown(t: secret Text) -> Text = t
+ pub one() -> Int = 1

Failing example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"

[trusted]
modules = ["keys"]
src/keys.unauna
trusted module keys

pub pepper() -> Int = 7
src/demo.unauna
module demo

pub policy reveal
  from secret Text
  to Text
  via shown
  purpose "show a digest"
  owner privacy

shown(t: secret Text) -> Text = t

Fixed example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"

[trusted]
modules = ["keys"]
src/keys.unauna
trusted module keys

pub pepper() -> Int = 7

pub policy reveal
  from secret Text
  to Text
  via shown
  purpose "show a digest"
  owner privacy

shown(t: secret Text) -> Text = t
src/demo.unauna
module demo

pub one() -> Int = 1