-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgenkeys.cc
48 lines (35 loc) · 837 Bytes
/
genkeys.cc
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
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include "intrinsics.h"
#include "log.h"
#include "ggentropy.h"
#include "libs/monocypher/monocypher.h"
int main( int argc, char ** argv ) {
u8 secret_key[ 32 ];
if( !ggentropy( secret_key, sizeof( secret_key ) ) )
FATAL( "ggentropy" );
u8 public_key[ 32 ];
crypto_sign_public_key( public_key, secret_key );
printf( "const u8 public_key[] = {" );
for( size_t i = 0; i < sizeof( public_key ); i++ ) {
if( i % 8 == 0 ) {
ggprint( "\n\t" );
}
else {
ggprint( " " );
}
ggprint( "0x{02x},", public_key[ i ] );
}
printf( "\n};\n" );
printf( "const u8 secret_key[] = {" );
for( size_t i = 0; i < sizeof( secret_key ); i++ ) {
if( i % 8 == 0 ) {
ggprint( "\n\t" );
}
else {
ggprint( " " );
}
ggprint( "0x{02x},", secret_key[ i ] );
}
printf( "\n};\n" );
return 0;
}