This library is used for simple hardware-backed ECIES encryption and decryption on both iOS and Android.
On iOS it use Secure Enclave for store the private key, and save public key to keychain. For getting the private key for decryption, user will need to enter his TouchID or FaceID if any is set.
Algorithm used: ECIESEncryptionStandardX963SHA256AESGCM
On Android it use google Tink for an easy application logic. It currently does not bound with Biometric Auth, but I will follow the discussion here
Algorithm used: ECIES_P256_HKDF_HMAC_SHA256_AES128_CTR_HMAC_SHA256
The library should be automatically linked on installation.
$ npm install react-native-ec-encryption --save
For iOS:
An extra installation step is needed on React Native 0.60(+) (see issue #99):
$ cd ios && pod install && cd ..
Tested with React Native version >=0.60
import ECEncryption from 'react-native-ec-encryption';
const encryptAndThenDecrypt = async () => {
try {
//Encrypt
const cipherText = await ECEncryption.encrypt({
data: 'some confidential data',
label: '0x5Cc5dc62be3c95C771C14232e30358B398265deF' //any identical string
});
//Decrypt
const clearText = await ECEncryption.decrypt({
data: cipherText,
label: '0x5Cc5dc62be3c95C771C14232e30358B398265deF' //the same identical string
});
console.log('decrypt result is ', clearText);
} catch(e) {
console.log(e);
}
};
The library is originally used for Parity Signer.
GNU General Public License v3.0