Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Sargon into many crates #317

Open
Sajjon opened this issue Dec 21, 2024 · 0 comments
Open

Split Sargon into many crates #317

Sajjon opened this issue Dec 21, 2024 · 0 comments

Comments

@Sajjon
Copy link
Contributor

Sajjon commented Dec 21, 2024

Split into many crates

Strategy is to use cargo-modules to analyze modules and plan crates.

Goal is a broad and not a deep tree.

TOC

Crates

Note

We might prefix all crates with sargon-, but omitted here for clarity.

core^

Lowest level possible modules

Click me
  • Contains many fundamental small enums types with no associated value (discriminator)
  • No dependencies on any other sargon crates.
  • Depends only on "small" external crates

Modules

  • has_sample_values
  • u11
  • u30
  • u31
  • network_id
  • factor_source_kind
  • key_kind
  • entity_kind
  • string_utils
  • unsafe_id_stepper
  • constants - split out only non-radix specific ones, e.g. time
  • common_error - must reduce complexity of associated values, we can then per crate declare tiny traits with helper ctors, e.g.:
// in crate `core`
pub enum CommonError {
  ...
    #[error("Account Already Present {bad_value}")]
-    AccountAlreadyPresent { bad_value: AccountAddress } = 10074,
+    AccountAlreadyPresent { bad_value: String } = 10074,
  ...
}

+ // in crate `addresses`
+ pub trait FromAccountAlreadyPresentErr {
+ fn account_already_present(bad_value: AccountAddress) -> CommonError {
+   CommonError::AccountAlreadyPresent { bad_value: bad_value.to_string() }
+   }
+ }
+ impl FromAccountAlreadyPresentErr for CommonError {}

Dependencies

Internal

NONE

External

  • serde - hmm can we make serde a feature flag for core crate?
  • thiserror
  • uuid ??

[!IMPORTANT] > All crates below depend on core
but it should be the only sargon crate that ALL crates depend on.

testing^

Testing utils.

Click me

Modules

  • assert_json

Dependencies

Internal

  • core

External

  • serde
  • serde_json
  • thiserror
  • assert_json_diff
  • pretty_assertions

collections

Collection datatypes

Click me

Modules

  • identified_vec_of
  • index_set_extensions
  • index_map_extensions
  • hash_map_extensions

Dependencies

Internal

  • core

External

  • indexmap

bytes

Fixed size byte arrays.

Click me

Modules

  • exactly_60_bytes (encrypted mnemonic for security questions factor)
  • exactly_12_bytes (AES encryption)
  • exactly_65_bytes (Secp256k1Signature)
  • exactly_33_bytes (Secp256k1PublicKey)
  • exactly_64_bytes (Ed25519Signature)
  • exactly_32_bytes (Ed25519PublicKey)
  • exactly_29_bytes (PublicKeyHash)

Dependencies

Internal

  • core

External

  • hex

hash

Blake hash

Click me

bip39

Click me

Modules

  • bip39_seed
  • bip39_word_count
  • bip39_word
  • bip39_entropy
  • mnemonic
  • bip39_passphrase
  • mnemonic_with_passphrase

bip32

Click me

bip44-like-path

Click me

Dependencies

Internal

  • bip32

cap26-core

Click me

Dependencies

Internal

  • bip32

account-path

Click me

Dependencies

Internal

  • cap26-core

identity-path

Click me

Dependencies

Internal

  • cap26-core

derivation-path

Click me

Dependencies

Internal

  • bip44-like-path
  • account-path
  • identity-path

derivation

Click me

Modules

Dependencies

Internal

  • bip39
  • derivation-path

decimal192

Click me

Modules

  • decimal192

Dependencies

Internal

  • core

External

addresses

All address types.

Click me

Modules

Dependencies

Internal

External

factor-source-id

ID of FactorSources

Click me

Modules

  • factor_source_id
  • factor_source_id_from_hash
  • factor_source_id_from_address

Dependencies

Internal

  • hash
  • addresses

External

factor-sources

All different FactorSource types and the FactorSource enum.

Click me ### Modules - `factor_source` - `device_factor_source` - `ledger_factor_source` - `arculus_factor_source` - `password_factor_source` - `off_device_mnemonic_factor_source` - `security_questions_factor_source` - `yubikey_factor_source` - `trusted_contact_factor_source`

Dependencies

Internal

  • core
  • factor-source-id

External

keys-collector

Multi-factor-multi-path derivation

Click me ### Modules - `keys_collector` - `key_derivation_interactor` - `key_derivation_request` - `key_derivation_response` - `derivation_purpose`

Dependencies

Internal

  • derivation-path
  • factor-source

External

TEMPLATE

DESCRIPTION

Click me ### Modules

Dependencies

Internal

  • core

External

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant