Tidied up a little
This commit is contained in:
parent
4da3c6e62b
commit
1863c5fe37
1
Makefile
1
Makefile
@ -10,3 +10,4 @@ LDPATH = -Ltarget/debug
|
||||
|
||||
test: src/test.c include/ecrecover.h target/debug/libecrecover.so
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDPATH)
|
||||
./test
|
||||
|
12
README.md
12
README.md
@ -1,2 +1,14 @@
|
||||
# ecrecover
|
||||
FFI export of Ethereum's ecrecover
|
||||
|
||||
prerequisite:
|
||||
- a checked out copy of parity-ethereum (https://github.com/paritytech/parity-ethereum) checked out in the same directory this is
|
||||
|
||||
to compile:
|
||||
`cargo build`
|
||||
|
||||
to test:
|
||||
`make` (requires gcc)
|
||||
./test
|
||||
|
||||
(if you don't see `Test passed` then something went wrong).
|
@ -2,22 +2,23 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../include/ecrecover.h"
|
||||
|
||||
|
||||
char *bin2hex(unsigned char*, int);
|
||||
|
||||
unsigned char *hex2bin(const char*);
|
||||
|
||||
#define OUTPUT_LENGTH 32
|
||||
|
||||
int main(int arc, char **argv) {
|
||||
// copied from Ethereum tests
|
||||
unsigned char *input = hex2bin("47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03");
|
||||
unsigned char *expected = "000000000000000000000000c08b5542d177ac6686946920409741463a15dddb";
|
||||
unsigned char *output = malloc(OUTPUT_LENGTH * sizeof(unsigned char));
|
||||
ecrecover(input, output);
|
||||
assert(strcmp(bin2hex(output, OUTPUT_LENGTH), expected) == 0);
|
||||
printf("Test passed\n");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user