diff --git a/src/lib_base/block_locator.ml b/src/lib_base/block_locator.ml index 6d69ca4a9..57f058ccc 100644 --- a/src/lib_base/block_locator.ml +++ b/src/lib_base/block_locator.ml @@ -65,20 +65,20 @@ module Step : sig end = struct - type state = int * int * Cstruct.t + type state = int * int * MBytes.t let init seed head = - let seed = - Nocrypto.Hash.digest `SHA256 @@ - Cstruct.concat - [ Cstruct.of_bigarray @@ P2p_peer.Id.to_bytes seed.sender_id ; - Cstruct.of_bigarray @@ P2p_peer.Id.to_bytes seed.receiver_id ; - Cstruct.of_bigarray @@ Block_hash.to_bytes head ] in - (1, 9, seed) + let open Hacl.Hash in + let st = SHA256.init () in + List.iter (SHA256.update st) [ + P2p_peer.Id.to_bytes seed.sender_id ; + P2p_peer.Id.to_bytes seed.receiver_id ; + Block_hash.to_bytes head ] ; + (1, 9, SHA256.finish st) let draw seed n = - Int32.to_int (MBytes.get_int32 (Cstruct.to_bigarray seed) 0) mod n, - Nocrypto.Hash.digest `SHA256 seed + Int32.to_int (MBytes.get_int32 seed 0) mod n, + Hacl.Hash.SHA256.digest seed let next (step, counter, seed) = let random_gap, seed = diff --git a/src/lib_crypto/base58.ml b/src/lib_crypto/base58.ml index db130c397..2436fa942 100644 --- a/src/lib_crypto/base58.ml +++ b/src/lib_crypto/base58.ml @@ -112,11 +112,9 @@ let raw_decode ?(alphabet=Alphabet.default) s = let checksum s = let hash = - Nocrypto.Hash.digest `SHA256 @@ - Nocrypto.Hash.digest `SHA256 @@ - Cstruct.of_string s in + Hacl.Hash.SHA256.(digest (digest (Bigstring.of_string s))) in let res = Bytes.make 4 '\000' in - Cstruct.blit_to_bytes hash 0 res 0 4 ; + Bigstring.blit_to_bytes hash 0 res 0 4 ; Bytes.to_string res (* Append a 4-bytes cryptographic checksum before encoding string s *) diff --git a/src/lib_crypto/jbuild b/src/lib_crypto/jbuild index db8edd1c2..099cdca8c 100644 --- a/src/lib_crypto/jbuild +++ b/src/lib_crypto/jbuild @@ -15,7 +15,6 @@ tezos-rpc tezos-clic lwt - nocrypto blake2 hacl secp256k1 diff --git a/src/lib_crypto/tezos-crypto.opam b/src/lib_crypto/tezos-crypto.opam index 328c87e83..95983b15e 100644 --- a/src/lib_crypto/tezos-crypto.opam +++ b/src/lib_crypto/tezos-crypto.opam @@ -15,7 +15,6 @@ depends: [ "tezos-rpc" "tezos-clic" "lwt" - "nocrypto" "blake2" "hacl" "zarith"