Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 939B8F3E for ; 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 ; 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: From: Thomas Kerin Message-ID: Date: Sun, 26 May 2019 20:34:55 +0100 MIME-Version: 1.0 In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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> 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