How to use verifyKeySignature on react-native-biometrics properly?

4 days ago 8
ARTICLE AD BOX

I'm working on biometrics login for our ReactNative app using @sbaiahmed1/react-native-biometrics.

First step is to register the biometric public key to the backend by sending these 4 values: deviceId, deviceName, deviceOS, and publicKey.

publicKey is generated this way:

const result = await createKeys(); const { publicKey} = result; // prepare to send result.publicKey to backend...

To do biometric login, first send the device ID to backend to get the challenge, like this:

POST 6A7AD5A2-C054-425E-BEF7-2EB6E7F93B3C {"challenge":"Qou9Fj0alwBenM4mTB4LFZbGwxqvOcBiFh7qfp9F7WY=","challengeId":"0cb8a00d-f816-4b02-b6ae-e53fc0ac58fd","expiresAt":"2025-12-01T09:34:41.602182551Z"}

Now we have the challenge, lets verify it:

const signatureResult = await verifyKeySignature(challenge, 'my-key');

The result is

signature result: {"error":"Cryptographic key not found","success":false,"errorCode":"KEY_NOT_FOUND"}

Let's try another way: replace my-key with the actual public key:

const signatureResult = await verifyKeySignature(challenge, "BFeS9nv9+F/SHY7BSpkeo4rFf0jSjlWLgms44Jtx8jF+pOt0ouj0PwKf+tu2jBmp/7Ozb1NxuQlFK4kLY/BF3dA=");

Same result:

signature result: {"error":"Cryptographic key not found","success":false,"errorCode":"KEY_NOT_FOUND"}

What's wrong here?

Read Entire Article