⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ecp_8h-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: ecp.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><div class="tabs">  <ul>    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>    <li><a href="namespaces.html"><span>Namespaces</span></a></li>    <li><a href="classes.html"><span>Classes</span></a></li>    <li class="current"><a href="files.html"><span>Files</span></a></li>  </ul></div><div class="tabs">  <ul>    <li><a href="files.html"><span>File&nbsp;List</span></a></li>    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>  </ul></div><h1>ecp.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_ECP_H</span><a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_ECP_H</span><a name="l00003"></a>00003 <span class="preprocessor"></span><a name="l00004"></a>00004 <span class="preprocessor">#include "modarith.h"</span><a name="l00005"></a>00005 <span class="preprocessor">#include "eprecomp.h"</span><a name="l00006"></a>00006 <span class="preprocessor">#include "smartptr.h"</span><a name="l00007"></a>00007 <span class="preprocessor">#include "<a class="code" href="pubkey_8h.html" title="This file contains helper classes/functions for implementing public key algorithms...">pubkey.h</a>"</span><a name="l00008"></a>00008 <a name="l00009"></a>00009 NAMESPACE_BEGIN(CryptoPP)<a name="l00010"></a>00010 <a name="l00011"></a>00011 <span class="comment">//! Elliptical Curve Point</span><a name="l00012"></a><a class="code" href="struct_e_c_p_point.html">00012</a> <span class="comment"></span>struct CRYPTOPP_DLL <a class="code" href="struct_e_c_p_point.html" title="Elliptical Curve Point.">ECPPoint</a><a name="l00013"></a>00013 {<a name="l00014"></a><a class="code" href="struct_e_c_p_point.html#9d6d4c25d6c2777d7e9bb27e3b0d2c37">00014</a>         ECPPoint() : identity(true) {}<a name="l00015"></a><a class="code" href="struct_e_c_p_point.html#c68bc9990c364313b6798669de55343f">00015</a>         ECPPoint(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;x, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;y)<a name="l00016"></a>00016                 : identity(false), x(x), y(y) {}<a name="l00017"></a>00017 <a name="l00018"></a><a class="code" href="struct_e_c_p_point.html#78988d351554f25761ca313c1d1d17e1">00018</a>         <span class="keywordtype">bool</span> <a class="code" href="gf2n_8h.html#22c25c181c409600aa2e4bf1067ac47a">operator==</a>(<span class="keyword">const</span> ECPPoint &amp;t)<span class="keyword"> const</span><a name="l00019"></a>00019 <span class="keyword">                </span>{<span class="keywordflow">return</span> (identity &amp;&amp; t.<a class="code" href="struct_e_c_p_point.html#806dedcf077e22de7904ccfd7987bcf9">identity</a>) || (!identity &amp;&amp; !t.<a class="code" href="struct_e_c_p_point.html#806dedcf077e22de7904ccfd7987bcf9">identity</a> &amp;&amp; x==t.<a class="code" href="struct_e_c_p_point.html#24bbcc7eb375ebe2b46d2ac9ee6bb0a8">x</a> &amp;&amp; y==t.<a class="code" href="struct_e_c_p_point.html#b47b82046f543e809bd90d78bf2c85bf">y</a>);}<a name="l00020"></a><a class="code" href="struct_e_c_p_point.html#fda11fc53c7a05a6980d0f333739c2f7">00020</a>         <span class="keywordtype">bool</span> <a class="code" href="gf2n_8h.html#f81f67e93bfb8bbb776cab689c83c7e9" title="compares degree">operator&lt; </a>(<span class="keyword">const</span> ECPPoint &amp;t)<span class="keyword"> const</span><a name="l00021"></a>00021 <span class="keyword">                </span>{<span class="keywordflow">return</span> identity ? !t.<a class="code" href="struct_e_c_p_point.html#806dedcf077e22de7904ccfd7987bcf9">identity</a> : (!t.<a class="code" href="struct_e_c_p_point.html#806dedcf077e22de7904ccfd7987bcf9">identity</a> &amp;&amp; (x&lt;t.<a class="code" href="struct_e_c_p_point.html#24bbcc7eb375ebe2b46d2ac9ee6bb0a8">x</a> || (x==t.<a class="code" href="struct_e_c_p_point.html#24bbcc7eb375ebe2b46d2ac9ee6bb0a8">x</a> &amp;&amp; y&lt;t.<a class="code" href="struct_e_c_p_point.html#b47b82046f543e809bd90d78bf2c85bf">y</a>)));}<a name="l00022"></a>00022 <a name="l00023"></a><a class="code" href="struct_e_c_p_point.html#806dedcf077e22de7904ccfd7987bcf9">00023</a>         <span class="keywordtype">bool</span> identity;<a name="l00024"></a><a class="code" href="struct_e_c_p_point.html#b47b82046f543e809bd90d78bf2c85bf">00024</a>         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> x, y;<a name="l00025"></a>00025 };<a name="l00026"></a>00026 <a name="l00027"></a>00027 CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_abstract_group.html" title="Abstract Group.">AbstractGroup&lt;ECPPoint&gt;</a>;<a name="l00028"></a>00028 <span class="comment"></span><a name="l00029"></a>00029 <span class="comment">//! Elliptic Curve over GF(p), where p is prime</span><a name="l00030"></a><a class="code" href="class_e_c_p.html">00030</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_DLL <a class="code" href="class_e_c_p.html" title="Elliptic Curve over GF(p), where p is prime.">ECP</a> : <span class="keyword">public</span> <a class="code" href="class_abstract_group.html" title="Abstract Group.">AbstractGroup</a>&lt;ECPPoint&gt;<a name="l00031"></a>00031 {<a name="l00032"></a>00032 <span class="keyword">public</span>:<a name="l00033"></a><a class="code" href="class_e_c_p.html#746aebbc43b99972e5a647ebabbbc931">00033</a>         <span class="keyword">typedef</span> <a class="code" href="class_modular_arithmetic.html" title="ring of congruence classes modulo n">ModularArithmetic</a> <a class="code" href="class_modular_arithmetic.html" title="ring of congruence classes modulo n">Field</a>;<a name="l00034"></a><a class="code" href="class_e_c_p.html#337e68ddf10edab098c55474d52c4d04">00034</a>         <span class="keyword">typedef</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">FieldElement</a>;<a name="l00035"></a><a class="code" href="class_e_c_p.html#99c34a437007f32af4e6c4ae275358ea">00035</a>         <span class="keyword">typedef</span> <a class="code" href="struct_e_c_p_point.html" title="Elliptical Curve Point.">ECPPoint</a> <a class="code" href="struct_e_c_p_point.html" title="Elliptical Curve Point.">Point</a>;<a name="l00036"></a>00036 <a name="l00037"></a><a class="code" href="class_e_c_p.html#50e65de68e93c6bf2e174c8dc2322731">00037</a>         <a class="code" href="class_e_c_p.html" title="Elliptic Curve over GF(p), where p is prime.">ECP</a>() {}<a name="l00038"></a>00038         <a class="code" href="class_e_c_p.html" title="Elliptic Curve over GF(p), where p is prime.">ECP</a>(<span class="keyword">const</span> <a class="code" href="class_e_c_p.html" title="Elliptic Curve over GF(p), where p is prime.">ECP</a> &amp;ecp, <span class="keywordtype">bool</span> convertToMontgomeryRepresentation = <span class="keyword">false</span>);<a name="l00039"></a><a class="code" href="class_e_c_p.html#7dbe4a90840d3b7cb23412a65414f4f5">00039</a>         <a class="code" href="class_e_c_p.html" title="Elliptic Curve over GF(p), where p is prime.">ECP</a>(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;modulus, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">FieldElement</a> &amp;a, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">FieldElement</a> &amp;b)<a name="l00040"></a>00040                 : m_fieldPtr(new <a class="code" href="class_modular_arithmetic.html" title="ring of congruence classes modulo n">Field</a>(modulus)), m_a(a.IsNegative() ? modulus+a : a), m_b(b) {}<a name="l00041"></a>00041         <span class="comment">// construct from BER encoded parameters</span><a name="l00042"></a>00042         <span class="comment">// this constructor will decode and extract the the fields fieldID and curve of the sequence ECParameters</span><a name="l00043"></a>00043         <a class="code" href="class_e_c_p.html" title="Elliptic Curve over GF(p), where p is prime.">ECP</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;bt);<a name="l00044"></a>00044 <a name="l00045"></a>00045         <span class="comment">// encode the fields fieldID and curve of the sequence ECParameters</span><a name="l00046"></a>00046         <span class="keywordtype">void</span> DEREncode(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;bt) <span class="keyword">const</span>;<a name="l00047"></a>00047 <a name="l00048"></a>00048         <span class="keywordtype">bool</span> Equal(<span class="keyword">const</span> Point &amp;P, <span class="keyword">const</span> Point &amp;Q) <span class="keyword">const</span>;<a name="l00049"></a>00049         <span class="keyword">const</span> Point&amp; Identity() <span class="keyword">const</span>;<a name="l00050"></a>00050         <span class="keyword">const</span> Point&amp; Inverse(<span class="keyword">const</span> Point &amp;P) <span class="keyword">const</span>;<a name="l00051"></a><a class="code" href="class_e_c_p.html#0031a4a3a18999fda3942713da554697">00051</a>         <span class="keywordtype">bool</span> <a class="code" href="class_abstract_group.html#257836994abefe25b80293f4c6b10f60">InversionIsFast</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">true</span>;}<a name="l00052"></a>00052         <span class="keyword">const</span> Point&amp; Add(<span class="keyword">const</span> Point &amp;P, <span class="keyword">const</span> Point &amp;Q) <span class="keyword">const</span>;<a name="l00053"></a>00053         <span class="keyword">const</span> Point&amp; <a class="code" href="class_abstract_group.html#e54ef772d5f231729e188cbe3b9173f6">Double</a>(<span class="keyword">const</span> Point &amp;P) <span class="keyword">const</span>;<a name="l00054"></a>00054         Point <a class="code" href="class_abstract_group.html#c01536b91c4fa3d0e0f929917143595b">ScalarMultiply</a>(<span class="keyword">const</span> Point &amp;P, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;k) <span class="keyword">const</span>;<a name="l00055"></a>00055         Point <a class="code" href="class_abstract_group.html#ca3e1ca578003aff2595cc8d73522894">CascadeScalarMultiply</a>(<span class="keyword">const</span> Point &amp;P, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;k1, <span class="keyword">const</span> Point &amp;Q, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;k2) <span class="keyword">const</span>;<a name="l00056"></a>00056         <span class="keywordtype">void</span> <a class="code" href="class_abstract_group.html#00a5cd4b22aab947ec107ec93ad13122">SimultaneousMultiply</a>(Point *results, <span class="keyword">const</span> Point &amp;base, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> *exponents, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> exponentsCount) <span class="keyword">const</span>;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -