MIMC52.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2024-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_MIMC52_HPP
  14. #define ZT_MIMC52_HPP
  15. #include "Constants.hpp"
  16. namespace ZeroTier {
  17. /**
  18. * Compute a number of rounds of the MIMC52 verifiable delay function
  19. *
  20. * @param salt Input salt
  21. * @param saltSize Size of salt in bytes
  22. * @param rounds Number of rounds to compute
  23. * @return Proof that rounds were computed (proof of CPU cycles spent)
  24. */
  25. uint64_t mimc52Delay(const void *salt,unsigned int saltSize,unsigned long rounds);
  26. /**
  27. * Verify a MIMC52 proof of work
  28. *
  29. * @param salt Original input salt
  30. * @param saltSize Size of salt in bytes
  31. * @param rounds Number of rounds originally computed
  32. * @param proof Proof to verify (most significant 12 bits are ignored)
  33. * @return True if proof is valid
  34. */
  35. bool mimc52Verify(const void *salt,unsigned int saltSize,unsigned long rounds,uint64_t proof);
  36. } // namespace ZeroTier
  37. #endif