custom_post_quantum 1.0.2-prerelease.8 copy "custom_post_quantum: ^1.0.2-prerelease.8" to clipboard
custom_post_quantum: ^1.0.2-prerelease.8 copied to clipboard

Dart implementation of NIST's post-quantum algorithm candidates, Kyber and Dilithium. which allows you to create Kyber with custom K

post_quantum #

plugin version likes pub points popularity Coverage Status

Dart implementation of NIST's post-quantum algorithm candidates.

Features #

This library includes the following algorithms:

  • Kyber, a post-quantum Key Encapsulation Mechanism.
  • Dilithium, a post quantum Signature scheme.

Usage #

Key Encapsulation with Kyber #

// Instantiate Kyber KEM.
var kyber = Kyber.kem512();

// Define a key generation seed.
var seed = base64Decode("AAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4PAAECAwQFBgcICQoLDA0ODw==");

// Generate keys from seed.
var (pk, sk) = kyber.generateKeys(seed);

// Define a KEM nonce.
var nonce = base64Decode("Dw8ODg0NDAwLCwoKCQkICAcHBgYFBQQEAwMCAgEBAAA=");

// Encapsulate nonce and retrieve cipher and shared key.
var (cipher, sharedKey1) = kyber.encapsulate(pk, nonce);

// Or decapsulate the cipher and retrieve the shared key.
var sharedKey2 = kyber.decapsulate(cipher, sk);

Encryption and decryption with the internal Kyber PKE #

// Instantiate Kyber's internal PKE.
var kyber = KyberPKE.pke512();

// Define a key generation seed.
var seed = base64Decode("AAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8=");

// Generate keys from seed.
var (pk, sk) = kyber.generateKeys(seed);

// Set the message.
var msg = base64Decode("Dw4NDAsKCQgHBgUEAwIBAA8ODQwLCgkIBwYFBAMCAQA=");

// Define an encryption randomizer.
var coins = base64Decode("Dw8ODg0NDAwLCwoKCQkICAcHBgYFBQQEAwMCAgEBAAA=");

// Encrypt the message with the public key.
var cipher = kyber.encrypt(pk, msg, coins);

// Decrypt the cipher with the private key.
var decryptedMsg = kyber.decrypt(sk, cipher);

Signing and validating with Dilithium #

// Instantiate Dilithium.
var dilithium = Dilithium.level2();

// Define a key generation seed.
var seed = base64Decode("AAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8=");

// Generate keys from seed.
var (pk, sk) = dilithium.generateKeys(seed);

// Set the message.
var msg = base64Decode("Dw4NDAsKCQgHBgUEAwIBAA8ODQwLCgkIBwYFBAMCAQA=");

// Sign the message with the private key.
var signature = dilithium.sign(sk, msg);

// Verify the signature with the public key.
var isValid = dilithium.verify(pk, msg, signature);

Disclaimer #

This library has not been reviewed by security specialists, and therefore should not be treated as cryptographically secure.

Acknowledgements #

This implementation is based on the python implementation written by Giacomo Pope. Please go and check and support all of his projects.

step para levantar la app traerse las dependencias de dart ---> dart pub get correr los test ---> dart pub global run coverage:test_with_coverage correr los ejemplos dentro de la carpeta example ejecutar ---> dart run nombreArchivo

0
likes
90
pub points
33%
popularity

Publisher

unverified uploader

Dart implementation of NIST's post-quantum algorithm candidates, Kyber and Dilithium. which allows you to create Kyber with custom K

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

hashlib

More

Packages that depend on custom_post_quantum