diff --git a/Makefile b/Makefile index d66c5d2..380069b 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,9 @@ build-darwin-arm64: code-gen-go: mkdir -p lightspark-crypto-go/internal - cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go + cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.1.5+v0.23.0 uniffi-bindgen-go src/lightspark_crypto.udl --out-dir lightspark-crypto-go - mv lightspark-crypto-go/uniffi/lightspark_crypto/lightspark_crypto.go lightspark-crypto-go/internal + mv lightspark-crypto-go/uniffi/lightspark_crypto/* lightspark-crypto-go/internal sed -i '' 's/package lightspark_crypto/package internal/g' lightspark-crypto-go/internal/lightspark_crypto.go rm -rf lightspark-crypto-go/uniffi diff --git a/lightspark-crypto-go/internal/lightspark_crypto.c b/lightspark-crypto-go/internal/lightspark_crypto.c new file mode 100644 index 0000000..59c74a7 --- /dev/null +++ b/lightspark-crypto-go/internal/lightspark_crypto.c @@ -0,0 +1,8 @@ +#include + +// This file exists beacause of +// https://github.com/golang/go/issues/11263 + +void cgo_rust_task_callback_bridge_lightspark_crypto(RustTaskCallback cb, const void * taskData, int8_t status) { + cb(taskData, status); +} \ No newline at end of file diff --git a/lightspark-crypto-go/internal/lightspark_crypto.go b/lightspark-crypto-go/internal/lightspark_crypto.go index a2493fa..dca8981 100644 --- a/lightspark-crypto-go/internal/lightspark_crypto.go +++ b/lightspark-crypto-go/internal/lightspark_crypto.go @@ -47,139 +47,139 @@ typedef struct RustCallStatus { // ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ #endif // def UNIFFI_SHARED_H -void ffi_lightspark_crypto_7bff_KeyPair_object_free( +void ffi_lightspark_crypto_3253_KeyPair_object_free( void* ptr, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_KeyPair_get_public_key( +RustBuffer lightspark_crypto_3253_KeyPair_get_public_key( void* ptr, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_KeyPair_get_private_key( +RustBuffer lightspark_crypto_3253_KeyPair_get_private_key( void* ptr, RustCallStatus* out_status ); -void ffi_lightspark_crypto_7bff_Mnemonic_object_free( +void ffi_lightspark_crypto_3253_Mnemonic_object_free( void* ptr, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_Mnemonic_random( +void* lightspark_crypto_3253_Mnemonic_random( RustCallStatus* out_status ); -void* lightspark_crypto_7bff_Mnemonic_from_entropy( +void* lightspark_crypto_3253_Mnemonic_from_entropy( RustBuffer entropy, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_Mnemonic_from_phrase( +void* lightspark_crypto_3253_Mnemonic_from_phrase( RustBuffer phrase, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_Mnemonic_as_string( +RustBuffer lightspark_crypto_3253_Mnemonic_as_string( void* ptr, RustCallStatus* out_status ); -void ffi_lightspark_crypto_7bff_Seed_object_free( +void ffi_lightspark_crypto_3253_Seed_object_free( void* ptr, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_Seed_new( +void* lightspark_crypto_3253_Seed_new( RustBuffer seed, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_Seed_from_mnemonic( +void* lightspark_crypto_3253_Seed_from_mnemonic( void* mnemonic, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_Seed_as_bytes( +RustBuffer lightspark_crypto_3253_Seed_as_bytes( void* ptr, RustCallStatus* out_status ); -void ffi_lightspark_crypto_7bff_InvoiceSignature_object_free( +void ffi_lightspark_crypto_3253_InvoiceSignature_object_free( void* ptr, RustCallStatus* out_status ); -int32_t lightspark_crypto_7bff_InvoiceSignature_get_recovery_id( +int32_t lightspark_crypto_3253_InvoiceSignature_get_recovery_id( void* ptr, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_InvoiceSignature_get_signature( +RustBuffer lightspark_crypto_3253_InvoiceSignature_get_signature( void* ptr, RustCallStatus* out_status ); -void ffi_lightspark_crypto_7bff_LightsparkSigner_object_free( +void ffi_lightspark_crypto_3253_LightsparkSigner_object_free( void* ptr, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_LightsparkSigner_new( +void* lightspark_crypto_3253_LightsparkSigner_new( void* seed, RustBuffer network, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_LightsparkSigner_from_bytes( +void* lightspark_crypto_3253_LightsparkSigner_from_bytes( RustBuffer seed, RustBuffer network, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_get_master_public_key( +RustBuffer lightspark_crypto_3253_LightsparkSigner_get_master_public_key( void* ptr, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_derive_public_key( +RustBuffer lightspark_crypto_3253_LightsparkSigner_derive_public_key( void* ptr, RustBuffer derivation_path, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_derive_public_key_hex( +RustBuffer lightspark_crypto_3253_LightsparkSigner_derive_public_key_hex( void* ptr, RustBuffer derivation_path, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_derive_private_key( +RustBuffer lightspark_crypto_3253_LightsparkSigner_derive_private_key( void* ptr, RustBuffer derivation_path, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_ecdh( +RustBuffer lightspark_crypto_3253_LightsparkSigner_ecdh( void* ptr, RustBuffer public_key, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_LightsparkSigner_sign_invoice( +void* lightspark_crypto_3253_LightsparkSigner_sign_invoice( void* ptr, RustBuffer unsigned_invoice, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_LightsparkSigner_sign_invoice_hash( +void* lightspark_crypto_3253_LightsparkSigner_sign_invoice_hash( void* ptr, RustBuffer unsigned_invoice, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_derive_key_and_sign( +RustBuffer lightspark_crypto_3253_LightsparkSigner_derive_key_and_sign( void* ptr, RustBuffer message, RustBuffer derivation_path, @@ -189,72 +189,79 @@ RustBuffer lightspark_crypto_7bff_LightsparkSigner_derive_key_and_sign( RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_get_per_commitment_point( +RustBuffer lightspark_crypto_3253_LightsparkSigner_get_per_commitment_point( void* ptr, RustBuffer derivation_path, uint64_t per_commitment_point_idx, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_release_per_commitment_secret( +RustBuffer lightspark_crypto_3253_LightsparkSigner_release_per_commitment_secret( void* ptr, RustBuffer derivation_path, uint64_t per_commitment_point_idx, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_generate_preimage_nonce( +RustBuffer lightspark_crypto_3253_LightsparkSigner_generate_preimage_nonce( void* ptr, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_generate_preimage( +RustBuffer lightspark_crypto_3253_LightsparkSigner_generate_preimage( void* ptr, RustBuffer nonce, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_LightsparkSigner_generate_preimage_hash( +RustBuffer lightspark_crypto_3253_LightsparkSigner_generate_preimage_hash( void* ptr, RustBuffer nonce, RustCallStatus* out_status ); -void ffi_lightspark_crypto_7bff_Validation_init_callback( +void ffi_lightspark_crypto_3253_Validation_init_callback( ForeignCallback callback_stub, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_sign_ecdsa( +RustBuffer lightspark_crypto_3253_sign_ecdsa( RustBuffer msg, RustBuffer private_key_bytes, RustCallStatus* out_status ); -int8_t lightspark_crypto_7bff_verify_ecdsa( +int8_t lightspark_crypto_3253_verify_ecdsa( RustBuffer msg, RustBuffer signature_bytes, RustBuffer public_key_bytes, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_encrypt_ecies( +RustBuffer lightspark_crypto_3253_encrypt_ecies( RustBuffer msg, RustBuffer public_key_bytes, RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_decrypt_ecies( +RustBuffer lightspark_crypto_3253_decrypt_ecies( RustBuffer cipher_text, RustBuffer private_key_bytes, RustCallStatus* out_status ); -void* lightspark_crypto_7bff_generate_keypair( +RustBuffer lightspark_crypto_3253_generate_multisig_address( + RustBuffer network, + RustBuffer pk1, + RustBuffer pk2, + RustCallStatus* out_status +); + +void* lightspark_crypto_3253_generate_keypair( RustCallStatus* out_status ); -RustBuffer lightspark_crypto_7bff_handle_remote_signing_webhook_event( +RustBuffer lightspark_crypto_3253_handle_remote_signing_webhook_event( RustBuffer webhook_data, RustBuffer webhook_signature, RustBuffer webhook_secret, @@ -263,29 +270,29 @@ RustBuffer lightspark_crypto_7bff_handle_remote_signing_webhook_event( RustCallStatus* out_status ); -RustBuffer ffi_lightspark_crypto_7bff_rustbuffer_alloc( +RustBuffer ffi_lightspark_crypto_3253_rustbuffer_alloc( int32_t size, RustCallStatus* out_status ); -RustBuffer ffi_lightspark_crypto_7bff_rustbuffer_from_bytes( +RustBuffer ffi_lightspark_crypto_3253_rustbuffer_from_bytes( ForeignBytes bytes, RustCallStatus* out_status ); -void ffi_lightspark_crypto_7bff_rustbuffer_free( +void ffi_lightspark_crypto_3253_rustbuffer_free( RustBuffer buf, RustCallStatus* out_status ); -RustBuffer ffi_lightspark_crypto_7bff_rustbuffer_reserve( +RustBuffer ffi_lightspark_crypto_3253_rustbuffer_reserve( RustBuffer buf, int32_t additional, RustCallStatus* out_status ); -int32_t lightspark_crypto_7bff_cgo_Validation(uint64_t, int32_t, RustBuffer, RustBuffer *); +int32_t lightspark_crypto_3253_cgo_Validation(uint64_t, int32_t, RustBuffer, RustBuffer *); */ import "C" @@ -345,7 +352,7 @@ func stringToCRustBuffer(str string) C.RustBuffer { func (rb rustBuffer) free() { rustCall(func(status *C.RustCallStatus) bool { - C.ffi_lightspark_crypto_7bff_rustbuffer_free(rb.self, status) + C.ffi_lightspark_crypto_3253_rustbuffer_free(rb.self, status) return false }) } @@ -796,7 +803,7 @@ func (_self *InvoiceSignature) GetRecoveryId() int32 { defer _self.ffiObject.decrementPointer() return FfiConverterint32INSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.int32_t { - return C.lightspark_crypto_7bff_InvoiceSignature_get_recovery_id( + return C.lightspark_crypto_3253_InvoiceSignature_get_recovery_id( _pointer, _uniffiStatus) })) @@ -806,7 +813,7 @@ func (_self *InvoiceSignature) GetSignature() []uint8 { defer _self.ffiObject.decrementPointer() return FfiConverterSequenceuint8INSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_InvoiceSignature_get_signature( + return C.lightspark_crypto_3253_InvoiceSignature_get_signature( _pointer, _uniffiStatus) })) @@ -826,7 +833,7 @@ func (c FfiConverterInvoiceSignature) lift(pointer unsafe.Pointer) *InvoiceSigna newFfiObject( pointer, func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.ffi_lightspark_crypto_7bff_InvoiceSignature_object_free(pointer, status) + C.ffi_lightspark_crypto_3253_InvoiceSignature_object_free(pointer, status) }), } runtime.SetFinalizer(result, (*InvoiceSignature).Destroy) @@ -865,7 +872,7 @@ func (_self *KeyPair) GetPublicKey() []uint8 { defer _self.ffiObject.decrementPointer() return FfiConverterSequenceuint8INSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_KeyPair_get_public_key( + return C.lightspark_crypto_3253_KeyPair_get_public_key( _pointer, _uniffiStatus) })) @@ -875,7 +882,7 @@ func (_self *KeyPair) GetPrivateKey() []uint8 { defer _self.ffiObject.decrementPointer() return FfiConverterSequenceuint8INSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_KeyPair_get_private_key( + return C.lightspark_crypto_3253_KeyPair_get_private_key( _pointer, _uniffiStatus) })) @@ -895,7 +902,7 @@ func (c FfiConverterKeyPair) lift(pointer unsafe.Pointer) *KeyPair { newFfiObject( pointer, func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.ffi_lightspark_crypto_7bff_KeyPair_object_free(pointer, status) + C.ffi_lightspark_crypto_3253_KeyPair_object_free(pointer, status) }), } runtime.SetFinalizer(result, (*KeyPair).Destroy) @@ -932,7 +939,7 @@ type LightsparkSigner struct { func NewLightsparkSigner(seed *Seed, network Network) (*LightsparkSigner, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_LightsparkSigner_new(FfiConverterSeedINSTANCE.lower(seed), FfiConverterTypeNetworkINSTANCE.lower(network), _uniffiStatus) + return C.lightspark_crypto_3253_LightsparkSigner_new(FfiConverterSeedINSTANCE.lower(seed), FfiConverterTypeNetworkINSTANCE.lower(network), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue *LightsparkSigner @@ -946,7 +953,7 @@ func NewLightsparkSigner(seed *Seed, network Network) (*LightsparkSigner, error) func LightsparkSignerFromBytes(seed []uint8, network Network) (*LightsparkSigner, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_LightsparkSigner_from_bytes(FfiConverterSequenceuint8INSTANCE.lower(seed), FfiConverterTypeNetworkINSTANCE.lower(network), _uniffiStatus) + return C.lightspark_crypto_3253_LightsparkSigner_from_bytes(FfiConverterSequenceuint8INSTANCE.lower(seed), FfiConverterTypeNetworkINSTANCE.lower(network), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue *LightsparkSigner @@ -962,7 +969,7 @@ func (_self *LightsparkSigner) GetMasterPublicKey() (string, error) { defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_get_master_public_key( + return C.lightspark_crypto_3253_LightsparkSigner_get_master_public_key( _pointer, _uniffiStatus) }) if _uniffiErr != nil { @@ -978,7 +985,7 @@ func (_self *LightsparkSigner) DerivePublicKey(derivationPath string) (string, e defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_derive_public_key( + return C.lightspark_crypto_3253_LightsparkSigner_derive_public_key( _pointer, FfiConverterstringINSTANCE.lower(derivationPath), _uniffiStatus) }) if _uniffiErr != nil { @@ -994,7 +1001,7 @@ func (_self *LightsparkSigner) DerivePublicKeyHex(derivationPath string) (string defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_derive_public_key_hex( + return C.lightspark_crypto_3253_LightsparkSigner_derive_public_key_hex( _pointer, FfiConverterstringINSTANCE.lower(derivationPath), _uniffiStatus) }) if _uniffiErr != nil { @@ -1010,7 +1017,7 @@ func (_self *LightsparkSigner) DerivePrivateKey(derivationPath string) (string, defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_derive_private_key( + return C.lightspark_crypto_3253_LightsparkSigner_derive_private_key( _pointer, FfiConverterstringINSTANCE.lower(derivationPath), _uniffiStatus) }) if _uniffiErr != nil { @@ -1026,7 +1033,7 @@ func (_self *LightsparkSigner) Ecdh(publicKey []uint8) ([]uint8, error) { defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_ecdh( + return C.lightspark_crypto_3253_LightsparkSigner_ecdh( _pointer, FfiConverterSequenceuint8INSTANCE.lower(publicKey), _uniffiStatus) }) if _uniffiErr != nil { @@ -1042,7 +1049,7 @@ func (_self *LightsparkSigner) SignInvoice(unsignedInvoice string) (*InvoiceSign defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_LightsparkSigner_sign_invoice( + return C.lightspark_crypto_3253_LightsparkSigner_sign_invoice( _pointer, FfiConverterstringINSTANCE.lower(unsignedInvoice), _uniffiStatus) }) if _uniffiErr != nil { @@ -1058,7 +1065,7 @@ func (_self *LightsparkSigner) SignInvoiceHash(unsignedInvoice []uint8) (*Invoic defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_LightsparkSigner_sign_invoice_hash( + return C.lightspark_crypto_3253_LightsparkSigner_sign_invoice_hash( _pointer, FfiConverterSequenceuint8INSTANCE.lower(unsignedInvoice), _uniffiStatus) }) if _uniffiErr != nil { @@ -1074,7 +1081,7 @@ func (_self *LightsparkSigner) DeriveKeyAndSign(message []uint8, derivationPath defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_derive_key_and_sign( + return C.lightspark_crypto_3253_LightsparkSigner_derive_key_and_sign( _pointer, FfiConverterSequenceuint8INSTANCE.lower(message), FfiConverterstringINSTANCE.lower(derivationPath), FfiConverterboolINSTANCE.lower(isRaw), FfiConverterOptionalSequenceuint8INSTANCE.lower(addTweak), FfiConverterOptionalSequenceuint8INSTANCE.lower(mulTweak), _uniffiStatus) }) if _uniffiErr != nil { @@ -1090,7 +1097,7 @@ func (_self *LightsparkSigner) GetPerCommitmentPoint(derivationPath string, perC defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_get_per_commitment_point( + return C.lightspark_crypto_3253_LightsparkSigner_get_per_commitment_point( _pointer, FfiConverterstringINSTANCE.lower(derivationPath), FfiConverteruint64INSTANCE.lower(perCommitmentPointIdx), _uniffiStatus) }) if _uniffiErr != nil { @@ -1106,7 +1113,7 @@ func (_self *LightsparkSigner) ReleasePerCommitmentSecret(derivationPath string, defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_release_per_commitment_secret( + return C.lightspark_crypto_3253_LightsparkSigner_release_per_commitment_secret( _pointer, FfiConverterstringINSTANCE.lower(derivationPath), FfiConverteruint64INSTANCE.lower(perCommitmentPointIdx), _uniffiStatus) }) if _uniffiErr != nil { @@ -1122,7 +1129,7 @@ func (_self *LightsparkSigner) GeneratePreimageNonce() []uint8 { defer _self.ffiObject.decrementPointer() return FfiConverterSequenceuint8INSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_generate_preimage_nonce( + return C.lightspark_crypto_3253_LightsparkSigner_generate_preimage_nonce( _pointer, _uniffiStatus) })) @@ -1132,7 +1139,7 @@ func (_self *LightsparkSigner) GeneratePreimage(nonce []uint8) ([]uint8, error) defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_generate_preimage( + return C.lightspark_crypto_3253_LightsparkSigner_generate_preimage( _pointer, FfiConverterSequenceuint8INSTANCE.lower(nonce), _uniffiStatus) }) if _uniffiErr != nil { @@ -1148,7 +1155,7 @@ func (_self *LightsparkSigner) GeneratePreimageHash(nonce []uint8) ([]uint8, err defer _self.ffiObject.decrementPointer() _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_LightsparkSigner_generate_preimage_hash( + return C.lightspark_crypto_3253_LightsparkSigner_generate_preimage_hash( _pointer, FfiConverterSequenceuint8INSTANCE.lower(nonce), _uniffiStatus) }) if _uniffiErr != nil { @@ -1174,7 +1181,7 @@ func (c FfiConverterLightsparkSigner) lift(pointer unsafe.Pointer) *LightsparkSi newFfiObject( pointer, func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.ffi_lightspark_crypto_7bff_LightsparkSigner_object_free(pointer, status) + C.ffi_lightspark_crypto_3253_LightsparkSigner_object_free(pointer, status) }), } runtime.SetFinalizer(result, (*LightsparkSigner).Destroy) @@ -1211,7 +1218,7 @@ type Mnemonic struct { func MnemonicRandom() (*Mnemonic, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_Mnemonic_random(_uniffiStatus) + return C.lightspark_crypto_3253_Mnemonic_random(_uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue *Mnemonic @@ -1224,7 +1231,7 @@ func MnemonicRandom() (*Mnemonic, error) { func MnemonicFromEntropy(entropy []uint8) (*Mnemonic, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_Mnemonic_from_entropy(FfiConverterSequenceuint8INSTANCE.lower(entropy), _uniffiStatus) + return C.lightspark_crypto_3253_Mnemonic_from_entropy(FfiConverterSequenceuint8INSTANCE.lower(entropy), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue *Mnemonic @@ -1237,7 +1244,7 @@ func MnemonicFromEntropy(entropy []uint8) (*Mnemonic, error) { func MnemonicFromPhrase(phrase string) (*Mnemonic, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeLightsparkSignerError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_Mnemonic_from_phrase(FfiConverterstringINSTANCE.lower(phrase), _uniffiStatus) + return C.lightspark_crypto_3253_Mnemonic_from_phrase(FfiConverterstringINSTANCE.lower(phrase), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue *Mnemonic @@ -1253,7 +1260,7 @@ func (_self *Mnemonic) AsString() string { defer _self.ffiObject.decrementPointer() return FfiConverterstringINSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_Mnemonic_as_string( + return C.lightspark_crypto_3253_Mnemonic_as_string( _pointer, _uniffiStatus) })) @@ -1273,7 +1280,7 @@ func (c FfiConverterMnemonic) lift(pointer unsafe.Pointer) *Mnemonic { newFfiObject( pointer, func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.ffi_lightspark_crypto_7bff_Mnemonic_object_free(pointer, status) + C.ffi_lightspark_crypto_3253_Mnemonic_object_free(pointer, status) }), } runtime.SetFinalizer(result, (*Mnemonic).Destroy) @@ -1310,7 +1317,7 @@ type Seed struct { func NewSeed(seed []uint8) *Seed { return FfiConverterSeedINSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_Seed_new(FfiConverterSequenceuint8INSTANCE.lower(seed), _uniffiStatus) + return C.lightspark_crypto_3253_Seed_new(FfiConverterSequenceuint8INSTANCE.lower(seed), _uniffiStatus) })) } @@ -1318,7 +1325,7 @@ func NewSeed(seed []uint8) *Seed { func SeedFromMnemonic(mnemonic *Mnemonic) *Seed { return FfiConverterSeedINSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_Seed_from_mnemonic(FfiConverterMnemonicINSTANCE.lower(mnemonic), _uniffiStatus) + return C.lightspark_crypto_3253_Seed_from_mnemonic(FfiConverterMnemonicINSTANCE.lower(mnemonic), _uniffiStatus) })) } @@ -1328,7 +1335,7 @@ func (_self *Seed) AsBytes() []uint8 { defer _self.ffiObject.decrementPointer() return FfiConverterSequenceuint8INSTANCE.lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_Seed_as_bytes( + return C.lightspark_crypto_3253_Seed_as_bytes( _pointer, _uniffiStatus) })) @@ -1348,7 +1355,7 @@ func (c FfiConverterSeed) lift(pointer unsafe.Pointer) *Seed { newFfiObject( pointer, func(pointer unsafe.Pointer, status *C.RustCallStatus) { - C.ffi_lightspark_crypto_7bff_Seed_object_free(pointer, status) + C.ffi_lightspark_crypto_3253_Seed_object_free(pointer, status) }), } runtime.SetFinalizer(result, (*Seed).Destroy) @@ -1467,6 +1474,7 @@ func (err CryptoError) Unwrap() error { // Err* are used for checking error type with `errors.Is` var ErrCryptoErrorSecp256k1Error = fmt.Errorf("CryptoErrorSecp256k1Error") var ErrCryptoErrorRustSecp256k1Error = fmt.Errorf("CryptoErrorRustSecp256k1Error") +var ErrCryptoErrorInvalidPublicKeyScriptError = fmt.Errorf("CryptoErrorInvalidPublicKeyScriptError") // Variant structs type CryptoErrorSecp256k1Error struct { @@ -1505,6 +1513,24 @@ func (self CryptoErrorRustSecp256k1Error) Is(target error) bool { return target == ErrCryptoErrorRustSecp256k1Error } +type CryptoErrorInvalidPublicKeyScriptError struct { + message string +} + +func NewCryptoErrorInvalidPublicKeyScriptError() *CryptoError { + return &CryptoError{ + err: &CryptoErrorInvalidPublicKeyScriptError{}, + } +} + +func (err CryptoErrorInvalidPublicKeyScriptError) Error() string { + return fmt.Sprintf("InvalidPublicKeyScriptError: %s", err.message) +} + +func (self CryptoErrorInvalidPublicKeyScriptError) Is(target error) bool { + return target == ErrCryptoErrorInvalidPublicKeyScriptError +} + type FfiConverterTypeCryptoError struct{} var FfiConverterTypeCryptoErrorINSTANCE = FfiConverterTypeCryptoError{} @@ -1527,6 +1553,8 @@ func (c FfiConverterTypeCryptoError) read(reader io.Reader) error { return &CryptoError{&CryptoErrorSecp256k1Error{message}} case 2: return &CryptoError{&CryptoErrorRustSecp256k1Error{message}} + case 3: + return &CryptoError{&CryptoErrorInvalidPublicKeyScriptError{message}} default: panic(fmt.Sprintf("Unknown error code %d in FfiConverterTypeCryptoError.read()", errorID)) } @@ -1539,6 +1567,8 @@ func (c FfiConverterTypeCryptoError) write(writer io.Writer, value *CryptoError) writeInt32(writer, 1) case *CryptoErrorRustSecp256k1Error: writeInt32(writer, 2) + case *CryptoErrorInvalidPublicKeyScriptError: + writeInt32(writer, 3) default: _ = variantValue panic(fmt.Sprintf("invalid error value `%v` in FfiConverterTypeCryptoError.write", value)) @@ -1933,8 +1963,8 @@ type Validation interface { // foreignCallbackTypeValidation cannot be callable be a compiled function at a same time type foreignCallbackTypeValidation struct{} -//export lightspark_crypto_7bff_cgo_Validation -func lightspark_crypto_7bff_cgo_Validation(handle C.uint64_t, method C.int32_t, args C.RustBuffer, outBuf *C.RustBuffer) C.int32_t { +//export lightspark_crypto_3253_cgo_Validation +func lightspark_crypto_3253_cgo_Validation(handle C.uint64_t, method C.int32_t, args C.RustBuffer, outBuf *C.RustBuffer) C.int32_t { cb := FfiConverterTypeValidationINSTANCE.lift(uint64(handle)) switch method { case 0: @@ -1981,7 +2011,7 @@ var FfiConverterTypeValidationINSTANCE = &FfiConverterTypeValidation{ // This is a static function because only 1 instance is supported for registering func (c *FfiConverterTypeValidation) register() { rustCall(func(status *C.RustCallStatus) int32 { - C.ffi_lightspark_crypto_7bff_Validation_init_callback(C.ForeignCallback(C.lightspark_crypto_7bff_cgo_Validation), status) + C.ffi_lightspark_crypto_3253_Validation_init_callback(C.ForeignCallback(C.lightspark_crypto_3253_cgo_Validation), status) return 0 }) } @@ -2111,7 +2141,7 @@ func (FfiDestroyerSequenceuint8) destroy(sequence []uint8) { func SignEcdsa(msg []uint8, privateKeyBytes []uint8) ([]uint8, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeCryptoError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_sign_ecdsa(FfiConverterSequenceuint8INSTANCE.lower(msg), FfiConverterSequenceuint8INSTANCE.lower(privateKeyBytes), _uniffiStatus) + return C.lightspark_crypto_3253_sign_ecdsa(FfiConverterSequenceuint8INSTANCE.lower(msg), FfiConverterSequenceuint8INSTANCE.lower(privateKeyBytes), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue []uint8 @@ -2125,7 +2155,7 @@ func SignEcdsa(msg []uint8, privateKeyBytes []uint8) ([]uint8, error) { func VerifyEcdsa(msg []uint8, signatureBytes []uint8, publicKeyBytes []uint8) (bool, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeCryptoError{}, func(_uniffiStatus *C.RustCallStatus) C.int8_t { - return C.lightspark_crypto_7bff_verify_ecdsa(FfiConverterSequenceuint8INSTANCE.lower(msg), FfiConverterSequenceuint8INSTANCE.lower(signatureBytes), FfiConverterSequenceuint8INSTANCE.lower(publicKeyBytes), _uniffiStatus) + return C.lightspark_crypto_3253_verify_ecdsa(FfiConverterSequenceuint8INSTANCE.lower(msg), FfiConverterSequenceuint8INSTANCE.lower(signatureBytes), FfiConverterSequenceuint8INSTANCE.lower(publicKeyBytes), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue bool @@ -2139,7 +2169,7 @@ func VerifyEcdsa(msg []uint8, signatureBytes []uint8, publicKeyBytes []uint8) (b func EncryptEcies(msg []uint8, publicKeyBytes []uint8) ([]uint8, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeCryptoError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_encrypt_ecies(FfiConverterSequenceuint8INSTANCE.lower(msg), FfiConverterSequenceuint8INSTANCE.lower(publicKeyBytes), _uniffiStatus) + return C.lightspark_crypto_3253_encrypt_ecies(FfiConverterSequenceuint8INSTANCE.lower(msg), FfiConverterSequenceuint8INSTANCE.lower(publicKeyBytes), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue []uint8 @@ -2153,7 +2183,7 @@ func EncryptEcies(msg []uint8, publicKeyBytes []uint8) ([]uint8, error) { func DecryptEcies(cipherText []uint8, privateKeyBytes []uint8) ([]uint8, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeCryptoError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_decrypt_ecies(FfiConverterSequenceuint8INSTANCE.lower(cipherText), FfiConverterSequenceuint8INSTANCE.lower(privateKeyBytes), _uniffiStatus) + return C.lightspark_crypto_3253_decrypt_ecies(FfiConverterSequenceuint8INSTANCE.lower(cipherText), FfiConverterSequenceuint8INSTANCE.lower(privateKeyBytes), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue []uint8 @@ -2164,10 +2194,24 @@ func DecryptEcies(cipherText []uint8, privateKeyBytes []uint8) ([]uint8, error) } +func GenerateMultisigAddress(network Network, pk1 []uint8, pk2 []uint8) (string, error) { + + _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeCryptoError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { + return C.lightspark_crypto_3253_generate_multisig_address(FfiConverterTypeNetworkINSTANCE.lower(network), FfiConverterSequenceuint8INSTANCE.lower(pk1), FfiConverterSequenceuint8INSTANCE.lower(pk2), _uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterstringINSTANCE.lift(_uniffiRV), _uniffiErr + } + +} + func GenerateKeypair() (*KeyPair, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeCryptoError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { - return C.lightspark_crypto_7bff_generate_keypair(_uniffiStatus) + return C.lightspark_crypto_3253_generate_keypair(_uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue *KeyPair @@ -2181,7 +2225,7 @@ func GenerateKeypair() (*KeyPair, error) { func HandleRemoteSigningWebhookEvent(webhookData []uint8, webhookSignature string, webhookSecret string, masterSeedBytes []uint8, validation Validation) (*RemoteSigningResponse, error) { _uniffiRV, _uniffiErr := rustCallWithError(FfiConverterTypeRemoteSigningError{}, func(_uniffiStatus *C.RustCallStatus) C.RustBuffer { - return C.lightspark_crypto_7bff_handle_remote_signing_webhook_event(FfiConverterSequenceuint8INSTANCE.lower(webhookData), FfiConverterstringINSTANCE.lower(webhookSignature), FfiConverterstringINSTANCE.lower(webhookSecret), FfiConverterSequenceuint8INSTANCE.lower(masterSeedBytes), FfiConverterTypeValidationINSTANCE.lower(validation), _uniffiStatus) + return C.lightspark_crypto_3253_handle_remote_signing_webhook_event(FfiConverterSequenceuint8INSTANCE.lower(webhookData), FfiConverterstringINSTANCE.lower(webhookSignature), FfiConverterstringINSTANCE.lower(webhookSecret), FfiConverterSequenceuint8INSTANCE.lower(masterSeedBytes), FfiConverterTypeValidationINSTANCE.lower(validation), _uniffiStatus) }) if _uniffiErr != nil { var _uniffiDefaultValue *RemoteSigningResponse diff --git a/lightspark-crypto-go/internal/lightspark_crypto.h b/lightspark-crypto-go/internal/lightspark_crypto.h new file mode 100644 index 0000000..7aab43d --- /dev/null +++ b/lightspark-crypto-go/internal/lightspark_crypto.h @@ -0,0 +1,735 @@ + + +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + + + +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V6 + #ifndef UNIFFI_SHARED_HEADER_V6 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V6 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V6 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V6 in this file. ⚠️ + +typedef struct RustBuffer { + int32_t capacity; + int32_t len; + uint8_t *data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, uint8_t *, int32_t, RustBuffer *); + +// Task defined in Rust that Go executes +typedef void (*RustTaskCallback)(const void *, int8_t); + +// Callback to execute Rust tasks using a Go routine +// +// Args: +// executor: ForeignExecutor lowered into a uint64_t value +// delay: Delay in MS +// task: RustTaskCallback to call +// task_data: data to pass the task callback +typedef int8_t (*ForeignExecutorCallback)(uint64_t, uint32_t, RustTaskCallback, void *); + +typedef struct ForeignBytes { + int32_t len; + const uint8_t *data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// Continuation callback for UniFFI Futures +typedef void (*RustFutureContinuation)(void * , int8_t); + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V6 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Needed because we can't execute the callback directly from go. +void cgo_rust_task_callback_bridge_lightspark_crypto(RustTaskCallback, const void *, int8_t); + +int8_t uniffiForeignExecutorCallbacklightspark_crypto(uint64_t, uint32_t, RustTaskCallback, void*); + +void uniffiFutureContinuationCallbacklightspark_crypto(void*, int8_t); + +void uniffi_lightspark_crypto_fn_free_invoicesignature( + void* ptr, + RustCallStatus* out_status +); + +int32_t uniffi_lightspark_crypto_fn_method_invoicesignature_get_recovery_id( + void* ptr, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_invoicesignature_get_signature( + void* ptr, + RustCallStatus* out_status +); + +void uniffi_lightspark_crypto_fn_free_keypair( + void* ptr, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_keypair_get_private_key( + void* ptr, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_keypair_get_public_key( + void* ptr, + RustCallStatus* out_status +); + +void uniffi_lightspark_crypto_fn_free_lightsparksigner( + void* ptr, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_constructor_lightsparksigner_from_bytes( + RustBuffer seed, + RustBuffer network, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_constructor_lightsparksigner_new( + void* seed, + RustBuffer network, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_derive_key_and_sign( + void* ptr, + RustBuffer message, + RustBuffer derivation_path, + int8_t is_raw, + RustBuffer add_tweak, + RustBuffer mul_tweak, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_derive_private_key( + void* ptr, + RustBuffer derivation_path, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_derive_public_key( + void* ptr, + RustBuffer derivation_path, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_derive_public_key_hex( + void* ptr, + RustBuffer derivation_path, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_ecdh( + void* ptr, + RustBuffer public_key, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_generate_preimage( + void* ptr, + RustBuffer nonce, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_generate_preimage_hash( + void* ptr, + RustBuffer nonce, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_generate_preimage_nonce( + void* ptr, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_get_master_public_key( + void* ptr, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_get_per_commitment_point( + void* ptr, + RustBuffer derivation_path, + uint64_t per_commitment_point_idx, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_lightsparksigner_release_per_commitment_secret( + void* ptr, + RustBuffer derivation_path, + uint64_t per_commitment_point_idx, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_method_lightsparksigner_sign_invoice( + void* ptr, + RustBuffer unsigned_invoice, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_method_lightsparksigner_sign_invoice_hash( + void* ptr, + RustBuffer unsigned_invoice, + RustCallStatus* out_status +); + +void uniffi_lightspark_crypto_fn_free_mnemonic( + void* ptr, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_constructor_mnemonic_from_entropy( + RustBuffer entropy, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_constructor_mnemonic_from_phrase( + RustBuffer phrase, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_constructor_mnemonic_random( + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_mnemonic_as_string( + void* ptr, + RustCallStatus* out_status +); + +void uniffi_lightspark_crypto_fn_free_seed( + void* ptr, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_constructor_seed_from_mnemonic( + void* mnemonic, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_constructor_seed_new( + RustBuffer seed, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_method_seed_as_bytes( + void* ptr, + RustCallStatus* out_status +); + +void uniffi_lightspark_crypto_fn_init_callback_validation( + ForeignCallback callback_stub, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_func_decrypt_ecies( + RustBuffer cipher_text, + RustBuffer private_key_bytes, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_func_encrypt_ecies( + RustBuffer msg, + RustBuffer public_key_bytes, + RustCallStatus* out_status +); + +void* uniffi_lightspark_crypto_fn_func_generate_keypair( + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_func_generate_multisig_address( + RustBuffer network, + RustBuffer pk1, + RustBuffer pk2, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_func_handle_remote_signing_webhook_event( + RustBuffer webhook_data, + RustBuffer webhook_signature, + RustBuffer webhook_secret, + RustBuffer master_seed_bytes, + uint64_t validation, + RustCallStatus* out_status +); + +RustBuffer uniffi_lightspark_crypto_fn_func_sign_ecdsa( + RustBuffer msg, + RustBuffer private_key_bytes, + RustCallStatus* out_status +); + +int8_t uniffi_lightspark_crypto_fn_func_verify_ecdsa( + RustBuffer msg, + RustBuffer signature_bytes, + RustBuffer public_key_bytes, + RustCallStatus* out_status +); + +RustBuffer ffi_lightspark_crypto_rustbuffer_alloc( + int32_t size, + RustCallStatus* out_status +); + +RustBuffer ffi_lightspark_crypto_rustbuffer_from_bytes( + ForeignBytes bytes, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rustbuffer_free( + RustBuffer buf, + RustCallStatus* out_status +); + +RustBuffer ffi_lightspark_crypto_rustbuffer_reserve( + RustBuffer buf, + int32_t additional, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_continuation_callback_set( + RustFutureContinuation callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_u8( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_u8( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_u8( + void* handle, + RustCallStatus* out_status +); + +uint8_t ffi_lightspark_crypto_rust_future_complete_u8( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_i8( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_i8( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_i8( + void* handle, + RustCallStatus* out_status +); + +int8_t ffi_lightspark_crypto_rust_future_complete_i8( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_u16( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_u16( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_u16( + void* handle, + RustCallStatus* out_status +); + +uint16_t ffi_lightspark_crypto_rust_future_complete_u16( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_i16( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_i16( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_i16( + void* handle, + RustCallStatus* out_status +); + +int16_t ffi_lightspark_crypto_rust_future_complete_i16( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_u32( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_u32( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_u32( + void* handle, + RustCallStatus* out_status +); + +uint32_t ffi_lightspark_crypto_rust_future_complete_u32( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_i32( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_i32( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_i32( + void* handle, + RustCallStatus* out_status +); + +int32_t ffi_lightspark_crypto_rust_future_complete_i32( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_u64( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_u64( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_u64( + void* handle, + RustCallStatus* out_status +); + +uint64_t ffi_lightspark_crypto_rust_future_complete_u64( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_i64( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_i64( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_i64( + void* handle, + RustCallStatus* out_status +); + +int64_t ffi_lightspark_crypto_rust_future_complete_i64( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_f32( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_f32( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_f32( + void* handle, + RustCallStatus* out_status +); + +float ffi_lightspark_crypto_rust_future_complete_f32( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_f64( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_f64( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_f64( + void* handle, + RustCallStatus* out_status +); + +double ffi_lightspark_crypto_rust_future_complete_f64( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_pointer( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_pointer( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_pointer( + void* handle, + RustCallStatus* out_status +); + +void* ffi_lightspark_crypto_rust_future_complete_pointer( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_rust_buffer( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_rust_buffer( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_rust_buffer( + void* handle, + RustCallStatus* out_status +); + +RustBuffer ffi_lightspark_crypto_rust_future_complete_rust_buffer( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_poll_void( + void* handle, + void* uniffi_callback, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_cancel_void( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_free_void( + void* handle, + RustCallStatus* out_status +); + +void ffi_lightspark_crypto_rust_future_complete_void( + void* handle, + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_func_decrypt_ecies( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_func_encrypt_ecies( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_func_generate_keypair( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_func_generate_multisig_address( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_func_handle_remote_signing_webhook_event( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_func_sign_ecdsa( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_func_verify_ecdsa( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_invoicesignature_get_recovery_id( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_invoicesignature_get_signature( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_keypair_get_private_key( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_keypair_get_public_key( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_derive_key_and_sign( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_derive_private_key( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_derive_public_key( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_derive_public_key_hex( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_ecdh( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_generate_preimage( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_generate_preimage_hash( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_generate_preimage_nonce( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_get_master_public_key( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_get_per_commitment_point( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_release_per_commitment_secret( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_sign_invoice( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_lightsparksigner_sign_invoice_hash( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_mnemonic_as_string( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_seed_as_bytes( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_constructor_lightsparksigner_from_bytes( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_constructor_lightsparksigner_new( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_constructor_mnemonic_from_entropy( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_constructor_mnemonic_from_phrase( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_constructor_mnemonic_random( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_constructor_seed_from_mnemonic( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_constructor_seed_new( + RustCallStatus* out_status +); + +uint16_t uniffi_lightspark_crypto_checksum_method_validation_should_sign( + RustCallStatus* out_status +); + +uint32_t ffi_lightspark_crypto_uniffi_contract_version( + RustCallStatus* out_status +); + + +int32_t lightspark_crypto_cgo_Validation(uint64_t, int32_t, uint8_t *, int32_t, RustBuffer *); + diff --git a/lightspark-crypto-go/libs/darwin/amd64/liblightspark_crypto.a b/lightspark-crypto-go/libs/darwin/amd64/liblightspark_crypto.a index f95ac01..b492ea5 100644 Binary files a/lightspark-crypto-go/libs/darwin/amd64/liblightspark_crypto.a and b/lightspark-crypto-go/libs/darwin/amd64/liblightspark_crypto.a differ diff --git a/lightspark-crypto-go/libs/darwin/arm64/liblightspark_crypto.a b/lightspark-crypto-go/libs/darwin/arm64/liblightspark_crypto.a index 08c16af..2208eae 100644 Binary files a/lightspark-crypto-go/libs/darwin/arm64/liblightspark_crypto.a and b/lightspark-crypto-go/libs/darwin/arm64/liblightspark_crypto.a differ diff --git a/lightspark-crypto-go/libs/linux/amd64/liblightspark_crypto.a b/lightspark-crypto-go/libs/linux/amd64/liblightspark_crypto.a index d674b35..1e01b55 100644 Binary files a/lightspark-crypto-go/libs/linux/amd64/liblightspark_crypto.a and b/lightspark-crypto-go/libs/linux/amd64/liblightspark_crypto.a differ diff --git a/lightspark-crypto-go/libs/linux/arm64/liblightspark_crypto.a b/lightspark-crypto-go/libs/linux/arm64/liblightspark_crypto.a index ced3f66..91fff57 100644 Binary files a/lightspark-crypto-go/libs/linux/arm64/liblightspark_crypto.a and b/lightspark-crypto-go/libs/linux/arm64/liblightspark_crypto.a differ diff --git a/lightspark-crypto-go/signing.go b/lightspark-crypto-go/signing.go index f2a491f..3142930 100644 --- a/lightspark-crypto-go/signing.go +++ b/lightspark-crypto-go/signing.go @@ -202,6 +202,21 @@ func DecryptEcies(message []byte, privateKey []byte) ([]byte, error) { return internal.DecryptEcies(message, privateKey) } +func GenerateMultiSigAddress(network BitcoinNetwork, publicKey1 []byte, publicKey2 []byte) (string, error) { + var ffiNetwork internal.Network + + switch network { + case Mainnet: + ffiNetwork = internal.NetworkBitcoin + case Testnet: + ffiNetwork = internal.NetworkTestnet + case Regtest: + ffiNetwork = internal.NetworkRegtest + } + + return internal.GenerateMultisigAddress(ffiNetwork, publicKey1, publicKey2) +} + func getLightsparkSigner(seedBytes []byte, network BitcoinNetwork) (*internal.LightsparkSigner, error) { seed := internal.NewSeed(seedBytes) defer seed.Destroy()