review the following code for passkey creation:
using System.Formats.Cbor;

namespace Miam.App.Services.Passkey;

public class AttestationObjectDecoder
{
    public static AttestationObject Decode(byte[] attestationObject)
    {
        ArgumentNullException.ThrowIfNull(attestationObject, nameof(attestationObject));

        var cborReader = new CborReader(attestationObject);

        if (cborReader.PeekState() != CborReaderState.StartMap)
            throw new FormatException("Invalid CBOR format for attestationObject");

        int mapLength = cborReader.ReadStartMap() ?? throw new FormatException("Unable to determine attestationObject map length");
        byte[]? authData = null;
        string? fmt = null;
        Dictionary<string, object?>? attStmt = null;

        for (int i = 0; i < mapLength; i++)
        {
            string key = cborReader.ReadTextString();
            switch (key)
            {
                case "authData":
                    authData = cborReader.ReadByteString();
                    break;
                case "fmt":
                    fmt = cborReader.ReadTextString();
                    break;
                case "attStmt":
                    attStmt = ReadAttStmt(cborReader);
                    break;
                default:
                    cborReader.SkipValue();
                    break;
            }
        }

        cborReader.ReadEndMap();

        if (authData == null || fmt == null || attStmt == null)
            throw new FormatException("Required fields are missing from attestationObject");

        return new AttestationObject { AuthData = authData, Fmt = fmt, AttStmt = attStmt };
    }

    private static Dictionary<string, object?> ReadAttStmt(CborReader cborReader)
    {
        if (cborReader.PeekState() != CborReaderState.StartMap)
            throw new FormatException("Invalid CBOR format for attStmt");

        int attStmtMapLength = cborReader.ReadStartMap() ?? throw new FormatException("Unable to determine attStmt map length");

        var attStmt = new Dictionary<string, object?>(attStmtMapLength);

        for (int i = 0; i < attStmtMapLength; i++)
        {
            string key = cborReader.ReadTextString();
            attStmt[key] = ReadCborValue(cborReader);
        }

        cborReader.ReadEndMap();
        return attStmt;
    }

    private static object? ReadCborValue(CborReader cborReader)
    {
        return cborReader.PeekState() switch
        {
            CborReaderState.TextString => cborReader.ReadTextString(),
            CborReaderState.ByteString => cborReader.ReadByteString(),
            CborReaderState.UnsignedInteger => cborReader.ReadUInt64(),
            CborReaderState.StartMap => ReadAttStmt(cborReader),
            CborReaderState.StartArray => ReadCborArray(cborReader),
            _ => SkipAndReturnNull(cborReader)
        };
    }

    private static List<object?> ReadCborArray(CborReader cborReader)
    {
        int arrayLength = cborReader.ReadStartArray() ?? throw new InvalidOperationException("Unable to determine array length");
        var array = new List<object?>(arrayLength);

        for (int i = 0; i < arrayLength; i++)
        {
            array.Add(ReadCborValue(cborReader));
        }

        cborReader.ReadEndArray();
        return array;
    }

    private static object? SkipAndReturnNull(CborReader cborReader)
    {
        cborReader.SkipValue();
        return null;
    }
}