@@ -101,12 +101,6 @@ type
101101proc ffi_cfr_zero * (): ptr CFr {.importc : " ffi_cfr_zero" , cdecl ,
102102 dynlib : RLN_LIB .}
103103proc ffi_cfr_one * (): ptr CFr {.importc : " ffi_cfr_one" , cdecl , dynlib : RLN_LIB .}
104- proc ffi_cfr_free * (x: ptr CFr ) {.importc : " ffi_cfr_free" , cdecl ,
105- dynlib : RLN_LIB .}
106- proc ffi_uint_to_cfr * (value: uint32 ): ptr CFr {.importc : " ffi_uint_to_cfr" ,
107- cdecl , dynlib : RLN_LIB .}
108- proc ffi_cfr_debug * (cfr: ptr CFr ): Vec_uint8 {.importc : " ffi_cfr_debug" , cdecl ,
109- dynlib : RLN_LIB .}
110104proc ffi_cfr_to_bytes_le * (cfr: ptr CFr ): VecU8Result {.importc : " ffi_cfr_to_bytes_le" ,
111105 cdecl , dynlib : RLN_LIB .}
112106proc ffi_cfr_to_bytes_be * (cfr: ptr CFr ): VecU8Result {.importc : " ffi_cfr_to_bytes_be" ,
@@ -115,6 +109,12 @@ proc ffi_bytes_le_to_cfr*(bytes: ptr Vec_uint8): CFrResult {.importc: "ffi_bytes
115109 cdecl , dynlib : RLN_LIB .}
116110proc ffi_bytes_be_to_cfr * (bytes: ptr Vec_uint8): CFrResult {.importc : " ffi_bytes_be_to_cfr" ,
117111 cdecl , dynlib : RLN_LIB .}
112+ proc ffi_uint_to_cfr * (value: uint32 ): ptr CFr {.importc : " ffi_uint_to_cfr" ,
113+ cdecl , dynlib : RLN_LIB .}
114+ proc ffi_cfr_debug * (cfr: ptr CFr ): Vec_uint8 {.importc : " ffi_cfr_debug" , cdecl ,
115+ dynlib : RLN_LIB .}
116+ proc ffi_cfr_free * (x: ptr CFr ) {.importc : " ffi_cfr_free" , cdecl ,
117+ dynlib : RLN_LIB .}
118118
119119# Vec<CFr> functions
120120proc ffi_vec_cfr_new * (capacity: CSize ): Vec_CFr {.importc : " ffi_vec_cfr_new" ,
@@ -163,50 +163,68 @@ proc ffi_poseidon_hash_pair*(a: ptr CFr,
163163 b: ptr CFr ): ptr CFr {.importc : " ffi_poseidon_hash_pair" , cdecl ,
164164 dynlib : RLN_LIB .}
165165
166- # Keygen function
166+ # Identity functions
167167proc ffi_key_gen * (): Vec_CFr {.importc : " ffi_key_gen" , cdecl , dynlib : RLN_LIB .}
168168proc ffi_seeded_key_gen * (seed: ptr Vec_uint8): Vec_CFr {.importc : " ffi_seeded_key_gen" ,
169169 cdecl , dynlib : RLN_LIB .}
170+
171+ # ExtendedIdentity functions
170172proc ffi_extended_key_gen * (): Vec_CFr {.importc : " ffi_extended_key_gen" , cdecl ,
171173 dynlib : RLN_LIB .}
172174proc ffi_seeded_extended_key_gen * (seed: ptr Vec_uint8): Vec_CFr {.importc : " ffi_seeded_extended_key_gen" ,
173175 cdecl , dynlib : RLN_LIB .}
174176
177+ # CString functions
178+ proc ffi_c_string_free * (s: Vec_uint8) {.importc : " ffi_c_string_free" , cdecl ,
179+ dynlib : RLN_LIB .}
180+
175181# RLN instance functions
176182proc ffi_rln_v3_new_stateless * (zkey_data: ptr Vec_uint8,
177183 graph_data: ptr Vec_uint8): RLNResult {.importc : " ffi_rln_v3_new_stateless" ,
178184 cdecl , dynlib : RLN_LIB .}
179- proc ffi_rln_v3_new_with_pm_tree * (tree_depth: CSize , zkey_data: ptr Vec_uint8,
180- graph_data: ptr Vec_uint8,
181- config_path: cstring ): RLNResult {.importc : " ffi_rln_v3_new_with_pm_tree" ,
185+ proc ffi_rln_v3_new_stateless_default * (): ptr RLN {.importc : " ffi_rln_v3_new_stateless_default" ,
182186 cdecl , dynlib : RLN_LIB .}
183187proc ffi_rln_v3_new_with_full_merkle_tree * (tree_depth: CSize ,
184188 zkey_data: ptr Vec_uint8,
185189 graph_data: ptr Vec_uint8): RLNResult {.importc : " ffi_rln_v3_new_with_full_merkle_tree" ,
186190 cdecl , dynlib : RLN_LIB .}
191+ proc ffi_rln_v3_new_with_full_merkle_tree_default * (): ptr RLN {.importc : " ffi_rln_v3_new_with_full_merkle_tree_default" ,
192+ cdecl , dynlib : RLN_LIB .}
187193proc ffi_rln_v3_new_with_optimal_merkle_tree * (tree_depth: CSize ,
188194 zkey_data: ptr Vec_uint8,
189195 graph_data: ptr Vec_uint8): RLNResult {.importc : " ffi_rln_v3_new_with_optimal_merkle_tree" ,
190196 cdecl , dynlib : RLN_LIB .}
197+ proc ffi_rln_v3_new_with_optimal_merkle_tree_default * (): ptr RLN {.importc : " ffi_rln_v3_new_with_optimal_merkle_tree_default" ,
198+ cdecl , dynlib : RLN_LIB .}
199+ proc ffi_rln_v3_new_with_pm_tree * (tree_depth: CSize ,
200+ zkey_data: ptr Vec_uint8,
201+ graph_data: ptr Vec_uint8,
202+ config_path: cstring ): RLNResult {.importc : " ffi_rln_v3_new_with_pm_tree" ,
203+ cdecl , dynlib : RLN_LIB .}
204+ proc ffi_rln_v3_new_with_pm_tree_default * (config_path: cstring ): ptr RLN {.
205+ importc : " ffi_rln_v3_new_with_pm_tree_default" ,
206+ cdecl , dynlib : RLN_LIB .}
191207proc ffi_rln_v3_generate_proof * (rln: ptr ptr RLN ,
192208 witness: ptr ptr Witness ): ProofResult {.importc : " ffi_rln_v3_generate_proof" ,
193209 cdecl , dynlib : RLN_LIB .}
194- proc ffi_rln_v3_verify * (rln: ptr ptr RLN , proof: ptr ptr Proof ,
195- x: ptr CFr ): CBoolResult {.importc : " ffi_rln_v3_verify" , cdecl ,
196- dynlib : RLN_LIB .}
210+ proc ffi_rln_v3_verify * (rln: ptr ptr RLN ,
211+ proof: ptr ptr Proof ,
212+ x: ptr CFr ): CBoolResult {.importc : " ffi_rln_v3_verify" ,
213+ cdecl , dynlib : RLN_LIB .}
197214proc ffi_rln_v3_verify_with_roots * (rln: ptr ptr RLN ,
198- proof: ptr ptr Proof , roots: ptr Vec_CFr,
199- x: ptr CFr ): CBoolResult {.importc : " ffi_rln_v3_verify_with_roots" , cdecl ,
200- dynlib : RLN_LIB .}
215+ proof: ptr ptr Proof ,
216+ roots: ptr Vec_CFr,
217+ x: ptr CFr ): CBoolResult {.importc : " ffi_rln_v3_verify_with_roots" ,
218+ cdecl , dynlib : RLN_LIB .}
201219proc ffi_rln_v3_generate_partial_proof * (rln: ptr ptr RLN ,
202220 witness: ptr ptr PartialWitness ): PartialProofResult {.importc : " ffi_rln_v3_generate_partial_proof" ,
203221 cdecl , dynlib : RLN_LIB .}
204222proc ffi_rln_v3_finish_proof * (rln: ptr ptr RLN ,
205223 partial: ptr ptr PartialProof ,
206224 witness: ptr ptr Witness ): ProofResult {.importc : " ffi_rln_v3_finish_proof" ,
207225 cdecl , dynlib : RLN_LIB .}
208- proc ffi_rln_v3_free * (rln: ptr RLN ) {.importc : " ffi_rln_v3_free" , cdecl ,
209- dynlib : RLN_LIB .}
226+ proc ffi_rln_v3_free * (rln: ptr RLN ) {.importc : " ffi_rln_v3_free" ,
227+ cdecl , dynlib : RLN_LIB .}
210228
211229# RLNWitnessInput functions
212230proc ffi_rln_v3_witness_input_new_single * (identity_secret: ptr CFr ,
@@ -254,9 +272,6 @@ proc ffi_bytes_le_to_rln_v3_witness*(bytes: ptr Vec_uint8): WitnessResult {.impo
254272 cdecl , dynlib : RLN_LIB .}
255273proc ffi_bytes_be_to_rln_v3_witness * (bytes: ptr Vec_uint8): WitnessResult {.importc : " ffi_bytes_be_to_rln_v3_witness" ,
256274 cdecl , dynlib : RLN_LIB .}
257- proc ffi_rln_v3_witness_to_partial_witness * (
258- w: ptr ptr Witness ): ptr PartialWitness {.importc : " ffi_rln_v3_witness_to_partial_witness" ,
259- cdecl , dynlib : RLN_LIB .}
260275proc ffi_rln_v3_witness_input_free * (w: ptr Witness ) {.importc : " ffi_rln_v3_witness_input_free" ,
261276 cdecl , dynlib : RLN_LIB .}
262277
@@ -277,6 +292,9 @@ proc ffi_rln_v3_partial_witness_input_get_path_elements*(
277292proc ffi_rln_v3_partial_witness_input_get_identity_path_index * (
278293 w: ptr ptr PartialWitness ): Vec_uint8 {.importc : " ffi_rln_v3_partial_witness_input_get_identity_path_index" ,
279294 cdecl , dynlib : RLN_LIB .}
295+ proc ffi_rln_v3_witness_to_partial_witness * (
296+ w: ptr ptr Witness ): ptr PartialWitness {.importc : " ffi_rln_v3_witness_to_partial_witness" ,
297+ cdecl , dynlib : RLN_LIB .}
280298proc ffi_rln_v3_partial_witness_to_bytes_le * (
281299 w: ptr ptr PartialWitness ): VecU8Result {.importc : " ffi_rln_v3_partial_witness_to_bytes_le" ,
282300 cdecl , dynlib : RLN_LIB .}
@@ -330,14 +348,14 @@ proc ffi_rln_v3_proof_values_get_y*(pv: ptr ptr ProofValues): CFrResult {.import
330348proc ffi_rln_v3_proof_values_get_nullifier * (
331349 pv: ptr ptr ProofValues ): CFrResult {.importc : " ffi_rln_v3_proof_values_get_nullifier" ,
332350 cdecl , dynlib : RLN_LIB .}
351+ proc ffi_rln_v3_proof_values_get_selector_used * (
352+ pv: ptr ptr ProofValues ): VecBoolResult {.importc : " ffi_rln_v3_proof_values_get_selector_used" ,
353+ cdecl , dynlib : RLN_LIB .}
333354proc ffi_rln_v3_proof_values_get_ys * (pv: ptr ptr ProofValues ): VecCFrResult {.importc : " ffi_rln_v3_proof_values_get_ys" ,
334355 cdecl , dynlib : RLN_LIB .}
335356proc ffi_rln_v3_proof_values_get_nullifiers * (
336357 pv: ptr ptr ProofValues ): VecCFrResult {.importc : " ffi_rln_v3_proof_values_get_nullifiers" ,
337358 cdecl , dynlib : RLN_LIB .}
338- proc ffi_rln_v3_proof_values_get_selector_used * (
339- pv: ptr ptr ProofValues ): VecBoolResult {.importc : " ffi_rln_v3_proof_values_get_selector_used" ,
340- cdecl , dynlib : RLN_LIB .}
341359proc ffi_rln_v3_proof_values_to_bytes_le * (
342360 pv: ptr ptr ProofValues ): VecU8Result {.importc : " ffi_rln_v3_proof_values_to_bytes_le" ,
343361 cdecl , dynlib : RLN_LIB .}
@@ -363,22 +381,22 @@ proc ffi_rln_v3_recover_id_secret*(pv1: ptr ptr ProofValues,
363381 cdecl , dynlib : RLN_LIB .}
364382
365383# Merkle tree operations (stateful mode)
366- proc ffi_rln_v3_set_next_leaf * (rln: ptr ptr RLN ,
367- leaf: ptr CFr ): CBoolResult {.importc : " ffi_rln_v3_set_next_leaf" , cdecl ,
384+ proc ffi_rln_v3_merkle_proof_free * (p: ptr MerkleProof ) {.importc : " ffi_rln_v3_merkle_proof_free" ,
385+ cdecl , dynlib : RLN_LIB .}
386+ proc ffi_rln_v3_delete_leaf * (rln: ptr ptr RLN ,
387+ index: CSize ): CBoolResult {.importc : " ffi_rln_v3_delete_leaf" , cdecl ,
368388 dynlib : RLN_LIB .}
369389proc ffi_rln_v3_set_leaf * (rln: ptr ptr RLN , index: CSize ,
370390 leaf: ptr CFr ): CBoolResult {.importc : " ffi_rln_v3_set_leaf" , cdecl ,
371391 dynlib : RLN_LIB .}
372392proc ffi_rln_v3_get_leaf * (rln: ptr ptr RLN ,
373393 index: CSize ): CFrResult {.importc : " ffi_rln_v3_get_leaf" , cdecl ,
374394 dynlib : RLN_LIB .}
375- proc ffi_rln_v3_delete_leaf * (rln: ptr ptr RLN ,
376- index: CSize ): CBoolResult {.importc : " ffi_rln_v3_delete_leaf" , cdecl ,
377- dynlib : RLN_LIB .}
378395proc ffi_rln_v3_leaves_set * (rln: ptr ptr RLN ): CSize {.importc : " ffi_rln_v3_leaves_set" ,
379396 cdecl , dynlib : RLN_LIB .}
380- proc ffi_rln_v3_get_root * (rln: ptr ptr RLN ): ptr CFr {.importc : " ffi_rln_v3_get_root" ,
381- cdecl , dynlib : RLN_LIB .}
397+ proc ffi_rln_v3_set_next_leaf * (rln: ptr ptr RLN ,
398+ leaf: ptr CFr ): CBoolResult {.importc : " ffi_rln_v3_set_next_leaf" , cdecl ,
399+ dynlib : RLN_LIB .}
382400proc ffi_rln_v3_set_leaves_from * (rln: ptr ptr RLN , index: CSize ,
383401 leaves: ptr Vec_CFr): CBoolResult {.importc : " ffi_rln_v3_set_leaves_from" ,
384402 cdecl , dynlib : RLN_LIB .}
@@ -393,11 +411,11 @@ proc ffi_rln_v3_seq_atomic_operation*(rln: ptr ptr RLN,
393411 leaves: ptr Vec_CFr,
394412 indices: ptr Vec_uint8): CBoolResult {.importc : " ffi_rln_v3_seq_atomic_operation" ,
395413 cdecl , dynlib : RLN_LIB .}
414+ proc ffi_rln_v3_get_root * (rln: ptr ptr RLN ): ptr CFr {.importc : " ffi_rln_v3_get_root" ,
415+ cdecl , dynlib : RLN_LIB .}
396416proc ffi_rln_v3_get_merkle_proof * (rln: ptr ptr RLN ,
397417 index: CSize ): MerkleProofResult {.importc : " ffi_rln_v3_get_merkle_proof" ,
398418 cdecl , dynlib : RLN_LIB .}
399- proc ffi_rln_v3_merkle_proof_free * (p: ptr MerkleProof ) {.importc : " ffi_rln_v3_merkle_proof_free" ,
400- cdecl , dynlib : RLN_LIB .}
401419proc ffi_rln_v3_set_metadata * (rln: ptr ptr RLN ,
402420 metadata: ptr Vec_uint8): CBoolResult {.importc : " ffi_rln_v3_set_metadata" ,
403421 cdecl , dynlib : RLN_LIB .}
@@ -406,10 +424,6 @@ proc ffi_rln_v3_get_metadata*(rln: ptr ptr RLN): VecU8Result {.importc: "ffi_rln
406424proc ffi_rln_v3_flush * (rln: ptr ptr RLN ): CBoolResult {.importc : " ffi_rln_v3_flush" ,
407425 cdecl , dynlib : RLN_LIB .}
408426
409- # Helpers functions
410- proc ffi_c_string_free * (s: Vec_uint8) {.importc : " ffi_c_string_free" , cdecl ,
411- dynlib : RLN_LIB .}
412-
413427proc asVecU8 (buf: var seq [uint8 ]): Vec_uint8 =
414428 result .dataPtr = if buf.len > 0 : addr buf[0 ] else : nil
415429 result .len = csize_t (buf.len)
0 commit comments