Sha256: 518ebb994423a08ec8374b8b17eef3ad8d8a1f93d639c3de417e75dfd9dabe0a
Contents?: true
Size: 984 Bytes
Versions: 1
Compression:
Stored size: 984 Bytes
Contents
# frozen_string_literal: true require "cose/key/base" require "openssl" module COSE module Key class CurveKey < Base LABEL_CRV = -1 LABEL_X = -2 LABEL_D = -4 attr_reader :crv, :d, :x def self.keyword_arguments_for_initialize(map) { crv: map[LABEL_CRV], x: map[LABEL_X], d: map[LABEL_D] } end def initialize(crv:, x: nil, d: nil, **keyword_arguments) # rubocop:disable Naming/MethodParameterName super(**keyword_arguments) if !crv raise ArgumentError, "Required crv is missing" elsif !x && !d raise ArgumentError, "x and d cannot be missing simultaneously" else @crv = crv @x = x @d = d end end def map map = super.merge( LABEL_CRV => crv, LABEL_X => x, LABEL_D => d ) map.reject { |_k, v| v.nil? } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cose-1.0.0 | lib/cose/key/curve_key.rb |