@@ -852,6 +852,93 @@ extern "C" {
852852 internal_pubkey : * const XOnlyPublicKey ,
853853 tweak32 : * const c_uchar ,
854854 ) -> c_int ;
855+
856+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_sender_create_outputs" ) ]
857+ pub fn secp256k1_silentpayments_sender_create_outputs (
858+ cx : * const Context ,
859+ generated_outputs : * mut * mut XOnlyPublicKey ,
860+ recipients : * mut * const SilentpaymentsRecipient ,
861+ n_recipients : size_t ,
862+ outpoint_smallest36 : * const c_uchar ,
863+ taproot_seckeys : * const * const Keypair ,
864+ n_taproot_seckeys : size_t ,
865+ plain_seckeys : * const * const c_uchar ,
866+ n_plain_seckeys : size_t ,
867+ ) -> c_int ;
868+
869+
870+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_create_label_tweak" ) ]
871+ pub fn secp256k1_silentpayments_recipient_create_label_tweak (
872+ cx : * const Context ,
873+ pubkey : * mut PublicKey ,
874+ label_tweak32 : * mut c_uchar ,
875+ recipient_scan_key : * const c_uchar ,
876+ m : c_uint ,
877+ ) -> c_int ;
878+
879+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_public_data_create" ) ]
880+ pub fn secp256k1_silentpayments_recipient_public_data_create (
881+ cx : * const Context ,
882+ public_data : * mut SilentpaymentsPublicData ,
883+ outpoint_smallest36 : * const c_uchar ,
884+ xonly_pubkeys : * const * const XOnlyPublicKey ,
885+ n_xonly_pubkeys : size_t ,
886+ plain_pubkeys : * const * const PublicKey ,
887+ n_plain_pubkeys : size_t ,
888+ ) -> c_int ;
889+
890+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_scan_outputs" ) ]
891+ pub fn secp256k1_silentpayments_recipient_scan_outputs (
892+ ctx : * const Context ,
893+ found_outputs : * mut * mut SilentpaymentsFoundOutput ,
894+ n_found_outputs : * mut size_t ,
895+ tx_outputs : * const * const XOnlyPublicKey ,
896+ n_tx_outputs : size_t ,
897+ recipient_scan_key : * const c_uchar ,
898+ public_data : * const SilentpaymentsPublicData ,
899+ recipient_spend_pubkey : * const PublicKey ,
900+ label_lookup : SilentpaymentsLabelLookupFunction ,
901+ label_context : * const c_void ,
902+ ) -> c_int ;
903+
904+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_public_data_serialize" ) ]
905+ pub fn secp256k1_silentpayments_recipient_public_data_serialize (
906+ ctx : * const Context ,
907+ output33 : * mut c_uchar ,
908+ public_data : * const SilentpaymentsPublicData ,
909+ ) -> c_int ;
910+
911+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_public_data_parse" ) ]
912+ pub fn secp256k1_silentpayments_recipient_public_data_parse (
913+ ctx : * const Context ,
914+ public_data : * mut SilentpaymentsPublicData ,
915+ input33 : * const c_uchar ,
916+ ) -> c_int ;
917+
918+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_create_shared_secret" ) ]
919+ pub fn secp256k1_silentpayments_recipient_create_shared_secret (
920+ ctx : * const Context ,
921+ shared_secret33 : * mut c_uchar ,
922+ recipient_scan_key : * const c_uchar ,
923+ public_data : * const SilentpaymentsPublicData ,
924+ ) -> c_int ;
925+
926+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_create_output_pubkey" ) ]
927+ pub fn secp256k1_silentpayments_recipient_create_output_pubkey (
928+ ctx : * const Context ,
929+ P_output_xonly : * mut XOnlyPublicKey ,
930+ shared_secret33 : * const c_uchar ,
931+ recipient_spend_pubkey : * const PublicKey ,
932+ k : c_uint ,
933+ ) -> c_int ;
934+
935+ #[ cfg_attr( not( rust_secp_no_symbol_renaming) , link_name = "rustsecp256k1_v0_10_0_silentpayments_recipient_create_labelled_spend_pubkey" ) ]
936+ pub fn secp256k1_silentpayments_recipient_create_labelled_spend_pubkey (
937+ ctx : * const Context ,
938+ labelled_spend_pubkey : * mut PublicKey ,
939+ recipient_spend_pubkey : * const PublicKey ,
940+ label : * const PublicKey ,
941+ ) -> c_int ;
855942}
856943
857944/// A reimplementation of the C function `secp256k1_context_create` in rust.
@@ -1084,6 +1171,117 @@ impl <T: CPtr> CPtr for Option<T> {
10841171 }
10851172}
10861173
1174+ #[ repr( C ) ]
1175+ #[ derive( Copy , Clone ) ]
1176+ pub struct SilentpaymentsRecipient {
1177+ scan_pubkey : PublicKey ,
1178+ spend_pubkey : PublicKey ,
1179+ index : size_t ,
1180+ }
1181+
1182+ impl SilentpaymentsRecipient {
1183+ pub fn new ( scan_pubkey : & PublicKey , spend_pubkey : & PublicKey , index : usize ) -> Self {
1184+ Self {
1185+ scan_pubkey : scan_pubkey. clone ( ) ,
1186+ spend_pubkey : spend_pubkey. clone ( ) ,
1187+ index
1188+ }
1189+ }
1190+ }
1191+
1192+ impl core:: fmt:: Debug for SilentpaymentsRecipient {
1193+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
1194+ f. debug_struct ( "SilentpaymentsRecipient" )
1195+ . field ( "scan_pubkey" , & self . scan_pubkey )
1196+ . field ( "spend_pubkey" , & self . spend_pubkey )
1197+ . field ( "index" , & self . index )
1198+ . finish ( )
1199+ }
1200+ }
1201+
1202+ #[ cfg( not( secp256k1_fuzz) ) ]
1203+ impl PartialEq for SilentpaymentsRecipient {
1204+ fn eq ( & self , other : & Self ) -> bool {
1205+ self . scan_pubkey == other. scan_pubkey &&
1206+ self . spend_pubkey == other. spend_pubkey &&
1207+ self . index == other. index
1208+ }
1209+ }
1210+
1211+ #[ cfg( not( secp256k1_fuzz) ) ]
1212+ impl Eq for SilentpaymentsRecipient { }
1213+
1214+ #[ repr( C ) ]
1215+ #[ derive( Copy , Clone ) ]
1216+ pub struct SilentpaymentsFoundOutput {
1217+ pub output : XOnlyPublicKey ,
1218+ tweak : [ u8 ; 32 ] ,
1219+ found_with_label : bool ,
1220+ label : PublicKey ,
1221+ }
1222+
1223+ impl SilentpaymentsFoundOutput {
1224+
1225+ pub fn empty ( ) -> Self {
1226+ Self {
1227+ output : unsafe { XOnlyPublicKey :: new ( ) } ,
1228+ tweak : [ 0 ; 32 ] ,
1229+ found_with_label : false ,
1230+ label : unsafe { PublicKey :: new ( ) } ,
1231+ }
1232+ }
1233+
1234+ pub fn new ( output : & XOnlyPublicKey , tweak : & [ u8 ; 32 ] , found_with_label : bool , label : & PublicKey ) -> Self {
1235+ Self {
1236+ output : output. clone ( ) ,
1237+ tweak : tweak. clone ( ) ,
1238+ found_with_label,
1239+ label : label. clone ( ) ,
1240+ }
1241+ }
1242+ }
1243+
1244+ #[ cfg( not( secp256k1_fuzz) ) ]
1245+ impl PartialEq for SilentpaymentsFoundOutput {
1246+ fn eq ( & self , other : & Self ) -> bool {
1247+ self . tweak == other. tweak &&
1248+ self . found_with_label == other. found_with_label &&
1249+ self . label == other. label
1250+ }
1251+ }
1252+
1253+ #[ cfg( not( secp256k1_fuzz) ) ]
1254+ impl Eq for SilentpaymentsFoundOutput { }
1255+
1256+ impl core:: fmt:: Debug for SilentpaymentsFoundOutput {
1257+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
1258+ f. debug_struct ( "SilentpaymentsFoundOutput" )
1259+ . field ( "output" , & self . output )
1260+ . field ( "tweak" , & self . tweak )
1261+ . field ( "found_with_label" , & self . found_with_label )
1262+ . field ( "label" , & self . label )
1263+ . finish ( )
1264+ }
1265+ }
1266+
1267+ #[ repr( C ) ]
1268+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
1269+ pub struct SilentpaymentsPublicData ( [ u8 ; 98 ] ) ;
1270+
1271+ impl SilentpaymentsPublicData {
1272+ pub fn from_array ( arr : [ u8 ; 98 ] ) -> Self {
1273+ SilentpaymentsPublicData ( arr)
1274+ }
1275+ pub fn to_array ( self ) -> [ u8 ; 98 ] {
1276+ self . 0
1277+ }
1278+ }
1279+
1280+ impl_array_newtype ! ( SilentpaymentsPublicData , u8 , 98 ) ;
1281+ impl_raw_debug ! ( SilentpaymentsPublicData ) ;
1282+
1283+ pub type SilentpaymentsLabelLookupFunction = unsafe extern "C" fn ( * const c_uchar , * const c_void ) -> * const c_uchar ;
1284+
10871285#[ cfg( secp256k1_fuzz) ]
10881286mod fuzz_dummy {
10891287 use super :: * ;
0 commit comments