From 850aa56691ee98fedc6c61c377e516c8864dccd0 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Tue, 9 Mar 2021 20:01:27 +0100 Subject: [PATCH] docs(core): Add references to SLIPs in the code. --- core/src/apps/bitcoin/ownership.py | 4 +++- core/src/apps/cardano/seed.py | 2 +- core/src/apps/common/seed.py | 5 +++++ core/src/apps/misc/cipher_key_value.py | 3 +++ core/src/apps/misc/get_ecdh_session_key.py | 3 +++ core/src/apps/misc/sign_identity.py | 3 +++ core/src/apps/webauthn/credential.py | 6 +++++- 7 files changed, 23 insertions(+), 3 deletions(-) diff --git a/core/src/apps/bitcoin/ownership.py b/core/src/apps/bitcoin/ownership.py index c00873ba0..587bbfa22 100644 --- a/core/src/apps/bitcoin/ownership.py +++ b/core/src/apps/bitcoin/ownership.py @@ -20,7 +20,9 @@ if False: from trezor.messages.TxInputType import EnumTypeInputScriptType from apps.common.coininfo import CoinInfo -# This module implements the SLIP-0019 proof of ownership format. +# This module implements the SLIP-0019 proof of ownership format, see +# https://github.com/satoshilabs/slips/blob/master/slip-0019.md. + _VERSION_MAGIC = b"SL\x00\x19" _FLAG_USER_CONFIRMED = 0x01 diff --git a/core/src/apps/cardano/seed.py b/core/src/apps/cardano/seed.py index b12e26372..e965d2b41 100644 --- a/core/src/apps/cardano/seed.py +++ b/core/src/apps/cardano/seed.py @@ -83,7 +83,7 @@ async def get_keychain(ctx: wire.Context) -> Keychain: assert secret_bytes is not None root = bip32.from_mnemonic_cardano(secret_bytes.decode(), passphrase) else: - # derive the root node via SLIP-0023 + # derive the root node via SLIP-0023 https://github.com/satoshilabs/slips/blob/master/slip-0022.md seed = await get_seed(ctx) root = bip32.from_seed(seed, "ed25519 cardano seed") diff --git a/core/src/apps/common/seed.py b/core/src/apps/common/seed.py index 3d161e0bc..81f5003b0 100644 --- a/core/src/apps/common/seed.py +++ b/core/src/apps/common/seed.py @@ -10,6 +10,11 @@ if False: class Slip21Node: + """ + This class implements the SLIP-0021 hierarchical derivation of symmetric keys, see + https://github.com/satoshilabs/slips/blob/master/slip-0021.md. + """ + def __init__(self, seed: bytes = None, data: bytes = None) -> None: assert seed is None or data is None, "Specify exactly one of: seed, data" if data is not None: diff --git a/core/src/apps/misc/cipher_key_value.py b/core/src/apps/misc/cipher_key_value.py index 5177de151..b88d5055d 100644 --- a/core/src/apps/misc/cipher_key_value.py +++ b/core/src/apps/misc/cipher_key_value.py @@ -11,6 +11,9 @@ if False: from trezor.messages.CipherKeyValue import CipherKeyValue from trezor.wire import Context +# This module implements the SLIP-0011 symmetric encryption of key-value pairs using a +# deterministic hierarchy, see https://github.com/satoshilabs/slips/blob/master/slip-0011.md. + async def cipher_key_value(ctx: Context, msg: CipherKeyValue) -> CipheredKeyValue: keychain = await get_keychain(ctx, "secp256k1", [AlwaysMatchingSchema]) diff --git a/core/src/apps/misc/get_ecdh_session_key.py b/core/src/apps/misc/get_ecdh_session_key.py index 42250c71c..da6692797 100644 --- a/core/src/apps/misc/get_ecdh_session_key.py +++ b/core/src/apps/misc/get_ecdh_session_key.py @@ -19,6 +19,9 @@ if False: from apps.common.paths import Bip32Path +# This module implements the SLIP-0017 Elliptic Curve Diffie-Hellman algorithm, using a +# determinstic hierarchy, see https://github.com/satoshilabs/slips/blob/master/slip-0017.md. + async def get_ecdh_session_key( ctx: wire.Context, msg: GetECDHSessionKey diff --git a/core/src/apps/misc/sign_identity.py b/core/src/apps/misc/sign_identity.py index dffa59cab..fc8945b0d 100644 --- a/core/src/apps/misc/sign_identity.py +++ b/core/src/apps/misc/sign_identity.py @@ -20,6 +20,9 @@ if False: from apps.common.paths import Bip32Path +# This module implements the SLIP-0013 authentication using a deterministic hierarchy, see +# https://github.com/satoshilabs/slips/blob/master/slip-0013.md. + async def sign_identity(ctx: wire.Context, msg: SignIdentity) -> SignedIdentity: if msg.ecdsa_curve_name is None: diff --git a/core/src/apps/webauthn/credential.py b/core/src/apps/webauthn/credential.py index 082b9a46e..103496219 100644 --- a/core/src/apps/webauthn/credential.py +++ b/core/src/apps/webauthn/credential.py @@ -103,8 +103,12 @@ class Credential: return U2fCredential.from_key_handle(data, rp_id_hash) -# SLIP-0022: FIDO2 credential ID format for HD wallets class Fido2Credential(Credential): + """ + This class implements the SLIP-0022 FIDO2 Credential ID format for HD wallets, see + https://github.com/satoshilabs/slips/blob/master/slip-0022.md. + """ + def __init__(self) -> None: super().__init__() self.rp_name: Optional[str] = None