Skip to main content

index/functions/normalizePrivateKey.md

normalizePrivateKey(input): Uint8Array

Normalizes a secp256k1 private key to a fresh 32-byte array (the caller may zero it). Also accepts 32 raw bytes, which are validated and copied. For strings it accepts what @gala-chain/api's normalizePrivateKey accepted for a usable key: 64 hex characters (optionally 0x-prefixed; a 63-character hex key is left-padded with a zero) or a 44-character base64 string.

Parameters​

ParameterType
inputstring | Uint8Array<ArrayBufferLike>

Returns​

Uint8Array

Throws​

GalaSDKError (INVALID_PRIVATE_KEY; params.reason is one of INVALID_PRIVATE_KEY_REASONS: wrong_length for raw bytes that are not 32 long, bad_encoding for any other string shape, not_on_curve for an out-of-range scalar).