簡體   English   中英

使用簽名驗證公鑰 -react native biometrics

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

我正在嘗試使用react native biometrics,但是在我創建並存儲了公鑰(作為下面示例代碼中的狀態)之后,它永遠不會與之后用同一根手指生成的簽名匹配。 如何驗證指紋?

代碼:

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)
  })

您需要使用生成的簽名和有效負載組合檢查服務器端的驗證。

轉到此站點並粘貼生成的公鑰、簽名、有效負載並驗證它。

https://8gwifi.org/RSAFunctionality?rsasignverifyfunctions=rsasignverifyfunctions&keysize=512

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM