Skip to content

Instantly share code, notes, and snippets.

@MiguelXCruz
MiguelXCruz / ECDSASignatureCheck
Created February 20, 2024 16:34
This piece of code compares if the recovered walletAddress from the signedMessage and Signature matches the desired WalletAddress. This way you can check if the ECDSA signature is valid
// This piece of code compares if the recovered walletAddress from the signedMessage and Signature matches the desired WalletAddress.
// This way you can check if the ECDSA signature is valid
public boolean isECDSAValidSignature(String walletAddress, String signature, String originalMessage)
throws SignatureException, UnsupportedEncodingException {
if (signature.startsWith("0x")) {
signature = signature.substring(2);
}
String r = signature.substring(0, 64);
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="com.combateafraude.documentdetector.controller.viewmodel.SDKViewModel" />
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="com.combateafraude.faceauthenticator.controller.viewmodel.SDKViewModel" />
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:keepScreenOn="true">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guidelineStart"
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="375dp"
android:height="667dp"
android:viewportWidth="375"
android:viewportHeight="667">
<path
android:pathData="M375,0V667H0V0H375ZM341,85H35V516H341V85Z"
android:strokeAlpha="0.35"
android:fillColor="#000000"
android:fillType="evenOdd"
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="375dp"
android:height="667dp"
android:viewportWidth="375"
android:viewportHeight="667">
<path
android:pathData="M375,0V667H0V0H375ZM341,85H35V516H341V85Z"
android:strokeAlpha="0.35"
android:fillColor="#000000"
android:fillType="evenOdd"
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="375dp"
android:height="667dp"
android:viewportWidth="375"
android:viewportHeight="667">
<path
android:pathData="M375,0V667H0V0H375ZM341,85H35V516H341V85Z"
android:strokeAlpha="0.35"
android:fillColor="#000000"
android:fillType="evenOdd"
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="375dp"
android:height="667dp"
android:viewportWidth="375"
android:viewportHeight="667">
<path
android:pathData="M375,0V667H0V0H375ZM341,85H35V516H341V85Z"
android:strokeAlpha="0.35"
android:fillColor="#000000"
android:fillType="evenOdd"
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="com.combateafraude.documentdetector.controller.viewmodel.SDKViewModel" />