index.js
function box(value, mayOpen) {
    if (typeof mayOpen !== 'function') {
      throw new TypeError(`Expected function not ${ mayOpen }`);
    }
    // Allocate an opaque token
    const newBox = new Box();
    boxes.set(
      newBox,
      freeze({ boxerPriv: privateKey, boxerPub: publicKey, value, mayOpen }));
    return newBox;
  }
function box(value, mayOpen) {
    if (typeof mayOpen !== 'function') {
      throw new TypeError(`Expected function not ${ mayOpen }`);
    }
    // Allocate an opaque token
    const newBox = new Box();
    boxes.set(
      newBox,
      freeze({ boxerPriv: privateKey, boxerPub: publicKey, value, mayOpen }));
    return newBox;
  }
function box ( value , mayOpen ) { if ( typeof mayOpen !== 'function' ) { throw new TypeError ( ` ${ mayOpen } ` ) ; } // Allocate an opaque token const newBox = new Box ( ) ; boxes . set ( newBox , freeze ( { boxerPriv : privateKey , boxerPub : publicKey , value , mayOpen } ) ) ; return newBox ; }
Wraps a value in a box so that only an approved
opener may unbox it.

@param {*} value the value that will be given to
an approved unboxer.
@param {!function(function():boolean):boolean} mayOpen
receives the public key of the opener.
Should return `true` to allow.
This will be called in the context of the opener's
private key, so the public key should also return true
called with no arguments.
@return {!Box} a box that is opaque to any receivers that cannot
unbox it.
Wraps a value in a box so that only an approved opener may unbox it .