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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// SPDX-License-Identifier: CC0-1.0
use core::ffi::{c_char, c_int};
unsafe extern "C" {
/// Verifies a single transaction input against the Tidecoin node interpreter.
pub fn tidecoin_node_verify_tx_input(
tx_hex: *const c_char,
input_index: usize,
prev_script: *const u8,
prev_script_len: usize,
amount: i64,
flags: u32,
script_error_out: *mut c_int,
) -> c_int;
/// Runs Tidecoin node `CheckTransaction` on a serialized transaction.
pub fn tidecoin_node_check_transaction(tx_hex: *const c_char) -> c_int;
/// Runs Tidecoin node scrypt-1024-1-1-256 over a pure 80-byte header.
pub fn tidecoin_node_scrypt_pow_hash(
header: *const u8,
header_len: usize,
out: *mut u8,
out_len: usize,
) -> c_int;
/// Runs Tidecoin node yespower over a pure 80-byte header.
pub fn tidecoin_node_yespower_pow_hash(
header: *const u8,
header_len: usize,
out: *mut u8,
out_len: usize,
) -> c_int;
/// Runs Tidecoin node-equivalent header PoW validation, including AuxPoW context.
pub fn tidecoin_node_has_valid_header_pow(
header_hex: *const c_char,
network: c_int,
has_height: c_int,
height: c_int,
) -> c_int;
/// Runs Tidecoin node-equivalent context-free block sanity validation.
pub fn tidecoin_node_check_block(
block_hex: *const c_char,
network: c_int,
check_pow: c_int,
check_merkle_root: c_int,
) -> c_int;
/// Runs Tidecoin node-equivalent UTXO-independent contextual block validation.
pub fn tidecoin_node_check_contextual_block(
block_hex: *const c_char,
network: c_int,
height: c_int,
lock_time_cutoff: i64,
enforce_bip34_height: c_int,
expect_witness_commitment: c_int,
) -> c_int;
/// Runs Tidecoin node-equivalent permitted difficulty transition checks.
pub fn tidecoin_node_permitted_difficulty_transition(
network: c_int,
height: i64,
old_nbits: u32,
new_nbits: u32,
) -> c_int;
/// Returns the Tidecoin node block subsidy for a network and height.
pub fn tidecoin_node_block_subsidy(network: c_int, height: c_int) -> i64;
/// Runs Tidecoin node `pq::VSizeP2WPKHInput`.
pub fn tidecoin_node_pq_p2wpkh_input_vsize(sig_len: usize, pubkey_len: usize) -> i64;
/// Runs Tidecoin node `pq::VSizeP2SH_P2WPKHInput`.
pub fn tidecoin_node_pq_p2sh_p2wpkh_input_vsize(sig_len: usize, pubkey_len: usize) -> i64;
/// Deterministically generates a PQ keypair from a raw seed using the Tidecoin node.
pub fn tidecoin_node_pq_keygen_from_seed(
scheme_prefix: u8,
seed: *const u8,
seed_len: usize,
pk_out: *mut u8,
pk_len: usize,
sk_out: *mut u8,
sk_len: usize,
) -> c_int;
/// Deterministically generates a PQHD keypair from a stream key using the Tidecoin node.
pub fn tidecoin_node_pqhd_keygen_from_stream_key(
scheme_prefix: u8,
stream_key: *const u8,
stream_key_len: usize,
pk_out: *mut u8,
pk_len: usize,
sk_out: *mut u8,
sk_len: usize,
) -> c_int;
/// Computes a PQ public key from a secret key using the Tidecoin node.
pub fn tidecoin_node_pq_compute_public_key(
scheme_prefix: u8,
sk: *const u8,
sk_len: usize,
pk_out: *mut u8,
pk_len: usize,
) -> c_int;
/// Signs a message using the Tidecoin node PQ API.
pub fn tidecoin_node_pq_sign_message(
scheme_prefix: u8,
msg: *const u8,
msg_len: usize,
sk: *const u8,
sk_len: usize,
legacy_mode: c_int,
sig_out: *mut u8,
sig_len: *mut usize,
) -> c_int;
/// Verifies a message signature using the Tidecoin node PQ API.
pub fn tidecoin_node_pq_verify_message(
scheme_prefix: u8,
msg: *const u8,
msg_len: usize,
sig: *const u8,
sig_len: usize,
pk: *const u8,
pk_len: usize,
legacy_mode: c_int,
) -> c_int;
/// Deterministically generates an ML-KEM-512 keypair using the Tidecoin node.
pub fn tidecoin_node_mlkem512_keypair_from_coins(
coins: *const u8,
coins_len: usize,
pk_out: *mut u8,
pk_len: usize,
sk_out: *mut u8,
sk_len: usize,
) -> c_int;
/// Deterministically encapsulates an ML-KEM-512 shared secret using the Tidecoin node.
pub fn tidecoin_node_mlkem512_encaps_deterministic(
pk: *const u8,
pk_len: usize,
coins: *const u8,
coins_len: usize,
ct_out: *mut u8,
ct_len: usize,
ss_out: *mut u8,
ss_len: usize,
) -> c_int;
/// Decapsulates an ML-KEM-512 ciphertext using the Tidecoin node.
pub fn tidecoin_node_mlkem512_decaps(
ct: *const u8,
ct_len: usize,
sk: *const u8,
sk_len: usize,
ss_out: *mut u8,
ss_len: usize,
) -> c_int;
/// Parses script assembly text using Tidecoin node helpers.
pub fn tidecoin_node_parse_script_asm(
script_asm: *const c_char,
out: *mut u8,
out_len: *mut usize,
) -> c_int;
/// Verifies an isolated script test case against the Tidecoin node interpreter.
pub fn tidecoin_node_verify_script_case(
script_sig: *const u8,
script_sig_len: usize,
script_pubkey: *const u8,
script_pubkey_len: usize,
witness_items: *const *const u8,
witness_lens: *const usize,
witness_count: usize,
amount: i64,
flags: u32,
script_error_out: *mut c_int,
) -> c_int;
}