Skip to content

Commit 0712347

Browse files
bkioshndamian-molinskidtscalacstevenjMr-Leshiy
authored
feat: rust key derivation (#1063)
* feat(cat-voice-package): add rust key derivation implementation Signed-off-by: bkioshn <[email protected]> * refactor: move uikit_example into utilities dir * fix: exclude example packages from melos bootstrap * refactor: move poc_local_storage into catalyst_voices/utilities * fix: key derivation implementation Signed-off-by: bkioshn <[email protected]> * fix: auto gen file Signed-off-by: bkioshn <[email protected]> * refactor: move catalyst_voices_remote_widgets package to catalyst_voices/utilities dir * refactor: move scripts into catalyst_voices dir * refactor: move catalyst_voices/packages into catalyst_voices/packages/internal * refactor: move catalyst_voices_packages into catalyst_voices/packages/external * refactor: move melos.yaml into catalyst_voices * fix: add word to dict Signed-off-by: bkioshn <[email protected]> * fix: key derivation implementation Signed-off-by: bkioshn <[email protected]> * fix: remove simple rs Signed-off-by: bkioshn <[email protected]> * fix: flutter format Signed-off-by: bkioshn <[email protected]> * refactor: move app into apps/voices dir * refactor: rename packages/external to packages/libs * docs: update README * style: dart lint issues * fix: builder target * fix: update paths in Earthfile * fix: uikit_example pubspec + libs examples deps override * chore: test * fix: update cspell and check markdown rules * fix: README formatting * fix: add description to module Signed-off-by: bkioshn <[email protected]> * fix: add cspell dict Signed-off-by: bkioshn <[email protected]> * feat: add sign data, verify sig, get pubkey Signed-off-by: bkioshn <[email protected]> * fix: auto gen file Signed-off-by: bkioshn <[email protected]> * feat: add rust project setup files Signed-off-by: bkioshn <[email protected]> * fix: flutter example Signed-off-by: bkioshn <[email protected]> * fix: build-web target path * fix: remove build-web target suffix separator * fix: wallet-automation tests target path * fix: wallet-automation builder target * fix: voices automation tests target * fix: code-generator target path * fix: typo and comment Signed-off-by: bkioshn <[email protected]> * fix: vscode launch.recommended paths * feat: catalyst_voices justfile * refactor: rename catalyst_voices_remote_widgets to remote_widgets * fix: remote_widget spelling and licence checks * fix: remote_widget analyzer * refactor: move repo-catalyst-voices from root Earthfile to catalyst_voices/Earthfile * fix: restructure rust key derivation and solve dispose value Signed-off-by: bkioshn <[email protected]> * fix: auto gen file Signed-off-by: bkioshn <[email protected]> * fix: ignore auto gen file Signed-off-by: bkioshn <[email protected]> * fix: remove auto gen file Signed-off-by: bkioshn <[email protected]> * fix: add justfile, fix readme, and remove run.sh Signed-off-by: bkioshn <[email protected]> * fix: markdown Signed-off-by: bkioshn <[email protected]> * fix: update git ignore Signed-off-by: bkioshn <[email protected]> * fix: ignore spelling check for dart auto gen file Signed-off-by: bkioshn <[email protected]> * fix: add ci check and build Signed-off-by: bkioshn <[email protected]> * fix: add earthfile and fix justfile Signed-off-by: bkioshn <[email protected]> * fix: deprecated api * fix: file drop * fix: force downgraded version of flutter_dropzone * chore: update repository links + codeowners paths * fix: deploy uikit workflow * fix: uikit_example earthly build target * fix: uikit deploy workflow path * chore: integration tests docs readme paths * chore: remote widget readme path * chore: markdown ignore macos pods path fix * chore: integration test scripts * chore: build_runner assets * chore: document flutter_dropzone issue * chore: revert dropzone fixes * chore: regenerate code * fix: remove frb generated rust file Signed-off-by: bkioshn <[email protected]> * fix: rename Signed-off-by: bkioshn <[email protected]> * fix: add word to dict Signed-off-by: bkioshn <[email protected]> * fix: cspell ignore auto gen flutter file Signed-off-by: bkioshn <[email protected]> * fix: auto gen file Signed-off-by: bkioshn <[email protected]> * fix: file path cspell Signed-off-by: bkioshn <[email protected]> * test: check target Signed-off-by: bkioshn <[email protected]> * fix: rust earthfile Signed-off-by: bkioshn <[email protected]> * chore: add blueprint.cue along with new Earthfile Signed-off-by: bkioshn <[email protected]> * chore: fix blueprint.cue Signed-off-by: bkioshn <[email protected]> * fix: linter and format Signed-off-by: bkioshn <[email protected]> * fix: remove simple.rs Signed-off-by: bkioshn <[email protected]> * fix: ci check create dummy Signed-off-by: bkioshn <[email protected]> * fix: ci check create dummy Signed-off-by: bkioshn <[email protected]> * fix: rust ci Signed-off-by: bkioshn <[email protected]> * fix: rust format Signed-off-by: bkioshn <[email protected]> * feat: add to hex functions Signed-off-by: bkioshn <[email protected]> * fix: auto gen file Signed-off-by: bkioshn <[email protected]> * fix: add toHex example to dart Signed-off-by: bkioshn <[email protected]> * fix: code-generator Signed-off-by: bkioshn <[email protected]> * fix: bump ci version to 3.2.24 Signed-off-by: bkioshn <[email protected]> * fix: update rustfmt.toml Signed-off-by: bkioshn <[email protected]> * fix: point flutter_rust_bridge ci to 3.2.23 Signed-off-by: bkioshn <[email protected]> * fix: ci bump version and deny.toml Signed-off-by: bkioshn <[email protected]> * fix: typo Signed-off-by: bkioshn <[email protected]> * make a separate target code-generator-local --------- Signed-off-by: bkioshn <[email protected]> Co-authored-by: Damian Molinski <[email protected]> Co-authored-by: Dominik Toton <[email protected]> Co-authored-by: Dominik Toton <[email protected]> Co-authored-by: Steven Johnson <[email protected]> Co-authored-by: Mr-Leshiy <[email protected]>
1 parent 8e7e569 commit 0712347

File tree

39 files changed

+3178
-389
lines changed

39 files changed

+3178
-389
lines changed

.config/dictionaries/project.dic

+3
Original file line numberDiff line numberDiff line change
@@ -320,5 +320,8 @@ xcodeproj
320320
xctest
321321
xctestrun
322322
xcworkspace
323+
xprv
324+
xpub
325+
xpublic
323326
xvfb
324327
yoroi

Earthfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.23 AS mdlint-ci
4-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.23 AS cspell-ci
5-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.2.23 AS postgresql-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.2.24 AS mdlint-ci
4+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.2.24 AS cspell-ci
5+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.2.24 AS postgresql-ci
66

77
FROM debian:stable-slim
88

catalyst-gateway/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.23 AS rust-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.24 AS rust-ci
44

55
#cspell: words rustfmt toolsets USERARCH stdcfgs
66

catalyst-gateway/event-db/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# the database and its associated software.
44
VERSION 0.8
55

6-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.2.23 AS postgresql-ci
6+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.2.24 AS postgresql-ci
77

88
# cspell: words
99

catalyst-gateway/rustfmt.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ max_width = 100
3636

3737
# Comments:
3838
normalize_comments = true
39-
normalize_doc_attributes = true
39+
normalize_doc_attributes = false
4040
wrap_comments = true
4141
comment_width = 90 # small excess is okay but prefer 80
4242
format_code_in_doc_comments = true
@@ -65,4 +65,4 @@ condense_wildcard_suffixes = true
6565
hex_literal_case = "Upper"
6666

6767
# Ignored files:
68-
ignore = []
68+
ignore = []

catalyst-gateway/tests/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
VERSION 0.8
2-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/spectral:v3.2.23 AS spectral-ci
2+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/spectral:v3.2.24 AS spectral-ci
33

44
# cspell: words oapi
55
# test-lint-openapi - OpenAPI linting from an artifact

catalyst-gateway/tests/api_tests/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.2.23 AS python-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.2.24 AS python-ci
44

55
builder:
66
FROM python-ci+python-base

catalyst_voices/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VERSION 0.8
22

33
IMPORT ../catalyst-gateway AS catalyst-gateway
4-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.23 AS flutter-ci
4+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.24 AS flutter-ci
55

66
# repo-catalyst-voices - Creates artifacts of all configuration files,
77
# packages and folders related to catalyst_voices frontend.

catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/Earthfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
2-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.23 AS flutter-ci
3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/playwright:v3.2.23 AS playwright-ci
2+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.24 AS flutter-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/playwright:v3.2.24 AS playwright-ci
44

55
deps:
66
DO playwright-ci+SETUP --workdir=/wallet-automation

catalyst_voices/packages/libs/catalyst_key_derivation/.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ migrate_working_dir/
2727
**/doc/api/
2828
.dart_tool/
2929
build/
30-
/web/pkg
30+
/web/pkg
31+
32+
# Ignore all auto generated file for rust
33+
rust/src/frb_generated.rs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
VERSION 0.8
2+
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter_rust_bridge:v3.2.24 AS flutter_rust_bridge
4+
5+
builder:
6+
FROM flutter_rust_bridge+builder
7+
COPY . .
8+
DO flutter_rust_bridge+CODE_GENERATOR_WEB
9+
10+
# Generated necessary files for running Flutter web locally.
11+
code-generator:
12+
FROM +builder
13+
14+
SAVE ARTIFACT ./assets/js assets_js
15+
SAVE ARTIFACT ./rust/src/frb_generated.rs frb_generated.rs
16+
SAVE ARTIFACT ./lib/src src
17+
18+
# Generated necessary files for running Flutter web locally and save it locally.
19+
code-generator-local:
20+
FROM +builder
21+
22+
SAVE ARTIFACT ./assets/js AS LOCAL ./assets/js
23+
SAVE ARTIFACT ./rust/src/frb_generated.rs AS LOCAL ./rust/src/frb_generated.rs
24+
SAVE ARTIFACT ./lib/src AS LOCAL ./lib/src
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# use with https://github.com/casey/just
2+
#
3+
# Catalyst Key Derivation developers' convenience functions.
4+
5+
# Generated necessary files using Earthly for running Flutter web locally.
6+
code-gen-web:
7+
earthly +code-generator
8+
9+
# Run local Flutter web.
10+
run-web: code-gen-web
11+
cd example
12+
flutter run --web-header=Cross-Origin-Opener-Policy=same-origin --web-header=Cross-Origin-Embedder-Policy=require-corp -d chrome

catalyst_voices/packages/libs/catalyst_key_derivation/README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* [Content](#content)
44
* [Features](#features)
5+
* [References](#references)
56
* [Requirements](#requirements)
67
* [Install](#install)
78
* [How to run](#how-to-run)
@@ -11,7 +12,14 @@
1112

1213
## Features
1314

14-
This package exposes a CIP-1852 Cardano HD Key Derivation.
15+
This package expose BIP32-Ed25519 and CIP-1852 Cardano HD Key Derivation.
16+
17+
## References
18+
19+
* [BIP32-Ed25519](https://input-output-hk.github.io/adrestia/static/Ed25519_BIP.pdf)
20+
* [SLIP-0023](https://github.com/satoshilabs/slips/blob/master/slip-0023.md)
21+
* [CIP-1852](https://cips.cardano.org/cip/CIP-1852)
22+
* [BIP-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
1523

1624
## Requirements
1725

@@ -27,8 +35,7 @@ dependencies:
2735
2836
## How to run
2937
30-
1. cd catalyst_key_derivation
31-
2. ./run.sh
38+
1. just run-web
3239
3340
## Example
3441
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version: "1.0.0"
2+
project: name: "catalyst-key-derivation"

catalyst_voices/packages/libs/catalyst_key_derivation/example/lib/main.dart

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: avoid_print
2+
13
import 'package:catalyst_key_derivation/catalyst_key_derivation.dart';
24
import 'package:flutter/material.dart';
35

@@ -34,7 +36,32 @@ class MyApp extends StatelessWidget {
3436
}
3537

3638
Future<void> _doMagic() async {
37-
// ignore: avoid_print
38-
print(await greet(name: 'Tom'));
39+
final xprv = await mnemonicToXprv(
40+
mnemonic: 'prevent company field green slot measure chief'
41+
' hero apple task eagle sunset endorse dress seed',
42+
);
43+
print('Master xprv ${xprv.inner}');
44+
45+
final xpub = await xprv.xpublicKey();
46+
print('Master xpub ${xpub.inner}');
47+
48+
final data = [1, 2, 3, 4];
49+
final sig = await xprv.signData(data: data);
50+
51+
final checkXprvSig = await xprv.verifySignature(data: data, signature: sig);
52+
print('Check signature by using xprv $checkXprvSig');
53+
54+
final checkXpubSig = await xpub.verifySignature(data: data, signature: sig);
55+
print('Check signature by using xpub $checkXpubSig');
56+
57+
const path = "m/1852'/1815'/0'/2/0";
58+
final childXprv = await xprv.deriveXprv(path: path);
59+
print('Derive xprv with $path: ${childXprv.inner}');
60+
61+
final childXprvHex = childXprv.toHex();
62+
print('Master xprv hex $childXprvHex');
63+
64+
xprv.drop();
65+
print('Master xprv dropped ${xprv.inner}');
3966
}
4067
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
library catalyst_key_derivation;
22

3-
export 'src/rust/api/simple.dart';
3+
export 'src/rust/api/key_derivation.dart';
44
export 'src/rust/frb_generated.dart' show RustLib;

0 commit comments

Comments
 (0)