Skip to content
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

Add blsct api #168

Merged
merged 44 commits into from
Oct 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
08523e4
add ext api working up to range proof prove
gogoex Jul 13, 2024
a4ecb44
fix token id problems
gogoex Jul 14, 2024
0ab0b6f
add missing dispose functions
gogoex Jul 14, 2024
74a5702
fix range proof memory allocation issue
gogoex Jul 20, 2024
42814ee
add range proof amount recovery apis
gogoex Jul 28, 2024
5d8d90c
handle memory allocation failures
gogoex Jul 28, 2024
9424fe5
let dispose_ret_val not to dispose its value. use void* for dispose_d…
gogoex Jul 30, 2024
97292db
replace most of dispose_* with free_obj
gogoex Jul 31, 2024
0770794
wip
gogoex Aug 2, 2024
f0012ae
fix missing symbol issue
gogoex Aug 17, 2024
9798a28
build libunivalue_blsct.a
gogoex Aug 17, 2024
1caba62
wip
gogoex Aug 17, 2024
476c651
rebase to up-to-date master
gogoex Aug 18, 2024
2f41d78
fully uncomment build_tx
gogoex Aug 18, 2024
34dd006
remove unused function header
gogoex Aug 22, 2024
fe1df72
deserialize tx up to txIns and txOuts level
gogoex Aug 25, 2024
9b01529
return objects with size
gogoex Aug 25, 2024
927fbc5
wip
gogoex Aug 26, 2024
a5bcdb5
add blsct data functions
gogoex Aug 27, 2024
2e631de
support scriptPubKey and rangeProof
gogoex Aug 27, 2024
6f364af
add txin serialization
gogoex Sep 8, 2024
01f363d
add msg signing and verification
gogoex Sep 19, 2024
b4519c9
add key derivation apis
gogoex Sep 22, 2024
6f84e1d
add rest of api functions w/ missing symbol issue
gogoex Sep 22, 2024
317fd6f
fix hash_id issue
gogoex Sep 27, 2024
3ab0054
fix build issues
gogoex Oct 16, 2024
b6788c4
avoid using a function in the locale-dependent funciton list
gogoex Oct 16, 2024
1b1656a
add blsct/key_io.h to BLSCT_H
gogoex Oct 16, 2024
a22bc8e
wip
gogoex Oct 16, 2024
5482653
use const reference for rp
gogoex Oct 16, 2024
80f88cd
apply wallet test fix patch
gogoex Oct 17, 2024
1cd8e56
add swap to fuzzer ci test
gogoex Oct 18, 2024
26f2725
replace VOID macro w/ TO_VOID
gogoex Oct 18, 2024
da7a22b
use 7 arguments for UPNP_GetValidIGD if MINIUPNPC_API_VERSION > 17
gogoex Oct 19, 2024
48b4cbe
use medium type for fuzzer task
gogoex Oct 19, 2024
7f718b4
test fuzzer ci check only
gogoex Oct 19, 2024
c6baeea
wip
gogoex Oct 19, 2024
e65fbd8
wip
gogoex Oct 19, 2024
e6841e1
wip
gogoex Oct 19, 2024
ba62a15
wip
gogoex Oct 19, 2024
64ac555
wip
gogoex Oct 19, 2024
d2b7995
wip
gogoex Oct 19, 2024
4783908
kick off ci
gogoex Oct 20, 2024
339df7c
uncomment all ci tasks. use small persistent_worker for lint
gogoex Oct 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add txin serialization
  • Loading branch information
gogoex committed Oct 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6f364afd78794965494f404e99e80e37b195084c
32 changes: 30 additions & 2 deletions src/blsct/external_api/blsct.cpp
Original file line number Diff line number Diff line change
@@ -509,7 +509,7 @@ BlsctRetVal* gen_out_point(
MALLOC(BlsctOutPoint, blsct_out_point);
RETURN_IF_MEM_ALLOC_FAILED(blsct_out_point);

std::string tx_id_str(tx_id_c_str, TXID_STR_LEN);
std::string tx_id_str(tx_id_c_str, TX_ID_STR_LEN);

auto tx_id = TxidFromString(tx_id_str);
COutPoint out_point { tx_id, out_index };
@@ -750,6 +750,7 @@ CMutableTransaction* deserialize_tx(
return tx;
}

// tx in
const std::vector<CTxIn>* get_tx_ins(const CMutableTransaction* tx) {
return &tx->vin;
}
@@ -766,6 +767,33 @@ const BlsctRetVal* get_tx_in(const std::vector<CTxIn>* tx_ins, const size_t i) {
return succ(tx_in_copy, tx_in_size);
}

const BlsctScript* get_tx_in_script_sig(const CTxIn* tx_in) {
auto copy = static_cast<BlsctScript*>(malloc(SCRIPT_SIZE));
std::memcpy(copy, &tx_in->scriptSig, SCRIPT_SIZE);
return copy;
}

uint32_t get_tx_in_sequence(const CTxIn* tx_in) {
return tx_in->nSequence;
}

const BlsctScript* get_tx_in_script_witness(const CTxIn* tx_in) {
auto copy = static_cast<BlsctScript*>(malloc(SCRIPT_SIZE));
std::memcpy(copy, &tx_in->scriptWitness, SCRIPT_SIZE);
return copy;
}

const BlsctTxId* get_tx_in_prev_out_hash(const CTxIn* tx_in) {
auto copy = static_cast<BlsctTxId*>(malloc(TX_ID_SIZE));
std::memcpy(copy, &tx_in->prevout.hash, TX_ID_SIZE);
return copy;
}

uint32_t get_tx_in_prev_out_n(const CTxIn* tx_in) {
return tx_in->prevout.n;
}

// tx out
const std::vector<CTxOut>* get_tx_outs(const CMutableTransaction* tx) {
return &tx->vout;
}
@@ -825,7 +853,7 @@ const BlsctPoint* get_tx_out_blinding_key(const CTxOut* tx_out) {
return copy;
}

const uint16_t get_tx_out_view_tag(const CTxOut* tx_out) {
uint16_t get_tx_out_view_tag(const CTxOut* tx_out) {
return tx_out->blsctData.viewTag;
}

17 changes: 15 additions & 2 deletions src/blsct/external_api/blsct.h
Original file line number Diff line number Diff line change
@@ -53,7 +53,8 @@
#define SCRIPT_SIZE 28
#define MAX_MEMO_LEN 100
#define MEMO_BUF_SIZE MAX_MEMO_LEN + 1
#define TXID_STR_LEN UINT256_SIZE * 2
#define TX_ID_SIZE UINT256_SIZE
#define TX_ID_STR_LEN TX_ID_SIZE * 2

/* return codes */
#define BLSCT_RESULT uint8_t
@@ -167,6 +168,7 @@ typedef uint8_t BlsctSubAddr[SUBADDRESS_SIZE];
typedef uint8_t BlsctSubAddrId[SUBADDRESS_ID_SIZE];
typedef uint8_t BlsctTokenId[TOKEN_ID_SIZE];
typedef uint8_t BlsctUint256[UINT256_SIZE];
typedef uint8_t BlsctTxId[TX_ID_SIZE];
typedef uint8_t BlsctViewTag[VIEW_TAG_SIZE];
typedef uint8_t BlsctOutPoint[OUT_POINT_SIZE];
typedef uint8_t BlsctSignature[SIGNATURE_SIZE];
@@ -444,6 +446,17 @@ size_t get_tx_outs_size(const std::vector<CTxOut>* tx_outs);

const BlsctRetVal* get_tx_out(const std::vector<CTxOut>* tx_outs, const size_t i);

// TxIn
const BlsctScript* get_tx_in_script_sig(const CTxIn* tx_in);

uint32_t get_tx_in_sequence(const CTxIn* tx_in);

const BlsctScript* get_tx_in_script_witness(const CTxIn* tx_in);

const BlsctTxId* get_tx_in_prev_out_hash(const CTxIn* tx_in);

uint32_t get_tx_in_prev_out_n(const CTxIn* tx_in);

// TxOut
uint64_t get_tx_out_value(const CTxOut* tx_out);

@@ -459,7 +472,7 @@ const BlsctPoint* get_tx_out_ephemeral_key(const CTxOut* tx_out);

const BlsctPoint* get_tx_out_blinding_key(const CTxOut* tx_out);

const uint16_t get_tx_out_view_tag(const CTxOut* tx_out);
uint16_t get_tx_out_view_tag(const CTxOut* tx_out);

const BlsctPoint* get_tx_out_range_proof_A(const CTxOut* tx_out);
const BlsctPoint* get_tx_out_range_proof_S(const CTxOut* tx_out);