Skip to content

Commit

Permalink
feat(core): add Zcash Rust primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
krnak committed Sep 12, 2022
1 parent 031bac4 commit 8715425
Show file tree
Hide file tree
Showing 40 changed files with 3,516 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/.changelog.d/2510.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Zcash Rust primitives
4 changes: 4 additions & 0 deletions core/SConscript.firmware
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ if UI2:
SOURCE_MOD += [
'embed/extmod/rustmods/modtrezorui2.c',
]
if EVERYTHING:
SOURCE_MOD += [
'embed/extmod/rustmods/modtrezorzcashprimitives.c'
]

# modutime
SOURCE_MOD += [
Expand Down
4 changes: 4 additions & 0 deletions core/SConscript.unix
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ if UI2:
SOURCE_MOD += [
'embed/extmod/rustmods/modtrezorui2.c',
]
if EVERYTHING:
SOURCE_MOD += [
'embed/extmod/rustmods/modtrezorzcashprimitives.c'
]

# modutime
SOURCE_MOD += [
Expand Down
32 changes: 32 additions & 0 deletions core/embed/extmod/rustmods/modtrezorzcashprimitives.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of the Trezor project, https://trezor.io/
*
* Copyright (c) SatoshiLabs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "py/runtime.h"

#include "librust.h"

#if MICROPY_PY_TREZORPALLAS
MP_REGISTER_MODULE(MP_QSTR_trezorpallas, mp_module_trezorpallas,
MICROPY_PY_TREZORPALLAS);
#endif // MICROPY_PY_TREZORPALLAS

#if MICROPY_PY_TREZORPOSEIDON
MP_REGISTER_MODULE(MP_QSTR_trezorposeidon, mp_module_trezorposeidon,
MICROPY_PY_TREZORPOSEIDON);
#endif // MICROPY_PY_TREZORPOSEIDON
2 changes: 2 additions & 0 deletions core/embed/firmware/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
#define MICROPY_PY_TREZORUTILS (1)
#define MICROPY_PY_TREZORPROTO (1)
#define MICROPY_PY_TREZORUI2 (1)
#define MICROPY_PY_TREZORPALLAS (1)
#define MICROPY_PY_TREZORPOSEIDON (1)

#ifdef SYSTEM_VIEW
#define MP_PLAT_PRINT_STRN(str, len) segger_print(str, len)
Expand Down
152 changes: 152 additions & 0 deletions core/embed/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions core/embed/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@ default_features = false
version = "0.2.4"
default_features = false

[dependencies.ff]
version = "0.12"
default-features = false

[dependencies.group]
version = "0.12"
default-features = false

[dependencies.bitvec]
version = "1"
default-features = false

[dependencies.rand_core]
version = "0.6.3"
default_features = false

[dependencies.blake2b_simd]
version = "1"
default_features = false

[dependencies.pasta_curves]
version = "0.4.0"
default-features = false

[dependencies.reddsa]
version = "0.3.0"
default_features = false

# Build dependencies

[build-dependencies.bindgen]
Expand All @@ -69,3 +97,14 @@ version = "1.0.69"
[build-dependencies.glob]
optional = true
version = "0.3.0"

[patch.crates-io.blake2b_simd]
path = "./blake2b_hal"

[patch.crates-io.pasta_curves]
git = "https://github.com/jarys/pasta_curves"
branch = "unboxed-hashtocurve-and-uninline"

[patch.crates-io.reddsa]
git = "https://github.com/jarys/reddsa"
branch = "fix-alloc-feature"
16 changes: 16 additions & 0 deletions core/embed/rust/blake2b_hal/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions core/embed/rust/blake2b_hal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "blake2b_simd"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cty = "0.2.2"
Loading

0 comments on commit 8715425

Please sign in to comment.