diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index 24ee85c9e..6fd815607 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -2159,6 +2159,78 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key() + }) + if checksum != 27155 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme() + }) + if checksum != 60810 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der() + }) + if checksum != 65507 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem() + }) + if checksum != 12369 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign() + }) + if checksum != 5798 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple() + }) + if checksum != 11597 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user() + }) + if checksum != 20597 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key() + }) + if checksum != 51137 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes() }) @@ -2177,6 +2249,78 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple() + }) + if checksum != 36777 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user() + }) + if checksum != 26362 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key() + }) + if checksum != 56083 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der() + }) + if checksum != 21325 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem() + }) + if checksum != 29137 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify() + }) + if checksum != 27904 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple() + }) + if checksum != 35045 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user() + }) + if checksum != 41639 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_public_key() }) @@ -4256,6 +4400,42 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der() + }) + if checksum != 45448 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem() + }) + if checksum != 20937 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate() + }) + if checksum != 49496 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new() + }) + if checksum != 35513 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_bytes() }) @@ -4310,6 +4490,42 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new() + }) + if checksum != 59813 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der() + }) + if checksum != 40127 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem() + }) + if checksum != 40573 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new() + }) + if checksum != 16080 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_der() }) @@ -14626,6 +14842,230 @@ func (_ FfiDestroyerPublish) Destroy(value *Publish) { +type Secp256k1PrivateKeyInterface interface { + PublicKey() *Secp256k1PublicKey + Scheme() SignatureScheme + // Serialize this private key as DER-encoded PKCS#8 + ToDer() ([]byte, error) + // Serialize this private key as PEM-encoded PKCS#8 + ToPem() (string, error) + TrySign(message []byte) (*Secp256k1Signature, error) + TrySignSimple(message []byte) (*SimpleSignature, error) + TrySignUser(message []byte) (*UserSignature, error) + VerifyingKey() *Secp256k1VerifyingKey +} +type Secp256k1PrivateKey struct { + ffiObject FfiObject +} +func NewSecp256k1PrivateKey(bytes []byte) (*Secp256k1PrivateKey, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_new(FfiConverterBytesINSTANCE.Lower(bytes),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Secp256k1PrivateKey + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSecp256k1PrivateKeyINSTANCE.Lift(_uniffiRV), nil + } +} + + +// Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary +// format). +func Secp256k1PrivateKeyFromDer(bytes []byte) (*Secp256k1PrivateKey, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_der(FfiConverterBytesINSTANCE.Lower(bytes),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Secp256k1PrivateKey + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSecp256k1PrivateKeyINSTANCE.Lift(_uniffiRV), nil + } +} + +// Deserialize PKCS#8-encoded private key from PEM. +func Secp256k1PrivateKeyFromPem(s string) (*Secp256k1PrivateKey, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_pem(FfiConverterStringINSTANCE.Lower(s),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Secp256k1PrivateKey + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSecp256k1PrivateKeyINSTANCE.Lift(_uniffiRV), nil + } +} + +func Secp256k1PrivateKeyGenerate() *Secp256k1PrivateKey { + return FfiConverterSecp256k1PrivateKeyINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_generate(_uniffiStatus) + })) +} + + + +func (_self *Secp256k1PrivateKey) PublicKey() *Secp256k1PublicKey { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + return FfiConverterSecp256k1PublicKeyINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_public_key( + _pointer,_uniffiStatus) + })) +} + +func (_self *Secp256k1PrivateKey) Scheme() SignatureScheme { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + return FfiConverterSignatureSchemeINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_scheme( + _pointer,_uniffiStatus), + } + })) +} + +// Serialize this private key as DER-encoded PKCS#8 +func (_self *Secp256k1PrivateKey) ToDer() ([]byte, error) { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_der( + _pointer,_uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue []byte + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil + } +} + +// Serialize this private key as PEM-encoded PKCS#8 +func (_self *Secp256k1PrivateKey) ToPem() (string, error) { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_pem( + _pointer,_uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *Secp256k1PrivateKey) TrySign(message []byte) (*Secp256k1Signature, error) { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign( + _pointer,FfiConverterBytesINSTANCE.Lower(message),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Secp256k1Signature + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSecp256k1SignatureINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *Secp256k1PrivateKey) TrySignSimple(message []byte) (*SimpleSignature, error) { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_simple( + _pointer,FfiConverterBytesINSTANCE.Lower(message),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *SimpleSignature + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSimpleSignatureINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *Secp256k1PrivateKey) TrySignUser(message []byte) (*UserSignature, error) { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_user( + _pointer,FfiConverterBytesINSTANCE.Lower(message),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *UserSignature + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterUserSignatureINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *Secp256k1PrivateKey) VerifyingKey() *Secp256k1VerifyingKey { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer _self.ffiObject.decrementPointer() + return FfiConverterSecp256k1VerifyingKeyINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_verifying_key( + _pointer,_uniffiStatus) + })) +} +func (object *Secp256k1PrivateKey) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterSecp256k1PrivateKey struct {} + +var FfiConverterSecp256k1PrivateKeyINSTANCE = FfiConverterSecp256k1PrivateKey{} + + +func (c FfiConverterSecp256k1PrivateKey) Lift(pointer unsafe.Pointer) *Secp256k1PrivateKey { + result := &Secp256k1PrivateKey { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_secp256k1privatekey(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_secp256k1privatekey(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*Secp256k1PrivateKey).Destroy) + return result +} + +func (c FfiConverterSecp256k1PrivateKey) Read(reader io.Reader) *Secp256k1PrivateKey { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterSecp256k1PrivateKey) Lower(value *Secp256k1PrivateKey) unsafe.Pointer { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the pointer will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked pointer. + pointer := value.ffiObject.incrementPointer("*Secp256k1PrivateKey") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterSecp256k1PrivateKey) Write(writer io.Writer, value *Secp256k1PrivateKey) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerSecp256k1PrivateKey struct {} + +func (_ FfiDestroyerSecp256k1PrivateKey) Destroy(value *Secp256k1PrivateKey) { + value.Destroy() +} + + + // A secp256k1 signature. // // # BCS @@ -14866,6 +15306,278 @@ func (_ FfiDestroyerSecp256k1Signature) Destroy(value *Secp256k1Signature) { +type Secp256k1VerifierInterface interface { + VerifySimple(message []byte, signature *SimpleSignature) error + VerifyUser(message []byte, signature *UserSignature) error +} +type Secp256k1Verifier struct { + ffiObject FfiObject +} +func NewSecp256k1Verifier() *Secp256k1Verifier { + return FfiConverterSecp256k1VerifierINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifier_new(_uniffiStatus) + })) +} + + + + +func (_self *Secp256k1Verifier) VerifySimple(message []byte, signature *SimpleSignature) error { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1Verifier") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_simple( + _pointer,FfiConverterBytesINSTANCE.Lower(message), FfiConverterSimpleSignatureINSTANCE.Lower(signature),_uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *Secp256k1Verifier) VerifyUser(message []byte, signature *UserSignature) error { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1Verifier") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_user( + _pointer,FfiConverterBytesINSTANCE.Lower(message), FfiConverterUserSignatureINSTANCE.Lower(signature),_uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} +func (object *Secp256k1Verifier) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterSecp256k1Verifier struct {} + +var FfiConverterSecp256k1VerifierINSTANCE = FfiConverterSecp256k1Verifier{} + + +func (c FfiConverterSecp256k1Verifier) Lift(pointer unsafe.Pointer) *Secp256k1Verifier { + result := &Secp256k1Verifier { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifier(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_secp256k1verifier(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*Secp256k1Verifier).Destroy) + return result +} + +func (c FfiConverterSecp256k1Verifier) Read(reader io.Reader) *Secp256k1Verifier { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterSecp256k1Verifier) Lower(value *Secp256k1Verifier) unsafe.Pointer { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the pointer will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked pointer. + pointer := value.ffiObject.incrementPointer("*Secp256k1Verifier") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterSecp256k1Verifier) Write(writer io.Writer, value *Secp256k1Verifier) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerSecp256k1Verifier struct {} + +func (_ FfiDestroyerSecp256k1Verifier) Destroy(value *Secp256k1Verifier) { + value.Destroy() +} + + + +type Secp256k1VerifyingKeyInterface interface { + PublicKey() *Secp256k1PublicKey + // Serialize this public key as DER-encoded data + ToDer() ([]byte, error) + // Serialize this public key into PEM + ToPem() (string, error) + Verify(message []byte, signature *Secp256k1Signature) error + VerifySimple(message []byte, signature *SimpleSignature) error + VerifyUser(message []byte, signature *UserSignature) error +} +type Secp256k1VerifyingKey struct { + ffiObject FfiObject +} +func NewSecp256k1VerifyingKey(publicKey *Secp256k1PublicKey) (*Secp256k1VerifyingKey, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_new(FfiConverterSecp256k1PublicKeyINSTANCE.Lower(publicKey),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Secp256k1VerifyingKey + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSecp256k1VerifyingKeyINSTANCE.Lift(_uniffiRV), nil + } +} + + +// Deserialize public key from ASN.1 DER-encoded data (binary format). +func Secp256k1VerifyingKeyFromDer(bytes []byte) (*Secp256k1VerifyingKey, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_der(FfiConverterBytesINSTANCE.Lower(bytes),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Secp256k1VerifyingKey + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSecp256k1VerifyingKeyINSTANCE.Lift(_uniffiRV), nil + } +} + +// Deserialize public key from PEM. +func Secp256k1VerifyingKeyFromPem(s string) (*Secp256k1VerifyingKey, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_pem(FfiConverterStringINSTANCE.Lower(s),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *Secp256k1VerifyingKey + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSecp256k1VerifyingKeyINSTANCE.Lift(_uniffiRV), nil + } +} + + + +func (_self *Secp256k1VerifyingKey) PublicKey() *Secp256k1PublicKey { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1VerifyingKey") + defer _self.ffiObject.decrementPointer() + return FfiConverterSecp256k1PublicKeyINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_public_key( + _pointer,_uniffiStatus) + })) +} + +// Serialize this public key as DER-encoded data +func (_self *Secp256k1VerifyingKey) ToDer() ([]byte, error) { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1VerifyingKey") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_der( + _pointer,_uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue []byte + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil + } +} + +// Serialize this public key into PEM +func (_self *Secp256k1VerifyingKey) ToPem() (string, error) { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1VerifyingKey") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_pem( + _pointer,_uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *Secp256k1VerifyingKey) Verify(message []byte, signature *Secp256k1Signature) error { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1VerifyingKey") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify( + _pointer,FfiConverterBytesINSTANCE.Lower(message), FfiConverterSecp256k1SignatureINSTANCE.Lower(signature),_uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *Secp256k1VerifyingKey) VerifySimple(message []byte, signature *SimpleSignature) error { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1VerifyingKey") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_simple( + _pointer,FfiConverterBytesINSTANCE.Lower(message), FfiConverterSimpleSignatureINSTANCE.Lower(signature),_uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *Secp256k1VerifyingKey) VerifyUser(message []byte, signature *UserSignature) error { + _pointer := _self.ffiObject.incrementPointer("*Secp256k1VerifyingKey") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_user( + _pointer,FfiConverterBytesINSTANCE.Lower(message), FfiConverterUserSignatureINSTANCE.Lower(signature),_uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} +func (object *Secp256k1VerifyingKey) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterSecp256k1VerifyingKey struct {} + +var FfiConverterSecp256k1VerifyingKeyINSTANCE = FfiConverterSecp256k1VerifyingKey{} + + +func (c FfiConverterSecp256k1VerifyingKey) Lift(pointer unsafe.Pointer) *Secp256k1VerifyingKey { + result := &Secp256k1VerifyingKey { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifyingkey(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_secp256k1verifyingkey(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*Secp256k1VerifyingKey).Destroy) + return result +} + +func (c FfiConverterSecp256k1VerifyingKey) Read(reader io.Reader) *Secp256k1VerifyingKey { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterSecp256k1VerifyingKey) Lower(value *Secp256k1VerifyingKey) unsafe.Pointer { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the pointer will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked pointer. + pointer := value.ffiObject.incrementPointer("*Secp256k1VerifyingKey") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterSecp256k1VerifyingKey) Write(writer io.Writer, value *Secp256k1VerifyingKey) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerSecp256k1VerifyingKey struct {} + +func (_ FfiDestroyerSecp256k1VerifyingKey) Destroy(value *Secp256k1VerifyingKey) { + value.Destroy() +} + + + type Secp256r1PrivateKeyInterface interface { // Get the public key corresponding to this private key. PublicKey() *Secp256r1PublicKey diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index f74eb265c..a7e776e15 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -2548,6 +2548,77 @@ RustBuffer uniffi_iota_sdk_ffi_fn_method_publish_dependencies(void* ptr, RustCal RustBuffer uniffi_iota_sdk_ffi_fn_method_publish_modules(void* ptr, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1PRIVATEKEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1PRIVATEKEY +void* uniffi_iota_sdk_ffi_fn_clone_secp256k1privatekey(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SECP256K1PRIVATEKEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SECP256K1PRIVATEKEY +void uniffi_iota_sdk_ffi_fn_free_secp256k1privatekey(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_DER +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_der(RustBuffer bytes, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_PEM +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_pem(RustBuffer s, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_GENERATE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_GENERATE +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_generate(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1PRIVATEKEY_NEW +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_new(RustBuffer bytes, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_PUBLIC_KEY +void* uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_public_key(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_SCHEME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_SCHEME +RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_scheme(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TO_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TO_DER +RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_der(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TO_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TO_PEM +RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_pem(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN +void* uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign(void* ptr, RustBuffer message, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_SIMPLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_SIMPLE +void* uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_simple(void* ptr, RustBuffer message, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_USER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_USER +void* uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_user(void* ptr, RustBuffer message, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_VERIFYING_KEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PRIVATEKEY_VERIFYING_KEY +void* uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_verifying_key(void* ptr, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1PUBLICKEY #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1PUBLICKEY void* uniffi_iota_sdk_ffi_fn_clone_secp256k1publickey(void* ptr, RustCallStatus *out_status @@ -2610,6 +2681,87 @@ void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_generate(RustCallSta RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1signature_to_bytes(void* ptr, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1VERIFIER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1VERIFIER +void* uniffi_iota_sdk_ffi_fn_clone_secp256k1verifier(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SECP256K1VERIFIER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SECP256K1VERIFIER +void uniffi_iota_sdk_ffi_fn_free_secp256k1verifier(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFIER_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFIER_NEW +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifier_new(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFIER_VERIFY_SIMPLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFIER_VERIFY_SIMPLE +void uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_simple(void* ptr, RustBuffer message, void* signature, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFIER_VERIFY_USER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFIER_VERIFY_USER +void uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_user(void* ptr, RustBuffer message, void* signature, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1VERIFYINGKEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1VERIFYINGKEY +void* uniffi_iota_sdk_ffi_fn_clone_secp256k1verifyingkey(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SECP256K1VERIFYINGKEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_SECP256K1VERIFYINGKEY +void uniffi_iota_sdk_ffi_fn_free_secp256k1verifyingkey(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_DER +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_der(RustBuffer bytes, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_PEM +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_pem(RustBuffer s, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFYINGKEY_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_SECP256K1VERIFYINGKEY_NEW +void* uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_new(void* public_key, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_PUBLIC_KEY +void* uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_public_key(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_TO_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_TO_DER +RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_der(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_TO_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_TO_PEM +RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_pem(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_VERIFY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_VERIFY +void uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify(void* ptr, RustBuffer message, void* signature, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_VERIFY_SIMPLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_VERIFY_SIMPLE +void uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_simple(void* ptr, RustBuffer message, void* signature, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_VERIFY_USER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1VERIFYINGKEY_VERIFY_USER +void uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_user(void* ptr, RustBuffer message, void* signature, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256R1PRIVATEKEY #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256R1PRIVATEKEY void* uniffi_iota_sdk_ffi_fn_clone_secp256r1privatekey(void* ptr, RustCallStatus *out_status @@ -5297,6 +5449,54 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_publish_dependencies(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_PUBLISH_MODULES uint16_t uniffi_iota_sdk_ffi_checksum_method_publish_modules(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_PUBLIC_KEY +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_SCHEME +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_SCHEME +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TO_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TO_DER +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TO_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TO_PEM +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_SIMPLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_SIMPLE +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_USER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_TRY_SIGN_USER +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_VERIFYING_KEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PRIVATEKEY_VERIFYING_KEY +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PUBLICKEY_TO_BYTES @@ -5309,6 +5509,54 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1SIGNATURE_TO_BYTES uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1signature_to_bytes(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFIER_VERIFY_SIMPLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFIER_VERIFY_SIMPLE +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFIER_VERIFY_USER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFIER_VERIFY_USER +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_PUBLIC_KEY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_PUBLIC_KEY +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_TO_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_TO_DER +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_TO_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_TO_PEM +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_VERIFY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_VERIFY +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_VERIFY_SIMPLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_VERIFY_SIMPLE +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_VERIFY_USER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1VERIFYINGKEY_VERIFY_USER +uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256R1PRIVATEKEY_PUBLIC_KEY @@ -6695,6 +6943,30 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_programmabletransaction_new(vo #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_PUBLISH_NEW uint16_t uniffi_iota_sdk_ffi_checksum_constructor_publish_new(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_DER +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_FROM_PEM +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_GENERATE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_GENERATE +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PRIVATEKEY_NEW +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1PUBLICKEY_FROM_BYTES @@ -6731,6 +7003,30 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_from_str(vo #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1SIGNATURE_GENERATE uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_generate(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFIER_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFIER_NEW +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_DER +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_DER +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_PEM +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFYINGKEY_FROM_PEM +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFYINGKEY_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256K1VERIFYINGKEY_NEW +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_SECP256R1PRIVATEKEY_FROM_DER diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index 5ba4fba99..d5b201e88 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -1878,6 +1878,60 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2314,10 +2368,42 @@ fun uniffi_iota_sdk_ffi_checksum_method_publish_dependencies( ): Short fun uniffi_iota_sdk_ffi_checksum_method_publish_modules( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key( +): Short fun uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes( ): Short fun uniffi_iota_sdk_ffi_checksum_method_secp256k1signature_to_bytes( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user( +): Short fun uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_public_key( ): Short fun uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_scheme( @@ -2780,6 +2866,14 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_programmabletransaction_new( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_publish_new( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_bytes( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_str( @@ -2792,6 +2886,14 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_from_str( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_generate( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_der( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_pem( @@ -3823,6 +3925,34 @@ fun uniffi_iota_sdk_ffi_fn_method_publish_dependencies(`ptr`: Pointer,uniffi_out ): RustBuffer.ByValue fun uniffi_iota_sdk_ffi_fn_method_publish_modules(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_clone_secp256k1privatekey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_secp256k1privatekey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_der(`bytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_pem(`s`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_generate(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_new(`bytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_public_key(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_scheme(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_der(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_pem(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign(`ptr`: Pointer,`message`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_simple(`ptr`: Pointer,`message`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_user(`ptr`: Pointer,`message`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_verifying_key(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer fun uniffi_iota_sdk_ffi_fn_clone_secp256k1publickey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_secp256k1publickey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -3847,6 +3977,38 @@ fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_generate(uniffi_out_er ): Pointer fun uniffi_iota_sdk_ffi_fn_method_secp256k1signature_to_bytes(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_clone_secp256k1verifier(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_secp256k1verifier(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifier_new(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_simple(`ptr`: Pointer,`message`: RustBuffer.ByValue,`signature`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_user(`ptr`: Pointer,`message`: RustBuffer.ByValue,`signature`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_clone_secp256k1verifyingkey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_secp256k1verifyingkey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_der(`bytes`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_pem(`s`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_new(`publicKey`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_public_key(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_der(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_pem(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify(`ptr`: Pointer,`message`: RustBuffer.ByValue,`signature`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_simple(`ptr`: Pointer,`message`: RustBuffer.ByValue,`signature`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_user(`ptr`: Pointer,`message`: RustBuffer.ByValue,`signature`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit fun uniffi_iota_sdk_ffi_fn_clone_secp256r1privatekey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_secp256r1privatekey(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -5049,12 +5211,60 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_publish_modules() != 26011.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key() != 27155.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme() != 60810.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der() != 65507.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem() != 12369.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign() != 5798.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple() != 11597.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user() != 20597.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key() != 51137.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes() != 49170.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1signature_to_bytes() != 49705.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple() != 36777.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user() != 26362.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key() != 56083.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der() != 21325.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem() != 29137.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify() != 27904.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple() != 35045.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user() != 41639.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_public_key() != 58075.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -5748,6 +5958,18 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_publish_new() != 4785.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der() != 45448.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem() != 20937.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate() != 49496.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new() != 35513.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_bytes() != 20339.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -5766,6 +5988,18 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_generate() != 63087.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new() != 59813.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der() != 40127.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem() != 40573.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new() != 16080.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_der() != 63595.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -26054,36 +26288,34 @@ public object FfiConverterTypePublish: FfiConverter { // -/** - * A secp256k1 signature. - * - * # BCS - * - * The BCS serialized form for this type is defined by the following ABNF: - * - * ```text - * secp256k1-signature = 64OCTECT - * ``` - */ -public interface Secp256k1PublicKeyInterface { +public interface Secp256k1PrivateKeyInterface { - fun `toBytes`(): kotlin.ByteArray + fun `publicKey`(): Secp256k1PublicKey + + fun `scheme`(): SignatureScheme + + /** + * Serialize this private key as DER-encoded PKCS#8 + */ + fun `toDer`(): kotlin.ByteArray + + /** + * Serialize this private key as PEM-encoded PKCS#8 + */ + fun `toPem`(): kotlin.String + + fun `trySign`(`message`: kotlin.ByteArray): Secp256k1Signature + + fun `trySignSimple`(`message`: kotlin.ByteArray): SimpleSignature + + fun `trySignUser`(`message`: kotlin.ByteArray): UserSignature + + fun `verifyingKey`(): Secp256k1VerifyingKey companion object } -/** - * A secp256k1 signature. - * - * # BCS - * - * The BCS serialized form for this type is defined by the following ABNF: - * - * ```text - * secp256k1-signature = 64OCTECT - * ``` - */ -open class Secp256k1PublicKey: Disposable, AutoCloseable, Secp256k1PublicKeyInterface +open class Secp256k1PrivateKey: Disposable, AutoCloseable, Secp256k1PrivateKeyInterface { constructor(pointer: Pointer) { @@ -26101,6 +26333,13 @@ open class Secp256k1PublicKey: Disposable, AutoCloseable, Secp256k1PublicKeyInte this.pointer = null this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) } + constructor(`bytes`: kotlin.ByteArray) : + this( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_new( + FfiConverterByteArray.lower(`bytes`),_status) +} + ) protected val pointer: Pointer? protected val cleanable: UniffiCleaner.Cleanable @@ -26153,7 +26392,7 @@ open class Secp256k1PublicKey: Disposable, AutoCloseable, Secp256k1PublicKeyInte override fun run() { pointer?.let { ptr -> uniffiRustCall { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_secp256k1publickey(ptr, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_secp256k1privatekey(ptr, status) } } } @@ -26161,15 +26400,15 @@ open class Secp256k1PublicKey: Disposable, AutoCloseable, Secp256k1PublicKeyInte fun uniffiClonePointer(): Pointer { return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_secp256k1publickey(pointer!!, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_secp256k1privatekey(pointer!!, status) } } - override fun `toBytes`(): kotlin.ByteArray { - return FfiConverterByteArray.lift( + override fun `publicKey`(): Secp256k1PublicKey { + return FfiConverterTypeSecp256k1PublicKey.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_to_bytes( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_public_key( it, _status) } } @@ -26177,37 +26416,139 @@ open class Secp256k1PublicKey: Disposable, AutoCloseable, Secp256k1PublicKeyInte } - - - - companion object { - - @Throws(SdkFfiException::class) fun `fromBytes`(`bytes`: kotlin.ByteArray): Secp256k1PublicKey { - return FfiConverterTypeSecp256k1PublicKey.lift( - uniffiRustCallWithError(SdkFfiException) { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_bytes( - FfiConverterByteArray.lower(`bytes`),_status) + override fun `scheme`(): SignatureScheme { + return FfiConverterTypeSignatureScheme.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_scheme( + it, _status) } + } ) } - - @Throws(SdkFfiException::class) fun `fromStr`(`s`: kotlin.String): Secp256k1PublicKey { - return FfiConverterTypeSecp256k1PublicKey.lift( + + /** + * Serialize this private key as DER-encoded PKCS#8 + */ + @Throws(SdkFfiException::class)override fun `toDer`(): kotlin.ByteArray { + return FfiConverterByteArray.lift( + callWithPointer { uniffiRustCallWithError(SdkFfiException) { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_str( - FfiConverterString.lower(`s`),_status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_der( + it, _status) } + } ) } - fun `generate`(): Secp256k1PublicKey { - return FfiConverterTypeSecp256k1PublicKey.lift( - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_generate( - _status) + + /** + * Serialize this private key as PEM-encoded PKCS#8 + */ + @Throws(SdkFfiException::class)override fun `toPem`(): kotlin.String { + return FfiConverterString.lift( + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_pem( + it, _status) +} + } + ) + } + + + + @Throws(SdkFfiException::class)override fun `trySign`(`message`: kotlin.ByteArray): Secp256k1Signature { + return FfiConverterTypeSecp256k1Signature.lift( + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign( + it, FfiConverterByteArray.lower(`message`),_status) +} + } + ) + } + + + + @Throws(SdkFfiException::class)override fun `trySignSimple`(`message`: kotlin.ByteArray): SimpleSignature { + return FfiConverterTypeSimpleSignature.lift( + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_simple( + it, FfiConverterByteArray.lower(`message`),_status) +} + } + ) + } + + + + @Throws(SdkFfiException::class)override fun `trySignUser`(`message`: kotlin.ByteArray): UserSignature { + return FfiConverterTypeUserSignature.lift( + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_user( + it, FfiConverterByteArray.lower(`message`),_status) +} + } + ) + } + + + override fun `verifyingKey`(): Secp256k1VerifyingKey { + return FfiConverterTypeSecp256k1VerifyingKey.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_verifying_key( + it, _status) +} + } + ) + } + + + + + + companion object { + + /** + * Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary + * format). + */ + @Throws(SdkFfiException::class) fun `fromDer`(`bytes`: kotlin.ByteArray): Secp256k1PrivateKey { + return FfiConverterTypeSecp256k1PrivateKey.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_der( + FfiConverterByteArray.lower(`bytes`),_status) +} + ) + } + + + + /** + * Deserialize PKCS#8-encoded private key from PEM. + */ + @Throws(SdkFfiException::class) fun `fromPem`(`s`: kotlin.String): Secp256k1PrivateKey { + return FfiConverterTypeSecp256k1PrivateKey.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_pem( + FfiConverterString.lower(`s`),_status) +} + ) + } + + + fun `generate`(): Secp256k1PrivateKey { + return FfiConverterTypeSecp256k1PrivateKey.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_generate( + _status) } ) } @@ -26221,25 +26562,25 @@ open class Secp256k1PublicKey: Disposable, AutoCloseable, Secp256k1PublicKeyInte /** * @suppress */ -public object FfiConverterTypeSecp256k1PublicKey: FfiConverter { +public object FfiConverterTypeSecp256k1PrivateKey: FfiConverter { - override fun lower(value: Secp256k1PublicKey): Pointer { + override fun lower(value: Secp256k1PrivateKey): Pointer { return value.uniffiClonePointer() } - override fun lift(value: Pointer): Secp256k1PublicKey { - return Secp256k1PublicKey(value) + override fun lift(value: Pointer): Secp256k1PrivateKey { + return Secp256k1PrivateKey(value) } - override fun read(buf: ByteBuffer): Secp256k1PublicKey { + override fun read(buf: ByteBuffer): Secp256k1PrivateKey { // The Rust code always writes pointers as 8 bytes, and will // fail to compile if they don't fit. return lift(Pointer(buf.getLong())) } - override fun allocationSize(value: Secp256k1PublicKey) = 8UL + override fun allocationSize(value: Secp256k1PrivateKey) = 8UL - override fun write(value: Secp256k1PublicKey, buf: ByteBuffer) { + override fun write(value: Secp256k1PrivateKey, buf: ByteBuffer) { // The Rust code always expects pointers written as 8 bytes, // and will fail to compile if they don't fit. buf.putLong(Pointer.nativeValue(lower(value))) @@ -26346,17 +26687,17 @@ public object FfiConverterTypeSecp256k1PublicKey: FfiConverter uniffiRustCall { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_secp256k1signature(ptr, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_secp256k1publickey(ptr, status) } } } @@ -26452,7 +26793,7 @@ open class Secp256k1Signature: Disposable, AutoCloseable, Secp256k1SignatureInte fun uniffiClonePointer(): Pointer { return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_secp256k1signature(pointer!!, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_secp256k1publickey(pointer!!, status) } } @@ -26460,7 +26801,7 @@ open class Secp256k1Signature: Disposable, AutoCloseable, Secp256k1SignatureInte return FfiConverterByteArray.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1signature_to_bytes( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_to_bytes( it, _status) } } @@ -26473,10 +26814,10 @@ open class Secp256k1Signature: Disposable, AutoCloseable, Secp256k1SignatureInte companion object { - @Throws(SdkFfiException::class) fun `fromBytes`(`bytes`: kotlin.ByteArray): Secp256k1Signature { - return FfiConverterTypeSecp256k1Signature.lift( + @Throws(SdkFfiException::class) fun `fromBytes`(`bytes`: kotlin.ByteArray): Secp256k1PublicKey { + return FfiConverterTypeSecp256k1PublicKey.lift( uniffiRustCallWithError(SdkFfiException) { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_from_bytes( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_bytes( FfiConverterByteArray.lower(`bytes`),_status) } ) @@ -26484,20 +26825,20 @@ open class Secp256k1Signature: Disposable, AutoCloseable, Secp256k1SignatureInte - @Throws(SdkFfiException::class) fun `fromStr`(`s`: kotlin.String): Secp256k1Signature { - return FfiConverterTypeSecp256k1Signature.lift( + @Throws(SdkFfiException::class) fun `fromStr`(`s`: kotlin.String): Secp256k1PublicKey { + return FfiConverterTypeSecp256k1PublicKey.lift( uniffiRustCallWithError(SdkFfiException) { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_from_str( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_str( FfiConverterString.lower(`s`),_status) } ) } - fun `generate`(): Secp256k1Signature { - return FfiConverterTypeSecp256k1Signature.lift( + fun `generate`(): Secp256k1PublicKey { + return FfiConverterTypeSecp256k1PublicKey.lift( uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_generate( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_generate( _status) } ) @@ -26512,25 +26853,929 @@ open class Secp256k1Signature: Disposable, AutoCloseable, Secp256k1SignatureInte /** * @suppress */ -public object FfiConverterTypeSecp256k1Signature: FfiConverter { +public object FfiConverterTypeSecp256k1PublicKey: FfiConverter { - override fun lower(value: Secp256k1Signature): Pointer { + override fun lower(value: Secp256k1PublicKey): Pointer { return value.uniffiClonePointer() } - override fun lift(value: Pointer): Secp256k1Signature { - return Secp256k1Signature(value) + override fun lift(value: Pointer): Secp256k1PublicKey { + return Secp256k1PublicKey(value) } - override fun read(buf: ByteBuffer): Secp256k1Signature { + override fun read(buf: ByteBuffer): Secp256k1PublicKey { // The Rust code always writes pointers as 8 bytes, and will // fail to compile if they don't fit. return lift(Pointer(buf.getLong())) } - override fun allocationSize(value: Secp256k1Signature) = 8UL + override fun allocationSize(value: Secp256k1PublicKey) = 8UL - override fun write(value: Secp256k1Signature, buf: ByteBuffer) { + override fun write(value: Secp256k1PublicKey, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + +// This template implements a class for working with a Rust struct via a Pointer/Arc +// to the live Rust struct on the other side of the FFI. +// +// Each instance implements core operations for working with the Rust `Arc` and the +// Kotlin Pointer to work with the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque pointer to the underlying Rust struct. +// Method calls need to read this pointer from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its pointer should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the pointer, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the pointer, but is interrupted +// before it can pass the pointer over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read pointer value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +/** + * A secp256k1 public key. + * + * # BCS + * + * The BCS serialized form for this type is defined by the following ABNF: + * + * ```text + * secp256k1-public-key = 33OCTECT + * ``` + */ +public interface Secp256k1SignatureInterface { + + fun `toBytes`(): kotlin.ByteArray + + companion object +} + +/** + * A secp256k1 public key. + * + * # BCS + * + * The BCS serialized form for this type is defined by the following ABNF: + * + * ```text + * secp256k1-public-key = 33OCTECT + * ``` + */ +open class Secp256k1Signature: Disposable, AutoCloseable, Secp256k1SignatureInterface +{ + + constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + /** + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noPointer: NoPointer) { + this.pointer = null + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + protected val pointer: Pointer? + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithPointer(block: (ptr: Pointer) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the pointer being freed concurrently. + try { + return block(this.uniffiClonePointer()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val pointer: Pointer?) : Runnable { + override fun run() { + pointer?.let { ptr -> + uniffiRustCall { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_secp256k1signature(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_secp256k1signature(pointer!!, status) + } + } + + override fun `toBytes`(): kotlin.ByteArray { + return FfiConverterByteArray.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1signature_to_bytes( + it, _status) +} + } + ) + } + + + + + + companion object { + + @Throws(SdkFfiException::class) fun `fromBytes`(`bytes`: kotlin.ByteArray): Secp256k1Signature { + return FfiConverterTypeSecp256k1Signature.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_from_bytes( + FfiConverterByteArray.lower(`bytes`),_status) +} + ) + } + + + + @Throws(SdkFfiException::class) fun `fromStr`(`s`: kotlin.String): Secp256k1Signature { + return FfiConverterTypeSecp256k1Signature.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_from_str( + FfiConverterString.lower(`s`),_status) +} + ) + } + + + fun `generate`(): Secp256k1Signature { + return FfiConverterTypeSecp256k1Signature.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1signature_generate( + _status) +} + ) + } + + + + } + +} + +/** + * @suppress + */ +public object FfiConverterTypeSecp256k1Signature: FfiConverter { + + override fun lower(value: Secp256k1Signature): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): Secp256k1Signature { + return Secp256k1Signature(value) + } + + override fun read(buf: ByteBuffer): Secp256k1Signature { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: Secp256k1Signature) = 8UL + + override fun write(value: Secp256k1Signature, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + +// This template implements a class for working with a Rust struct via a Pointer/Arc +// to the live Rust struct on the other side of the FFI. +// +// Each instance implements core operations for working with the Rust `Arc` and the +// Kotlin Pointer to work with the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque pointer to the underlying Rust struct. +// Method calls need to read this pointer from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its pointer should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the pointer, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the pointer, but is interrupted +// before it can pass the pointer over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read pointer value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +public interface Secp256k1VerifierInterface { + + fun `verifySimple`(`message`: kotlin.ByteArray, `signature`: SimpleSignature) + + fun `verifyUser`(`message`: kotlin.ByteArray, `signature`: UserSignature) + + companion object +} + +open class Secp256k1Verifier: Disposable, AutoCloseable, Secp256k1VerifierInterface +{ + + constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + /** + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noPointer: NoPointer) { + this.pointer = null + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + constructor() : + this( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifier_new( + _status) +} + ) + + protected val pointer: Pointer? + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithPointer(block: (ptr: Pointer) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the pointer being freed concurrently. + try { + return block(this.uniffiClonePointer()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val pointer: Pointer?) : Runnable { + override fun run() { + pointer?.let { ptr -> + uniffiRustCall { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_secp256k1verifier(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifier(pointer!!, status) + } + } + + + @Throws(SdkFfiException::class)override fun `verifySimple`(`message`: kotlin.ByteArray, `signature`: SimpleSignature) + = + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_simple( + it, FfiConverterByteArray.lower(`message`),FfiConverterTypeSimpleSignature.lower(`signature`),_status) +} + } + + + + + @Throws(SdkFfiException::class)override fun `verifyUser`(`message`: kotlin.ByteArray, `signature`: UserSignature) + = + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_user( + it, FfiConverterByteArray.lower(`message`),FfiConverterTypeUserSignature.lower(`signature`),_status) +} + } + + + + + + + + companion object + +} + +/** + * @suppress + */ +public object FfiConverterTypeSecp256k1Verifier: FfiConverter { + + override fun lower(value: Secp256k1Verifier): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): Secp256k1Verifier { + return Secp256k1Verifier(value) + } + + override fun read(buf: ByteBuffer): Secp256k1Verifier { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: Secp256k1Verifier) = 8UL + + override fun write(value: Secp256k1Verifier, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + +// This template implements a class for working with a Rust struct via a Pointer/Arc +// to the live Rust struct on the other side of the FFI. +// +// Each instance implements core operations for working with the Rust `Arc` and the +// Kotlin Pointer to work with the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque pointer to the underlying Rust struct. +// Method calls need to read this pointer from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its pointer should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the pointer, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the pointer, but is interrupted +// before it can pass the pointer over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read pointer value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +public interface Secp256k1VerifyingKeyInterface { + + fun `publicKey`(): Secp256k1PublicKey + + /** + * Serialize this public key as DER-encoded data + */ + fun `toDer`(): kotlin.ByteArray + + /** + * Serialize this public key into PEM + */ + fun `toPem`(): kotlin.String + + fun `verify`(`message`: kotlin.ByteArray, `signature`: Secp256k1Signature) + + fun `verifySimple`(`message`: kotlin.ByteArray, `signature`: SimpleSignature) + + fun `verifyUser`(`message`: kotlin.ByteArray, `signature`: UserSignature) + + companion object +} + +open class Secp256k1VerifyingKey: Disposable, AutoCloseable, Secp256k1VerifyingKeyInterface +{ + + constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + /** + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noPointer: NoPointer) { + this.pointer = null + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + constructor(`publicKey`: Secp256k1PublicKey) : + this( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_new( + FfiConverterTypeSecp256k1PublicKey.lower(`publicKey`),_status) +} + ) + + protected val pointer: Pointer? + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithPointer(block: (ptr: Pointer) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the pointer being freed concurrently. + try { + return block(this.uniffiClonePointer()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val pointer: Pointer?) : Runnable { + override fun run() { + pointer?.let { ptr -> + uniffiRustCall { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_secp256k1verifyingkey(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifyingkey(pointer!!, status) + } + } + + override fun `publicKey`(): Secp256k1PublicKey { + return FfiConverterTypeSecp256k1PublicKey.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_public_key( + it, _status) +} + } + ) + } + + + + /** + * Serialize this public key as DER-encoded data + */ + @Throws(SdkFfiException::class)override fun `toDer`(): kotlin.ByteArray { + return FfiConverterByteArray.lift( + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_der( + it, _status) +} + } + ) + } + + + + /** + * Serialize this public key into PEM + */ + @Throws(SdkFfiException::class)override fun `toPem`(): kotlin.String { + return FfiConverterString.lift( + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_pem( + it, _status) +} + } + ) + } + + + + @Throws(SdkFfiException::class)override fun `verify`(`message`: kotlin.ByteArray, `signature`: Secp256k1Signature) + = + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify( + it, FfiConverterByteArray.lower(`message`),FfiConverterTypeSecp256k1Signature.lower(`signature`),_status) +} + } + + + + + @Throws(SdkFfiException::class)override fun `verifySimple`(`message`: kotlin.ByteArray, `signature`: SimpleSignature) + = + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_simple( + it, FfiConverterByteArray.lower(`message`),FfiConverterTypeSimpleSignature.lower(`signature`),_status) +} + } + + + + + @Throws(SdkFfiException::class)override fun `verifyUser`(`message`: kotlin.ByteArray, `signature`: UserSignature) + = + callWithPointer { + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_user( + it, FfiConverterByteArray.lower(`message`),FfiConverterTypeUserSignature.lower(`signature`),_status) +} + } + + + + + + + companion object { + + /** + * Deserialize public key from ASN.1 DER-encoded data (binary format). + */ + @Throws(SdkFfiException::class) fun `fromDer`(`bytes`: kotlin.ByteArray): Secp256k1VerifyingKey { + return FfiConverterTypeSecp256k1VerifyingKey.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_der( + FfiConverterByteArray.lower(`bytes`),_status) +} + ) + } + + + + /** + * Deserialize public key from PEM. + */ + @Throws(SdkFfiException::class) fun `fromPem`(`s`: kotlin.String): Secp256k1VerifyingKey { + return FfiConverterTypeSecp256k1VerifyingKey.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_pem( + FfiConverterString.lower(`s`),_status) +} + ) + } + + + + } + +} + +/** + * @suppress + */ +public object FfiConverterTypeSecp256k1VerifyingKey: FfiConverter { + + override fun lower(value: Secp256k1VerifyingKey): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): Secp256k1VerifyingKey { + return Secp256k1VerifyingKey(value) + } + + override fun read(buf: ByteBuffer): Secp256k1VerifyingKey { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: Secp256k1VerifyingKey) = 8UL + + override fun write(value: Secp256k1VerifyingKey, buf: ByteBuffer) { // The Rust code always expects pointers written as 8 bytes, // and will fail to compile if they don't fit. buf.putLong(Pointer.nativeValue(lower(value))) diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index de762659c..77ea54a11 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -861,10 +861,42 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_publish_modules() != 26011: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key() != 27155: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme() != 60810: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der() != 65507: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem() != 12369: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign() != 5798: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple() != 11597: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user() != 20597: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key() != 51137: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes() != 49170: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1signature_to_bytes() != 49705: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple() != 36777: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user() != 26362: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key() != 56083: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der() != 21325: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem() != 29137: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify() != 27904: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple() != 35045: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user() != 41639: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_public_key() != 58075: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_scheme() != 20973: @@ -1327,6 +1359,14 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_publish_new() != 4785: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der() != 45448: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem() != 20937: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate() != 49496: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new() != 35513: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_bytes() != 20339: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_str() != 24158: @@ -1339,6 +1379,14 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_generate() != 63087: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new() != 59813: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der() != 40127: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem() != 40573: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new() != 16080: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_der() != 63595: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_pem() != 28166: @@ -3781,6 +3829,78 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_publish_modules.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1privatekey.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1privatekey.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1privatekey.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1privatekey.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_der.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_der.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_pem.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_pem.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_generate.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_generate.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_new.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_public_key.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_public_key.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_scheme.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_scheme.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_der.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_der.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_pem.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_pem.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_simple.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_simple.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_user.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_user.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_verifying_key.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_verifying_key.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1publickey.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -3839,6 +3959,95 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1signature_to_bytes.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifier.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifier.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1verifier.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1verifier.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifier_new.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifier_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_simple.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_simple.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_user.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_user.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifyingkey.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifyingkey.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1verifyingkey.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1verifyingkey.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_der.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_der.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_pem.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_pem.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_new.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_public_key.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_public_key.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_der.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_der.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_pem.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_pem.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_simple.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_simple.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_user.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_user.restype = None _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256r1privatekey.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -5919,12 +6128,60 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_publish_modules.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_publish_modules.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_public_key.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_scheme.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_der.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_to_pem.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_simple.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_try_sign_user.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1privatekey_verifying_key.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1signature_to_bytes.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1signature_to_bytes.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_simple.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifier_verify_user.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_public_key.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_der.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_to_pem.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_simple.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256k1verifyingkey_verify_user.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_public_key.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_secp256r1privatekey_public_key.restype = ctypes.c_uint16 @@ -6618,6 +6875,18 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_publish_new.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_publish_new.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_der.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_from_pem.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_generate.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1privatekey_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_bytes.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1publickey_from_bytes.restype = ctypes.c_uint16 @@ -6636,6 +6905,18 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_generate.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1signature_generate.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifier_new.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_der.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_from_pem.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256k1verifyingkey_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_der.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_secp256r1privatekey_from_der.restype = ctypes.c_uint16 @@ -7180,6 +7461,12 @@ def write(value, buf): + + + + + + @@ -28317,48 +28604,48 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: PublishProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class Secp256k1PublicKeyProtocol(typing.Protocol): - """ - A secp256k1 signature. - - # BCS - - The BCS serialized form for this type is defined by the following ABNF: - - ```text - secp256k1-signature = 64OCTECT - ``` - """ - - def to_bytes(self, ): +class Secp256k1PrivateKeyProtocol(typing.Protocol): + def public_key(self, ): raise NotImplementedError -# Secp256k1PublicKey is a Rust-only trait - it's a wrapper around a Rust implementation. -class Secp256k1PublicKey(): - """ - A secp256k1 signature. - - # BCS - - The BCS serialized form for this type is defined by the following ABNF: + def scheme(self, ): + raise NotImplementedError + def to_der(self, ): + """ + Serialize this private key as DER-encoded PKCS#8 + """ - ```text - secp256k1-signature = 64OCTECT - ``` - """ + raise NotImplementedError + def to_pem(self, ): + """ + Serialize this private key as PEM-encoded PKCS#8 + """ + raise NotImplementedError + def try_sign(self, message: "bytes"): + raise NotImplementedError + def try_sign_simple(self, message: "bytes"): + raise NotImplementedError + def try_sign_user(self, message: "bytes"): + raise NotImplementedError + def verifying_key(self, ): + raise NotImplementedError +# Secp256k1PrivateKey is a Rust-only trait - it's a wrapper around a Rust implementation. +class Secp256k1PrivateKey(): _pointer: ctypes.c_void_p - - def __init__(self, *args, **kwargs): - raise ValueError("This class has no default constructor") + def __init__(self, bytes: "bytes"): + _UniffiConverterBytes.check_lower(bytes) + + self._pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_new, + _UniffiConverterBytes.lower(bytes)) def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1publickey, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1privatekey, pointer) def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1publickey, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1privatekey, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -28369,67 +28656,270 @@ def _make_instance_(cls, pointer): inst._pointer = pointer return inst @classmethod - def from_bytes(cls, bytes: "bytes"): + def from_der(cls, bytes: "bytes"): + """ + Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary + format). + """ + _UniffiConverterBytes.check_lower(bytes) # Call the (fallible) function before creating any half-baked object instances. - pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_bytes, + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_der, _UniffiConverterBytes.lower(bytes)) return cls._make_instance_(pointer) @classmethod - def from_str(cls, s: "str"): + def from_pem(cls, s: "str"): + """ + Deserialize PKCS#8-encoded private key from PEM. + """ + _UniffiConverterString.check_lower(s) # Call the (fallible) function before creating any half-baked object instances. - pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_str, + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_from_pem, _UniffiConverterString.lower(s)) return cls._make_instance_(pointer) @classmethod def generate(cls, ): # Call the (fallible) function before creating any half-baked object instances. - pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_generate,) + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1privatekey_generate,) return cls._make_instance_(pointer) - def to_bytes(self, ) -> "bytes": - return _UniffiConverterBytes.lift( - _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_to_bytes,self._uniffi_clone_pointer(),) + def public_key(self, ) -> "Secp256k1PublicKey": + return _UniffiConverterTypeSecp256k1PublicKey.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_public_key,self._uniffi_clone_pointer(),) ) + def scheme(self, ) -> "SignatureScheme": + return _UniffiConverterTypeSignatureScheme.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_scheme,self._uniffi_clone_pointer(),) + ) -class _UniffiConverterTypeSecp256k1PublicKey: - - @staticmethod - def lift(value: int): - return Secp256k1PublicKey._make_instance_(value) - @staticmethod - def check_lower(value: Secp256k1PublicKey): - if not isinstance(value, Secp256k1PublicKey): - raise TypeError("Expected Secp256k1PublicKey instance, {} found".format(type(value).__name__)) - @staticmethod - def lower(value: Secp256k1PublicKeyProtocol): - if not isinstance(value, Secp256k1PublicKey): - raise TypeError("Expected Secp256k1PublicKey instance, {} found".format(type(value).__name__)) - return value._uniffi_clone_pointer() - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) - @classmethod - def write(cls, value: Secp256k1PublicKeyProtocol, buf: _UniffiRustBuffer): + def to_der(self, ) -> "bytes": + """ + Serialize this private key as DER-encoded PKCS#8 + """ + + return _UniffiConverterBytes.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_der,self._uniffi_clone_pointer(),) + ) + + + + + + def to_pem(self, ) -> "str": + """ + Serialize this private key as PEM-encoded PKCS#8 + """ + + return _UniffiConverterString.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_to_pem,self._uniffi_clone_pointer(),) + ) + + + + + + def try_sign(self, message: "bytes") -> "Secp256k1Signature": + _UniffiConverterBytes.check_lower(message) + + return _UniffiConverterTypeSecp256k1Signature.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message)) + ) + + + + + + def try_sign_simple(self, message: "bytes") -> "SimpleSignature": + _UniffiConverterBytes.check_lower(message) + + return _UniffiConverterTypeSimpleSignature.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_simple,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message)) + ) + + + + + + def try_sign_user(self, message: "bytes") -> "UserSignature": + _UniffiConverterBytes.check_lower(message) + + return _UniffiConverterTypeUserSignature.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_try_sign_user,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message)) + ) + + + + + + def verifying_key(self, ) -> "Secp256k1VerifyingKey": + return _UniffiConverterTypeSecp256k1VerifyingKey.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1privatekey_verifying_key,self._uniffi_clone_pointer(),) + ) + + + + + + +class _UniffiConverterTypeSecp256k1PrivateKey: + + @staticmethod + def lift(value: int): + return Secp256k1PrivateKey._make_instance_(value) + + @staticmethod + def check_lower(value: Secp256k1PrivateKey): + if not isinstance(value, Secp256k1PrivateKey): + raise TypeError("Expected Secp256k1PrivateKey instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: Secp256k1PrivateKeyProtocol): + if not isinstance(value, Secp256k1PrivateKey): + raise TypeError("Expected Secp256k1PrivateKey instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: Secp256k1PrivateKeyProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class Secp256k1PublicKeyProtocol(typing.Protocol): + """ + A secp256k1 signature. + + # BCS + + The BCS serialized form for this type is defined by the following ABNF: + + ```text + secp256k1-signature = 64OCTECT + ``` + """ + + def to_bytes(self, ): + raise NotImplementedError +# Secp256k1PublicKey is a Rust-only trait - it's a wrapper around a Rust implementation. +class Secp256k1PublicKey(): + """ + A secp256k1 signature. + + # BCS + + The BCS serialized form for this type is defined by the following ABNF: + + ```text + secp256k1-signature = 64OCTECT + ``` + """ + + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1publickey, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1publickey, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + @classmethod + def from_bytes(cls, bytes: "bytes"): + _UniffiConverterBytes.check_lower(bytes) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_bytes, + _UniffiConverterBytes.lower(bytes)) + return cls._make_instance_(pointer) + + @classmethod + def from_str(cls, s: "str"): + _UniffiConverterString.check_lower(s) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_from_str, + _UniffiConverterString.lower(s)) + return cls._make_instance_(pointer) + + @classmethod + def generate(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1publickey_generate,) + return cls._make_instance_(pointer) + + + + def to_bytes(self, ) -> "bytes": + return _UniffiConverterBytes.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_to_bytes,self._uniffi_clone_pointer(),) + ) + + + + + + +class _UniffiConverterTypeSecp256k1PublicKey: + + @staticmethod + def lift(value: int): + return Secp256k1PublicKey._make_instance_(value) + + @staticmethod + def check_lower(value: Secp256k1PublicKey): + if not isinstance(value, Secp256k1PublicKey): + raise TypeError("Expected Secp256k1PublicKey instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: Secp256k1PublicKeyProtocol): + if not isinstance(value, Secp256k1PublicKey): + raise TypeError("Expected Secp256k1PublicKey instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: Secp256k1PublicKeyProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) class Secp256k1SignatureProtocol(typing.Protocol): """ @@ -28545,6 +29035,272 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: Secp256k1SignatureProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) +class Secp256k1VerifierProtocol(typing.Protocol): + def verify_simple(self, message: "bytes",signature: "SimpleSignature"): + raise NotImplementedError + def verify_user(self, message: "bytes",signature: "UserSignature"): + raise NotImplementedError +# Secp256k1Verifier is a Rust-only trait - it's a wrapper around a Rust implementation. +class Secp256k1Verifier(): + _pointer: ctypes.c_void_p + def __init__(self, ): + self._pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifier_new,) + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1verifier, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifier, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + + + def verify_simple(self, message: "bytes",signature: "SimpleSignature") -> None: + _UniffiConverterBytes.check_lower(message) + + _UniffiConverterTypeSimpleSignature.check_lower(signature) + + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_simple,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message), + _UniffiConverterTypeSimpleSignature.lower(signature)) + + + + + + + def verify_user(self, message: "bytes",signature: "UserSignature") -> None: + _UniffiConverterBytes.check_lower(message) + + _UniffiConverterTypeUserSignature.check_lower(signature) + + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifier_verify_user,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message), + _UniffiConverterTypeUserSignature.lower(signature)) + + + + + + + +class _UniffiConverterTypeSecp256k1Verifier: + + @staticmethod + def lift(value: int): + return Secp256k1Verifier._make_instance_(value) + + @staticmethod + def check_lower(value: Secp256k1Verifier): + if not isinstance(value, Secp256k1Verifier): + raise TypeError("Expected Secp256k1Verifier instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: Secp256k1VerifierProtocol): + if not isinstance(value, Secp256k1Verifier): + raise TypeError("Expected Secp256k1Verifier instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: Secp256k1VerifierProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class Secp256k1VerifyingKeyProtocol(typing.Protocol): + def public_key(self, ): + raise NotImplementedError + def to_der(self, ): + """ + Serialize this public key as DER-encoded data + """ + + raise NotImplementedError + def to_pem(self, ): + """ + Serialize this public key into PEM + """ + + raise NotImplementedError + def verify(self, message: "bytes",signature: "Secp256k1Signature"): + raise NotImplementedError + def verify_simple(self, message: "bytes",signature: "SimpleSignature"): + raise NotImplementedError + def verify_user(self, message: "bytes",signature: "UserSignature"): + raise NotImplementedError +# Secp256k1VerifyingKey is a Rust-only trait - it's a wrapper around a Rust implementation. +class Secp256k1VerifyingKey(): + _pointer: ctypes.c_void_p + def __init__(self, public_key: "Secp256k1PublicKey"): + _UniffiConverterTypeSecp256k1PublicKey.check_lower(public_key) + + self._pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_new, + _UniffiConverterTypeSecp256k1PublicKey.lower(public_key)) + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_secp256k1verifyingkey, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_secp256k1verifyingkey, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + @classmethod + def from_der(cls, bytes: "bytes"): + """ + Deserialize public key from ASN.1 DER-encoded data (binary format). + """ + + _UniffiConverterBytes.check_lower(bytes) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_der, + _UniffiConverterBytes.lower(bytes)) + return cls._make_instance_(pointer) + + @classmethod + def from_pem(cls, s: "str"): + """ + Deserialize public key from PEM. + """ + + _UniffiConverterString.check_lower(s) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_secp256k1verifyingkey_from_pem, + _UniffiConverterString.lower(s)) + return cls._make_instance_(pointer) + + + + def public_key(self, ) -> "Secp256k1PublicKey": + return _UniffiConverterTypeSecp256k1PublicKey.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_public_key,self._uniffi_clone_pointer(),) + ) + + + + + + def to_der(self, ) -> "bytes": + """ + Serialize this public key as DER-encoded data + """ + + return _UniffiConverterBytes.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_der,self._uniffi_clone_pointer(),) + ) + + + + + + def to_pem(self, ) -> "str": + """ + Serialize this public key into PEM + """ + + return _UniffiConverterString.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_to_pem,self._uniffi_clone_pointer(),) + ) + + + + + + def verify(self, message: "bytes",signature: "Secp256k1Signature") -> None: + _UniffiConverterBytes.check_lower(message) + + _UniffiConverterTypeSecp256k1Signature.check_lower(signature) + + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message), + _UniffiConverterTypeSecp256k1Signature.lower(signature)) + + + + + + + def verify_simple(self, message: "bytes",signature: "SimpleSignature") -> None: + _UniffiConverterBytes.check_lower(message) + + _UniffiConverterTypeSimpleSignature.check_lower(signature) + + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_simple,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message), + _UniffiConverterTypeSimpleSignature.lower(signature)) + + + + + + + def verify_user(self, message: "bytes",signature: "UserSignature") -> None: + _UniffiConverterBytes.check_lower(message) + + _UniffiConverterTypeUserSignature.check_lower(signature) + + _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_method_secp256k1verifyingkey_verify_user,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(message), + _UniffiConverterTypeUserSignature.lower(signature)) + + + + + + + +class _UniffiConverterTypeSecp256k1VerifyingKey: + + @staticmethod + def lift(value: int): + return Secp256k1VerifyingKey._make_instance_(value) + + @staticmethod + def check_lower(value: Secp256k1VerifyingKey): + if not isinstance(value, Secp256k1VerifyingKey): + raise TypeError("Expected Secp256k1VerifyingKey instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: Secp256k1VerifyingKeyProtocol): + if not isinstance(value, Secp256k1VerifyingKey): + raise TypeError("Expected Secp256k1VerifyingKey instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: Secp256k1VerifyingKeyProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) class Secp256r1PrivateKeyProtocol(typing.Protocol): def public_key(self, ): """ @@ -33049,8 +33805,11 @@ async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, "PasskeyVerifier", "ProgrammableTransaction", "Publish", + "Secp256k1PrivateKey", "Secp256k1PublicKey", "Secp256k1Signature", + "Secp256k1Verifier", + "Secp256k1VerifyingKey", "Secp256r1PrivateKey", "Secp256r1PublicKey", "Secp256r1Signature", diff --git a/crates/iota-sdk-ffi/src/crypto/mod.rs b/crates/iota-sdk-ffi/src/crypto/mod.rs index 262614306..7147e55c8 100644 --- a/crates/iota-sdk-ffi/src/crypto/mod.rs +++ b/crates/iota-sdk-ffi/src/crypto/mod.rs @@ -3,5 +3,6 @@ pub mod ed25519; pub mod passkey; +pub mod secp256k1; pub mod secp256r1; pub mod simple; diff --git a/crates/iota-sdk-ffi/src/crypto/secp256k1.rs b/crates/iota-sdk-ffi/src/crypto/secp256k1.rs new file mode 100644 index 000000000..4a17a9b94 --- /dev/null +++ b/crates/iota-sdk-ffi/src/crypto/secp256k1.rs @@ -0,0 +1,177 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use iota_types::SignatureScheme; +use rand::rngs::OsRng; + +use crate::{ + error::{Result, SdkFfiError}, + types::{ + crypto::{Secp256k1PublicKey, Secp256k1Signature}, + signature::{SimpleSignature, UserSignature}, + }, +}; + +#[derive(derive_more::From, uniffi::Object)] +pub struct Secp256k1PrivateKey(iota_crypto::secp256k1::Secp256k1PrivateKey); + +#[uniffi::export] +impl Secp256k1PrivateKey { + #[uniffi::constructor] + pub fn new(bytes: Vec) -> Result { + Ok(Self(iota_crypto::secp256k1::Secp256k1PrivateKey::new( + bytes.try_into().map_err(|v: Vec| { + SdkFfiError::custom(format!("expected bytes of length 32, found {}", v.len())) + })?, + )?)) + } + + pub fn scheme(&self) -> SignatureScheme { + self.0.scheme() + } + + pub fn verifying_key(&self) -> Secp256k1VerifyingKey { + self.0.verifying_key().into() + } + + pub fn public_key(&self) -> Secp256k1PublicKey { + self.0.public_key().into() + } + + #[uniffi::constructor] + pub fn generate() -> Self { + Self(iota_crypto::secp256k1::Secp256k1PrivateKey::generate(OsRng)) + } + + /// Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary + /// format). + #[uniffi::constructor] + pub fn from_der(bytes: &[u8]) -> Result { + Ok(iota_crypto::secp256k1::Secp256k1PrivateKey::from_der(bytes)?.into()) + } + + /// Serialize this private key as DER-encoded PKCS#8 + pub fn to_der(&self) -> Result> { + Ok(self.0.to_der()?) + } + + /// Deserialize PKCS#8-encoded private key from PEM. + #[uniffi::constructor] + pub fn from_pem(s: &str) -> Result { + Ok(iota_crypto::secp256k1::Secp256k1PrivateKey::from_pem(s)?.into()) + } + + /// Serialize this private key as PEM-encoded PKCS#8 + pub fn to_pem(&self) -> Result { + Ok(self.0.to_pem()?) + } + + pub fn try_sign(&self, message: &[u8]) -> Result { + Ok( + iota_crypto::Signer::::try_sign(&self.0, message)? + .into(), + ) + } + + pub fn try_sign_simple(&self, message: &[u8]) -> Result { + Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + } + + pub fn try_sign_user(&self, message: &[u8]) -> Result { + Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + } +} + +#[derive(derive_more::From, uniffi::Object)] +pub struct Secp256k1VerifyingKey(iota_crypto::secp256k1::Secp256k1VerifyingKey); + +#[uniffi::export] +impl Secp256k1VerifyingKey { + #[uniffi::constructor] + pub fn new(public_key: &Secp256k1PublicKey) -> Result { + Ok(iota_crypto::secp256k1::Secp256k1VerifyingKey::new(&public_key.0).map(Self)?) + } + + pub fn public_key(&self) -> Secp256k1PublicKey { + self.0.public_key().into() + } + + /// Deserialize public key from ASN.1 DER-encoded data (binary format). + #[uniffi::constructor] + pub fn from_der(bytes: &[u8]) -> Result { + Ok(iota_crypto::secp256k1::Secp256k1VerifyingKey::from_der(bytes)?.into()) + } + + /// Serialize this public key as DER-encoded data + pub fn to_der(&self) -> Result> { + Ok(self.0.to_der()?) + } + + /// Deserialize public key from PEM. + #[uniffi::constructor] + pub fn from_pem(s: &str) -> Result { + Ok(iota_crypto::secp256k1::Secp256k1VerifyingKey::from_pem(s)?.into()) + } + + /// Serialize this public key into PEM + pub fn to_pem(&self) -> Result { + Ok(self.0.to_pem()?) + } + + pub fn verify(&self, message: &[u8], signature: &Secp256k1Signature) -> Result<()> { + Ok( + iota_crypto::Verifier::::verify( + &self.0, + message, + &signature.0, + )?, + ) + } + + pub fn verify_simple(&self, message: &[u8], signature: &SimpleSignature) -> Result<()> { + Ok( + iota_crypto::Verifier::::verify( + &self.0, + message, + &signature.0, + )?, + ) + } + + pub fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { + Ok(iota_crypto::Verifier::::verify( + &self.0, + message, + &signature.0, + )?) + } +} + +#[derive(derive_more::From, uniffi::Object)] +pub struct Secp256k1Verifier(iota_crypto::secp256k1::Secp256k1Verifier); + +#[uniffi::export] +impl Secp256k1Verifier { + #[uniffi::constructor] + pub fn new() -> Self { + Self(iota_crypto::secp256k1::Secp256k1Verifier::new()) + } + + fn verify_simple(&self, message: &[u8], signature: &SimpleSignature) -> Result<()> { + Ok( + iota_crypto::Verifier::::verify( + &self.0, + message, + &signature.0, + )?, + ) + } + + fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { + Ok(iota_crypto::Verifier::::verify( + &self.0, + message, + &signature.0, + )?) + } +}