1
0
Fork 0
This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/factories/ecurve_keys.rb

28 lines
700 B
Ruby

# frozen_string_literal: true
FactoryBot.define do
factory :ecurve_key do
association :account, factory: :usual_account
public_key_pem do
point = OpenSSL::PKey::EC.generate(curve).public_key
pkey = OpenSSL::PKey::EC.new point.group
pkey.public_key = point
pkey.to_pem
end
public_key_der do
point = OpenSSL::PKey::EC.generate(curve).public_key
pkey = OpenSSL::PKey::EC.new point.group
pkey.public_key = point
pkey.to_der
end
has_password { [false, true].sample }
sha1 { Digest::SHA1.hexdigest SecureRandom.hex }
sha256 { Digest::SHA256.hexdigest SecureRandom.hex }
curve { EcurveKey::CURVES.sample }
end
end