kepler 1.0.3 copy "kepler: ^1.0.3" to clipboard
kepler: ^1.0.3 copied to clipboard

Encrypt and decrypt data using the secp256k1 elliptic curve. This is the High level API build from pointycastle. A fork of secp256k1Cipher.

Kepler #

This package provides an api for encrypting data using public and private keys created by the secp256k1 elliptic curve.

This is a fork of secp256k1Cipher.

Example usage.

 
  // Create Alice's keypair
  var alice = generateKeyPair();

  print(
    "alice private key: " +
        strinifyPrivateKey(alice.privateKey as ECPrivateKey),
  );
  print(
    "alice public key: " + strinifyPublicKey(alice.publicKey as ECPublicKey),
  );

  // Create Bob's keypair
  var bob = generateKeyPair();

  // This is what alice wants to say to bob
  var rawStr = 'Encrypt and decrypt data using secp256k1';

  // use alic's privatekey and bob's publickey means alice says to bob
  var encMap = pubkeyEncrypt(
    strinifyPrivateKey(alice.privateKey as ECPrivateKey),
    strinifyPublicKey(bob.publicKey as ECPublicKey),
    rawStr,
  );

  // Get encrypted base64 string
  var encStr = encMap['enc'];
  print("encrypted text: " + encStr);

  // Get random IV
  var iv = encMap['iv'];
  print("iv: " + iv);
  
  // Now, you can send enc_str and IV to Bob

  // Use bob's privatekey and alice's publickey to decrypt alices message, for Bob to read.
  var decryptd = privateDecrypt(
    strinifyPrivateKey(bob.privateKey as ECPrivateKey),
    strinifyPublicKey(alice.publicKey as ECPublicKey),
    encStr,
    iv,
  );
  print('decrypted text: $decryptd');
0
likes
160
pub points
67%
popularity

Publisher

unverified uploader

Encrypt and decrypt data using the secp256k1 elliptic curve. This is the High level API build from pointycastle. A fork of secp256k1Cipher.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

base58check, hex, pointycastle

More

Packages that depend on kepler