mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-14 18:48:36 -07:00
Use X64 ASM ed25519 signatures on Linux/x64, which are about 10X faster. Will matter a lot for network controllers, not so much for other things.
This commit is contained in:
parent
a59912f3af
commit
beb170e4fb
68 changed files with 37123 additions and 68 deletions
58
ext/ed25519-amd64-asm/index_heap.c
Normal file
58
ext/ed25519-amd64-asm/index_heap.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "sc25519.h"
|
||||
#include "index_heap.h"
|
||||
|
||||
/* caller's responsibility to ensure hlen>=3 */
|
||||
void heap_init(unsigned long long *h, unsigned long long hlen, sc25519 *scalars)
|
||||
{
|
||||
h[0] = 0;
|
||||
unsigned long long i=1;
|
||||
while(i<hlen)
|
||||
heap_push(h, &i, i, scalars);
|
||||
}
|
||||
|
||||
void heap_extend(unsigned long long *h, unsigned long long oldlen, unsigned long long newlen, sc25519 *scalars)
|
||||
{
|
||||
unsigned long long i=oldlen;
|
||||
while(i<newlen)
|
||||
heap_push(h, &i, i, scalars);
|
||||
}
|
||||
|
||||
|
||||
void heap_push(unsigned long long *h, unsigned long long *hlen, unsigned long long elem, sc25519 *scalars)
|
||||
{
|
||||
/* Move up towards the root */
|
||||
/* XXX: Check size of hlen, whether cast to signed value is ok */
|
||||
signed long long pos = *hlen;
|
||||
signed long long ppos = (pos-1)/2;
|
||||
unsigned long long t;
|
||||
h[*hlen] = elem;
|
||||
while(pos > 0)
|
||||
{
|
||||
/* if(sc25519_lt_vartime(&scalars[h[ppos]], &scalars[h[pos]])) */
|
||||
if(sc25519_lt(&scalars[h[ppos]], &scalars[h[pos]]))
|
||||
{
|
||||
t = h[ppos];
|
||||
h[ppos] = h[pos];
|
||||
h[pos] = t;
|
||||
pos = ppos;
|
||||
ppos = (pos-1)/2;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
(*hlen)++;
|
||||
}
|
||||
|
||||
/* Put the largest value in the heap in max1, the second largest in max2 */
|
||||
void heap_get2max(unsigned long long *h, unsigned long long *max1, unsigned long long *max2, sc25519 *scalars)
|
||||
{
|
||||
*max1 = h[0];
|
||||
*max2 = h[1];
|
||||
if(sc25519_lt(&scalars[h[1]],&scalars[h[2]]))
|
||||
*max2 = h[2];
|
||||
}
|
||||
|
||||
/* After the root has been replaced, restore heap property */
|
||||
/* extern void heap_rootreplaced(unsigned long long *h, unsigned long long hlen, sc25519 *scalars);
|
||||
*/
|
||||
/* extern void heap_rootreplaced_shortscalars(unsigned long long *h, unsigned long long hlen, sc25519 *scalars);
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue