简体   繁体   English

使用签名验证公钥 -react native biometrics

[英]Validate public key with the signature -react native biometrics

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.我正在尝试使用react native biometrics,但是在我创建并存储了公钥(作为下面示例代码中的状态)之后,它永远不会与之后用同一根手指生成的签名匹配。 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 https://8gwifi.org/RSAFunctionality?rsasignverifyfunctions=rsasignverifyfunctions&keysize=512

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM