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.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/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()