app/src/main/java/com/xuexiang/cdaccount/biometriclib/BiometricPromptApi28.java
/**
     * Generate NIST P-256 EC Key pair for signing and verification
     * @return KeyPair
     * @throws Exception  ds
     */
Generate NIST P-256 EC Key pair for signing and verification
@return KeyPair
@throws Exception  ds
Generate NIST P - 256 EC Key pair for signing and verification @return KeyPair @throws Exception ds
@RequiresApi(api = Build.VERSION_CODES.N)
    private KeyPair generateKeyPair() throws Exception {
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_EC, "AndroidKeyStore");
        KeyGenParameterSpec.Builder builder = new KeyGenParameterSpec.Builder(BiometricPromptApi28.KEY_NAME,
                KeyProperties.PURPOSE_SIGN)
                .setAlgorithmParameterSpec(new ECGenParameterSpec("secp256r1"))
                .setDigests(KeyProperties.DIGEST_SHA256,
                        KeyProperties.DIGEST_SHA384,
                        KeyProperties.DIGEST_SHA512)
                .setUserAuthenticationRequired(true)
                .setInvalidatedByBiometricEnrollment(true);
        keyPairGenerator.initialize(builder.build());
        return keyPairGenerator.generateKeyPair();
    }
@ RequiresApi ( api = Build . VERSION_CODES . N ) private KeyPair generateKeyPair ( ) throws Exception { KeyPairGenerator keyPairGenerator = KeyPairGenerator . getInstance ( KeyProperties . KEY_ALGORITHM_EC , "AndroidKeyStore" ) ; KeyGenParameterSpec . Builder builder = new KeyGenParameterSpec . Builder ( BiometricPromptApi28 . KEY_NAME , KeyProperties . PURPOSE_SIGN ) . setAlgorithmParameterSpec ( new ECGenParameterSpec ( "secp256r1" ) ) . setDigests ( KeyProperties . DIGEST_SHA256 , KeyProperties . DIGEST_SHA384 , KeyProperties . DIGEST_SHA512 ) . setUserAuthenticationRequired ( true ) . setInvalidatedByBiometricEnrollment ( true ) ; keyPairGenerator . initialize ( builder . build ( ) ) ; return keyPairGenerator . generateKeyPair ( ) ; }
Generate NIST P-256 EC Key pair for signing and verification
 @return KeyPair
 @throws Exception  ds
Generate NIST P - 256 EC Key pair for signing and verification @return KeyPair @throws Exception ds
// Require the user to authenticate with a biometric to authorize every use of the key