<!DOCTYPE html><htmllang="en"><head><metacharSet="utf-8"/><metahttp-equiv="X-UA-Compatible"content="IE=edge"/><title>Sign API · bitcoin-s</title><metaname="viewport"content="width=device-width, initial-scale=1.0"/><metaname="generator"content="Docusaurus"/><metaname="description"content="### The [`Sign` API](org/bitcoins/core/crypto/Sign.scala)"/><metaname="docsearch:version"content="1.9.1"/><metaname="docsearch:language"content="en"/><metaproperty="og:title"content="Sign API · bitcoin-s"/><metaproperty="og:type"content="website"/><metaproperty="og:url"content="https://bitcoin-s.org/"/><metaproperty="og:description"content="### The [`Sign` API](org/bitcoins/core/crypto/Sign.scala)"/><metaproperty="og:image"content="https://bitcoin-s.org/img/undraw_online.svg"/><metaname="twitter:card"content="summary"/><metaname="twitter:image"content="https://bitcoin-s.org/img/undraw_tweetstorm.svg"/><linkrel="shortcut icon"href="/img/favicon.ico"/><linkrel="stylesheet"href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"/><linkrel="stylesheet"href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
<p>This is the API we define to sign things with. It takes in an arbitrary byte vector and returns a <code>Future[ECDigitalSignature]</code>. The reason we incorporate <code>Future</code>s here is for extensibility of this API. We would like to provide implementations of this API for hardware devices, which need to be asynchrnous since they may require user input.</p>
<p>The <code>ByteVector</code> that is input to the <code>signFunction</code> should be the hash that is output from <ahref="/api/org/bitcoins/core/crypto/TransactionSignatureSerializer"><code>TransactionSignatureSerializer</code></a>'s <code>hashForSignature</code> method. Our in-memory <ahref="/api/org/bitcoins/core/crypto/ECKey"><code>ECKey</code></a> types implement the <code>Sign</code> API.</p>
<p>If you wanted to implement a new <code>Sign</code> api for a hardware wallet, you can easily pass it into the <code>TxBuilder</code>/<code>Signer</code> classes to allow for you to use those devices to sign with Bitcoin-S.</p>
<p>This API is currently used to sign ordinary transactions with our <ahref="/api/org/bitcoins/core/wallet/signer/Signer"><code>Signer</code></a>s. The <code>Signer</code> subtypes (i.e. <code>P2PKHSigner</code>) implement the specific functionality needed to produce a valid digital signature for their corresponding script type.</p>
<p>An <ahref="org/bitcoins/core/crypto/ExtKey.scala">ExtKey</a> is a data structure that can be used to generate more keys from a parent key. For more information look at <ahref="hd-keys.md">/docs/core/hd-keys</a></p>
<p>You can sign with <code>ExtPrivateKey</code> the same way you could with a normal <code>ECPrivateKey</code>.</p>
<p>With <code>ExtSign</code>, you can use <code>ExtPrivateKey</code> to sign transactions inside of <code>TxBuilder</code> since <code>UTXOSpendingInfo</code> takes in <code>Sign</code> as a parameter.</p>
<p>You can also provide a <code>path</code> to use to derive a child <code>ExtPrivateKey</code>, and then sign with that child private key</p>