2 void *worker_batch(void *task
)
4 union pubonionunion pubonion
;
5 u8
* const pk
= &pubonion
.raw
[PKPREFIX_SIZE
];
6 u8 secret
[SKPREFIX_SIZE
+ SECRET_LEN
];
7 u8
* const sk
= &secret
[SKPREFIX_SIZE
];
9 u8 hashsrc
[checksumstrlen
+ PUBLIC_LEN
+ 1];
10 u8 wpk
[PUBLIC_LEN
+ 1];
14 ge_p3 ge_batch
[BATCHNUM
];
15 fe
*(batchgez
)[BATCHNUM
];
16 fe tmp_batch
[BATCHNUM
];
17 bytes32 pk_batch
[BATCHNUM
];
23 struct statstruct
*st
= (struct statstruct
*)task
;
26 for (size_t b
= 0;b
< BATCHNUM
;++b
)
27 batchgez
[b
] = &GEZ(ge_batch
[b
]);
31 memcpy(secret
,skprefix
,SKPREFIX_SIZE
);
33 memset(&pubonion
,0,sizeof(pubonion
));
34 memcpy(pubonion
.raw
,pkprefix
,PKPREFIX_SIZE
);
35 // write version later as it will be overwritten by hash
36 memcpy(hashsrc
,checksumstr
,checksumstrlen
);
37 hashsrc
[checksumstrlen
+ PUBLIC_LEN
] = 0x03; // version
45 randombytes(seed
,sizeof(seed
));
46 ed25519_seckey_expand(sk
,seed
);
48 ge_scalarmult_base(&ge_public
,sk
);
50 for (counter
= 0;counter
< SIZE_MAX
-(8*BATCHNUM
);counter
+= 8*BATCHNUM
) {
53 if (unlikely(endwork
))
56 for (size_t b
= 0;b
< BATCHNUM
;++b
) {
57 ge_batch
[b
] = ge_public
;
58 ge_add(&sum
,&ge_public
,&ge_eightpoint
);
59 ge_p1p1_to_p3(&ge_public
,&sum
);
61 // NOTE: leaves unfinished
62 ge_p3_batchtobytes_destructive_1(pk_batch
,ge_batch
,batchgez
,tmp_batch
,BATCHNUM
);
65 st
->numcalc
.v
+= BATCHNUM
;
68 for (size_t b
= 0;b
< BATCHNUM
;++b
) {
69 DOFILTER(i
,pk_batch
[b
],{
71 shiftpk(wpk
,pk_batch
[b
],filter_len(i
));
74 DOFILTER(j
,wpk
,goto secondfind
);
79 shiftpk(wpk
,wpk
,filter_len(j
));
84 ge_p3_batchtobytes_destructive_finish(pk_batch
[b
],&ge_batch
[b
]);
86 memcpy(pk
,pk_batch
[b
],PUBLIC_LEN
);
87 // update secret key with counter
88 addsztoscalar32(sk
,counter
+ (b
* 8));
90 if ((sk
[0] & 248) != sk
[0] || ((sk
[31] & 63) | 64) != sk
[31])
96 memcpy(&hashsrc
[checksumstrlen
],pk
,PUBLIC_LEN
);
97 FIPS202_SHA3_256(hashsrc
,sizeof(hashsrc
),&pk
[PUBLIC_LEN
]);
99 pk
[PUBLIC_LEN
+ 2] = 0x03;
101 strcpy(base32_to(&sname
[direndpos
],pk
,PUBONION_LEN
),".onion");
102 onionready(sname
,secret
,pubonion
.raw
);
103 pk
[PUBLIC_LEN
] = 0; // what is this for?
104 // don't reuse same seed
116 sodium_memzero(secret
,sizeof(secret
));
117 sodium_memzero(seed
,sizeof(seed
));