Skip to content
Merged
6 changes: 2 additions & 4 deletions bindings/go/examples/generate_ed25519_address/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ func main() {
panic(err)
}
publicKey := privateKey.PublicKey()
flaggedPublicKey := publicKey.ToFlaggedBytes()
address := publicKey.DeriveAddress()
publicKeyBytes := publicKey.ToBytes()

flaggedPublicKey := append([]byte{byte(sdk.SignatureSchemeEd25519)}, publicKeyBytes...)

fmt.Println("Private Key:", privateKeyBech32)
fmt.Println("Public Key:", sdk.Base64Encode(publicKeyBytes))
fmt.Println("Public Key:", sdk.Base64Encode(publicKey.ToBytes()))
fmt.Println("Public Key With Flag:", sdk.Base64Encode(flaggedPublicKey))
fmt.Println("Address:", address.ToHex())
}
87 changes: 78 additions & 9 deletions bindings/go/iota_sdk_ffi/iota_sdk_ffi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ func uniffiCheckChecksums() {
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_ed25519publickey_scheme()
})
if checksum != 141 {
if checksum != 3041 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_ed25519publickey_scheme: UniFFI API checksum mismatch")
}
Expand All @@ -1106,6 +1106,15 @@ func uniffiCheckChecksums() {
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_ed25519publickey_to_flagged_bytes()
})
if checksum != 62359 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_ed25519publickey_to_flagged_bytes: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_ed25519signature_to_bytes()
})
Expand Down Expand Up @@ -2936,7 +2945,7 @@ func uniffiCheckChecksums() {
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_scheme()
})
if checksum != 798 {
if checksum != 60874 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_scheme: UniFFI API checksum mismatch")
}
Expand All @@ -2951,6 +2960,15 @@ func uniffiCheckChecksums() {
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_flagged_bytes()
})
if checksum != 46673 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_flagged_bytes: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_secp256k1signature_to_bytes()
})
Expand Down Expand Up @@ -3134,7 +3152,7 @@ func uniffiCheckChecksums() {
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_secp256r1publickey_scheme()
})
if checksum != 12227 {
if checksum != 48083 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256r1publickey_scheme: UniFFI API checksum mismatch")
}
Expand All @@ -3149,6 +3167,15 @@ func uniffiCheckChecksums() {
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_secp256r1publickey_to_flagged_bytes()
})
if checksum != 14205 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_secp256r1publickey_to_flagged_bytes: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_secp256r1signature_to_bytes()
})
Expand Down Expand Up @@ -10869,9 +10896,11 @@ type Ed25519PublicKeyInterface interface {
//
// `hash(32-byte ed25519 public key)`
DeriveAddress() *Address
// Return the flag for this signature scheme
// Returns the signature scheme for this public key.
Scheme() SignatureScheme
ToBytes() []byte
// Returns the bytes with signature scheme flag prepended.
ToFlaggedBytes() []byte
}
// An ed25519 public key.
//
Expand Down Expand Up @@ -10934,7 +10963,7 @@ func (_self *Ed25519PublicKey) DeriveAddress() *Address {
}))
}

// Return the flag for this signature scheme
// Returns the signature scheme for this public key.
func (_self *Ed25519PublicKey) Scheme() SignatureScheme {
_pointer := _self.ffiObject.incrementPointer("*Ed25519PublicKey")
defer _self.ffiObject.decrementPointer()
Expand All @@ -10956,6 +10985,18 @@ func (_self *Ed25519PublicKey) ToBytes() []byte {
}
}))
}

// Returns the bytes with signature scheme flag prepended.
func (_self *Ed25519PublicKey) ToFlaggedBytes() []byte {
_pointer := _self.ffiObject.incrementPointer("*Ed25519PublicKey")
defer _self.ffiObject.decrementPointer()
return FfiConverterBytesINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI {
return GoRustBuffer {
inner: C.uniffi_iota_sdk_ffi_fn_method_ed25519publickey_to_flagged_bytes(
_pointer,_uniffiStatus),
}
}))
}
func (object *Ed25519PublicKey) Destroy() {
runtime.SetFinalizer(object, nil)
object.ffiObject.destroy()
Expand Down Expand Up @@ -19382,9 +19423,11 @@ type Secp256k1PublicKeyInterface interface {
//
// `hash( 0x01 || 33-byte secp256k1 public key)`
DeriveAddress() *Address
// Return the flag for this signature scheme
// Returns the signature scheme for this public key.
Scheme() SignatureScheme
ToBytes() []byte
// Returns the bytes with signature scheme flag prepended.
ToFlaggedBytes() []byte
}
// A secp256k1 signature.
//
Expand Down Expand Up @@ -19448,7 +19491,7 @@ func (_self *Secp256k1PublicKey) DeriveAddress() *Address {
}))
}

// Return the flag for this signature scheme
// Returns the signature scheme for this public key.
func (_self *Secp256k1PublicKey) Scheme() SignatureScheme {
_pointer := _self.ffiObject.incrementPointer("*Secp256k1PublicKey")
defer _self.ffiObject.decrementPointer()
Expand All @@ -19470,6 +19513,18 @@ func (_self *Secp256k1PublicKey) ToBytes() []byte {
}
}))
}

// Returns the bytes with signature scheme flag prepended.
func (_self *Secp256k1PublicKey) ToFlaggedBytes() []byte {
_pointer := _self.ffiObject.incrementPointer("*Secp256k1PublicKey")
defer _self.ffiObject.decrementPointer()
return FfiConverterBytesINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI {
return GoRustBuffer {
inner: C.uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_to_flagged_bytes(
_pointer,_uniffiStatus),
}
}))
}
func (object *Secp256k1PublicKey) Destroy() {
runtime.SetFinalizer(object, nil)
object.ffiObject.destroy()
Expand Down Expand Up @@ -20215,9 +20270,11 @@ type Secp256r1PublicKeyInterface interface {
//
// `hash( 0x02 || 33-byte secp256r1 public key)`
DeriveAddress() *Address
// Return the flag for this signature scheme
// Returns the signature scheme for this public key.
Scheme() SignatureScheme
ToBytes() []byte
// Returns the bytes with signature scheme flag prepended
ToFlaggedBytes() []byte
}
// A secp256r1 signature.
//
Expand Down Expand Up @@ -20281,7 +20338,7 @@ func (_self *Secp256r1PublicKey) DeriveAddress() *Address {
}))
}

// Return the flag for this signature scheme
// Returns the signature scheme for this public key.
func (_self *Secp256r1PublicKey) Scheme() SignatureScheme {
_pointer := _self.ffiObject.incrementPointer("*Secp256r1PublicKey")
defer _self.ffiObject.decrementPointer()
Expand All @@ -20303,6 +20360,18 @@ func (_self *Secp256r1PublicKey) ToBytes() []byte {
}
}))
}

// Returns the bytes with signature scheme flag prepended
func (_self *Secp256r1PublicKey) ToFlaggedBytes() []byte {
_pointer := _self.ffiObject.incrementPointer("*Secp256r1PublicKey")
defer _self.ffiObject.decrementPointer()
return FfiConverterBytesINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI {
return GoRustBuffer {
inner: C.uniffi_iota_sdk_ffi_fn_method_secp256r1publickey_to_flagged_bytes(
_pointer,_uniffiStatus),
}
}))
}
func (object *Secp256r1PublicKey) Destroy() {
runtime.SetFinalizer(object, nil)
object.ffiObject.destroy()
Expand Down
33 changes: 33 additions & 0 deletions bindings/go/iota_sdk_ffi/iota_sdk_ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,11 @@ RustBuffer uniffi_iota_sdk_ffi_fn_method_ed25519publickey_scheme(void* ptr, Rust
RustBuffer uniffi_iota_sdk_ffi_fn_method_ed25519publickey_to_bytes(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_ED25519PUBLICKEY_TO_FLAGGED_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_ED25519PUBLICKEY_TO_FLAGGED_BYTES
RustBuffer uniffi_iota_sdk_ffi_fn_method_ed25519publickey_to_flagged_bytes(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_ED25519SIGNATURE
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_ED25519SIGNATURE
void* uniffi_iota_sdk_ffi_fn_clone_ed25519signature(void* ptr, RustCallStatus *out_status
Expand Down Expand Up @@ -3470,6 +3475,11 @@ RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_scheme(void* ptr, Ru
RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_to_bytes(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PUBLICKEY_TO_FLAGGED_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256K1PUBLICKEY_TO_FLAGGED_BYTES
RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256k1publickey_to_flagged_bytes(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1SIGNATURE
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256K1SIGNATURE
void* uniffi_iota_sdk_ffi_fn_clone_secp256k1signature(void* ptr, RustCallStatus *out_status
Expand Down Expand Up @@ -3709,6 +3719,11 @@ RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256r1publickey_scheme(void* ptr, Ru
RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256r1publickey_to_bytes(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256R1PUBLICKEY_TO_FLAGGED_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_SECP256R1PUBLICKEY_TO_FLAGGED_BYTES
RustBuffer uniffi_iota_sdk_ffi_fn_method_secp256r1publickey_to_flagged_bytes(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256R1SIGNATURE
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_SECP256R1SIGNATURE
void* uniffi_iota_sdk_ffi_fn_clone_secp256r1signature(void* ptr, RustCallStatus *out_status
Expand Down Expand Up @@ -6095,6 +6110,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_ed25519publickey_scheme(void
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_ED25519PUBLICKEY_TO_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_method_ed25519publickey_to_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_ED25519PUBLICKEY_TO_FLAGGED_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_ED25519PUBLICKEY_TO_FLAGGED_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_method_ed25519publickey_to_flagged_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_ED25519SIGNATURE_TO_BYTES
Expand Down Expand Up @@ -7325,6 +7346,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_scheme(void
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PUBLICKEY_TO_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PUBLICKEY_TO_FLAGGED_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1PUBLICKEY_TO_FLAGGED_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256k1publickey_to_flagged_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256K1SIGNATURE_TO_BYTES
Expand Down Expand Up @@ -7457,6 +7484,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256r1publickey_scheme(void
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256R1PUBLICKEY_TO_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256r1publickey_to_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256R1PUBLICKEY_TO_FLAGGED_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256R1PUBLICKEY_TO_FLAGGED_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_method_secp256r1publickey_to_flagged_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SECP256R1SIGNATURE_TO_BYTES
Expand Down
5 changes: 2 additions & 3 deletions bindings/kotlin/examples/GenerateEd25519Address.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ fun main() {
val privateKey = Ed25519PrivateKey.generate()
val privateKeyBech32 = privateKey.toBech32()
val publicKey = privateKey.publicKey()
val publicKeyBytes = publicKey.toBytes()
val flaggedPublicKey = byteArrayOf((publicKey.scheme().ordinal + 1).toByte()) + publicKeyBytes
val flaggedPublicKey = publicKey.toFlaggedBytes()
val address = publicKey.deriveAddress()

println("Private Key: ${privateKeyBech32}")
println("Public Key: ${base64Encode(publicKeyBytes)}")
println("Public Key: ${base64Encode(publicKey.toBytes())}")
println("Public Key With Flag: ${base64Encode(flaggedPublicKey)}")
println("Address: ${address.toHex()}")
}
Loading