one_time_key.rb 696 B

123456789101112131415161718192021
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: one_time_keys
  5. #
  6. # id :bigint(8) not null, primary key
  7. # device_id :bigint(8)
  8. # key_id :string default(""), not null
  9. # key :text default(""), not null
  10. # signature :text default(""), not null
  11. # created_at :datetime not null
  12. # updated_at :datetime not null
  13. #
  14. class OneTimeKey < ApplicationRecord
  15. belongs_to :device
  16. validates :key_id, :key, :signature, presence: true
  17. validates :key, ed25519_key: true
  18. validates :signature, ed25519_signature: { message: :key, verify_key: ->(one_time_key) { one_time_key.device.fingerprint_key } }
  19. end