I am trying to use react native biometrics but after I've created and stored the public key(as a state in the example code below), it never matches with the signature generated afterward with the same finger. How can I verify the fingerPrint?
code:
registerFingerPrint = () => {
Biometrics.isSensorAvailable()
.then((biometryType) => {
if (biometryType === Biometrics.TouchID) {
Biometrics.createKeys('Confirm fingerprint')
.then((publicKey) => {
console.log("create", publicKey)
this.setState({
create: publicKey
})
})
}
})
}
fingerPrintCheck = () => {
Biometrics.createSignature('Sign in', payload)
.then((signature) => {
if (this.state.create === signature){
console.log("success");
}else {
console.log('failure'); //always returns failure here
}
})
}
render() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={()=> this.registerFingerPrint()}>
<Text style={{ marginBottom: 10}}>
Register
</Text>
</TouchableHighlight>
<TouchableHighlight onPress={()=> this.fingerPrintCheck()}>
<Text>
Authenticate with Biometrics
</Text>
</TouchableHighlight>
</View>
);
}
}
let epochTimeSeconds = Math.round((new Date()).getTime() / 1000).toString()
let payload = epochTimeSeconds +'some message' ;
Biometrics.createSignature('Sign in Test', payload)
.then((signature) => {
console.log(payload+" signature "+signature)
verifySignatureWithServer(signature, payload)
})
you need to check the validation in server side using the generated signature and payload combination.
go to this site and paste the generated public key, signature , payload and verify it.
https://8gwifi.org/RSAFunctionality?rsasignverifyfunctions=rsasignverifyfunctions&keysize=512
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.