Repository navigation
jet: add Bitcoin transaction environment (#331 redux) #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
delta1
wants to merge
10
commits into
BlockstreamResearch:master
Choose a base branch
from
delta1:pr/bitcoin-tx-env-331-replacement
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+836
−88
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a0b5435
simplicity-sys: split up bitcoin and elements build
apoelstra 8607ed8
simplicity-sys: split env.c into bitcoin_env.c
apoelstra 0182d01
simplicity-sys: define bitcoin transaction environment
apoelstra 87549f6
jet: switch from Deref to Borrow for transaction environments
apoelstra a5ff079
simplicity-sys: update libsimplicity to bitcoin branch
apoelstra 179a9c5
jet: generalize JetEnvironment impls to use Borrow<T>
delta1 1dfdf0f
jet: drop unnecessary Arcs in environments
apoelstra e85d8f5
jet: implement Rust bitcoin environment
apoelstra cae2c23
jet: populate annexes in Bitcoin environment
apoelstra 1f91d94
bitcoin: extract annex per BIP341 instead of Witness::taproot_annex
delta1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #include <stdlib.h> | ||
| #include <stdalign.h> | ||
| #include "simplicity/bitcoin/env.h" | ||
| #include "simplicity/bitcoin/txEnv.h" | ||
| #include "simplicity/bitcoin/primitive.h" | ||
|
|
||
| typedef rawBitcoinBuffer rawBuffer; | ||
| typedef rawBitcoinBuffer rawBuffer; | ||
| typedef rawBitcoinOutput rawOutput; | ||
| typedef rawBitcoinInput rawInput; | ||
| typedef rawBitcoinTransaction rawTransaction; | ||
| typedef rawBitcoinTapEnv rawTapEnv; | ||
|
|
||
| const size_t rustsimplicity_0_8_c_sizeof_rawBitcoinBuffer = sizeof(rawBitcoinBuffer); | ||
| const size_t rustsimplicity_0_8_c_sizeof_rawBitcoinOutput = sizeof(rawBitcoinOutput); | ||
| const size_t rustsimplicity_0_8_c_sizeof_rawBitcoinInput = sizeof(rawBitcoinInput); | ||
| const size_t rustsimplicity_0_8_c_sizeof_rawBitcoinTransaction = sizeof(rawBitcoinTransaction); | ||
| const size_t rustsimplicity_0_8_c_sizeof_rawBitcoinTapEnv = sizeof(rawBitcoinTapEnv); | ||
| const size_t rustsimplicity_0_8_c_sizeof_bitcoinTxEnv = sizeof(txEnv); | ||
|
|
||
| const size_t rustsimplicity_0_8_c_alignof_rawBitcoinBuffer = alignof(rawBitcoinBuffer); | ||
| const size_t rustsimplicity_0_8_c_alignof_rawBitcoinOutput = alignof(rawBitcoinOutput); | ||
| const size_t rustsimplicity_0_8_c_alignof_rawBitcoinInput = alignof(rawBitcoinInput); | ||
| const size_t rustsimplicity_0_8_c_alignof_rawBitcoinTransaction = alignof(rawBitcoinTransaction); | ||
| const size_t rustsimplicity_0_8_c_alignof_rawBitcoinTapEnv = alignof(rawBitcoinTapEnv); | ||
| const size_t rustsimplicity_0_8_c_alignof_bitcoinTxEnv = alignof(txEnv); | ||
|
|
||
| void rustsimplicity_0_8_c_bitcoin_set_txEnv(txEnv *result, const bitcoinTransaction *tx, const bitcoinTapEnv *taproot, unsigned int ix) | ||
| { | ||
| *result = rustsimplicity_0_8_bitcoin_build_txEnv(tx, taproot, ix); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
|
|
||
| project(BitcoinSimplicity) | ||
|
|
||
| set(CMAKE_C_STANDARD 11) | ||
| set(CMAKE_C_EXTENSIONS OFF) | ||
|
|
||
| add_library(BitcoinSimplicity STATIC | ||
| bitstream.c | ||
| dag.c | ||
| deserialize.c | ||
| eval.c | ||
| frame.c | ||
| jets-secp256k1.c | ||
| jets.c | ||
| rsort.c | ||
| sha256.c | ||
| type.c | ||
| typeInference.c | ||
| bitcoin/env.c | ||
| bitcoin/exec.c | ||
| bitcoin/bitcoinJets.c | ||
| bitcoin/ops.c | ||
| bitcoin/primitive.c | ||
| bitcoin/txEnv.c | ||
| ) | ||
|
|
||
| option(PRODUCTION "Enable production build" ON) | ||
| if (PRODUCTION) | ||
| target_compile_definitions(BitcoinSimplicity PRIVATE "PRODUCTION") | ||
| endif() | ||
|
|
||
| target_include_directories(BitcoinSimplicity PUBLIC | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #include <simplicity/bitcoin/cmr.h> | ||
|
|
||
| #include "../cmr.h" | ||
| #include "primitive.h" | ||
|
|
||
| /* Deserialize a Simplicity 'program' and compute its CMR. | ||
| * | ||
| * Caution: no typechecking is performed, only a well-formedness check. | ||
| * | ||
| * If at any time malloc fails then '*error' is set to 'SIMPLICITY_ERR_MALLOC' and 'false' is returned, | ||
| * Otherwise, 'true' is returned indicating that the result was successfully computed and returned in the '*error' value. | ||
| * | ||
| * If the operation completes successfully then '*error' is set to 'SIMPLICITY_NO_ERROR', and the 'cmr' array is filled in with the program's computed CMR. | ||
| * | ||
| * Precondition: NULL != error; | ||
| * unsigned char cmr[32] | ||
| * unsigned char program[program_len] | ||
| */ | ||
| bool rustsimplicity_0_8_bitcoin_computeCmr( simplicity_err* error, unsigned char* cmr | ||
| , const unsigned char* program, size_t program_len) { | ||
| return rustsimplicity_0_8_computeCmr(error, cmr, rustsimplicity_0_8_bitcoin_decodeJet, program, program_len); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the intention of this comment, we could remove it if this check is redundant. Or, we could add a TODO here to say that we will add the Bitcoin version later.
Either way, if somebody is even bored enough to do this, let's maybe do it in a follow-up, so we don't stall the review with small stuff.