Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork28
TweetNaCl in Java - a port of TweetNaCl-js
License
NotificationsYou must be signed in to change notification settings
InstantWebP2P/tweetnacl-java
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
TweetNacl in Java: port oftweetnacl-js
implementation "io.github.instantwebp2p:tweetnacl-java:1.1.2"Suggest always useTweetNaclFast implementation
- get key pair: Box.KeyPair kp = Box.keyPair(), kp = Box.keyPair_fromSecretKey(sk)
- new Box object: Box box = new Box(theirPublicKey, mySecretKey, Nonce);
- encryption: cipher = box.box(message);
- decryption: message = box.open(cipher);
- Nonce MUST be unique for ever message passed between same peers
As an alternative, the nonce can be omitted from the Box() call, and passed in the box and open calls, like:
- byte [] nonce = new byte[nonceLength], randombytes(theNonce, nonceLength);
- Box.KeyPair kp = Box.keyPair(), kp = Box.keyPair_fromSecretKey(sk)
- Box box = new Box(theirPublicKey, mySecretKey);
- encryption: cipher = box.box(message, nonce);
- decryption: message = box.open(cipher, nonce);
- get shared key: crypto random, what you have
- new SecretBox object: SecretBox sbox = new SecretBox(sharedKey, Nonce);
- encryption: cipher = sbox.box(message);
- decryption: message = sbox.open(cipher);
- Nonce MUST be unique for ever message passed between same peers
As an alternative, the nonce can be omitted from the SecretBox() call, and passed in the box and open calls, like:
- byte [] nonce = new byte[nonceLength], randombytes(theNonce, nonceLength);
- SecretBox sbox = new SecretBox(sharedKey);
- cipher = sbox.box(message, nonce);
- decryption: message = sbox.open(cipher, nonce);
- get key pair: Signature.KeyPair kp = Signature.keyPair(), kp = Signature.keyPair_fromSecretKey(sk);
- new Signature object: Signature sig = new Signature(theirPublicKey, mySecretKey);
- sign: signedMessage = sig.sign(message);
- verify: message = sig.open(signedMessage);
- Nonce MUST be unique for ever message passed between same peers
- generate SHA-512: byte [] tag = Hash.sha512(message);
- the library uses java.security.SecureRandom for key generation
- you can always use the library to generate key, or use a Crypto Random like java.security.SecureRandom
In top directory:
$ mvn test- Welcome contributing on document, codes, tests and issues
- Copyright(2014-present) by tom zhou,appnet.link@gmail.com
About
TweetNaCl in Java - a port of TweetNaCl-js
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.