crypto_operation
lib callCapy
function crypto_operation(request : any) any
Description
crypto_operation() runs an ES256 operation from a request map.
Set algorithm to "ES256". Set operation to "key_generate", "jwt_sign", "cbor_decode", "cose_es256_parse", or "es256_verify".
The success value contains the operation fields without operation or algorithm. For key_generate, these are public_jwk, private_jwk, kid, and thumbprint. For jwt_sign, the value contains jwt. For es256_verify, it contains valid. For cbor_decode, value is the decoded value itself.
An invalid request returns {ok: false, error: "invalid_request"}.
Parameters
request : an ES256 operation request map
Return Values
{ok: true, value: ...} on success. A failure returns {ok: false, error: "..."}.
Example
Capy
var result := crypto_operation(operation: "cbor_decode", algorithm: "ES256", cbor_base64url: "ggFiaGk") print(json_encode(result.value), "\n")
Output
{"type": "array", "items": [{"type": "unsigned", "value": "1"}, {"type": "text", "value": "hi"}]}