summaryrefslogtreecommitdiff
path: root/0b/827c6758a3a336c000ac37e75e2250b9bca580
blob: a8db5460ac7fe2e8cb97a58fac6d75eeb6b150f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Return-Path: <me@thomaskerin.io>
Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org
	[172.17.192.35])
	by mail.linuxfoundation.org (Postfix) with ESMTPS id 939B8F3E
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Sun, 26 May 2019 19:43:10 +0000 (UTC)
X-Greylist: delayed 00:08:04 by SQLgrey-1.7.6
Received: from mail.thomaskerin.io (mail.thomaskerin.io [5.196.75.231])
	by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 810F2A9
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Sun, 26 May 2019 19:43:08 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thomaskerin.io;
	s=2017; t=1558899300;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	to:to:cc:mime-version:mime-version:content-type:content-type:
	content-transfer-encoding:content-transfer-encoding:
	in-reply-to:in-reply-to:references:references;
	bh=aB+jRypNqM7v5nELApCsxKPOB/VyYdpayrCqrhQfxQk=;
	b=uYmihMvBcppNNcS8+fnAmpliiTNV/KWBKcU8W07Zo4GAcE+M/IyB32FR7JMC2lQ2StJWsS
	1AMFv6UBwyQYE3Otpxu+DfOIfLLj4wfLsAxrbY/YFZU0vG8wif4z67d4Q4pTU3HIOmTA/L
	C7kYn/N5C/7WkW+VKI3yYJSFNRuuX2/XaaNblDvvMr68vU0ZqZltAh+TRnpMgpJ+PvtcoP
	jYSB02O0pmNgc5c4eYR8ZGixxsZMOqi0L7+LPGHM3PmGTKfqQGQCKuvTnPSenXBIr1aJ/A
	bk7pgasuVQlhD5vzhBroA7QEi+s9pRrR7yO9iEkKwov0ZNhse4J2cf/pT2gA5Q==
To: bitcoin-dev@lists.linuxfoundation.org, vitteaymeric@gmail.com
References: <e537e781-e10f-7299-fddb-67fab74124c0@gmail.com>
From: Thomas Kerin <me@thomaskerin.io>
Message-ID: <cbd7d991-ad8d-e311-661f-e93f05171522@thomaskerin.io>
Date: Sun, 26 May 2019 20:34:55 +0100
MIME-Version: 1.0
In-Reply-To: <e537e781-e10f-7299-fddb-67fab74124c0@gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Content-Language: en-US
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=thomaskerin.io; 
	s=2017; t=1558899300;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	to:to:cc:mime-version:mime-version:content-type:content-type:
	content-transfer-encoding:content-transfer-encoding:
	in-reply-to:in-reply-to:references:references;
	bh=aB+jRypNqM7v5nELApCsxKPOB/VyYdpayrCqrhQfxQk=;
	b=th4C4fvj6wDXVtgPurgxPf/xgvUOgnISUAQxEPpgCec/Vr284HRPdYgXr6KBlWJUPerL9M
	yJpd4qWLr8I9t/ksvddshksx61HeFUtYPUOzH+AraNsiJjlgZWnoWd3yP0iML5CXn7Yq47
	q8iZIQVzszT79mV90neKGmHQKWmHmubn7FTDez4dPvmIqxTOH6r8LG8yl/VpBDdXWDYAy+
	hFWN2N7aIEK0tlEahFqUEZPwC7S68M5jZYpKFRzX6PaX/Iud/3nSZaA23bIBr4CeSFpY/P
	E1iF+LgyuUgyPgoDxswsA+vYIzAMNKGcheSQucPtYbOrtCYXcDOQWBFnmrqU/A==
ARC-Seal: i=1; s=2017; d=thomaskerin.io; t=1558899300; a=rsa-sha256; cv=none;
	b=Ha4vPNA7hDKSuomg8fnSfumQKUI745+W+LNtJwM8g+K05i+i2UkoNQBxFrLlkKSgwusb+E
	FID+vW01IbXsDZxX6THbda3hqL81BRCEPJo62YAsVizfFELO9X4W4nlOOjQ03DvFKtsuV8
	5Ro+CVOOJXvcrowf882IUTWlzgEdkBh+oD1SAgNebTLNQ9AoeFCHRu0fL/QFRTQgc0IKjq
	HKYyIUzm2ST16xUvmRdkYxZEvIW8CWtXLCRL1VMBdo552OS9zEPhqzgY2yGph1qeGkFO5X
	s+aOIAZ4U+kU9nSSubkMcHKDqXUF+tU6UTgfWoIr3ojXC7V7YdBPptTpgCOL3A==
ARC-Authentication-Results: i=1; ORIGINATING;
	auth=pass smtp.auth=me@thomaskerin.io smtp.mailfrom=me@thomaskerin.io
Authentication-Results: ORIGINATING;
	auth=pass smtp.auth=me@thomaskerin.io smtp.mailfrom=me@thomaskerin.io
X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU autolearn=ham version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	smtp1.linux-foundation.org
X-Mailman-Approved-At: Mon, 27 May 2019 14:28:56 +0000
Subject: Re: [bitcoin-dev] Two questions about segwit implementation
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Sun, 26 May 2019 19:43:10 -0000

The scriptSig when evaluated populates the stack so opcodes can operate
on them. A witness is essentially a list of data elements, quite similar
to the script stack (the witness is passed in as the script stack in fact)

OP_0 when evaluated pushes a _zero length_ value onto the stack, hence
the 00 (the varlen) in the witness serialization. OP_1 (51 in decimal)
pushes 0x01 to the stack, so when serialized would be 0101.

It may help to consider the entire witness structure as
vector<vector<data element>> and it's length must equal the number of
inputs - so a non-segwit input must have a zero sized witness.

On 5/26/19 12:56 AM, Aymeric Vitte via bitcoin-dev wrote:
> I realized recently that my segwit implementation was not correct,
> basically some time ago, wrongly reading the specs (and misleaded by
> what follows), I thought that scriptsig would go into witness data as it
> was, but that's not the case, op_pushdata is replaced by varlen
>
> Now reading correctly the specs, they seem to be not totally correct,
> then the first question is: why OP_0 is 00 in witness data and not 0100?
> Does this apply to other op_codes? This does not look logical at all
>
> The second question is: why for non segwit inputs there is a 00 length
> in segwit data, what is the rational for that? It should just be nothing
> since you don't need this to reconciliate things
>
> _______________________________________________
> bitcoin-dev mailing list
> bitcoin-dev@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev