<commit_before>module Testkeys
  def sig01_key_base64
    {
        kty:"EC",
        kid:"11",
        crv:"P-256",
        x:"<KEY>",
        y:"<KEY>",
        d:"V8kgd2ZBRuh2dgyVINBUqpPDr7BOMGcF<KEY>"
    }
  end

  def sig02_key_base64
    {
      "kty":"EC",
     "kid":"P384",
     "crv":"P-384",
     "x":"<KEY>",
     "y":"<KEY>",
     "d":"<KEY>"
    }
  end

  def sig01_rng_stream
    [
      "20DB1328B01EBB78122CE86D5B1A3A097EC44EAC603FD5F60108EDF98EA81393"
    ]
  end
  def sig01_decode_private_key
    bd=ECDSA::Format::IntegerOctetString.decode(Base64.urlsafe_decode64(sig01_key_base64[:d]))
  end

  def decode_pub_key_from_example(example)
    x = example[:x] || example["x"]
    y = example[:y] || example["y"]
    bx=ECDSA::Format::IntegerOctetString.decode(Base64.urlsafe_decode64(x))
    by=ECDSA::Format::IntegerOctetString.decode(Base64.urlsafe_decode64(y))

    crv = example[:crv] || example["crv"]
    case crv
    when 'P-256'
      ECDSA::Group::Nistp256.new_point([bx, by])
    when 'P-384'
      ECDSA::Group::Nistp384.new_point([bx, by])
    end
  end

  def sig01_priv_key
    @sig01_priv_key ||= sig01_decode_private_key
  end

  def sig01_pub_key
    @sig01_pub_key ||= decode_pub_key_from_example(sig01_key_base64)
  end
end<commit_msg>refactor create_point so it can be used for private keys<commit_after>module Testkeys
  def sig01_key_base64
    {
        kty:"EC",
        kid:"11",
        crv:"P-256",
        x:"<KEY>",
        y:"<KEY>",
        d:"<KEY>"
    }
  end

  def sig02_key_base64
    {
      "kty":"EC",
     "kid":"P384",
     "crv":"P-384",
     "x":"<KEY>",
     "y":"<KEY>",
     "d":"<KEY>MU7DWbkLQ5dU90snHuuHVDjEPmtV0fTo"
    }
  end

  def sig01_rng_stream
    [
      "20DB1328B01EBB78122CE86D5B1A3A097EC44EAC603FD5F60108EDF98EA81393"
    ]
  end

  def create_point_from_example(example, px, py)
    crv = example[:crv] || example["crv"]

    case crv
    when 'P-256'
      ECDSA::Group::Nistp256.new_point([px, py])
    when 'P-384'
      ECDSA::Group::Nistp384.new_point([px, py])
    end
  end

  def sig01_decode_private_key(example)
    bd = ECDSA::Format::IntegerOctetString.decode(Base64.urlsafe_decode64(sig01_key_base64[:d]))

    #create_point_from_example(example, bd)
    return bd
  end

  def decode_pub_key_from_example(example)
    x = example[:x] || example["x"]
    y = example[:y] || example["y"]
    bx=ECDSA::Format::IntegerOctetString.decode(Base64.urlsafe_decode64(x))
    by=ECDSA::Format::IntegerOctetString.decode(Base64.urlsafe_decode64(y))

    create_point_from_example(example, bx, by)
  end

  def sig01_priv_key
    @sig01_priv_key ||= sig01_decode_private_key(sig01_key_base64)
  end

  def sig01_pub_key
    @sig01_pub_key ||= decode_pub_key_from_example(sig01_key_base64)
  end
end
{'fraction_non_alphanumeric': 0.1400862068965517, 'fraction_numerical': 0.07938218390804598, 'mean_word_length': 3.4347133757961785, 'pattern_counts': {'":': 12, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5413629', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1139, 'n_words': 149}