-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from spacemeshos/cffi
Add remote-wallet crate for talking to hardware wallets
- Loading branch information
Showing
17 changed files
with
313 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# spacemesh-sdk | ||
Low-level Rust SDK | ||
|
||
This repository contains a low-level Rust SDK for the Spacemesh protocol and associated tooling. Various crates implement utilities such as key derivation and communication with Ledger hardware wallets (see inline Rust documentation for more information). Certain functions are externalized via Wasm bindings and CFFI bindings for use in upstream applications including [Smapp](https://github.com/spacemeshos/smapp/) and [Smcli](https://github.com/spacemeshos/smcli). | ||
|
||
See the Github workflow files for information on how to build on various platforms as a dynamic or static library. | ||
|
||
Portions of the codebase are forked from [Solana](https://github.com/solana-labs/solana/) with gratitude. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
|
||
|
||
language = "C++" | ||
language = "C" | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ | ||
|
||
#include <cstdarg> | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <ostream> | ||
#include <new> | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
|
||
|
||
extern "C" { | ||
|
||
/// derive_c generates a keypair from a 64-byte BIP39-compatible seed and BIP32 hierarchical | ||
/// derivation path. it returns 64 bytes. the first 32 bytes are the secret key and the second 32 | ||
/// bytes are the public key. | ||
/// this function does the same thing as derive_key, which is bound for wasm rather than CFFI. | ||
/// it adds error handling in order to be friendlier to the FFI caller: in case of an error, it | ||
/// prints the error and returns a null pointer. | ||
/// note that the caller must call derive_free_c() to free the returned memory as ownership is | ||
/// transferred to the caller. | ||
uint8_t *derive_c(const uint8_t *seed, size_t seedlen, const uint8_t *path, size_t pathlen); | ||
|
||
/// free the memory allocated and returned by the derive functions by transferring ownership back to | ||
/// Rust. must be called on each pointer returned by the functions precisely once to ensure safety. | ||
void derive_free_c(uint8_t *ptr); | ||
|
||
} // extern "C" | ||
/** | ||
* derive_c generates a keypair from a 64-byte BIP39-compatible seed and BIP32 hierarchical | ||
* derivation path. It writes the keypair bytes to result, which must be at least 64 bytes long. | ||
* It returns a status code, with a return value of zero indicating success. | ||
* This function does the same thing as derive_key, which is bound for wasm rather than CFFI. | ||
* it adds error handling in order to be friendlier to the FFI caller: in case of an error, it | ||
* prints the error and returns a nonzero value. | ||
*/ | ||
uint16_t derive_c(const uint8_t *seed, | ||
size_t seedlen, | ||
const char *derivation_path_ptr, | ||
uint8_t *result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.