one_time_key_fabricator.rb 421 B

123456789101112
  1. Fabricator(:one_time_key) do
  2. device
  3. key_id { Faker::Alphanumeric.alphanumeric(number: 10) }
  4. key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) }
  5. signature do |attrs|
  6. signing_key = Ed25519::SigningKey.generate
  7. attrs[:device].update(fingerprint_key: Base64.strict_encode64(signing_key.verify_key.to_bytes))
  8. Base64.strict_encode64(signing_key.sign(attrs[:key]))
  9. end
  10. end