KDFParam.fromCbor constructor

KDFParam.fromCbor(
  1. CborObject cbor
)

Implementation

factory KDFParam.fromCbor(CborObject cbor) {
  if (cbor is! CborTagValue || cbor.value is! CborListValue) {
    throw const Web3SecretStorageDefinationV3Exception(
        "invalid secret wallet cbor bytes");
  }
  if (BytesUtils.bytesEqual(cbor.tags, _SecretStorageConst.pbdkdf2Tag)) {
    final toObj = KDF2.fromCbor(cbor.value);
    return toObj;
  } else if (BytesUtils.bytesEqual(
      cbor.tags, _SecretStorageConst.scryptTag)) {
    return KDFScrypt.fromCbor(cbor.value);
  } else {
    throw const Web3SecretStorageDefinationV3Exception(
        "invalid secret wallet cbor bytes");
  }
}