KEY.PRIV

KEY.PRIV validates the format of the private member of a public/private key pair then returns a hashed and Base64 encoded digest.

If the key is not valid or cannot be extracted, KEY.PRIV will throw an error. It is designed for use within the Xapix system.

Function category: Key

Syntax

KEY.PRIV(arg1)

Arguments

Description

arg1

Private key of a public/private key pair.

Examples

Example 1: Extract and validate token using the private key

Let's say we are given the following private key:

{ keys:
{ private: "-----BEGIN EC PRIVATE KEY-----
MHcCAQEEINCzFsHTrgu6zJMGR+HHWxNZDrV69EOzmb7mSOJ0+J3soAoGCCqGSM49
AwEHoUQDQgAEdOaYkKtVJrSWFmBnZvjofkjMNqL84PdCIKp85JglpuM9m11Pg2Jv
UkFefPmR48p0SxJoTNyC9oZ9wA3KFTcNXA==
-----END EC PRIVATE KEY-----"
}
}

If we wanted to extract and validate the token with the key above, we could do so with KEY.PRIV:

KEY.PRIV(keys.private)

This returns the following:

"u8VowWT3lK6IlEmARreueWkGauYwL2zBa5YnLrYWW58="

This can then be passed into a call to JWT.SIGN as a signature for a JWT or JWS.