sidan-gin 0.1.1__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sidan-gin might be problematic. Click here for more details.
- sidan_gin/__init__.py +2 -1
- sidan_gin/encryption/__init__.py +3 -0
- sidan_gin/encryption/cipher.py +127 -0
- sidan_gin/python_signing_module/.git +1 -0
- sidan_gin/python_signing_module/.gitignore +11 -0
- sidan_gin/python_signing_module/.vscode/settings.json +32 -0
- sidan_gin/python_signing_module/Cargo.lock +1914 -0
- sidan_gin/python_signing_module/Cargo.toml +14 -0
- sidan_gin/python_signing_module/README.md +2 -0
- sidan_gin/python_signing_module/__init__.py +1 -0
- sidan_gin/python_signing_module/build.rs +9 -0
- sidan_gin/python_signing_module/build.sh +9 -0
- sidan_gin/python_signing_module/src/CardanoSigner.py +70 -0
- sidan_gin/python_signing_module/src/_CardanoSigner.cpython-311-x86_64-linux-gnu.so +0 -0
- sidan_gin/python_signing_module/src/__init__.py +0 -0
- sidan_gin/python_signing_module/src/build/lib.linux-x86_64-cpython-311/_CardanoSigner.cpython-311-x86_64-linux-gnu.so +0 -0
- sidan_gin/python_signing_module/src/build/temp.linux-x86_64-cpython-311/signer.o +0 -0
- sidan_gin/python_signing_module/src/build/temp.linux-x86_64-cpython-311/signer_wrap.o +0 -0
- sidan_gin/python_signing_module/src/cxx.h +1149 -0
- sidan_gin/python_signing_module/src/lib.rs +57 -0
- sidan_gin/python_signing_module/src/lib.rs.h +403 -0
- sidan_gin/python_signing_module/src/libsigner.a +0 -0
- sidan_gin/python_signing_module/src/setup.py +16 -0
- sidan_gin/python_signing_module/src/signer.cpp +73 -0
- sidan_gin/python_signing_module/src/signer.h +37 -0
- sidan_gin/python_signing_module/src/signer.i +16 -0
- sidan_gin/python_signing_module/src/signer_wrap.cxx +4092 -0
- sidan_gin/wallet/__init__.py +3 -0
- sidan_gin/wallet/cli.py +13 -0
- sidan_gin/wallet/derivation_indices.py +30 -0
- sidan_gin/wallet/mnemonic.py +24 -0
- sidan_gin/wallet/root_key.py +24 -0
- sidan_gin/wallet/wallet.py +48 -0
- sidan_gin-0.1.5.dist-info/METADATA +63 -0
- sidan_gin-0.1.5.dist-info/RECORD +47 -0
- {sidan_gin-0.1.1.dist-info → sidan_gin-0.1.5.dist-info}/WHEEL +1 -1
- sidan_gin/signing/__init__.py +0 -3
- sidan_gin/signing/wallet.py +0 -40
- sidan_gin-0.1.1.dist-info/METADATA +0 -33
- sidan_gin-0.1.1.dist-info/RECORD +0 -17
- {sidan_gin-0.1.1.dist-info → sidan_gin-0.1.5.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
use whisky_wallet::{
|
|
2
|
+
derivation_indices::DerivationIndices, Account, MnemonicWallet, RootKeyWallet, Wallet,
|
|
3
|
+
WalletType,
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
#[cxx::bridge]
|
|
7
|
+
mod ffi {
|
|
8
|
+
// Rust types and signatures exposed to C++.
|
|
9
|
+
extern "Rust" {
|
|
10
|
+
type Signer;
|
|
11
|
+
fn new_mnemonic_signer(mnemonic_phrase: &str, derivation_path: &str) -> Box<Signer>;
|
|
12
|
+
fn new_bech32_signer(root_private_key: &str, derivation_path: &str) -> Box<Signer>;
|
|
13
|
+
fn new_cli_signer(ed25519_key: &str) -> Box<Signer>;
|
|
14
|
+
fn sign_transaction(&mut self, tx_hex: &str) -> String;
|
|
15
|
+
fn get_public_key(&self) -> String;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fn new_mnemonic_signer(mnemonic_phrase: &str, derivation_path: &str) -> Box<Signer> {
|
|
20
|
+
let wallet = Wallet::new(WalletType::MnemonicWallet(MnemonicWallet {
|
|
21
|
+
mnemonic_phrase: mnemonic_phrase.to_string(),
|
|
22
|
+
derivation_indices: DerivationIndices::from_str(derivation_path),
|
|
23
|
+
}));
|
|
24
|
+
let account = wallet.get_account().unwrap();
|
|
25
|
+
Box::new(Signer { account })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fn new_bech32_signer(root_private_key: &str, derivation_path: &str) -> Box<Signer> {
|
|
29
|
+
let wallet = Wallet::new(WalletType::RootKeyWallet(RootKeyWallet {
|
|
30
|
+
root_key: root_private_key.to_string(),
|
|
31
|
+
derivation_indices: DerivationIndices::from_str(derivation_path),
|
|
32
|
+
}));
|
|
33
|
+
let account = wallet.get_account().unwrap();
|
|
34
|
+
Box::new(Signer { account })
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fn new_cli_signer(ed25519_key: &str) -> Box<Signer> {
|
|
38
|
+
let wallet = Wallet::new_cli(ed25519_key);
|
|
39
|
+
let account = wallet.get_account().unwrap();
|
|
40
|
+
Box::new(Signer { account })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
struct Signer {
|
|
44
|
+
account: Account,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
impl Signer {
|
|
48
|
+
pub fn sign_transaction(&self, tx_hex: &str) -> String {
|
|
49
|
+
self.account.sign_transaction(tx_hex).unwrap_or_else(|_| {
|
|
50
|
+
panic!("Failed to sign transaction with the provided account");
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
pub fn get_public_key(&self) -> String {
|
|
55
|
+
self.account.public_key.to_hex()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <array>
|
|
3
|
+
#include <cstddef>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <new>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <type_traits>
|
|
8
|
+
#include <utility>
|
|
9
|
+
#if __cplusplus >= 201703L
|
|
10
|
+
#include <string_view>
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
namespace rust {
|
|
14
|
+
inline namespace cxxbridge1 {
|
|
15
|
+
// #include "rust/cxx.h"
|
|
16
|
+
|
|
17
|
+
struct unsafe_bitcopy_t;
|
|
18
|
+
|
|
19
|
+
namespace {
|
|
20
|
+
template <typename T>
|
|
21
|
+
class impl;
|
|
22
|
+
} // namespace
|
|
23
|
+
|
|
24
|
+
#ifndef CXXBRIDGE1_RUST_STRING
|
|
25
|
+
#define CXXBRIDGE1_RUST_STRING
|
|
26
|
+
class String final {
|
|
27
|
+
public:
|
|
28
|
+
String() noexcept;
|
|
29
|
+
String(const String &) noexcept;
|
|
30
|
+
String(String &&) noexcept;
|
|
31
|
+
~String() noexcept;
|
|
32
|
+
|
|
33
|
+
String(const std::string &);
|
|
34
|
+
String(const char *);
|
|
35
|
+
String(const char *, std::size_t);
|
|
36
|
+
String(const char16_t *);
|
|
37
|
+
String(const char16_t *, std::size_t);
|
|
38
|
+
#ifdef __cpp_char8_t
|
|
39
|
+
String(const char8_t *s);
|
|
40
|
+
String(const char8_t *s, std::size_t len);
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
static String lossy(const std::string &) noexcept;
|
|
44
|
+
static String lossy(const char *) noexcept;
|
|
45
|
+
static String lossy(const char *, std::size_t) noexcept;
|
|
46
|
+
static String lossy(const char16_t *) noexcept;
|
|
47
|
+
static String lossy(const char16_t *, std::size_t) noexcept;
|
|
48
|
+
|
|
49
|
+
String &operator=(const String &) & noexcept;
|
|
50
|
+
String &operator=(String &&) & noexcept;
|
|
51
|
+
|
|
52
|
+
explicit operator std::string() const;
|
|
53
|
+
|
|
54
|
+
const char *data() const noexcept;
|
|
55
|
+
std::size_t size() const noexcept;
|
|
56
|
+
std::size_t length() const noexcept;
|
|
57
|
+
bool empty() const noexcept;
|
|
58
|
+
|
|
59
|
+
const char *c_str() noexcept;
|
|
60
|
+
|
|
61
|
+
std::size_t capacity() const noexcept;
|
|
62
|
+
void reserve(size_t new_cap) noexcept;
|
|
63
|
+
|
|
64
|
+
using iterator = char *;
|
|
65
|
+
iterator begin() noexcept;
|
|
66
|
+
iterator end() noexcept;
|
|
67
|
+
|
|
68
|
+
using const_iterator = const char *;
|
|
69
|
+
const_iterator begin() const noexcept;
|
|
70
|
+
const_iterator end() const noexcept;
|
|
71
|
+
const_iterator cbegin() const noexcept;
|
|
72
|
+
const_iterator cend() const noexcept;
|
|
73
|
+
|
|
74
|
+
bool operator==(const String &) const noexcept;
|
|
75
|
+
bool operator!=(const String &) const noexcept;
|
|
76
|
+
bool operator<(const String &) const noexcept;
|
|
77
|
+
bool operator<=(const String &) const noexcept;
|
|
78
|
+
bool operator>(const String &) const noexcept;
|
|
79
|
+
bool operator>=(const String &) const noexcept;
|
|
80
|
+
|
|
81
|
+
void swap(String &) noexcept;
|
|
82
|
+
|
|
83
|
+
String(unsafe_bitcopy_t, const String &) noexcept;
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
struct lossy_t;
|
|
87
|
+
String(lossy_t, const char *, std::size_t) noexcept;
|
|
88
|
+
String(lossy_t, const char16_t *, std::size_t) noexcept;
|
|
89
|
+
friend void swap(String &lhs, String &rhs) noexcept { lhs.swap(rhs); }
|
|
90
|
+
|
|
91
|
+
std::array<std::uintptr_t, 3> repr;
|
|
92
|
+
};
|
|
93
|
+
#endif // CXXBRIDGE1_RUST_STRING
|
|
94
|
+
|
|
95
|
+
#ifndef CXXBRIDGE1_RUST_STR
|
|
96
|
+
#define CXXBRIDGE1_RUST_STR
|
|
97
|
+
class Str final {
|
|
98
|
+
public:
|
|
99
|
+
Str() noexcept;
|
|
100
|
+
Str(const String &) noexcept;
|
|
101
|
+
Str(const std::string &);
|
|
102
|
+
Str(const char *);
|
|
103
|
+
Str(const char *, std::size_t);
|
|
104
|
+
|
|
105
|
+
Str &operator=(const Str &) & noexcept = default;
|
|
106
|
+
|
|
107
|
+
explicit operator std::string() const;
|
|
108
|
+
#if __cplusplus >= 201703L
|
|
109
|
+
explicit operator std::string_view() const;
|
|
110
|
+
#endif
|
|
111
|
+
|
|
112
|
+
const char *data() const noexcept;
|
|
113
|
+
std::size_t size() const noexcept;
|
|
114
|
+
std::size_t length() const noexcept;
|
|
115
|
+
bool empty() const noexcept;
|
|
116
|
+
|
|
117
|
+
Str(const Str &) noexcept = default;
|
|
118
|
+
~Str() noexcept = default;
|
|
119
|
+
|
|
120
|
+
using iterator = const char *;
|
|
121
|
+
using const_iterator = const char *;
|
|
122
|
+
const_iterator begin() const noexcept;
|
|
123
|
+
const_iterator end() const noexcept;
|
|
124
|
+
const_iterator cbegin() const noexcept;
|
|
125
|
+
const_iterator cend() const noexcept;
|
|
126
|
+
|
|
127
|
+
bool operator==(const Str &) const noexcept;
|
|
128
|
+
bool operator!=(const Str &) const noexcept;
|
|
129
|
+
bool operator<(const Str &) const noexcept;
|
|
130
|
+
bool operator<=(const Str &) const noexcept;
|
|
131
|
+
bool operator>(const Str &) const noexcept;
|
|
132
|
+
bool operator>=(const Str &) const noexcept;
|
|
133
|
+
|
|
134
|
+
void swap(Str &) noexcept;
|
|
135
|
+
|
|
136
|
+
private:
|
|
137
|
+
class uninit;
|
|
138
|
+
Str(uninit) noexcept;
|
|
139
|
+
friend impl<Str>;
|
|
140
|
+
|
|
141
|
+
std::array<std::uintptr_t, 2> repr;
|
|
142
|
+
};
|
|
143
|
+
#endif // CXXBRIDGE1_RUST_STR
|
|
144
|
+
|
|
145
|
+
#ifndef CXXBRIDGE1_RUST_BOX
|
|
146
|
+
#define CXXBRIDGE1_RUST_BOX
|
|
147
|
+
template <typename T>
|
|
148
|
+
class Box final {
|
|
149
|
+
public:
|
|
150
|
+
using element_type = T;
|
|
151
|
+
using const_pointer =
|
|
152
|
+
typename std::add_pointer<typename std::add_const<T>::type>::type;
|
|
153
|
+
using pointer = typename std::add_pointer<T>::type;
|
|
154
|
+
|
|
155
|
+
Box() = delete;
|
|
156
|
+
Box(Box &&) noexcept;
|
|
157
|
+
~Box() noexcept;
|
|
158
|
+
|
|
159
|
+
explicit Box(const T &);
|
|
160
|
+
explicit Box(T &&);
|
|
161
|
+
|
|
162
|
+
Box &operator=(Box &&) & noexcept;
|
|
163
|
+
|
|
164
|
+
const T *operator->() const noexcept;
|
|
165
|
+
const T &operator*() const noexcept;
|
|
166
|
+
T *operator->() noexcept;
|
|
167
|
+
T &operator*() noexcept;
|
|
168
|
+
|
|
169
|
+
template <typename... Fields>
|
|
170
|
+
static Box in_place(Fields &&...);
|
|
171
|
+
|
|
172
|
+
void swap(Box &) noexcept;
|
|
173
|
+
|
|
174
|
+
static Box from_raw(T *) noexcept;
|
|
175
|
+
|
|
176
|
+
T *into_raw() noexcept;
|
|
177
|
+
|
|
178
|
+
/* Deprecated */ using value_type = element_type;
|
|
179
|
+
|
|
180
|
+
private:
|
|
181
|
+
class uninit;
|
|
182
|
+
class allocation;
|
|
183
|
+
Box(uninit) noexcept;
|
|
184
|
+
void drop() noexcept;
|
|
185
|
+
|
|
186
|
+
friend void swap(Box &lhs, Box &rhs) noexcept { lhs.swap(rhs); }
|
|
187
|
+
|
|
188
|
+
T *ptr;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
template <typename T>
|
|
192
|
+
class Box<T>::uninit {};
|
|
193
|
+
|
|
194
|
+
template <typename T>
|
|
195
|
+
class Box<T>::allocation {
|
|
196
|
+
static T *alloc() noexcept;
|
|
197
|
+
static void dealloc(T *) noexcept;
|
|
198
|
+
|
|
199
|
+
public:
|
|
200
|
+
allocation() noexcept : ptr(alloc()) {}
|
|
201
|
+
~allocation() noexcept {
|
|
202
|
+
if (this->ptr) {
|
|
203
|
+
dealloc(this->ptr);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
T *ptr;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
template <typename T>
|
|
210
|
+
Box<T>::Box(Box &&other) noexcept : ptr(other.ptr) {
|
|
211
|
+
other.ptr = nullptr;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
template <typename T>
|
|
215
|
+
Box<T>::Box(const T &val) {
|
|
216
|
+
allocation alloc;
|
|
217
|
+
::new (alloc.ptr) T(val);
|
|
218
|
+
this->ptr = alloc.ptr;
|
|
219
|
+
alloc.ptr = nullptr;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
template <typename T>
|
|
223
|
+
Box<T>::Box(T &&val) {
|
|
224
|
+
allocation alloc;
|
|
225
|
+
::new (alloc.ptr) T(std::move(val));
|
|
226
|
+
this->ptr = alloc.ptr;
|
|
227
|
+
alloc.ptr = nullptr;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
template <typename T>
|
|
231
|
+
Box<T>::~Box() noexcept {
|
|
232
|
+
if (this->ptr) {
|
|
233
|
+
this->drop();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
template <typename T>
|
|
238
|
+
Box<T> &Box<T>::operator=(Box &&other) & noexcept {
|
|
239
|
+
if (this->ptr) {
|
|
240
|
+
this->drop();
|
|
241
|
+
}
|
|
242
|
+
this->ptr = other.ptr;
|
|
243
|
+
other.ptr = nullptr;
|
|
244
|
+
return *this;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
template <typename T>
|
|
248
|
+
const T *Box<T>::operator->() const noexcept {
|
|
249
|
+
return this->ptr;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
template <typename T>
|
|
253
|
+
const T &Box<T>::operator*() const noexcept {
|
|
254
|
+
return *this->ptr;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
template <typename T>
|
|
258
|
+
T *Box<T>::operator->() noexcept {
|
|
259
|
+
return this->ptr;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
template <typename T>
|
|
263
|
+
T &Box<T>::operator*() noexcept {
|
|
264
|
+
return *this->ptr;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
template <typename T>
|
|
268
|
+
template <typename... Fields>
|
|
269
|
+
Box<T> Box<T>::in_place(Fields &&...fields) {
|
|
270
|
+
allocation alloc;
|
|
271
|
+
auto ptr = alloc.ptr;
|
|
272
|
+
::new (ptr) T{std::forward<Fields>(fields)...};
|
|
273
|
+
alloc.ptr = nullptr;
|
|
274
|
+
return from_raw(ptr);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
template <typename T>
|
|
278
|
+
void Box<T>::swap(Box &rhs) noexcept {
|
|
279
|
+
using std::swap;
|
|
280
|
+
swap(this->ptr, rhs.ptr);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
template <typename T>
|
|
284
|
+
Box<T> Box<T>::from_raw(T *raw) noexcept {
|
|
285
|
+
Box box = uninit{};
|
|
286
|
+
box.ptr = raw;
|
|
287
|
+
return box;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
template <typename T>
|
|
291
|
+
T *Box<T>::into_raw() noexcept {
|
|
292
|
+
T *raw = this->ptr;
|
|
293
|
+
this->ptr = nullptr;
|
|
294
|
+
return raw;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
template <typename T>
|
|
298
|
+
Box<T>::Box(uninit) noexcept {}
|
|
299
|
+
#endif // CXXBRIDGE1_RUST_BOX
|
|
300
|
+
|
|
301
|
+
#ifndef CXXBRIDGE1_RUST_OPAQUE
|
|
302
|
+
#define CXXBRIDGE1_RUST_OPAQUE
|
|
303
|
+
class Opaque {
|
|
304
|
+
public:
|
|
305
|
+
Opaque() = delete;
|
|
306
|
+
Opaque(const Opaque &) = delete;
|
|
307
|
+
~Opaque() = delete;
|
|
308
|
+
};
|
|
309
|
+
#endif // CXXBRIDGE1_RUST_OPAQUE
|
|
310
|
+
|
|
311
|
+
#ifndef CXXBRIDGE1_IS_COMPLETE
|
|
312
|
+
#define CXXBRIDGE1_IS_COMPLETE
|
|
313
|
+
namespace detail {
|
|
314
|
+
namespace {
|
|
315
|
+
template <typename T, typename = std::size_t>
|
|
316
|
+
struct is_complete : std::false_type {};
|
|
317
|
+
template <typename T>
|
|
318
|
+
struct is_complete<T, decltype(sizeof(T))> : std::true_type {};
|
|
319
|
+
} // namespace
|
|
320
|
+
} // namespace detail
|
|
321
|
+
#endif // CXXBRIDGE1_IS_COMPLETE
|
|
322
|
+
|
|
323
|
+
#ifndef CXXBRIDGE1_LAYOUT
|
|
324
|
+
#define CXXBRIDGE1_LAYOUT
|
|
325
|
+
class layout {
|
|
326
|
+
template <typename T>
|
|
327
|
+
friend std::size_t size_of();
|
|
328
|
+
template <typename T>
|
|
329
|
+
friend std::size_t align_of();
|
|
330
|
+
template <typename T>
|
|
331
|
+
static typename std::enable_if<std::is_base_of<Opaque, T>::value,
|
|
332
|
+
std::size_t>::type
|
|
333
|
+
do_size_of() {
|
|
334
|
+
return T::layout::size();
|
|
335
|
+
}
|
|
336
|
+
template <typename T>
|
|
337
|
+
static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
|
|
338
|
+
std::size_t>::type
|
|
339
|
+
do_size_of() {
|
|
340
|
+
return sizeof(T);
|
|
341
|
+
}
|
|
342
|
+
template <typename T>
|
|
343
|
+
static
|
|
344
|
+
typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
|
|
345
|
+
size_of() {
|
|
346
|
+
return do_size_of<T>();
|
|
347
|
+
}
|
|
348
|
+
template <typename T>
|
|
349
|
+
static typename std::enable_if<std::is_base_of<Opaque, T>::value,
|
|
350
|
+
std::size_t>::type
|
|
351
|
+
do_align_of() {
|
|
352
|
+
return T::layout::align();
|
|
353
|
+
}
|
|
354
|
+
template <typename T>
|
|
355
|
+
static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
|
|
356
|
+
std::size_t>::type
|
|
357
|
+
do_align_of() {
|
|
358
|
+
return alignof(T);
|
|
359
|
+
}
|
|
360
|
+
template <typename T>
|
|
361
|
+
static
|
|
362
|
+
typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
|
|
363
|
+
align_of() {
|
|
364
|
+
return do_align_of<T>();
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
template <typename T>
|
|
369
|
+
std::size_t size_of() {
|
|
370
|
+
return layout::size_of<T>();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
template <typename T>
|
|
374
|
+
std::size_t align_of() {
|
|
375
|
+
return layout::align_of<T>();
|
|
376
|
+
}
|
|
377
|
+
#endif // CXXBRIDGE1_LAYOUT
|
|
378
|
+
} // namespace cxxbridge1
|
|
379
|
+
} // namespace rust
|
|
380
|
+
|
|
381
|
+
struct Signer;
|
|
382
|
+
|
|
383
|
+
#ifndef CXXBRIDGE1_STRUCT_Signer
|
|
384
|
+
#define CXXBRIDGE1_STRUCT_Signer
|
|
385
|
+
struct Signer final : public ::rust::Opaque {
|
|
386
|
+
::rust::String sign_transaction(::rust::Str tx_hex) noexcept;
|
|
387
|
+
::rust::String get_public_key() const noexcept;
|
|
388
|
+
~Signer() = delete;
|
|
389
|
+
|
|
390
|
+
private:
|
|
391
|
+
friend ::rust::layout;
|
|
392
|
+
struct layout {
|
|
393
|
+
static ::std::size_t size() noexcept;
|
|
394
|
+
static ::std::size_t align() noexcept;
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
#endif // CXXBRIDGE1_STRUCT_Signer
|
|
398
|
+
|
|
399
|
+
::rust::Box<::Signer> new_mnemonic_signer(::rust::Str mnemonic_phrase, ::rust::Str derivation_path) noexcept;
|
|
400
|
+
|
|
401
|
+
::rust::Box<::Signer> new_bech32_signer(::rust::Str root_private_key, ::rust::Str derivation_path) noexcept;
|
|
402
|
+
|
|
403
|
+
::rust::Box<::Signer> new_cli_signer(::rust::Str ed25519_key) noexcept;
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from setuptools import setup, Extension
|
|
2
|
+
|
|
3
|
+
signer_module = Extension(
|
|
4
|
+
'_CardanoSigner',
|
|
5
|
+
sources=['signer_wrap.cxx', 'signer.cpp'], # signer_wrap.cxx is going to be generated by swig
|
|
6
|
+
extra_objects=["libsigner.a"] # this is the static library that we are going to link with
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
setup (
|
|
10
|
+
name = 'CardanoSigner',
|
|
11
|
+
version = '0.0',
|
|
12
|
+
author = "YOUR_NAME",
|
|
13
|
+
description = "CardanoSigner swig",
|
|
14
|
+
ext_modules = [signer_module],
|
|
15
|
+
py_modules = ["CardanoSigner"], # name of module that we're going import
|
|
16
|
+
)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#include "lib.rs.h"
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
// class MnemonicSigner
|
|
7
|
+
// {
|
|
8
|
+
// public:
|
|
9
|
+
// MnemonicSigner(std::string mnemonic, std::uint32_t account_index, std::uint32_t key_index)
|
|
10
|
+
// {
|
|
11
|
+
// this->mnemonic_secret = mnemonic;
|
|
12
|
+
// this->account_index = account_index;
|
|
13
|
+
// this->key_index = key_index;
|
|
14
|
+
// };
|
|
15
|
+
// ~MnemonicSigner() = default;
|
|
16
|
+
|
|
17
|
+
// std::string sign_tx(std::string tx_hex)
|
|
18
|
+
// {
|
|
19
|
+
// auto signer = new_mnemonic_signer(mnemonic_secret, account_index, key_index);
|
|
20
|
+
// std::string signed_tx = signer->sign_transaction(tx_hex).c_str();
|
|
21
|
+
// return signed_tx;
|
|
22
|
+
// };
|
|
23
|
+
|
|
24
|
+
// private:
|
|
25
|
+
// std::string mnemonic_secret;
|
|
26
|
+
// std::uint32_t account_index;
|
|
27
|
+
// std::uint32_t key_index;
|
|
28
|
+
// };
|
|
29
|
+
|
|
30
|
+
// class Bech32Signer
|
|
31
|
+
// {
|
|
32
|
+
// public:
|
|
33
|
+
// Bech32Signer(std::string bech32, std::uint32_t account_index, std::uint32_t key_index)
|
|
34
|
+
// {
|
|
35
|
+
// this->bech32_secret = bech32;
|
|
36
|
+
// this->account_index = account_index;
|
|
37
|
+
// this->key_index = key_index;
|
|
38
|
+
// };
|
|
39
|
+
// ~Bech32Signer() = default;
|
|
40
|
+
|
|
41
|
+
// std::string sign_tx(std::string tx_hex)
|
|
42
|
+
// {
|
|
43
|
+
// auto signer = new_bech32_signer(bech32_secret, account_index, key_index);
|
|
44
|
+
// std::string signed_tx = signer->sign_transaction(tx_hex).c_str();
|
|
45
|
+
// return signed_tx;
|
|
46
|
+
// };
|
|
47
|
+
|
|
48
|
+
// private:
|
|
49
|
+
// std::string bech32_secret;
|
|
50
|
+
// std::uint32_t account_index;
|
|
51
|
+
// std::uint32_t key_index;
|
|
52
|
+
// };
|
|
53
|
+
|
|
54
|
+
std::string sign_mnemonic(std::string mnemonic, std::string derivation_path, std::string tx_hex)
|
|
55
|
+
{
|
|
56
|
+
auto signer = new_mnemonic_signer(mnemonic, derivation_path);
|
|
57
|
+
std::string signed_tx = signer->sign_transaction(tx_hex).c_str();
|
|
58
|
+
return signed_tx;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
std::string sign_bech32(std::string bech32, std::string derivation_path, std::string tx_hex)
|
|
62
|
+
{
|
|
63
|
+
auto signer = new_bech32_signer(bech32, derivation_path);
|
|
64
|
+
std::string signed_tx = signer->sign_transaction(tx_hex).c_str();
|
|
65
|
+
return signed_tx;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
std::string sign_cli(std::string ed25519_key, std::string tx_hex)
|
|
69
|
+
{
|
|
70
|
+
auto signer = new_cli_signer(ed25519_key);
|
|
71
|
+
std::string signed_tx = signer->sign_transaction(tx_hex).c_str();
|
|
72
|
+
return signed_tx;
|
|
73
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#include "lib.rs.h"
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
// class MnemonicSigner
|
|
6
|
+
// {
|
|
7
|
+
// public:
|
|
8
|
+
// MnemonicSigner(std::string mnemonic, std::uint32_t account_index, std::uint32_t key_index);
|
|
9
|
+
// ~MnemonicSigner() = default;
|
|
10
|
+
|
|
11
|
+
// std::string sign_tx(std::string tx_hex);
|
|
12
|
+
|
|
13
|
+
// private:
|
|
14
|
+
// std::string mnemonic_secret;
|
|
15
|
+
// std::uint32_t account_index;
|
|
16
|
+
// std::uint32_t key_index;
|
|
17
|
+
// };
|
|
18
|
+
|
|
19
|
+
// class Bech32Signer
|
|
20
|
+
// {
|
|
21
|
+
// public:
|
|
22
|
+
// Bech32Signer(std::string bech32, std::uint32_t account_index, std::uint32_t key_index);
|
|
23
|
+
// ~Bech32Signer() = default;
|
|
24
|
+
|
|
25
|
+
// std::string sign_tx(std::string tx_hex);
|
|
26
|
+
|
|
27
|
+
// private:
|
|
28
|
+
// std::string bech32_secret;
|
|
29
|
+
// std::uint32_t account_index;
|
|
30
|
+
// std::uint32_t key_index;
|
|
31
|
+
// };
|
|
32
|
+
|
|
33
|
+
std::string sign_mnemonic(std::string mnemonic, std::string derivation_path, std::string tx_hex);
|
|
34
|
+
|
|
35
|
+
std::string sign_bech32(std::string bech32, std::string derivation_path, std::string tx_hex);
|
|
36
|
+
|
|
37
|
+
std::string sign_cli(std::string ed25519_key, std::string tx_hex);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
%module CardanoSigner
|
|
2
|
+
|
|
3
|
+
%include "std_string.i"
|
|
4
|
+
|
|
5
|
+
%{
|
|
6
|
+
#define SWIG_FILE_WITH_INIT
|
|
7
|
+
#include "lib.rs.h"
|
|
8
|
+
#include "signer.h"
|
|
9
|
+
#include <string>
|
|
10
|
+
%}
|
|
11
|
+
|
|
12
|
+
std::string sign_mnemonic(std::string mnemonic, std::string derivation_path, std::string tx_hex);
|
|
13
|
+
|
|
14
|
+
std::string sign_bech32(std::string bech32, std::string derivation_path, std::string tx_hex);
|
|
15
|
+
|
|
16
|
+
std::string sign_cli(std::string ed25519_key, std::string tx_hex);
|