pycape.function_ref module#

A structured set of metadata representing a deployed Cape function.

A FunctionRef is intended to capture any/all metadata related to a Cape function. The metadata is generally user-supplied, provided to them with the output of the Cape CLI’s deploy command.


fid = "asdf231lkg1324afdg"
fchecksum = str(b"2l1h21jhgb2k1jh3".hex())
fref = FunctionRef(fid, fchecksum)

cape = Cape()
class pycape.function_ref.FunctionRef(id, token, checksum=None)[source]#

Bases: object

A reference to a Cape function.

  • id (str) – Required string denoting the function ID of the deployed Cape function. Typically given with the output of the Cape CLI’s deploy command.

  • token (str) – Required string containing a Cape function token generated by the Cape CLI during cape token.

  • checksum (Optional[str]) – Optional string denoting the checksum of the deployed Cape function. If supplied as part of a FunctionRef, the Cape client will verify that enclave responses includes a matching checksum whenever the FunctionRef is included in Cape requests.

property checksum#
classmethod from_json(function_json)[source]#

Construct a FunctionRef from a JSON string or file.


function_json (Union[str, PathLike]) – a JSON string or filepath containing function ID, token, and optional checksum, e.g. as generated by the Cape CLI token command.

Return type:



A FunctionRef representing the deployed Cape function.


ValueError – if the json token file doesn’t exist or, the token file doesn’t contain a function_id or a function_token.

property id#

Write this FunctionRef to a JSON string or file.


path (Union[str, PathLike, None]) – Optional file path to write the resulting JSON to.

Return type:



If path is None, a string with this FunctionRef as a JSON struct.

property token#