turnkey_crypto 0.1.3 copy "turnkey_crypto: ^0.1.3" to clipboard
turnkey_crypto: ^0.1.3 copied to clipboard

This package consolidates some common cryptographic utilities used across our applications, particularly primitives related to keys, encryption, and decryption in a pure Dart implementation.

turnkey-crypto #

This package provides cryptographic utilities used across our applications, specifically for key generation, encryption, and decryption.

Example usage (Hpke E2E):

final senderKeyPair = generateP256KeyPair();
final receiverKeyPair = generateP256KeyPair();

final receiverPublicKeyUncompressed =
    uncompressRawPublicKey(hexToUint8List(receiverKeyPair.publicKey));

final plainText = "Hello, this is a secure message!";
final plainTextBuf = Uint8List.fromList(utf8.encode(plainText));

final encryptedData = hpkeEncrypt(
    plainTextBuf: plainTextBuf,
    encappedKeyBuf: receiverPublicKeyUncompressed,
    senderPriv: senderKeyPair.privateKey,
);

// Extract the encapsulated key buffer and the ciphertext
final encappedKeyBuf = encryptedData.sublist(0, 33);
final ciphertextBuf = encryptedData.sublist(33);

final decryptedData = hpkeDecrypt(
    ciphertextBuf: ciphertextBuf,
    encappedKeyBuf: uncompressRawPublicKey(encappedKeyBuf),
    receiverPriv: receiverKeyPair.privateKey,
);

// Convert decrypted data back to a string
final decryptedText = utf8.decode(decryptedData);
1
likes
120
points
555
downloads

Documentation

API reference

Publisher

verified publisherturnkey.com

Weekly Downloads

This package consolidates some common cryptographic utilities used across our applications, particularly primitives related to keys, encryption, and decryption in a pure Dart implementation.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

base58check, bs58, cryptography, pointycastle, turnkey_encoding

More

Packages that depend on turnkey_crypto