From dc0061c5d9756fade88c251a075dc311baf4ba29 Mon Sep 17 00:00:00 2001 From: Eitan Chatav Date: Thu, 3 Nov 2016 11:15:31 -0700 Subject: [PATCH] crypto box initial utility functions for encrypted communication using crypto box (X25519/XSalsa20-Poly1305) --- src/Makefile | 2 ++ src/utils/crypto_box.ml | 21 +++++++++++++++++++++ src/utils/crypto_box.mli | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/utils/crypto_box.ml create mode 100644 src/utils/crypto_box.mli diff --git a/src/Makefile b/src/Makefile index 5425b524f..7e36cde65 100644 --- a/src/Makefile +++ b/src/Makefile @@ -106,6 +106,7 @@ UTILS_LIB_INTFS := \ utils/hex_encode.mli \ utils/utils.mli \ utils/cli_entries.mli \ + utils/crypto_box.mli \ utils/compare.mli \ utils/data_encoding.mli \ utils/time.mli \ @@ -123,6 +124,7 @@ UTILS_LIB_IMPLS := \ utils/utils.ml \ utils/cli_entries.ml \ utils/compare.ml \ + utils/crypto_box.ml \ utils/data_encoding.ml \ utils/time.ml \ utils/hash.ml \ diff --git a/src/utils/crypto_box.ml b/src/utils/crypto_box.ml new file mode 100644 index 000000000..f633f851c --- /dev/null +++ b/src/utils/crypto_box.ml @@ -0,0 +1,21 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2016. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Tezos - X25519/XSalsa20-Poly1305 cryptography *) + +type secret_key = Sodium.Box.secret_key +type public_key = Sodium.Box.public_key +type channel_key = Sodium.Box.channel_key +type nonce = Sodium.Box.nonce + +let random_keypair = Sodium.Box.random_keypair +let random_nonce = Sodium.Box.random_nonce +let increment_nonce = Sodium.Box.increment_nonce +let box = Sodium.Box.Bigbytes.box +let box_open = Sodium.Box.Bigbytes.box_open diff --git a/src/utils/crypto_box.mli b/src/utils/crypto_box.mli new file mode 100644 index 000000000..1df44ea44 --- /dev/null +++ b/src/utils/crypto_box.mli @@ -0,0 +1,20 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2016. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +(** Tezos - X25519/XSalsa20-Poly1305 cryptography *) + +type secret_key +type public_key +type nonce + +val random_keypair : unit -> secret_key * public_key +val random_nonce : unit -> nonce +val increment_nonce : ?step:int -> nonce -> nonce +val box : secret_key -> public_key -> MBytes.t -> nonce -> MBytes.t +val box_open : secret_key -> public_key -> MBytes.t -> nonce -> MBytes.t