Skip to content

Commit 5e0c8ee

Browse files
committedJun 7, 2020
add example to doc
1 parent bd51f74 commit 5e0c8ee

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed
 

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ TAGS
1717
*pbxproj
1818
*xcodeproj
1919
build
20-
*print*

‎README.org

+11-4
Original file line numberDiff line numberDiff line change
@@ -40,45 +40,52 @@ Add -DSR25519_FORCE_32BIT to force the use of 32 bit routines even when compilin
4040
cmake .. -DSR25519_FORCE_32BIT=true
4141
#+END_SRC
4242

43+
* Test
44+
#+BEGIN_SRC sh
45+
./sr25519DonnaTests
46+
#+END_SRC
4347
* Integration
48+
[[https://github.com/TerenceGe/sr25519-donna/blob/954fc1ff50aa919a05b23e28695dc92cab510467/example/CMakeLists.txt#L13][example]]
4449
#+BEGIN_SRC cmake
4550
include_directories(../build/include/) # replace it with your sr25519-donna installed location if required
4651
link_directories(../build/lib/) # replace it with your sr25519-donna installed location if required
4752

4853
add_executable(yourApp ${SOURCE_FILES})
4954
target_link_libraries(yourApp libsr25519_donna.dylib) # replace it with libsr25519_donna_static.a if you want to use static lib.
5055

51-
#+END_SRC
52-
* Test
53-
#+BEGIN_SRC sh
54-
./sr25519DonnaTests
5556
#+END_SRC
5657
* Usage
5758
** include
5859
#+BEGIN_SRC C
5960
#include "sr25519-donna.h"
6061
#+END_SRC
6162
** create keypair from seed
63+
[[https://github.com/TerenceGe/sr25519-donna/blob/954fc1ff50aa919a05b23e28695dc92cab510467/example/src/main.c#L27][example]]
6264
#+BEGIN_SRC C
6365
void sr25519_keypair_from_seed(sr25519_keypair keypair, const sr25519_mini_secret_key seed);
6466
#+END_SRC
6567
** sign message
68+
[[https://github.com/TerenceGe/sr25519-donna/blob/954fc1ff50aa919a05b23e28695dc92cab510467/example/src/main.c#L45][example]]
6669
#+BEGIN_SRC C
6770
void sr25519_sign(sr25519_signature signature, const sr25519_public_key public, const sr25519_secret_key secret, const uint8_t *message, unsigned long message_length);
6871
#+END_SRC
6972
** verify message
73+
[[https://github.com/TerenceGe/sr25519-donna/blob/954fc1ff50aa919a05b23e28695dc92cab510467/example/src/main.c#L64][example]]
7074
#+BEGIN_SRC C
7175
bool sr25519_verify(const sr25519_signature signature, const uint8_t *message, unsigned long message_length, const sr25519_public_key public);
7276
#+END_SRC
7377
** soft derive keypair
78+
[[https://github.com/TerenceGe/sr25519-donna/blob/954fc1ff50aa919a05b23e28695dc92cab510467/example/src/main.c#L77][example]]
7479
#+BEGIN_SRC C
7580
void sr25519_derive_keypair_soft(sr25519_keypair derived, const sr25519_keypair keypair, const sr25519_chain_code chain_code);
7681
#+END_SRC
7782
** soft derive public key
83+
[[https://github.com/TerenceGe/sr25519-donna/blob/954fc1ff50aa919a05b23e28695dc92cab510467/example/src/main.c#L100][example]]
7884
#+BEGIN_SRC C
7985
void sr25519_derive_public_soft(sr25519_public_key derived_public, const sr25519_public_key public, const sr25519_chain_code chain_code);
8086
#+END_SRC
8187
** hard derive keypair
88+
[[https://github.com/TerenceGe/sr25519-donna/blob/954fc1ff50aa919a05b23e28695dc92cab510467/example/src/main.c#L118][example]]
8289
#+BEGIN_SRC C
8390
void sr25519_derive_keypair_hard(sr25519_keypair derived, const sr25519_keypair keypair, const sr25519_chain_code chain_code);
8491
#+END_SRC

‎example/src/print.c

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "print.h"
2+
3+
void print_hash(const uint8_t *hash, size_t len) {
4+
for(int i = 0; i < len; i++) {
5+
printf("%02x", hash[i]);
6+
}
7+
putchar( '\n' );
8+
}

‎example/src/print.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef __PRINT_H__
2+
#define __PRINT_H__
3+
4+
#include <stdio.h>
5+
#include <stdint.h>
6+
7+
void print_hash(const uint8_t *ptr, size_t len);
8+
9+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.