Skip to content
Dan Connolly edited this page Mar 29, 2023 · 6 revisions

A sealer and unsealer work a bit like public key cryptography conceptually.

One gives something to the sealer and it puts that into a box that only the corresponding unsealer can open.

They are an example of a rights amplification pattern that provides Synergy.

Useful for passing objects through untrusted callers/objects/parties with out the latter gaining direct access to those passed objects.

makeSealerUnsealer in Rholang

from MultiSigRevVault.rho#L34-L56

    contract MultiSigRevVault(@"makeSealerUnsealer", ret) = {
      new mapStore, sealer, unsealer in {
        mapStore!({}) |
        contract sealer(@value, retS) = {
          for (@map <- mapStore) {
            new box in {
              mapStore!(map.set(*box, value)) |
              retS!(*box)
            }
          }
        } |
        contract unsealer(@box, retU) = {
          for (@map <<- mapStore) {
            if (map.contains(box)) {
              retU!((true, map.get(box)))
            } else {
              retU!((false, "Invalid box"))
            }
          }
        } |
        ret!((*sealer, *unsealer))
      }
    } |

References

todo: integrate caja version: https://github.com/googlearchive/caja/blob/1056be89dad487f9178d89f462fe5cb207c7e604/src/com/google/caja/ses/ejectorsGuardsTrademarks.js#L158-L186