crypto box

initial utility functions for encrypted communication using crypto box
(X25519/XSalsa20-Poly1305)
This commit is contained in:
Eitan Chatav 2016-11-03 11:15:31 -07:00
parent 1ac018188e
commit dc0061c5d9
3 changed files with 43 additions and 0 deletions

View File

@ -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 \

21
src/utils/crypto_box.ml Normal file
View File

@ -0,0 +1,21 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2016. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* 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

20
src/utils/crypto_box.mli Normal file
View File

@ -0,0 +1,20 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2016. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* 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