React Native Android have runtime exception customauth-react-native-sdk@4.0.1

Could not invoke RNCustomAuthSdk.init

Failed resolution of:Lorg/bouncycastle/crypto/ec/CustomNamedCurves;

Screenshot 2023-06-07 at 1.32.05 PM

Hey there,

Have you followed the documentation here for setting up the CustomAuth SDK for Android?

Also please share your implementation code alongside the platform and sdk version so that we’re able to debug and reproduce the error. Most probably, this error is happening due to non configuration of the gradle files.

We are using the following libs:

“react-native”: “0.66.5”,
@toruslabs/customauth-react-native-sdk”: “^4.0.1”
@tkey/default”: “^9.0.1”,
@tkey/security-questions”: “^9.0.0”,
@tkey/share-serialization”: “^9.0.1”,

Android Gradle: 4.2.2

The init code is the following.

try {
    CustomAuth.init({
      redirectUri: resolvedRedirectUrl,
      browserRedirectUri: 'https://scripts.toruswallet.io/redirect.html',
      network: 'testnet', // details for test net
    });
    const parsedToken = parseIdToken(idToken);
    const verifier = Config.AW_WEB3AUTH_VERIFIER;
    const verifierId = parsedToken.sub;
    const loginDetails = await CustomAuth.getTorusKey(
      verifier,
      verifierId,
      {
        verifierIdField: 'sub',
      },
      idToken,
    );
    tKey.serviceProvider.postboxKey = loginDetails.privateKey;
    (tKey.serviceProvider as any).verifierName = verifier;
    (tKey.serviceProvider as any).verifierId = verifierId;
    await tKey.initialize();
    console.log(
      '2 shares created credentials and device',
      tKey.getKeyDetails(),
    );
    //creating default pin
    if (isRegister) {
      await setTkeyDefaultSecurityQuestion();
    } else {
      //getting share of default pin if not set
      const isDefaultShare = await TkeyIsDefaultSecurityQuestion();
      if (isDefaultShare) {
        getTkeyDefaultSecurityQuestionShare();
      }
    }
  } catch (e) {
    Alert.alert('Error', `Unable to ${isRegister ? 'Register' : 'Login'}`);
  }

Yes we have followed it.

android/build.gradle:

buildscript {

	ext {
		buildToolsVersion = "30.0.3"
		minSdkVersion = project.hasProperty('minSdkVersion') ? project.getProperty('minSdkVersion') : 24
    compileSdkVersion = 32
    targetSdkVersion = 32
//		kotlin_version = "1.5.31"
    kotlin_version = "1.6.0"
		kotlinVersion = "$kotlin_version"
    ndkVersion = "21.4.7075529"
		supportLibVersion = "28.0.0"
	}
	repositories {
		google()
		mavenCentral()
		gradlePluginPortal()
		maven { url "https://jitpack.io" }
	}

	dependencies {
		classpath('com.android.tools.build:gradle:4.2.2')
		classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
		// NOTE: Do not place your application dependencies here; they belong
		// in the individual module build.gradle files
	}
}

allprojects {
	repositories {
		mavenLocal()
		maven {		// Replace AAR from original RN with AAR from react-native-v8
			url("$rootDir/../node_modules/react-native-v8/dist")
		}
		maven {
			// prebuilt libv8android.so
			url("$rootDir/../node_modules/v8-android/dist")
		}
		maven {
			// All of Detox' artifacts are provided via the npm module
			url "$rootDir/../node_modules/detox/Detox-android"
		}
		maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
		maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
		google()
		mavenCentral()
		maven { url 'https://jitpack.io' }
		gradlePluginPortal()
	}

Hey @shazadshiraz97,
As discussed on call, you have to upgrade android gradle version. Have you tried that?

Hey @gaurav ,
Ugrading the gradle for whole project is very difficult for us. It would be great if you can help us wo run sdk on lower graddle version as mentioned above.

can you update the react native to version mentioned in example and try once @shazadshiraz97

Hey @productionsillegal

We tried internally, but supporting a lower gradle version is not possible from our end. The workaround can be to use the SFA NodeJS SDK and use it in place of CustomAuth React Native SDK.

To securely support the process, you can create a public/ private key pair in the frontend. Send the pub key to the backend and encrypt the real key using that and send it back. Now, in the frontend, decrypt the encrypted blob in frontend using the temp private key.

I hope this will resolve the issue.

@yashovardhan

We have tried that but getting below error in frontend side on android

Response: 403

Url: https://metadata.tor.us/bulk_set_stream

[CoreError: setMetadata errored {“error”:{“index”:0,“timestamp”:“Message has been signed more than 60s ago”},“success”:false}]

and some time below error

[CoreError: getAuthMetadata errored , Custom Signature not valid for returning metadata]