Documentation
¶
Overview ¶
Package zenroom is a CGO wrapper for the Zenroom virtual machine, which aims to make Zenroom easily usable from Go programs. Currently the C binary we wrap is only available for Linux.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exec ¶
Exec is our primary public API method, and it is here that we call Zenroom's zenroom_exec_tobuf function. This method attempts to pass a required script, and some optional extra parameters to the Zenroom virtual machine, where cryptographic operations are performed with the result being returned to the caller. The method signature has been tweaked slightly from the original function defined by Zenroom; rather than making all parameters required, instead we have just included as a required parameter the input SCRIPT, while all other properties must be supplied via one of the previously defined Option helpers.
Returns the output of the execution of the Zenroom virtual machine, or an error.
Example ¶
script := []byte(`print("hello")`) res, _ := zenroom.Exec(script) fmt.Println(string(res))
Output: hello
Types ¶
type Option ¶
type Option func(*config)
Option is a type alias we use to supply optional configuration to the primary Exec method this library exposes. Option is a functional configuration type alias for a function that takes as a parameter an unexported configuration object. Callers can supply keys, data, conf and verbosity via an Option using one of the WithXXX helper functions.
func WithConf ¶
WithConf is a configuration helper that allows the caller to pass in a value for the CONF parameter that Zenroom supports. The default for this value if not supplied is an empty string.
func WithData ¶
WithData is a configuration helper that allows the caller to pass in a value for the DATA parameter that Zenroom supports. The value of KEYS is a string, often but not required to be JSON formatted, containing data over which the script should operate. As with the KEYS property, DATA is passed separately from either the SCRIPT or the KEYS as these different values will often have different security requirements or may come from different sources. DATA must be passed as a byte slice.
func WithKeys ¶
WithKeys is a configuration helper that allows the caller to pass in a value for the KEYS parameter that Zenroom supports. The value of KEYS is typically a string, often JSON formatted, that contains one or more keys that the primary script requires in order to operate. These are passed separately from the main script as they will typically have different security requirements than the main script contents. Keys must be passed in to the helper in a byte slice.
func WithVerbosity ¶
WithVerbosity is a configuration helper that allows the caller to specify how verbose Zenroom should be with its output. The value of this configuration must be an integer from 1 to 3, where 1 is the least verbose, and 3 is the most. The default if this value is not supplied is 1.