decodeSuiSecretKey static method

(SuiKeyAlgorithm, List<int>) decodeSuiSecretKey(
  1. String secretKey
)

Decodes a Sui Bech32 secret key into its corresponding private key.

Implementation

static (SuiKeyAlgorithm, List<int>) decodeSuiSecretKey(String secretKey) {
  try {
    final decode =
        Bech32Decoder.decode(SuiKeypairConst.suiPrivateKeyPrefix, secretKey);
    final algorithm = SuiKeyAlgorithm.fromFlag(decode[0]);
    return (algorithm, decode.sublist(1).asImmutableBytes);
  } on DartSuiPluginException {
    rethrow;
  } catch (e) {
    throw DartSuiPluginException("Invalid sui bech32 secret key.",
        details: {"error": e.toString()});
  }
}