66 lines
16 KiB
HTML
66 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html class="paged">
|
|
<head>
|
|
<title>Signing Key</title>
|
|
<link rel="stylesheet" type="text/css" href="/v5/static/style.css">
|
|
<meta property="og:title" content="Signing Key"/>
|
|
<meta property="og:description" content="Documentation for ethers, a complete, tiny and simple Ethereum library."/>
|
|
|
|
<meta property="og:image" content="/v5/static/social.jpg"/>
|
|
|
|
</head>
|
|
<body>
|
|
<div class="sidebar">
|
|
<div class="header">
|
|
<div class="logo"><a href="/v5/"><div class="image"></div><div class="name">ethers</div><div class="version">v5.0</div></a></div>
|
|
<div class="search"><form action="/v5/search/" method="GET"><input name="search" id="search" /></form><span class="search-icon">⚲</span></div>
|
|
</div>
|
|
<div class="toc"><div>
|
|
<div class="link title"><a href="/v5/">Documentation</a></div><div class="base show link depth-1"><a href="/v5/getting-started/">Getting Started</a></div><div class="base show link depth-1"><a href="/v5/concepts/">Ethereum Basics</a></div><div class="hide link depth-2"><a href="/v5/concepts/events/">Events</a></div><div class="hide link depth-2"><a href="/v5/concepts/gas/">Gas</a></div><div class="hide link depth-2"><a href="/v5/concepts/security/">Security</a></div><div class="hide link depth-2"><a href="/v5/concepts/best-practices/">Best Practices</a></div><div class="base show link depth-1"><a href="/v5/api-keys/">Provider API Keys</a></div><div class="base ancestor show link depth-1"><a href="/v5/api/">Application Programming Interface</a></div><div class="show link depth-2"><a href="/v5/api/providers/">Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/provider/">Provider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/api-providers/">API Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/other/">Other Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/types/">Types</a></div><div class="show link depth-2"><a href="/v5/api/signer/">Signers</a></div><div class="show link depth-2"><a href="/v5/api/contract/">Contract Interaction</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract/">Contract</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract-factory/">ContractFactory</a></div><div class="hide link depth-3"><a href="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><div class="ancestor show link depth-2"><a href="/v5/api/utils/">Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/abi/">Application Binary Interface</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/coder/">AbiCoder</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/formats/">ABI Formats</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/fragments/">Fragments</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/interface/">Interface</a></div><div class="show link depth-3"><a href="/v5/api/utils/address/">Addresses</a></div><div class="show link depth-3"><a href="/v5/api/utils/bignumber/">BigNumber</a></div><div class="show link depth-3"><a href="/v5/api/utils/bytes/">Byte Manipulation</a></div><div class="show link depth-3"><a href="/v5/api/utils/constants/">Constants</a></div><div class="show link depth-3"><a href="/v5/api/utils/display-logic/">Display Logic and Input</a></div><div class="show link depth-3"><a href="/v5/api/utils/encoding/">Encoding Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/fixednumber/">FixedNumber</a></div><div class="show link depth-3"><a href="/v5/api/utils/hashing/">Hashing Algorithms</a></div><div class="show link depth-3"><a href="/v5/api/utils/hdnode/">HD Wallet</a></div><div class="show link depth-3"><a href="/v5/api/utils/logger/">Logging</a></div><div class="show link depth-3"><a href="/v5/api/utils/properties/">Property Utilities</a></div><div class="myself ancestor ancestor show link depth-3"><a href="/v5/api/utils/signing-key/">Signing Key</a></div><div class="link show child depth-4"><a href="#SigningKey--other-functions">Other Functions</a></div><div class="show link depth-3"><a href="/v5/api/utils/strings/">Strings</a></div><div class="show link depth-3"><a href="/v5/api/utils/transactions/">Transactions</a></div><div class="show link depth-3"><a href="/v5/api/utils/web/">Web Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/wordlists/">Wordlists</a></div><div class="show link depth-2"><a href="/v5/api/other/">Other Libraries</a></div><div class="hide link depth-3"><a href="/v5/api/other/assembly/">Assembly</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/api/">Utilities</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><div class="hide link depth-3"><a href="/v5/api/other/hardware/">Hardware Wallets</a></div><div class="show link depth-2"><a href="/v5/api/experimental/">Experimental</a></div><div class="base show link depth-1"><a href="/v5/cli/">Command Line Interfaces</a></div><div class="hide link depth-2"><a href="/v5/cli/ethers/">Sandbox Utility</a></div><div class="hide link depth-2"><a href="/v5/cli/asm/">Assembler</a></div><div class="hide link depth-2"><a href="/v5/cli/ens/">Ethereum Naming Service</a></div><div class="hide link depth-2"><a href="/v5/cli/typescript/">TypeScript</a></div><div class="hide link depth-2"><a href="/v5/cli/plugin/">Making Your Own</a></div><div class="base show link depth-1"><a href="/v5/cookbook/">Cookbook</a></div><div class="hide link depth-2"><a href="/v5/cookbook/react-native/">React Native (and ilk)</a></div><div class="base show link depth-1"><a href="/v5/migration/">Migration Guide</a></div><div class="hide link depth-2"><a href="/v5/migration/web3/">Migration: From Web3.js</a></div><div class="hide link depth-2"><a href="/v5/migration/ethers-v4/">Migration: From Ethers v4</a></div><div class="base show link depth-1"><a href="/v5/testing/">Testing</a></div><div class="base show link depth-1"><a href="/v5/contributing/">Contributing and Hacking</a></div><div class="base show link depth-1"><a href="/v5/other-resources/">Other Resources</a></div><div class="base show link depth-1"><a href="/v5/documentation/">Flatworm Docs</a></div><div class="base show link depth-1"><a href="/v5/license/">License and Copyright</a></div>
|
|
</div></div>
|
|
<div class="footer">
|
|
<a href="/v5/single-page/">Single Page</a>
|
|
</div>
|
|
</div>
|
|
<div class="content">
|
|
<div class="breadcrumbs"><a href="/v5/">Documentation</a> » <a href="/v5/api/">API</a> » <a href="/v5/api/utils/">Utilities</a> » <span class="current">Signing Key</span></div>
|
|
|
|
<a name="SigningKey"></a><a name="SigningKey"></a><h1 class="show-anchors"><div>Signing Key<div class="anchors"><a class="self" href="/v5/api/utils/signing-key/#SigningKey"></a></div></div></h1>
|
|
<a name="SigningKey-constructor"></a><div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">SigningKey</span><span class="symbol">(</span> <span class="param">privateKey</span> <span class="symbol">)</span><div class="anchors"><a class="self" href="/v5/api/utils/signing-key/#SigningKey-constructor"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/signing-key/src.ts/index.ts#L32">source</a></div></div><div class="body"><p>Create a new SigningKey for <i>privateKey</i>.</p>
|
|
|
|
</div></div><div class="property show-anchors"><div class="signature"><span class="path">signingKey</span><span class="symbol">.</span><span class="method">privateKey</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 32 > ></span><div class="anchors"></div></div><div class="body"><p>The private key for this Signing Key.</p>
|
|
|
|
</div></div><div class="property show-anchors"><div class="signature"><span class="path">signingKey</span><span class="symbol">.</span><span class="method">publicKey</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 65 > ></span><div class="anchors"></div></div><div class="body"><p>The uncompressed public key for this Signing Key. It will always be 65 bytes (130 nibbles) and begins with <code class="inline">0x04</code>.</p>
|
|
|
|
</div></div><div class="property show-anchors"><div class="signature"><span class="path">signingKey</span><span class="symbol">.</span><span class="method">compressedPublicKey</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 33 > ></span><div class="anchors"></div></div><div class="body"><p>The compressed public key for this Signing Key. It will always be 33 bytes (66 nibbles) and begins with either <code class="inline">0x02</code> or <code class="inline">0x03</code>.</p>
|
|
|
|
</div></div><div class="property show-anchors"><div class="signature"><span class="path">signingKey</span><span class="symbol">.</span><span class="method">signDigest</span><span class="symbol">(</span> <span class="param">digest</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="/v5/api/utils/bytes/#Signature">Signature</a></span><div class="anchors"></div></div><div class="body"><p>Sign the <i>digest</i> and return the signature.</p>
|
|
|
|
</div></div><div class="property show-anchors"><div class="signature"><span class="path">signingKey</span><span class="symbol">.</span><span class="method">computeSharedSecret</span><span class="symbol">(</span> <span class="param">otherKey</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 32 > ></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/signing-key/src.ts/index.ts#L65">source</a></div></div><div class="body"><p>Compute the ECDH shared secret with <i>otherKey</i>. The <i>otherKey</i> may be either a public key or a private key, but generally will be a public key from another party.</p>
|
|
|
|
<p>It is best practice that each party computes the hash of this before using it as a symmetric key.</p>
|
|
|
|
</div></div><div class="property show-anchors"><div class="signature"><span class="path">SigningKey</span><span class="symbol">.</span><span class="method">isSigningKey</span><span class="symbol">(</span> <span class="param">anObject</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/signing-key/src.ts/index.ts#L71">source</a></div></div><div class="body"><p>Returns true if <i>anObject</i> is a SigningKey.</p>
|
|
|
|
</div></div><a name="SigningKey--other-functions"></a><h2 class="show-anchors"><div>Other Functions<div class="anchors"><a class="self" href="/v5/api/utils/signing-key/#SigningKey--other-functions"></a></div></div></h2>
|
|
<a name="utils-verifyMessage"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">verifyMessage</span><span class="symbol">(</span> <span class="param">message</span> <span class="symbol">,</span> <span class="param">signature</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address">Address</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/signing-key/#utils-verifyMessage"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/wallet/src.ts/index.ts#L198">source</a></div></div><div class="body"><p>Returns the address that signed <i>message</i> producing <i>signature</i>. The signature may have a non-canonical v (i.e. does not need to be 27 or 28), in which case it will be normalized to compute the `recoveryParam` which will then be used to compute the address; this allows systems which use the v to encode additional data (such as <a href="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a>) to be used since the v parameter is still completely non-ambiguous.</p>
|
|
|
|
</div></div><a name="utils-verifyTypedData"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">verifyTypedData</span><span class="symbol">(</span> <span class="param">domain</span> <span class="symbol">,</span> <span class="param">types</span> <span class="symbol">,</span> <span class="param">value</span> <span class="symbol">,</span> <span class="param">signature</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address">Address</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/signing-key/#utils-verifyTypedData"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/wallet/src.ts/index.ts#L202">source</a></div></div><div class="body"><p>Returns the address that signed the <a href="https://eips.ethereum.org/EIPS/eip-712">EIP-712</a> <i>value</i> for the <i>domain</i> and <i>types</i> to produce the signature.</p>
|
|
|
|
</div></div><a name="utils-recoverPublicKey"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">recoverPublicKey</span><span class="symbol">(</span> <span class="param">digest</span> <span class="symbol">,</span> <span class="param">signature</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 65 > ></span><div class="anchors"><a class="self" href="/v5/api/utils/signing-key/#utils-recoverPublicKey"></a></div></div><div class="body"><p>Returns the uncompressed public key (i.e. the first byte will be <code class="inline">0x04</code>) of the private key that was used to sign <i>digest</i> which gave the <i>signature</i>.</p>
|
|
|
|
</div></div><a name="utils-computePublicKey"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">computePublicKey</span><span class="symbol">(</span> <span class="param">key</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">compressed</span> = <span class="param">false</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/signing-key/#utils-computePublicKey"></a></div></div><div class="body"><p>Computes the public key of <i>key</i>, optionally compressing it. The <i>key</i> can be any form of public key (compressed or uncompressed) or a private key.</p>
|
|
|
|
</div></div>
|
|
|
|
<div class="footer">
|
|
<div class="nav previous"><a href="/v5/api/utils/properties/"><span class="arrow">←</span>Property Utilities</a></div>
|
|
<div class="nav next"><a href="/v5/api/utils/strings/">Strings<span class="arrow">→</span></a></div>
|
|
</div>
|
|
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on February 8, 2021, 3:25pm.</div>
|
|
</div>
|
|
<script src="/v5/static/script.js" type="text/javascript"></script>
|
|
<!--EXTRASCRIPT-->
|
|
</body>
|
|
</html>
|