<p>Thanks for your comments. This is the proposed fix: <a href="https://github.com/bitcoin/bips/pull/416" rel="nofollow">https://github.com/bitcoin/bips/pull/416</a></p>

CC BY-SA 3.0
2016-07-10T16:52:05.670Z
Thanks - those changes are consistent with the definition in the paragraph I quoted, and clear up all of my questions. In other words, a witness program is a hash value. Still, I'm uneasy about using the term "witness program" to refer to something that isn't actually a program or even Script. What's the origin of that term and the compelling reason to use it rather than something more consistent with function?
Rich Apodaca
CC BY-SA 3.0
2016-08-09T17:40:37.760Z
The witness program is still a script, just a trivial one, and one that follows a fixed structure that is given a new meaning.
Pieter Wuille
CC BY-SA 3.0
2017-06-07T19:34:59.650Z
@PieterWuille, the current BIP-141 staes "The value of the first push is called the "version byte". The following byte vector pushed is called the "witness program"." Yet "witness program" is clearly identified as a hash value elsewhere in the BIP. A hash value is not a script in any way I can decipher. It's a hash value of a script. Am I missing something?
Rich Apodaca
CC BY-SA 3.0
2018-01-06T14:23:44.667Z
See it as a continuation of P2SH. P2SH scripts are clearly programs (they're executed, and contain opcodes); however, their only substance is the script hash they contain. Witness programs just continue that trend - the encoding as script bytes is vestigial, but there are actual semantics involved (P2WPKH and P2WSH have different semantics, for example).
Pieter Wuille
CC BY-SA 3.0
2016-07-10T14:38:23.480Z
2016-07-10T14:38:23.480Z
Johnson Lau
<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawik" rel="noreferrer">BIP 141</a> uses the term "witness program" extensively without, apparently, adhering to a consistent definition.</p>

<p>From the heading "Witness Program":</p>

<blockquote>
  <p>A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of a 1-byte push opcode (for 0 to 16) followed by a data push between 2 and 40 bytes gets a new special meaning. The value of the first push is called the "version byte". <strong>The following byte vector pushed is called the "witness program".</strong> [my emphasis]</p>
</blockquote>

<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program" rel="noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program</a></p>

<p>In other words, a "witness program" is a byte sequence 2 to 40 bytes in length. In P2WPKH authentication, the witness program is the 20-byte hash value of a public key. In P2WSH authentication, the witness program is the 32-byte hash value of the serialize "witness script" (last element of witness data).</p>

<p>At least, this is what I gather from reading the definition under the heading.</p>

<p>However, BIP 141 makes other references to "witness program" that seem to suggest something else. For example:</p>

<ul>
<li>"In addition, opcodes within the witness program are counted identical to as previously within the P2SH check script."</li>
<li>"The P2WPKH witness program is then executed as described in the previous example."</li>
</ul>

<p>Also, headings seem to suggest that "witness program" means something else:</p>

<ul>
<li>"P2WPKH witness program" (describes a new authentication template) <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh-witness-program" rel="noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh-witness-program</a></li>
<li>"P2WSH witness program" (describes a new authentication template) <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wsh-witness-program" rel="noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wsh-witness-program</a></li>
</ul>

<p>What is a precise definition for the term "witness program?"</p>

CC BY-SA 4.0
2018-11-21T04:26:39.010Z
The usage of the term "authentication" above might be replaced with "identification" or removed altogether.
Jonathan Cross
<segregated-witness>
What is the precise definition of "witness program"?
Rich Apodaca
# What is the precise definition of "witness program"?

(Asked by: username_0 on 2016-07-09)

[BIP 141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawik) uses the term "witness program" extensively without, apparently, adhering to a consistent definition.

From the heading "Witness Program":

> A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of a 1-byte push opcode (for 0 to 16) followed by a data push between 2 and 40 bytes gets a new special meaning. The value of the first push is called the "version byte". **The following byte vector pushed is called the "witness program".** [my emphasis]

<https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program>

In other words, a "witness program" is a byte sequence 2 to 40 bytes in length. In P2WPKH authentication, the witness program is the 20-byte hash value of a public key. In P2WSH authentication, the witness program is the 32-byte hash value of the serialize "witness script" (last element of witness data).

At least, this is what I gather from reading the definition under the heading.

However, BIP 141 makes other references to "witness program" that seem to suggest something else. For example:

* "In addition, opcodes within the witness program are counted identical to as previously within the P2SH check script."
* "The P2WPKH witness program is then executed as described in the previous example."

Also, headings seem to suggest that "witness program" means something else:

* "P2WPKH witness program" (describes a new authentication template) <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh-witness-program>
* "P2WSH witness program" (describes a new authentication template) <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wsh-witness-program>

What is a precise definition for the term "witness program?"

**Tags:** segregated-witness

> **Comments:**
> **username_1**: The usage of the term "authentication" above might be replaced with "identification" or removed altogether.  

---

## 1 answers

### Answer by username_2 on 2016-07-10. Score: 4 | Accepted answer

Thanks for your comments. This is the proposed fix: <https://github.com/bitcoin/bips/pull/416>

> **Comments:**
> **username_0**: Thanks - those changes are consistent with the definition in the paragraph I quoted, and clear up all of my questions. In other words, a witness program is a hash value. Still, I'm uneasy about using the term "witness program" to refer to something that isn't actually a program or even Script. What's the origin of that term and the compelling reason to use it rather than something more consistent with function?  
> **username_3**: The witness program is still a script, just a trivial one, and one that follows a fixed structure that is given a new meaning.  
> **username_0**: @username_3, the current BIP-141 staes "The value of the first push is called the "version byte". The following byte vector pushed is called the "witness program"." Yet "witness program" is clearly identified as a hash value elsewhere in the BIP. A hash value is not a script in any way I can decipher. It's a hash value of a script. Am I missing something?  
> **username_3**: See it as a continuation of P2SH. P2SH scripts are clearly programs (they're executed, and contain opcodes); however, their only substance is the script hash they contain. Witness programs just continue that trend - the encoding as script bytes is vestigial, but there are actual semantics involved (P2WPKH and P2WSH have different semantics, for example).  

---

