Android Question Exploring Ed25519 Signing in B4A: My Experience and Challenges

carlos7000

Well-Known Member
Licensed User
Longtime User
Hello everyone.

I need to sign communications with Ed25519 in B4A. Despite not finding much information in the forums, I came across a library in https://mavenlibs.com/jar/file/net.i2p.crypto/eddsa that implements functions for key generation and signing. I attempted to make it work using the line #AdditionalJar: eddsa-0.3.0.jar and the attached code, but honestly, I have no prior experience with something like this.

I’ve been reading posts that explain how to create a wrapper with an example, but so far, I haven’t achieved anything. The code I’ve been testing is as follows:

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    
End Sub

#AdditionalJar: eddsa-0.3.0.jar

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    GetEddsa.RunMethodJO("keyPairGenerator", Array())
End Sub

Sub GetEddsa As JavaObject
    Dim jo As JavaObject
    'com.squareup.picasso.Picasso.with(context)
    Return jo.InitializeStatic("net.i2p.crypto.eddsa").RunMethod("keyPairGenerator", Array(GetContext))
End Sub

Sub GetContext As JavaObject
    Return GetBA.GetField("context")
End Sub

Sub GetBA As JavaObject
    Dim jo As JavaObject
    Dim cls As String = Me
    cls = cls.SubString("class ".Length)
    jo.InitializeStatic(cls)
    Return jo.GetFieldJO("processBA")
End Sub

I found a wrapper from the Chilkat in https://www.b4x.com/android/forum/threads/chilkat-bundle.125870/ that includes EdDsa, although Chilkatbundle doesn't include EdDsa. but I couldn't try the library

I also tried creating the wrapper with Android Studio, but it’s beyond my current knowledge. I’ve never used Android Studio before.
 
Top