Skip to content

Conversation

@sanket1729
Copy link
Contributor

Please refer to the new spec here. #1019

@sanket1729 sanket1729 force-pushed the opcodes branch 2 times, most recently from fc24a94 to 3e389b8 Compare August 2, 2021 16:22
stack.push_back(vchAssetBlindingNonce);
} else { // No issuance
stack.push_back(vchFalse);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurs to me that there is no way to get the actual asset ID (though maybe you can gin it up using the streaming hash opcodes..). Worth thinking about in a future softfork, I don't want to extend the scope of this one too much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can compute the asset ID with our CAT and SHA256. If not, we can add new opcodes at a later date.

case 0: // Version
{
// This does an inplicit conversion from version(int32_t) to (uint32_t)
push4_le(stack, (uint32_t) checker.GetTxVersion());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling: implicit.

Also it's not implicit, because you have an explicit cast :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe static_casts are preferred in C++.

Copy link
Contributor Author

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the WIP from title. Ready for another review round.

@sanket1729 sanket1729 changed the title [WIP]: Tapscript new opcodes Tapscript new opcodes Aug 3, 2021
@sanket1729 sanket1729 force-pushed the opcodes branch 2 times, most recently from c52f710 to a1ab6b3 Compare August 3, 2021 16:51
@sanket1729 sanket1729 force-pushed the opcodes branch 2 times, most recently from c0a6c34 to 8483744 Compare August 27, 2021 02:06
}

// Check the script has sufficient sigops budget for checksig(crypto) operation
inline bool udpate_validation_weight(ScriptExecutionData& execdata, ScriptError* serror)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/udpate/update/

if (!pk.IsCompressed() || !res.IsCompressed())
return set_error(serror, SCRIPT_ERR_PUBKEYTYPE);

if(!udpate_validation_weight(execdata, serror)) return false; // serror is set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/if(/if (/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And elsewhere.

src/pubkey.cpp Outdated
std::pair<XOnlyPubKey, bool> ret;
secp256k1_xonly_pubkey out_xonly;
if (!secp256k1_xonly_pubkey_from_pubkey(secp256k1_context_verify, &out_xonly, &parity, &out)) return nullopt;
secp256k1_xonly_pubkey_serialize(secp256k1_context_verify, ret.first.begin(), &out_xonly);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer ret.first.data() over ret.first.begin() for grabbing a value that is morally a pointer rather than morally an iterator.

Copy link
Contributor Author

@sanket1729 sanket1729 Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, upstream only has

const unsigned char* data() const { return m_keydata.begin(); }

and not

unsigned char* data() { return m_keydata.begin(); }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the function in this commit

src/pubkey.h Outdated
#include <uint256.h>

#include <stdexcept>
#include <cstring>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is cstring used for?

sanket1729 and others added 7 commits August 27, 2021 19:24
That results in a much safer interface (making the tweak commit
to the key implicitly using a fixed tag means it can't be used for
unrelated tweaking).

bitcoin/bitcoin#22051 (5/9)
We actually preserve the "unrelated tweaking" method so we can
use it in OP_TWEAKVERIFY
bitcoin/bitcoin#22051 (6/9)

Modified to use the old-style Optional rather than std::optional
{
secp256k1_xonly_pubkey base_point;
if (!secp256k1_xonly_pubkey_parse(secp256k1_context_verify, &base_point, base.data())) return false;
return secp256k1_xonly_pubkey_tweak_add_check(secp256k1_context_verify, m_keydata.begin(), parity, &base_point, hash.begin());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shakes my fist at upstream

@roconnor-blockstream
Copy link
Contributor

I can no longer find anything worth complaining about.

@apoelstra
Copy link
Member

ACK 1577ed4

@apoelstra apoelstra merged commit feee029 into ElementsProject:master Aug 30, 2021
gwillen pushed a commit that referenced this pull request Jun 1, 2022
Messy merge conflicts because this PR backported some ad-hoc stuff from
upstream while keeping a few things that upstream deleted. Hopefully
reviewing is easier than doing this in the first place, since ultimately
all I did was delete code from one side or another of the conflicts.
(Ok, I also changed some boost optional stuff to std::optional, and had
to patch up a test file for test framework changes.)

When reviewing the detailed crypto, bear in mind that taptweaks, like all
hashes are the kind of crypto that cannot be subtly wrong -- it will either
fail very hard or be correct. And we have independent implementations in
C++ and Python that cross-check each other, si it's unlikely to be the former.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants