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
#ifndef SIMPLICITY_RSORT_H
#define SIMPLICITY_RSORT_H
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include "limitations.h"
#include "sha256.h"
/* Sorts an array of pointers to 'sha256_midstate's in place in memcmp order.
* If malloc fails, returns false.
* Otherwise, returns true.
*
* The time complexity of rsort is O('len').
*
* We are sorting in memcmp order, which is the lexicographical order of the object representation, i.e. the order that one
* gets when casting 'sha256_midstate' to a 'unsigned char[]'. This representation is implementation defined, and will differ
* on big endian and little endian architectures.
*
* It is critical that the details of this order remain unobservable from the consensus rules.
*
* Precondition: For all 0 <= i < len, NULL != a[i];
*/
bool rustsimplicity_0_6_rsort(const sha256_midstate** a, uint_fast32_t len);
/* Searches for duplicates in an array of 'sha256_midstate's.
* If malloc fails, returns -1.
* If no duplicates are found, returns 0.
* If duplicates are found, returns a positive value.
*
* Precondition: const sha256_midstate a[len];
* len <= DAG_LEN_MAX;
*/
int rustsimplicity_0_6_hasDuplicates(const sha256_midstate* a, uint_fast32_t len);
#endif