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.
uint8 array normalize private key
Parameters
| Parameter | Type |
|---|---|
input | string | Uint8Array<ArrayBufferLike> |
uint8 array buffer like
Returns
Uint8Array
uint8 array
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).
invalid private key reasons wrong length bad encoding not on curve