1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
/// This module contains an unsecure non-cryptographic hash function. The purpose of this library is to allow
/// seamless benchmarking of systems without taking into account the cost of cryptographic primitives - and hence
/// providing a theoretical maximal throughput that a system could achieve if the cost of crypto is optimized
/// away.
///
/// Warning: All schemes in this file are completely unsafe to use in production.
/// This module contains an implementation of a negligible-cost (apart from some occasional pk copying) trivial
/// cryptographic signature scheme. The purpose of this library is to allow seamless benchmarking of systems
/// without taking into account the cost of cryptographic primitives - and hence providing a theoretical maximal
/// throughput that a system could achieve if the cost of crypto is optimized away.
///
/// The scheme is implemented as follows: The private key is PRIVATE_KEY_LENGTH random bytes and the public
/// key is defined from the private key as follows:
///
/// if PRIVATE_KEY_LENGTH >= PUBLIC_KEY_LENGTH {
/// pk = sk[0..PUBLIC_KEY_LENGTH]
/// } else {
/// pk = sk || 0...0
/// }
///
/// Signatures are implemented as H(pk || msg) where H is the non-cryptographic hash function XXHash, and
/// an aggregated signature is computed as the XOR of the individual signatures.
///
/// Warning: All schemes in this file are completely unsafe to use in production.