API user creation for Custody Infrastructure systems in MPC-Driven mode can be performed from the MPC desktop app by an Admin.
Log in to the MPC desktop.
Navigate to the User Management area and click the + button to create a new user.
Complete the following fields of the New User Creation dialog:
- First Name, Last Name: This will identify the API user in notifications and activity audits.
- Email: Enter a username for the API user in the form of an email address, for example: [email protected]
- Role: Choose the role that the API user will use. The API user will be governed by the same policies as any other user in that role.
- User Group: Choose the user group that the API user will be part of. The API user will be governed by the same policies as any other user in that group.
- Public Key: Here, insert the typing key received from running the script above, prefixed by 0 (zero). This is the FIRST key output by the script you ran earlier.
If the Typing Key does not begin with 0, add it manually. The UI requires this format.
Before the change comes into effect, it must be approved by the relevant admins.
The request details appear for verification.
The API user is created as soon as the request is approved according to policy.
Custody Infrastructure API User Registration
API user registration is performed from the SDK by running the following:
from ApiClient import ApiClient
public_key = "Enter here the public key received from the generateKeysForRemoteUser function above"
from MpcDriven.EnumTypes import SignatureType
signature_type = SignatureType.SECP256K1
# Register the user and capture returned values
name, new_user = ApiClient.registerMpcUser(
public_key,
signature_type,
"ip address of the MCS",
is_production=True,
is_strict=True
)
# ✅ This line confirms the response's organization name
assert name == "organization name" # Must match value set by GK8 support
new_user.generateNewAccessToken()
Make sure to insert the public key from the first step above before running the code. Once completed, you are ready to run API calls. If no errors are returned, the user has been successfully created.
Store user keys to alternative location (optional)
The usual flow is to allow the Custody Infrastructure system to save the new user public and private keys to a secure location on your device. However, should you wish to store these keys in a different location, such as save them to a USB drive, or write them on paper and store in a safe place, follow this 2 step process:
Step 1: Generate and securely store the user keys
When creating a new user account, the context for the account must be set to GK8Context().
This prevents the creation of the GK8Storage.json file, which by default stores the public and private keys created for the new account. Instead, the keys are saved in memory and are lost when the session ends.
It is essential that the keys are saved to another location, such as a file generated by the administrator and stored on a USB drive. Alternatively, for optimal security, write down the keys on paper and store this in a secure location.
Generate the keys for the new user.
In your python script add the following:
private_key, public_key, typing_key = ApiClient.generateKeysForRemoteUser(curve=ec.SECP256K1(), context=GK8Context())
This saves the values of the private, public and typing key as variables in the system memory.
Export the private_key and public_key values to a secure location in a format that satisfies the security needs of the organization, i.e. a JSON file to a USB drive.
The typing_key is used in the Desktop app when adding the new user to the system. This should also be saved or written down and kept for this use. However, it doesn’t need to be saved with the other keys or used with the API calls.
Step 2: Register the API user with the existing keys
Run a second python script to register the existing user with the API. Depending on how the keys were saved, the code should either call the keys from the saved location, ie. on a USB drive, or the administrator might need to manually enter the public and private keys that were saved in the previous step.
Define the private_key and public_key:
private_key = "Enter your private key here or read it from your file",
public_key = "Enter your public key here or read it from your file"
Define the signature type:
signature_type = SignatureType.SECP256K1
Define the User keys by storing the keys to the helpers function:
helpers.storeUserKeys(private_key, public_key, context)
Ensure that helpers library is imported - from gk8_sdk.Helpers import helpers
Finally assign the user data.
name, new_user = ApiClient.registerMpcUser(public_key, signature_type, "YOUR_MCS_IP_HERE", is_production=True, is_impenetrable_vault_deployed=False, context=context)
OR this could be written:
name, new_user = ApiClient.registerMpcUser(public_key=public_key, signature_type=signature_type, ip="YOUR_MCS_IP_HERE", is_production=True, is_impenetrable_vault_deployed=False, context=context)
For a uMPC system is_impenetrable_vault_deployed will be False.
The user is now registered and can now make any API function call in the normal way, for example: