decodeSuiPrivateKey function

(SignatureScheme, Uint8List) decodeSuiPrivateKey(
  1. String value
)

This returns an ParsedKeypair object based by validating the 33-byte Bech32 encoded string starting with suiprivkey, and parse out the signature scheme and the private key in bytes.

Implementation

(SignatureScheme, Uint8List) decodeSuiPrivateKey(String value) {
  final result = bech32.decode(value);
	if (result.hrp != SUI_PRIVATE_KEY_PREFIX) {
		throw ArgumentError('Invalid private key prefix');
	}
	final extendedSecretKey = bech32.fromWords(result.data);
	final signatureScheme = SIGNATURE_SCHEME_TO_FLAG.flagToScheme(extendedSecretKey[0]);
	final secretKey = Uint8List.fromList(extendedSecretKey.sublist(1));
	return (signatureScheme, secretKey);
}