You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: registration_service.rb
    path of file: ./repos/discourse/lib/discourse_webauthn
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
require "cbor"
require "cose"

module DiscourseWebauthn
  class RegistrationService < BaseValidationService
    ##
    # See https://w3c.github.io/webauthn/#sctn-registering-a-new-credential for
    # the registration steps followed here. Memoized methods are called in their
    # place in the step flow to make the process clearer.
    def register_security_key
      # 4. Verify that the value of C.type is webauthn.creat
    
    def extract_public_key_and_credential_from_attestation(auth_data)
      # see https://w3c.github.io/webauthn/#authenticator-data for lengths
      # of authdata for extraction
      rp_id_length = 32
      flags_length = 1
      sign_count_length = 4

      attested_credential_data_start_position = rp_id_length + flags_length + sign_count_length # 37
      attested_credential_data_length = auth_data.size - attested_credential_data_start_position
      attested_credential_data =
        auth_data[
          attested_credential_data_start_position..(
            attested_credential_data_start_position + attested_credential_data_length - 1
          )
        ]

      # see https://w3c.github.io/webauthn/#attested-credential-data for lengths
      # of data for extraction
      aa_guid = attested_credential_data[0..15]
      credential_id_length = attested_credential_data[16..17].unpack("n*")[0]
      credential_id = attested_credential_data[18..(18 + credential_id_length - 1)]

      public_key_start_position = 18 + credential_id_length
      public_key_bytes =
        attested_credential_data[
          public_key_start_position..(public_key_start_position + attested_credential_data.size - 1)
        ]
      public_key = COSE::Key.deserialize(public_key_bytes)

      [public_key, public_key_bytes, credential_id]
    end