HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/share/doc/ruby/html/OpenSSL/PKey/EC/Point.html
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::PKey::EC::Point - RDoc Documentation</title>

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../";
  var index_rel_prefix = "../../../";
</script>

<script src="../../../js/navigation.js" defer></script>
<script src="../../../js/search.js" defer></script>
<script src="../../../js/search_index.js" defer></script>
<script src="../../../js/searcher.js" defer></script>
<script src="../../../js/darkfish.js" defer></script>

<link href="../../../css/fonts.css" rel="stylesheet">
<link href="../../../css/rdoc.css" rel="stylesheet">




<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../../../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../../../table_of_contents.html#pages">Pages</a>
    <a href="../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    <div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  
  <p class="link"><a href="../../../Object.html">Object</a>
  
</div>

    
    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-c-new">::new</a>
    
    <li ><a href="#method-i-3D-3D">#==</a>
    
    <li ><a href="#method-i-eql-3F">#eql?</a>
    
    <li ><a href="#method-i-infinity-3F">#infinity?</a>
    
    <li ><a href="#method-i-initialize_copy">#initialize_copy</a>
    
    <li ><a href="#method-i-invert-21">#invert!</a>
    
    <li ><a href="#method-i-make_affine-21">#make_affine!</a>
    
    <li ><a href="#method-i-mul">#mul</a>
    
    <li ><a href="#method-i-on_curve-3F">#on_curve?</a>
    
    <li ><a href="#method-i-set_to_infinity-21">#set_to_infinity!</a>
    
    <li ><a href="#method-i-to_bn">#to_bn</a>
    
    <li ><a href="#method-i-to_octet_string">#to_octet_string</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-OpenSSL::PKey::EC::Point">
  <h1 id="class-OpenSSL::PKey::EC::Point" class="class">
    class OpenSSL::PKey::EC::Point
  </h1>

  <section class="description">
    
  </section>

  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    
    <section class="attribute-method-details" class="method-section">
      <header>
        <h3>Attributes</h3>
      </header>

      
      <div id="attribute-i-group" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">group</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
    </section>
    

    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

    
      <div id="method-c-new" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            OpenSSL::PKey::EC::Point.new(point)
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            OpenSSL::PKey::EC::Point.new(group [, encoded_point])
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Creates a new instance of <a href="Point.html"><code>OpenSSL::PKey::EC::Point</code></a>. If the only argument is an instance of <a href="Point.html"><code>EC::Point</code></a>, a copy is returned. Otherwise, creates a point that belongs to <em>group</em>.</p>

<p><em>encoded_point</em> is the octet string representation of the point. This must be either a <a href="../../../String.html"><code>String</code></a> or an <a href="../../BN.html"><code>OpenSSL::BN</code></a>.</p>
          
          

          
          <div class="method-source-code" id="new-source">
            <pre>static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
{
    EC_POINT *point;
    VALUE group_v, arg2;
    const EC_GROUP *group;

    TypedData_Get_Struct(self, EC_POINT, &amp;ossl_ec_point_type, point);
    if (point)
        rb_raise(eEC_POINT, &quot;EC_POINT already initialized&quot;);

    rb_scan_args(argc, argv, &quot;11&quot;, &amp;group_v, &amp;arg2);
    if (rb_obj_is_kind_of(group_v, cEC_POINT)) {
        if (argc != 1)
            rb_raise(rb_eArgError, &quot;invalid second argument&quot;);
        return ossl_ec_point_initialize_copy(self, group_v);
    }

    GetECGroup(group_v, group);
    if (argc == 1) {
        point = EC_POINT_new(group);
        if (!point)
            ossl_raise(eEC_POINT, &quot;EC_POINT_new&quot;);
    }
    else {
        if (rb_obj_is_kind_of(arg2, cBN)) {
            point = EC_POINT_bn2point(group, GetBNPtr(arg2), NULL, ossl_bn_ctx);
            if (!point)
                ossl_raise(eEC_POINT, &quot;EC_POINT_bn2point&quot;);
        }
        else {
            StringValue(arg2);
            point = EC_POINT_new(group);
            if (!point)
                ossl_raise(eEC_POINT, &quot;EC_POINT_new&quot;);
            if (!EC_POINT_oct2point(group, point,
                                    (unsigned char *)RSTRING_PTR(arg2),
                                    RSTRING_LEN(arg2), ossl_bn_ctx)) {
                EC_POINT_free(point);
                ossl_raise(eEC_POINT, &quot;EC_POINT_oct2point&quot;);
            }
        }
    }

    RTYPEDDATA_DATA(self) = point;
    rb_ivar_set(self, id_i_group, group_v);

    return self;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-3D-3D" class="method-detail method-alias">
        
        <div class="method-heading">
          <span class="method-name">==</span><span
            class="method-args">(p1)</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
        </div>

        

        
        <div class="aliases">
          Alias for: <a href="Point.html#method-i-eql-3F">eql?</a>
        </div>
        
      </div>

    
      <div id="method-i-eql-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            eql?(point2) &rarr; true | false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            point1 == point2 &rarr; true | false
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="eql-3F-source">
            <pre>static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
{
    EC_POINT *point1, *point2;
    VALUE group_v1 = rb_attr_get(a, id_i_group);
    VALUE group_v2 = rb_attr_get(b, id_i_group);
    const EC_GROUP *group;

    if (ossl_ec_group_eql(group_v1, group_v2) == Qfalse)
        return Qfalse;

    GetECPoint(a, point1);
    GetECPoint(b, point2);
    GetECGroup(group_v1, group);

    if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1)
        return Qfalse;

    return Qtrue;
}</pre>
          </div>
          
        </div>

        
        <div class="aliases">
          Also aliased as: <a href="Point.html#method-i-3D-3D">==</a>
        </div>
        

        
      </div>

    
      <div id="method-i-infinity-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            infinity? &rarr; true | false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="infinity-3F-source">
            <pre>static VALUE ossl_ec_point_is_at_infinity(VALUE self)
{
    EC_POINT *point;
    const EC_GROUP *group;

    GetECPoint(self, point);
    GetECPointGroup(self, group);

    switch (EC_POINT_is_at_infinity(group, point)) {
    case 1: return Qtrue;
    case 0: return Qfalse;
    default: ossl_raise(cEC_POINT, &quot;EC_POINT_is_at_infinity&quot;);
    }

    UNREACHABLE;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-initialize_copy" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">initialize_copy</span><span
            class="method-args">(p1)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="initialize_copy-source">
            <pre>static VALUE
ossl_ec_point_initialize_copy(VALUE self, VALUE other)
{
    EC_POINT *point, *point_new;
    EC_GROUP *group;
    VALUE group_v;

    TypedData_Get_Struct(self, EC_POINT, &amp;ossl_ec_point_type, point_new);
    if (point_new)
        ossl_raise(eEC_POINT, &quot;EC::Point already initialized&quot;);
    GetECPoint(other, point);

    group_v = rb_obj_dup(rb_attr_get(other, id_i_group));
    GetECGroup(group_v, group);

    point_new = EC_POINT_dup(point, group);
    if (!point_new)
        ossl_raise(eEC_POINT, &quot;EC_POINT_dup&quot;);
    RTYPEDDATA_DATA(self) = point_new;
    rb_ivar_set(self, id_i_group, group_v);

    return self;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-invert-21" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            invert! &rarr; self
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="invert-21-source">
            <pre>static VALUE ossl_ec_point_invert(VALUE self)
{
    EC_POINT *point;
    const EC_GROUP *group;

    GetECPoint(self, point);
    GetECPointGroup(self, group);

    if (EC_POINT_invert(group, point, ossl_bn_ctx) != 1)
        ossl_raise(cEC_POINT, &quot;EC_POINT_invert&quot;);

    return self;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-make_affine-21" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            make_affine! &rarr; self
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="make_affine-21-source">
            <pre>static VALUE ossl_ec_point_make_affine(VALUE self)
{
    EC_POINT *point;
    const EC_GROUP *group;

    GetECPoint(self, point);
    GetECPointGroup(self, group);

    if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
        ossl_raise(cEC_POINT, &quot;EC_POINT_make_affine&quot;);

    return self;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-mul" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            mul(bn1 [, bn2]) &rarr; point
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            mul(bns, points [, bn2]) &rarr; point
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Performs elliptic curve point multiplication.</p>

<p>The first form calculates <code>bn1 * point + bn2 * G</code>, where <code>G</code> is the generator of the group of <em>point</em>. <em>bn2</em> may be omitted, and in that case, the result is just <code>bn1 * point</code>.</p>

<p>The second form calculates <code>bns[0] * point + bns[1] * points[0] + ... + bns[-1] * points[-1] + bn2 * G</code>. <em>bn2</em> may be omitted. <em>bns</em> must be an array of <a href="../../BN.html"><code>OpenSSL::BN</code></a>. <em>points</em> must be an array of <a href="Point.html"><code>OpenSSL::PKey::EC::Point</code></a>. Please note that <code>points[0]</code> is not multiplied by <code>bns[0]</code>, but <code>bns[1]</code>.</p>
          
          

          
          <div class="method-source-code" id="mul-source">
            <pre>static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
{
    EC_POINT *point_self, *point_result;
    const EC_GROUP *group;
    VALUE group_v = rb_attr_get(self, id_i_group);
    VALUE arg1, arg2, arg3, result;
    const BIGNUM *bn_g = NULL;

    GetECPoint(self, point_self);
    GetECGroup(group_v, group);

    result = rb_obj_alloc(cEC_POINT);
    ossl_ec_point_initialize(1, &amp;group_v, result);
    GetECPoint(result, point_result);

    rb_scan_args(argc, argv, &quot;12&quot;, &amp;arg1, &amp;arg2, &amp;arg3);
    if (!RB_TYPE_P(arg1, T_ARRAY)) {
        BIGNUM *bn = GetBNPtr(arg1);

        if (!NIL_P(arg2))
            bn_g = GetBNPtr(arg2);
        if (EC_POINT_mul(group, point_result, bn_g, point_self, bn, ossl_bn_ctx) != 1)
            ossl_raise(eEC_POINT, NULL);
    } else {
        /*
         * bignums | arg1[0] | arg1[1] | arg1[2] | ...
         * points  | self    | arg2[0] | arg2[1] | ...
         */
        long i, num;
        VALUE bns_tmp, tmp_p, tmp_b;
        const EC_POINT **points;
        const BIGNUM **bignums;

        Check_Type(arg1, T_ARRAY);
        Check_Type(arg2, T_ARRAY);
        if (RARRAY_LEN(arg1) != RARRAY_LEN(arg2) + 1) /* arg2 must be 1 larger */
            ossl_raise(rb_eArgError, &quot;bns must be 1 longer than points; see the documentation&quot;);

        num = RARRAY_LEN(arg1);
        bns_tmp = rb_ary_tmp_new(num);
        bignums = ALLOCV_N(const BIGNUM *, tmp_b, num);
        for (i = 0; i &lt; num; i++) {
            VALUE item = RARRAY_AREF(arg1, i);
            bignums[i] = GetBNPtr(item);
            rb_ary_push(bns_tmp, item);
        }

        points = ALLOCV_N(const EC_POINT *, tmp_p, num);
        points[0] = point_self; /* self */
        for (i = 0; i &lt; num - 1; i++)
            GetECPoint(RARRAY_AREF(arg2, i), points[i + 1]);

        if (!NIL_P(arg3))
            bn_g = GetBNPtr(arg3);

        if (EC_POINTs_mul(group, point_result, bn_g, num, points, bignums, ossl_bn_ctx) != 1) {
            ALLOCV_END(tmp_b);
            ALLOCV_END(tmp_p);
            ossl_raise(eEC_POINT, NULL);
        }

        ALLOCV_END(tmp_b);
        ALLOCV_END(tmp_p);
    }

    return result;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-on_curve-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            on_curve? &rarr; true | false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="on_curve-3F-source">
            <pre>static VALUE ossl_ec_point_is_on_curve(VALUE self)
{
    EC_POINT *point;
    const EC_GROUP *group;

    GetECPoint(self, point);
    GetECPointGroup(self, group);

    switch (EC_POINT_is_on_curve(group, point, ossl_bn_ctx)) {
    case 1: return Qtrue;
    case 0: return Qfalse;
    default: ossl_raise(cEC_POINT, &quot;EC_POINT_is_on_curve&quot;);
    }

    UNREACHABLE;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-set_to_infinity-21" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            set_to_infinity! &rarr; self
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          
          
          

          
          <div class="method-source-code" id="set_to_infinity-21-source">
            <pre>static VALUE ossl_ec_point_set_to_infinity(VALUE self)
{
    EC_POINT *point;
    const EC_GROUP *group;

    GetECPoint(self, point);
    GetECPointGroup(self, group);

    if (EC_POINT_set_to_infinity(group, point) != 1)
        ossl_raise(cEC_POINT, &quot;EC_POINT_set_to_infinity&quot;);

    return self;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-to_bn" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            to_bn([conversion_form]) &rarr; OpenSSL::BN
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the octet string representation of the <a href="../EC.html"><code>EC</code></a> point as an instance of <a href="../../BN.html"><code>OpenSSL::BN</code></a>.</p>

<p>If <em>conversion_form</em> is not given, the <em>point_conversion_form</em> attribute set to the group is used.</p>

<p>See <a href="Point.html#method-i-to_octet_string"><code>to_octet_string</code></a> for more information.</p>
          
          

          
          <div class="method-source-code" id="to_bn-source">
            <pre><span class="ruby-comment"># File ext/openssl/lib/openssl/pkey.rb, line 20</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_bn</span>(<span class="ruby-identifier">conversion_form</span> = <span class="ruby-identifier">group</span>.<span class="ruby-identifier">point_conversion_form</span>)
  <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">BN</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">to_octet_string</span>(<span class="ruby-identifier">conversion_form</span>), <span class="ruby-value">2</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-to_octet_string" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            to_octet_string(conversion_form) &rarr; String
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the octet string representation of the elliptic curve point.</p>

<p><em>conversion_form</em> specifies how the point is converted. Possible values are:</p>
<ul><li>
<p><code>:compressed</code></p>
</li><li>
<p><code>:uncompressed</code></p>
</li><li>
<p><code>:hybrid</code></p>
</li></ul>
          
          

          
          <div class="method-source-code" id="to_octet_string-source">
            <pre>static VALUE
ossl_ec_point_to_octet_string(VALUE self, VALUE conversion_form)
{
    EC_POINT *point;
    const EC_GROUP *group;
    point_conversion_form_t form;
    VALUE str;
    size_t len;

    GetECPoint(self, point);
    GetECPointGroup(self, group);
    form = parse_point_conversion_form_symbol(conversion_form);

    len = EC_POINT_point2oct(group, point, form, NULL, 0, ossl_bn_ctx);
    if (!len)
        ossl_raise(eEC_POINT, &quot;EC_POINT_point2oct&quot;);
    str = rb_str_new(NULL, (long)len);
    if (!EC_POINT_point2oct(group, point, form,
                            (unsigned char *)RSTRING_PTR(str), len,
                            ossl_bn_ctx))
        ossl_raise(eEC_POINT, &quot;EC_POINT_point2oct&quot;);
    return str;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>

</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>