Next: , Previous: , Up: actor-lib: A standard library of sorts   [Contents][Index]


6.14 Sealers

The (goblins actor-lib sealers) module provides a mechanism for ensuring the authenticity of data. A sealer is used to place data within a wrapper. This wrapper can only be unsealed by the corresponding unsealer, and can be checked with a predicate to ensure it is authentic. Sealers and unsealers are analogous to public key cryptography, but do not use any cryptography at all.

Procedure: spawn-sealer-triplet [name] [#:make-sealer-triplet simple:make-sealer-triplet]

Return values holding a sealer, unsealer, and check capability. name, if provided, is the debug name of the underlying Scheme record object. make-sealer-triplet, if provided, is the primitive used to create the sealer objects. Each sealer object can be invoked with a single argument:

  • sealer value: Seal value and return a reference to the sealed object.
  • unsealer value: Unseal the value sealed with the corresponding sealer. If the unsealed object is near, it is returned directly; otherwise, a promise is returned.

As an example, consider a metaphorical food delivery service and its rival service:

> (define-values (our-lunch:seal our-lunch:unseal our-can?)
    (spawn-sealer-triplet))
> (define-values (rival-lunch:seal rival-lunch:unseal rival-can?)
    (spawn-sealer-triplet))
> ($ our-lunch:seal 'fried-rice)
=> #<local-object sealed-value>
> (define chickpea-lunch ($ our-lunch:seal 'chickpea-salad))
> ($ our-can? chickpea-lunch)
=> #t
> ($ our-can? ($ rival-lunch:seal 'melted-ice-cream))
=> #f
> ($ our-lunch:unseal chickpea-lunch)
=> chickpea-salad
Procedure: make-spawn-sealer-triplet namespace known-sealers

[default-make-sealer-triplet]

Returns two values, the first is a spawn-sealer-triplet function setup with a set of custom sealers and the second is a persistence environment for Goblins’ persistence system.

namespace is a atomic value which must uniquely identify this set of sealers within the object graph.

known-sealers is an alist mapping a unique name to a thunk which returns three values (sealer function, unsealer function and trademark function).

default-make-sealer-triplet specifies what the default make-sealer-triplet function is used when none is specified.

If a custom sealer triplet is provided to the returned spawn-sealer-triplet function without being specified in the known-sealers alist, an error will be thrown.

(define* (my-custom-sealer-triplet #:optional name)
  (define-record-type <custom-sealers>
    (seal val)
    sealed?
    (val unseal))
  (values seal unseal sealed?))

(define custom-sealers-list
  `(((ward-sealer-triplet) . ,my-custom-sealer-triplet)))

(define-values (custom-spawn-sealer-triplet custom-sealer-env)
  (make-spawn-sealer-triplet '(my-library sealers) custom-sealers-list
			     #:default-make-sealer-triplet my-custom-sealer-triplet))
Persistence Environment: sealers-env

Next: Selfish-Spawn, Previous: Queue, Up: actor-lib: A standard library of sorts   [Contents][Index]