diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml index 3df8eb01..ba7eaa70 100644 --- a/.github/workflows/code-analysis.yml +++ b/.github/workflows/code-analysis.yml @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.13 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.13" - name: Install dependencies diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index e3ab3e4b..c94e5972 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.13 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.13" - name: Install dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ceefd917..91941234 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -68,7 +68,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -98,7 +98,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -126,7 +126,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/test_min_reqs.yml b/.github/workflows/test_min_reqs.yml index a77bf2df..63c9db8c 100644 --- a/.github/workflows/test_min_reqs.yml +++ b/.github/workflows/test_min_reqs.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.7 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.7" - name: Install minimum dependencies @@ -52,6 +52,7 @@ jobs: pip install pycryptodome==3.15 pip install pynacl==1.5 pip install py-sr25519-bindings==0.1.3 + pip install pytoniq-core-fork==0.1.47 pip install typing_extensions - name: Run tests run: | @@ -69,7 +70,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.8 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.8" - name: Install minimum dependencies @@ -84,6 +85,7 @@ jobs: pip install pycryptodome==3.15 pip install pynacl==1.5 pip install py-sr25519-bindings==0.1.3 + pip install pytoniq-core-fork==0.1.47 - name: Run tests run: | pytest @@ -100,7 +102,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" - name: Install minimum dependencies @@ -115,6 +117,7 @@ jobs: pip install pycryptodome==3.15 pip install pynacl==1.5 pip install py-sr25519-bindings==0.1.3 + pip install pytoniq-core-fork==0.1.47 - name: Run tests run: | pytest @@ -132,7 +135,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: Install minimum dependencies @@ -147,6 +150,7 @@ jobs: pip install pycryptodome==3.15 pip install pynacl==1.5 pip install py-sr25519-bindings==0.1.4 + pip install pytoniq-core-fork==0.1.47 - name: Run tests run: | pytest @@ -163,7 +167,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.11 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install minimum dependencies @@ -178,6 +182,7 @@ jobs: pip install pycryptodome==3.15 pip install pynacl==1.5 pip install py-sr25519-bindings==0.2.0 + pip install pytoniq-core-fork==0.1.47 - name: Run tests run: | pytest @@ -194,7 +199,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.12 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install minimum dependencies @@ -209,6 +214,7 @@ jobs: pip install pycryptodome==3.15 pip install pynacl==1.5 pip install py-sr25519-bindings==0.2.0 + pip install pytoniq-core-fork==0.1.47 - name: Run tests run: | pytest @@ -225,7 +231,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.13 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.13" - name: Install minimum dependencies @@ -240,6 +246,7 @@ jobs: pip install pycryptodome==3.15 pip install pynacl==1.5 pip install py-sr25519-bindings==0.2.2 + pip install pytoniq-core-fork==0.1.47 - name: Run tests run: | pytest diff --git a/LICENSE b/LICENSE index aafa2fda..1d823cb5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Emanuele Bellocchia +Copyright (c) 2026 Emanuele Bellocchia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 02a5f43b..ea9eab07 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Package dependencies: - [ed25519-blake2b](https://pypi.org/project/ed25519-blake2b/) for ed25519-blake2b curve - [pynacl](https://pypi.org/project/PyNaCl/) for ed25519 curve - [py-sr25519-bindings](https://pypi.org/project/py-sr25519-bindings/) for sr25519 curve +- [pytoniq-core-fork](https://github.com/ebellocchia/pytoniq-core) for TON primitives (my fork to extend compatibility to Python >= 3.7) Please note that, for the py-sr25519-bindings library, Rust is required to be installed. @@ -120,6 +121,7 @@ Supported BIP coins: - Terra - Tezos - Theta Network +- Ton - Tron - VeChain - Verge @@ -198,6 +200,7 @@ To run code analysis: - [Electrum](https://github.com/ebellocchia/bip_utils/tree/master/readme/electrum.md) - [Monero](https://github.com/ebellocchia/bip_utils/tree/master/readme/monero.md) - [Substrate](https://github.com/ebellocchia/bip_utils/tree/master/readme/substrate.md) +- [Ton](https://github.com/ebellocchia/bip_utils/tree/master/readme/ton.md) - [Utility libraries](https://github.com/ebellocchia/bip_utils/tree/master/readme/utility_libs.md) ## Documentation diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 181aa2b3..2a8f5101 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/benchmark_tests_base.py b/benchmark/tests/benchmark_tests_base.py index ec016698..442578b7 100644 --- a/benchmark/tests/benchmark_tests_base.py +++ b/benchmark/tests/benchmark_tests_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/bip44_tests.py b/benchmark/tests/bip44_tests.py index b1286992..c35ad072 100644 --- a/benchmark/tests/bip44_tests.py +++ b/benchmark/tests/bip44_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/ed25519_blake2b_tests.py b/benchmark/tests/ed25519_blake2b_tests.py index 5919601a..1d635b76 100644 --- a/benchmark/tests/ed25519_blake2b_tests.py +++ b/benchmark/tests/ed25519_blake2b_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/ed25519_kholaw_tests.py b/benchmark/tests/ed25519_kholaw_tests.py index f07b2f61..11f5e8a0 100644 --- a/benchmark/tests/ed25519_kholaw_tests.py +++ b/benchmark/tests/ed25519_kholaw_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/ed25519_tests.py b/benchmark/tests/ed25519_tests.py index 7f050b27..e1c8eabf 100644 --- a/benchmark/tests/ed25519_tests.py +++ b/benchmark/tests/ed25519_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/monero_tests.py b/benchmark/tests/monero_tests.py index 17d9d742..586713f5 100644 --- a/benchmark/tests/monero_tests.py +++ b/benchmark/tests/monero_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/nist256p1_tests.py b/benchmark/tests/nist256p1_tests.py index ae357d50..fd83c533 100644 --- a/benchmark/tests/nist256p1_tests.py +++ b/benchmark/tests/nist256p1_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/secp256k1_tests.py b/benchmark/tests/secp256k1_tests.py index 553c81a5..c07698f8 100644 --- a/benchmark/tests/secp256k1_tests.py +++ b/benchmark/tests/secp256k1_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/benchmark/tests/substrate_tests.py b/benchmark/tests/substrate_tests.py index 73567aa3..9b138e18 100644 --- a/benchmark/tests/substrate_tests.py +++ b/benchmark/tests/substrate_tests.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/__init__.py b/bip_utils/__init__.py index db3e642e..c7815ab5 100644 --- a/bip_utils/__init__.py +++ b/bip_utils/__init__.py @@ -116,6 +116,8 @@ SuiAddr, SuiAddrDecoder, SuiAddrEncoder, + TonAddr, + TonAddrEncoder, TrxAddr, TrxAddrDecoder, TrxAddrEncoder, @@ -384,6 +386,30 @@ SubstrateScaleU256Encoder, ) +# TON +from bip_utils.ton import ( + Ton, + TonKeyError, + TonPrivateKey, + TonPublicKey, +) +from bip_utils.ton.addr import ( + TonAddrVersions, + TonV3R1AddrEncoder, + TonV3R2AddrEncoder, + TonV4AddrEncoder, + TonV5R1AddrEncoder, +) +from bip_utils.ton.mnemonic import ( + TonLanguages, + TonMnemonic, + TonMnemonicGenerator, + TonMnemonicValidator, + TonSeedGenerator, + TonSeedTypes, + TonWordsNum, +) + # Utils from bip_utils.utils.crypto import ( AesEcbDecrypter, @@ -412,6 +438,8 @@ AlgoUtils, Base32Decoder, Base32Encoder, + Base64Decoder, + Base64Encoder, BitUtils, BytesUtils, DataBytes, diff --git a/bip_utils/addr/P2PKH_addr.py b/bip_utils/addr/P2PKH_addr.py index b61005de..45ac76ff 100644 --- a/bip_utils/addr/P2PKH_addr.py +++ b/bip_utils/addr/P2PKH_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/P2SH_addr.py b/bip_utils/addr/P2SH_addr.py index 9f29946e..6aad5f18 100644 --- a/bip_utils/addr/P2SH_addr.py +++ b/bip_utils/addr/P2SH_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/P2TR_addr.py b/bip_utils/addr/P2TR_addr.py index eed055b7..9d9c4704 100644 --- a/bip_utils/addr/P2TR_addr.py +++ b/bip_utils/addr/P2TR_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/P2WPKH_addr.py b/bip_utils/addr/P2WPKH_addr.py index 32d7e277..55f200a7 100644 --- a/bip_utils/addr/P2WPKH_addr.py +++ b/bip_utils/addr/P2WPKH_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/__init__.py b/bip_utils/addr/__init__.py index 39f67a6f..eea72977 100644 --- a/bip_utils/addr/__init__.py +++ b/bip_utils/addr/__init__.py @@ -76,6 +76,7 @@ SubstrateSr25519AddrEncoder, ) from bip_utils.addr.sui_addr import SuiAddr, SuiAddrDecoder, SuiAddrEncoder +from bip_utils.addr.ton_addr import TonAddr, TonAddrEncoder from bip_utils.addr.trx_addr import TrxAddr, TrxAddrDecoder, TrxAddrEncoder from bip_utils.addr.xlm_addr import XlmAddr, XlmAddrDecoder, XlmAddrEncoder, XlmAddrTypes from bip_utils.addr.xmr_addr import ( diff --git a/bip_utils/addr/ada_byron_addr.py b/bip_utils/addr/ada_byron_addr.py index e800b6c1..ee24ee6b 100644 --- a/bip_utils/addr/ada_byron_addr.py +++ b/bip_utils/addr/ada_byron_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/ada_shelley_addr.py b/bip_utils/addr/ada_shelley_addr.py index 0fcfad96..1f0e69e3 100644 --- a/bip_utils/addr/ada_shelley_addr.py +++ b/bip_utils/addr/ada_shelley_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/addr_dec_utils.py b/bip_utils/addr/addr_dec_utils.py index f201819a..1ec02265 100644 --- a/bip_utils/addr/addr_dec_utils.py +++ b/bip_utils/addr/addr_dec_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/addr_key_validator.py b/bip_utils/addr/addr_key_validator.py index a4aa8e43..20762e4d 100644 --- a/bip_utils/addr/addr_key_validator.py +++ b/bip_utils/addr/addr_key_validator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/algo_addr.py b/bip_utils/addr/algo_addr.py index cd7e87f2..315ae30e 100644 --- a/bip_utils/addr/algo_addr.py +++ b/bip_utils/addr/algo_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/aptos_addr.py b/bip_utils/addr/aptos_addr.py index d88fd6ac..07403c39 100644 --- a/bip_utils/addr/aptos_addr.py +++ b/bip_utils/addr/aptos_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/atom_addr.py b/bip_utils/addr/atom_addr.py index e3e103c3..b928092f 100644 --- a/bip_utils/addr/atom_addr.py +++ b/bip_utils/addr/atom_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/avax_addr.py b/bip_utils/addr/avax_addr.py index cbb12d14..a5b6fdfa 100644 --- a/bip_utils/addr/avax_addr.py +++ b/bip_utils/addr/avax_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/bch_addr_converter.py b/bip_utils/addr/bch_addr_converter.py index 8acb773a..84d251f3 100644 --- a/bip_utils/addr/bch_addr_converter.py +++ b/bip_utils/addr/bch_addr_converter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/egld_addr.py b/bip_utils/addr/egld_addr.py index 725a7d5d..0fc4f5be 100644 --- a/bip_utils/addr/egld_addr.py +++ b/bip_utils/addr/egld_addr.py @@ -1,5 +1,5 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/eos_addr.py b/bip_utils/addr/eos_addr.py index 83457130..3eed0382 100644 --- a/bip_utils/addr/eos_addr.py +++ b/bip_utils/addr/eos_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/ergo_addr.py b/bip_utils/addr/ergo_addr.py index 3866b519..49a9c0d7 100644 --- a/bip_utils/addr/ergo_addr.py +++ b/bip_utils/addr/ergo_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/eth_addr.py b/bip_utils/addr/eth_addr.py index 92bb529a..1dba5bc4 100644 --- a/bip_utils/addr/eth_addr.py +++ b/bip_utils/addr/eth_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/fil_addr.py b/bip_utils/addr/fil_addr.py index c44329c4..363fc1ea 100644 --- a/bip_utils/addr/fil_addr.py +++ b/bip_utils/addr/fil_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/iaddr_decoder.py b/bip_utils/addr/iaddr_decoder.py index 00b0e382..a2b2401b 100644 --- a/bip_utils/addr/iaddr_decoder.py +++ b/bip_utils/addr/iaddr_decoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/iaddr_encoder.py b/bip_utils/addr/iaddr_encoder.py index 7662e93a..d9e8afb9 100644 --- a/bip_utils/addr/iaddr_encoder.py +++ b/bip_utils/addr/iaddr_encoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/icx_addr.py b/bip_utils/addr/icx_addr.py index 64cde26e..f9ddd849 100644 --- a/bip_utils/addr/icx_addr.py +++ b/bip_utils/addr/icx_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/inj_addr.py b/bip_utils/addr/inj_addr.py index 3153cadf..3b7f5c4e 100644 --- a/bip_utils/addr/inj_addr.py +++ b/bip_utils/addr/inj_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/mvrk_addr.py b/bip_utils/addr/mvrk_addr.py index fe5abfd9..5819f407 100644 --- a/bip_utils/addr/mvrk_addr.py +++ b/bip_utils/addr/mvrk_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/nano_addr.py b/bip_utils/addr/nano_addr.py index b0e2596d..6afd26ef 100644 --- a/bip_utils/addr/nano_addr.py +++ b/bip_utils/addr/nano_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/near_addr.py b/bip_utils/addr/near_addr.py index 0357f352..132e298d 100644 --- a/bip_utils/addr/near_addr.py +++ b/bip_utils/addr/near_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/neo_addr.py b/bip_utils/addr/neo_addr.py index 0d84cf3c..79d1ae0a 100644 --- a/bip_utils/addr/neo_addr.py +++ b/bip_utils/addr/neo_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/neo_legacy_addr.py b/bip_utils/addr/neo_legacy_addr.py index 61c38cb3..f0259dd1 100644 --- a/bip_utils/addr/neo_legacy_addr.py +++ b/bip_utils/addr/neo_legacy_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/neo_n3_addr.py b/bip_utils/addr/neo_n3_addr.py index 2a3a4bb2..e0fe8c68 100644 --- a/bip_utils/addr/neo_n3_addr.py +++ b/bip_utils/addr/neo_n3_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/nim_addr.py b/bip_utils/addr/nim_addr.py index ea45030a..772ac8d6 100644 --- a/bip_utils/addr/nim_addr.py +++ b/bip_utils/addr/nim_addr.py @@ -1,5 +1,5 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/okex_addr.py b/bip_utils/addr/okex_addr.py index fb639a37..611a369a 100644 --- a/bip_utils/addr/okex_addr.py +++ b/bip_utils/addr/okex_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/one_addr.py b/bip_utils/addr/one_addr.py index f6aa70f9..9f7a8fc9 100644 --- a/bip_utils/addr/one_addr.py +++ b/bip_utils/addr/one_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/sol_addr.py b/bip_utils/addr/sol_addr.py index 95e9488a..ce6a4113 100644 --- a/bip_utils/addr/sol_addr.py +++ b/bip_utils/addr/sol_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/substrate_addr.py b/bip_utils/addr/substrate_addr.py index 3ba4ca59..e0e0626e 100644 --- a/bip_utils/addr/substrate_addr.py +++ b/bip_utils/addr/substrate_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/sui_addr.py b/bip_utils/addr/sui_addr.py index 52778bd2..9a1058c5 100644 --- a/bip_utils/addr/sui_addr.py +++ b/bip_utils/addr/sui_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/ton_addr.py b/bip_utils/addr/ton_addr.py new file mode 100644 index 00000000..b7c82a41 --- /dev/null +++ b/bip_utils/addr/ton_addr.py @@ -0,0 +1,84 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Module for TON address encoding.""" + +# Imports +from typing import Any, Union + +from bip_utils.addr.addr_key_validator import AddrKeyValidator +from bip_utils.addr.iaddr_encoder import IAddrEncoder +from bip_utils.ecc import IPublicKey +from bip_utils.ton.addr import ( + TonAddrVersions, + TonV3R1AddrEncoder, + TonV3R2AddrEncoder, + TonV4AddrEncoder, + TonV5R1AddrEncoder, +) +from bip_utils.ton.ton_keys import TonPublicKey + + +class TonAddrEncoder(IAddrEncoder): + """ + Ton address encoder class. + It allows the Ton address encoding. + """ + + @staticmethod + def EncodeKey(pub_key: Union[bytes, IPublicKey], + **kwargs: Any) -> str: + """ + Encode a public key to Ton address. + + Args: + pub_key (bytes or IPublicKey): Public key bytes or object + + Other Parameters: + version (TonAddrVersions, optional): Address version (default: v4) + is_bounceable (bool, optional) : Whether the address is bounceable (default: False) + + Returns: + str: Address string + + Raised: + ValueError: If the public key is not valid + TypeError: If the public key is not ed25519 + """ + version = kwargs.get("version", TonAddrVersions.V4) + if not isinstance(version, TonAddrVersions): + raise TypeError("Version is not an enumerative of TonAddrVersions") + is_bounceable = kwargs.get("is_bounceable", False) + + pub_key_obj = AddrKeyValidator.ValidateAndGetEd25519Key(pub_key) + ton_pub_key_obj = TonPublicKey.FromBytesOrKeyObject(pub_key_obj) + + if version == TonAddrVersions.V5R1: + return TonV5R1AddrEncoder(ton_pub_key_obj).Encode(is_bounceable) + elif version == TonAddrVersions.V4: + return TonV4AddrEncoder(ton_pub_key_obj).Encode(is_bounceable) + elif version == TonAddrVersions.V3R2: + return TonV3R2AddrEncoder(ton_pub_key_obj).Encode(is_bounceable) + else: + return TonV3R1AddrEncoder(ton_pub_key_obj).Encode(is_bounceable) + + +# Deprecated: only for compatibility, Encoder class shall be used instead +TonAddr = TonAddrEncoder diff --git a/bip_utils/addr/trx_addr.py b/bip_utils/addr/trx_addr.py index 397cdcb5..fea7162c 100644 --- a/bip_utils/addr/trx_addr.py +++ b/bip_utils/addr/trx_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/xlm_addr.py b/bip_utils/addr/xlm_addr.py index 8996d6e9..111f8c8a 100644 --- a/bip_utils/addr/xlm_addr.py +++ b/bip_utils/addr/xlm_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/xmr_addr.py b/bip_utils/addr/xmr_addr.py index 88c0d928..3cea927f 100644 --- a/bip_utils/addr/xmr_addr.py +++ b/bip_utils/addr/xmr_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/xrp_addr.py b/bip_utils/addr/xrp_addr.py index 31786334..d40b1764 100644 --- a/bip_utils/addr/xrp_addr.py +++ b/bip_utils/addr/xrp_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/xtz_addr.py b/bip_utils/addr/xtz_addr.py index 51946f93..dd6e15cd 100644 --- a/bip_utils/addr/xtz_addr.py +++ b/bip_utils/addr/xtz_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/addr/zil_addr.py b/bip_utils/addr/zil_addr.py index 78073601..040c0d6b 100644 --- a/bip_utils/addr/zil_addr.py +++ b/bip_utils/addr/zil_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_entropy_generator.py b/bip_utils/algorand/mnemonic/algorand_entropy_generator.py index 2f4f32f7..de16b0b0 100644 --- a/bip_utils/algorand/mnemonic/algorand_entropy_generator.py +++ b/bip_utils/algorand/mnemonic/algorand_entropy_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_mnemonic.py b/bip_utils/algorand/mnemonic/algorand_mnemonic.py index e36748e8..1a3d9e06 100644 --- a/bip_utils/algorand/mnemonic/algorand_mnemonic.py +++ b/bip_utils/algorand/mnemonic/algorand_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_mnemonic_decoder.py b/bip_utils/algorand/mnemonic/algorand_mnemonic_decoder.py index cfd3ceaa..2000b52f 100644 --- a/bip_utils/algorand/mnemonic/algorand_mnemonic_decoder.py +++ b/bip_utils/algorand/mnemonic/algorand_mnemonic_decoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_mnemonic_encoder.py b/bip_utils/algorand/mnemonic/algorand_mnemonic_encoder.py index d7896614..cca062b8 100644 --- a/bip_utils/algorand/mnemonic/algorand_mnemonic_encoder.py +++ b/bip_utils/algorand/mnemonic/algorand_mnemonic_encoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_mnemonic_generator.py b/bip_utils/algorand/mnemonic/algorand_mnemonic_generator.py index 3a269ece..e7efff4d 100644 --- a/bip_utils/algorand/mnemonic/algorand_mnemonic_generator.py +++ b/bip_utils/algorand/mnemonic/algorand_mnemonic_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_mnemonic_utils.py b/bip_utils/algorand/mnemonic/algorand_mnemonic_utils.py index d23dcb58..e89a2ca0 100644 --- a/bip_utils/algorand/mnemonic/algorand_mnemonic_utils.py +++ b/bip_utils/algorand/mnemonic/algorand_mnemonic_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_mnemonic_validator.py b/bip_utils/algorand/mnemonic/algorand_mnemonic_validator.py index 2f2f5083..960c7fc7 100644 --- a/bip_utils/algorand/mnemonic/algorand_mnemonic_validator.py +++ b/bip_utils/algorand/mnemonic/algorand_mnemonic_validator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/algorand/mnemonic/algorand_seed_generator.py b/bip_utils/algorand/mnemonic/algorand_seed_generator.py index d96e273f..2aa2f6e9 100644 --- a/bip_utils/algorand/mnemonic/algorand_seed_generator.py +++ b/bip_utils/algorand/mnemonic/algorand_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/base58/base58.py b/bip_utils/base58/base58.py index 24dd39d8..149481cc 100644 --- a/bip_utils/base58/base58.py +++ b/bip_utils/base58/base58.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/base58/base58_ex.py b/bip_utils/base58/base58_ex.py index 8821beb2..24e4855b 100644 --- a/bip_utils/base58/base58_ex.py +++ b/bip_utils/base58/base58_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/base58/base58_xmr.py b/bip_utils/base58/base58_xmr.py index 1314a23a..0cdd372b 100644 --- a/bip_utils/base58/base58_xmr.py +++ b/bip_utils/base58/base58_xmr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bech32/bch_bech32.py b/bip_utils/bech32/bch_bech32.py index 6ae315e5..4600aef0 100644 --- a/bip_utils/bech32/bch_bech32.py +++ b/bip_utils/bech32/bch_bech32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bech32/bech32.py b/bip_utils/bech32/bech32.py index f83a23d3..24f75c5f 100644 --- a/bip_utils/bech32/bech32.py +++ b/bip_utils/bech32/bech32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bech32/bech32_base.py b/bip_utils/bech32/bech32_base.py index c529fc4d..365b73d4 100644 --- a/bip_utils/bech32/bech32_base.py +++ b/bip_utils/bech32/bech32_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bech32/bech32_ex.py b/bip_utils/bech32/bech32_ex.py index 3f5a6f01..25564569 100644 --- a/bip_utils/bech32/bech32_ex.py +++ b/bip_utils/bech32/bech32_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bech32/segwit_bech32.py b/bip_utils/bech32/segwit_bech32.py index e997dac5..a0494050 100644 --- a/bip_utils/bech32/segwit_bech32.py +++ b/bip_utils/bech32/segwit_bech32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/base/bip32_base.py b/bip_utils/bip/bip32/base/bip32_base.py index e63ba5e4..7a6eb46f 100644 --- a/bip_utils/bip/bip32/base/bip32_base.py +++ b/bip_utils/bip/bip32/base/bip32_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/base/ibip32_key_derivator.py b/bip_utils/bip/bip32/base/ibip32_key_derivator.py index 65f9a273..48a15e81 100644 --- a/bip_utils/bip/bip32/base/ibip32_key_derivator.py +++ b/bip_utils/bip/bip32/base/ibip32_key_derivator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/base/ibip32_mst_key_generator.py b/bip_utils/bip/bip32/base/ibip32_mst_key_generator.py index ccf779aa..a376a40a 100644 --- a/bip_utils/bip/bip32/base/ibip32_mst_key_generator.py +++ b/bip_utils/bip/bip32/base/ibip32_mst_key_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_const.py b/bip_utils/bip/bip32/bip32_const.py index b8c8ffd2..c3e745ca 100644 --- a/bip_utils/bip/bip32/bip32_const.py +++ b/bip_utils/bip/bip32/bip32_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_ex.py b/bip_utils/bip/bip32/bip32_ex.py index dd13fd0d..e5dc2072 100644 --- a/bip_utils/bip/bip32/bip32_ex.py +++ b/bip_utils/bip/bip32/bip32_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_key_data.py b/bip_utils/bip/bip32/bip32_key_data.py index a61428ee..ae130309 100644 --- a/bip_utils/bip/bip32/bip32_key_data.py +++ b/bip_utils/bip/bip32/bip32_key_data.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_key_net_ver.py b/bip_utils/bip/bip32/bip32_key_net_ver.py index f1da7f96..340b6c8f 100644 --- a/bip_utils/bip/bip32/bip32_key_net_ver.py +++ b/bip_utils/bip/bip32/bip32_key_net_ver.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_key_ser.py b/bip_utils/bip/bip32/bip32_key_ser.py index 893139c2..da6890bd 100644 --- a/bip_utils/bip/bip32/bip32_key_ser.py +++ b/bip_utils/bip/bip32/bip32_key_ser.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_keys.py b/bip_utils/bip/bip32/bip32_keys.py index b919ecbb..c5bbb30d 100644 --- a/bip_utils/bip/bip32/bip32_keys.py +++ b/bip_utils/bip/bip32/bip32_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_path.py b/bip_utils/bip/bip32/bip32_path.py index 88dc0652..c051c4c2 100644 --- a/bip_utils/bip/bip32/bip32_path.py +++ b/bip_utils/bip/bip32/bip32_path.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/bip32_utils.py b/bip_utils/bip/bip32/bip32_utils.py index 0a593094..a9448677 100644 --- a/bip_utils/bip/bip32/bip32_utils.py +++ b/bip_utils/bip/bip32/bip32_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519.py b/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519.py index 363cd267..d402ddc1 100644 --- a/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519.py +++ b/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519_key_derivator.py b/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519_key_derivator.py index 9532d60d..53c28ea8 100644 --- a/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519_key_derivator.py +++ b/bip_utils/bip/bip32/kholaw/bip32_kholaw_ed25519_key_derivator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/kholaw/bip32_kholaw_key_derivator_base.py b/bip_utils/bip/bip32/kholaw/bip32_kholaw_key_derivator_base.py index 81f17ea3..3f820050 100644 --- a/bip_utils/bip/bip32/kholaw/bip32_kholaw_key_derivator_base.py +++ b/bip_utils/bip/bip32/kholaw/bip32_kholaw_key_derivator_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/kholaw/bip32_kholaw_mst_key_generator.py b/bip_utils/bip/bip32/kholaw/bip32_kholaw_mst_key_generator.py index ebb7b676..baf29048 100644 --- a/bip_utils/bip/bip32/kholaw/bip32_kholaw_mst_key_generator.py +++ b/bip_utils/bip/bip32/kholaw/bip32_kholaw_mst_key_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519.py b/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519.py index 6fcee021..28f9a825 100644 --- a/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519.py +++ b/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519_blake2b.py b/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519_blake2b.py index a721cedb..9cbd292b 100644 --- a/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519_blake2b.py +++ b/bip_utils/bip/bip32/slip10/bip32_slip10_ed25519_blake2b.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/slip10/bip32_slip10_key_derivator.py b/bip_utils/bip/bip32/slip10/bip32_slip10_key_derivator.py index e8d75f67..208ad355 100644 --- a/bip_utils/bip/bip32/slip10/bip32_slip10_key_derivator.py +++ b/bip_utils/bip/bip32/slip10/bip32_slip10_key_derivator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/slip10/bip32_slip10_mst_key_generator.py b/bip_utils/bip/bip32/slip10/bip32_slip10_mst_key_generator.py index 45634bce..acfd866c 100644 --- a/bip_utils/bip/bip32/slip10/bip32_slip10_mst_key_generator.py +++ b/bip_utils/bip/bip32/slip10/bip32_slip10_mst_key_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/slip10/bip32_slip10_nist256p1.py b/bip_utils/bip/bip32/slip10/bip32_slip10_nist256p1.py index 58a6713e..50d033a7 100644 --- a/bip_utils/bip/bip32/slip10/bip32_slip10_nist256p1.py +++ b/bip_utils/bip/bip32/slip10/bip32_slip10_nist256p1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip32/slip10/bip32_slip10_secp256k1.py b/bip_utils/bip/bip32/slip10/bip32_slip10_secp256k1.py index c8c75c11..a3822a4f 100644 --- a/bip_utils/bip/bip32/slip10/bip32_slip10_secp256k1.py +++ b/bip_utils/bip/bip32/slip10/bip32_slip10_secp256k1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip38/bip38.py b/bip_utils/bip/bip38/bip38.py index 020023b7..a5ec2a36 100644 --- a/bip_utils/bip/bip38/bip38.py +++ b/bip_utils/bip/bip38/bip38.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip38/bip38_addr.py b/bip_utils/bip/bip38/bip38_addr.py index bce32618..ced168c2 100644 --- a/bip_utils/bip/bip38/bip38_addr.py +++ b/bip_utils/bip/bip38/bip38_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip38/bip38_ec.py b/bip_utils/bip/bip38/bip38_ec.py index abf95069..3bb730ab 100644 --- a/bip_utils/bip/bip38/bip38_ec.py +++ b/bip_utils/bip/bip38/bip38_ec.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip38/bip38_no_ec.py b/bip_utils/bip/bip38/bip38_no_ec.py index 945befde..04732beb 100644 --- a/bip_utils/bip/bip38/bip38_no_ec.py +++ b/bip_utils/bip/bip38/bip38_no_ec.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_entropy_generator.py b/bip_utils/bip/bip39/bip39_entropy_generator.py index b25842bc..49855ee9 100644 --- a/bip_utils/bip/bip39/bip39_entropy_generator.py +++ b/bip_utils/bip/bip39/bip39_entropy_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_mnemonic.py b/bip_utils/bip/bip39/bip39_mnemonic.py index fc0c5e5b..a4665c2b 100644 --- a/bip_utils/bip/bip39/bip39_mnemonic.py +++ b/bip_utils/bip/bip39/bip39_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_mnemonic_decoder.py b/bip_utils/bip/bip39/bip39_mnemonic_decoder.py index a566c8ae..7998a367 100644 --- a/bip_utils/bip/bip39/bip39_mnemonic_decoder.py +++ b/bip_utils/bip/bip39/bip39_mnemonic_decoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_mnemonic_encoder.py b/bip_utils/bip/bip39/bip39_mnemonic_encoder.py index bd6dc6f5..1fad310e 100644 --- a/bip_utils/bip/bip39/bip39_mnemonic_encoder.py +++ b/bip_utils/bip/bip39/bip39_mnemonic_encoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_mnemonic_generator.py b/bip_utils/bip/bip39/bip39_mnemonic_generator.py index f241e28d..4002dbe2 100644 --- a/bip_utils/bip/bip39/bip39_mnemonic_generator.py +++ b/bip_utils/bip/bip39/bip39_mnemonic_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_mnemonic_utils.py b/bip_utils/bip/bip39/bip39_mnemonic_utils.py index 36dec516..55642210 100644 --- a/bip_utils/bip/bip39/bip39_mnemonic_utils.py +++ b/bip_utils/bip/bip39/bip39_mnemonic_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_mnemonic_validator.py b/bip_utils/bip/bip39/bip39_mnemonic_validator.py index 03d624a3..0ae42b67 100644 --- a/bip_utils/bip/bip39/bip39_mnemonic_validator.py +++ b/bip_utils/bip/bip39/bip39_mnemonic_validator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/bip39_seed_generator.py b/bip_utils/bip/bip39/bip39_seed_generator.py index eff5b327..5d84a8e8 100644 --- a/bip_utils/bip/bip39/bip39_seed_generator.py +++ b/bip_utils/bip/bip39/bip39_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip39/ibip39_seed_generator.py b/bip_utils/bip/bip39/ibip39_seed_generator.py index 9ef2263c..605cb885 100644 --- a/bip_utils/bip/bip39/ibip39_seed_generator.py +++ b/bip_utils/bip/bip39/ibip39_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip44/bip44.py b/bip_utils/bip/bip44/bip44.py index fc4498ec..77bfb8f9 100644 --- a/bip_utils/bip/bip44/bip44.py +++ b/bip_utils/bip/bip44/bip44.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip44_base/bip44_base.py b/bip_utils/bip/bip44_base/bip44_base.py index 729b28e8..fa9984b4 100644 --- a/bip_utils/bip/bip44_base/bip44_base.py +++ b/bip_utils/bip/bip44_base/bip44_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip44_base/bip44_base_ex.py b/bip_utils/bip/bip44_base/bip44_base_ex.py index 0915286d..384368cb 100644 --- a/bip_utils/bip/bip44_base/bip44_base_ex.py +++ b/bip_utils/bip/bip44_base/bip44_base_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip44_base/bip44_keys.py b/bip_utils/bip/bip44_base/bip44_keys.py index f471e14b..cdff2f67 100644 --- a/bip_utils/bip/bip44_base/bip44_keys.py +++ b/bip_utils/bip/bip44_base/bip44_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip49/bip49.py b/bip_utils/bip/bip49/bip49.py index 1be45d54..086cd0c1 100644 --- a/bip_utils/bip/bip49/bip49.py +++ b/bip_utils/bip/bip49/bip49.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip84/bip84.py b/bip_utils/bip/bip84/bip84.py index 9da708fb..f5cfb5f3 100644 --- a/bip_utils/bip/bip84/bip84.py +++ b/bip_utils/bip/bip84/bip84.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/bip86/bip86.py b/bip_utils/bip/bip86/bip86.py index 801a9c3a..706fc6f3 100644 --- a/bip_utils/bip/bip86/bip86.py +++ b/bip_utils/bip/bip86/bip86.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip44/bip44_coins.py b/bip_utils/bip/conf/bip44/bip44_coins.py index 286f3a3f..57f2274f 100644 --- a/bip_utils/bip/conf/bip44/bip44_coins.py +++ b/bip_utils/bip/conf/bip44/bip44_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -109,6 +109,7 @@ class Bip44Coins(BipCoins): TERRA = auto() TEZOS = auto() THETA = auto() + TON = auto() TRON = auto() VECHAIN = auto() VERGE = auto() diff --git a/bip_utils/bip/conf/bip44/bip44_conf.py b/bip_utils/bip/conf/bip44/bip44_conf.py index a98a5082..0b5bfcbe 100644 --- a/bip_utils/bip/conf/bip44/bip44_conf.py +++ b/bip_utils/bip/conf/bip44/bip44_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -50,6 +50,7 @@ SolAddrEncoder, SubstrateEd25519AddrEncoder, SuiAddrEncoder, + TonAddrEncoder, TrxAddrEncoder, XlmAddrEncoder, XlmAddrTypes, @@ -1340,6 +1341,21 @@ class Bip44Conf: addr_cls=EthAddrEncoder, addr_params={}, ) + # Configuration for Ton + Ton: BipCoinConf = BipCoinConf( + coin_names=CoinsConf.Ton.CoinNames(), + coin_idx=Slip44.TON, + is_testnet=False, + def_path=DER_PATH_HARDENED_SHORT, + key_net_ver=_BIP44_BTC_KEY_NET_VER_MAIN, + wif_net_ver=None, + bip32_cls=Bip32Slip10Ed25519, + addr_cls=TonAddrEncoder, + addr_params={ + "version": CoinsConf.Ton.ParamByKey("version"), + "is_bounceable": CoinsConf.Ton.ParamByKey("is_bounceable"), + }, + ) # Configuration for Tron Tron: BipCoinConf = BipCoinConf( diff --git a/bip_utils/bip/conf/bip44/bip44_conf_getter.py b/bip_utils/bip/conf/bip44/bip44_conf_getter.py index 6b89d414..0366f50e 100644 --- a/bip_utils/bip/conf/bip44/bip44_conf_getter.py +++ b/bip_utils/bip/conf/bip44/bip44_conf_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -121,6 +121,7 @@ class Bip44ConfGetterConst: Bip44Coins.TERRA: Bip44Conf.Terra, Bip44Coins.TEZOS: Bip44Conf.Tezos, Bip44Coins.THETA: Bip44Conf.Theta, + Bip44Coins.TON: Bip44Conf.Ton, Bip44Coins.TRON: Bip44Conf.Tron, Bip44Coins.VECHAIN: Bip44Conf.VeChain, Bip44Coins.VERGE: Bip44Conf.Verge, diff --git a/bip_utils/bip/conf/bip49/bip49_coins.py b/bip_utils/bip/conf/bip49/bip49_coins.py index f138bb6e..38c39686 100644 --- a/bip_utils/bip/conf/bip49/bip49_coins.py +++ b/bip_utils/bip/conf/bip49/bip49_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip49/bip49_conf.py b/bip_utils/bip/conf/bip49/bip49_conf.py index 7a2ab9fd..4f797014 100644 --- a/bip_utils/bip/conf/bip49/bip49_conf.py +++ b/bip_utils/bip/conf/bip49/bip49_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip49/bip49_conf_getter.py b/bip_utils/bip/conf/bip49/bip49_conf_getter.py index 3922dd1d..a2b4dfb7 100644 --- a/bip_utils/bip/conf/bip49/bip49_conf_getter.py +++ b/bip_utils/bip/conf/bip49/bip49_conf_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip84/bip84_coins.py b/bip_utils/bip/conf/bip84/bip84_coins.py index 0dc05600..1a53efa5 100644 --- a/bip_utils/bip/conf/bip84/bip84_coins.py +++ b/bip_utils/bip/conf/bip84/bip84_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip84/bip84_conf.py b/bip_utils/bip/conf/bip84/bip84_conf.py index cb43bb1d..51ec3181 100644 --- a/bip_utils/bip/conf/bip84/bip84_conf.py +++ b/bip_utils/bip/conf/bip84/bip84_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip84/bip84_conf_getter.py b/bip_utils/bip/conf/bip84/bip84_conf_getter.py index a2f16116..ecf7e655 100644 --- a/bip_utils/bip/conf/bip84/bip84_conf_getter.py +++ b/bip_utils/bip/conf/bip84/bip84_conf_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip86/bip86_coins.py b/bip_utils/bip/conf/bip86/bip86_coins.py index b68ecf8c..86f6f153 100644 --- a/bip_utils/bip/conf/bip86/bip86_coins.py +++ b/bip_utils/bip/conf/bip86/bip86_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip86/bip86_conf.py b/bip_utils/bip/conf/bip86/bip86_conf.py index 4fd8d2f8..6d1783f1 100644 --- a/bip_utils/bip/conf/bip86/bip86_conf.py +++ b/bip_utils/bip/conf/bip86/bip86_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/bip86/bip86_conf_getter.py b/bip_utils/bip/conf/bip86/bip86_conf_getter.py index 1dea8bc3..ef22b16e 100644 --- a/bip_utils/bip/conf/bip86/bip86_conf_getter.py +++ b/bip_utils/bip/conf/bip86/bip86_conf_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/common/bip_bitcoin_cash_conf.py b/bip_utils/bip/conf/common/bip_bitcoin_cash_conf.py index ef18355e..3bd5b349 100644 --- a/bip_utils/bip/conf/common/bip_bitcoin_cash_conf.py +++ b/bip_utils/bip/conf/common/bip_bitcoin_cash_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/common/bip_coin_conf.py b/bip_utils/bip/conf/common/bip_coin_conf.py index b2e9f7d8..d97be9fe 100644 --- a/bip_utils/bip/conf/common/bip_coin_conf.py +++ b/bip_utils/bip/conf/common/bip_coin_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/common/bip_coins.py b/bip_utils/bip/conf/common/bip_coins.py index be8112d7..89909600 100644 --- a/bip_utils/bip/conf/common/bip_coins.py +++ b/bip_utils/bip/conf/common/bip_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/common/bip_conf_const.py b/bip_utils/bip/conf/common/bip_conf_const.py index 6feee47f..94670ae4 100644 --- a/bip_utils/bip/conf/common/bip_conf_const.py +++ b/bip_utils/bip/conf/common/bip_conf_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/bip/conf/common/bip_litecoin_conf.py b/bip_utils/bip/conf/common/bip_litecoin_conf.py index 7d06ab02..b7731e82 100644 --- a/bip_utils/bip/conf/common/bip_litecoin_conf.py +++ b/bip_utils/bip/conf/common/bip_litecoin_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/brainwallet/brainwallet.py b/bip_utils/brainwallet/brainwallet.py index 32f2189b..04bf0e9c 100644 --- a/bip_utils/brainwallet/brainwallet.py +++ b/bip_utils/brainwallet/brainwallet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/brainwallet/brainwallet_algo.py b/bip_utils/brainwallet/brainwallet_algo.py index c4bd6228..840ad0c7 100644 --- a/bip_utils/brainwallet/brainwallet_algo.py +++ b/bip_utils/brainwallet/brainwallet_algo.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/brainwallet/brainwallet_algo_getter.py b/bip_utils/brainwallet/brainwallet_algo_getter.py index fb6d89ec..78c97668 100644 --- a/bip_utils/brainwallet/brainwallet_algo_getter.py +++ b/bip_utils/brainwallet/brainwallet_algo_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/brainwallet/ibrainwallet_algo.py b/bip_utils/brainwallet/ibrainwallet_algo.py index 97b21101..bde2310f 100644 --- a/bip_utils/brainwallet/ibrainwallet_algo.py +++ b/bip_utils/brainwallet/ibrainwallet_algo.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/bip32/cardano_byron_legacy_bip32.py b/bip_utils/cardano/bip32/cardano_byron_legacy_bip32.py index 5ed4198e..d742ec41 100644 --- a/bip_utils/cardano/bip32/cardano_byron_legacy_bip32.py +++ b/bip_utils/cardano/bip32/cardano_byron_legacy_bip32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/bip32/cardano_byron_legacy_key_derivator.py b/bip_utils/cardano/bip32/cardano_byron_legacy_key_derivator.py index 2a9cca6b..0d7fc590 100644 --- a/bip_utils/cardano/bip32/cardano_byron_legacy_key_derivator.py +++ b/bip_utils/cardano/bip32/cardano_byron_legacy_key_derivator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/bip32/cardano_byron_legacy_mst_key_generator.py b/bip_utils/cardano/bip32/cardano_byron_legacy_mst_key_generator.py index 7f227a77..930f4288 100644 --- a/bip_utils/cardano/bip32/cardano_byron_legacy_mst_key_generator.py +++ b/bip_utils/cardano/bip32/cardano_byron_legacy_mst_key_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/bip32/cardano_icarus_bip32.py b/bip_utils/cardano/bip32/cardano_icarus_bip32.py index a00e3e41..e78f30ef 100644 --- a/bip_utils/cardano/bip32/cardano_icarus_bip32.py +++ b/bip_utils/cardano/bip32/cardano_icarus_bip32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/bip32/cardano_icarus_mst_key_generator.py b/bip_utils/cardano/bip32/cardano_icarus_mst_key_generator.py index 034d6159..f285139e 100644 --- a/bip_utils/cardano/bip32/cardano_icarus_mst_key_generator.py +++ b/bip_utils/cardano/bip32/cardano_icarus_mst_key_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/byron/cardano_byron_legacy.py b/bip_utils/cardano/byron/cardano_byron_legacy.py index 69372201..b0fd4bd6 100644 --- a/bip_utils/cardano/byron/cardano_byron_legacy.py +++ b/bip_utils/cardano/byron/cardano_byron_legacy.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/cip1852/cip1852.py b/bip_utils/cardano/cip1852/cip1852.py index 7339872d..ee1bad26 100644 --- a/bip_utils/cardano/cip1852/cip1852.py +++ b/bip_utils/cardano/cip1852/cip1852.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/cip1852/conf/cip1852_coins.py b/bip_utils/cardano/cip1852/conf/cip1852_coins.py index 2a3ba4cf..efbf2187 100644 --- a/bip_utils/cardano/cip1852/conf/cip1852_coins.py +++ b/bip_utils/cardano/cip1852/conf/cip1852_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/cip1852/conf/cip1852_conf.py b/bip_utils/cardano/cip1852/conf/cip1852_conf.py index a24071b3..a55618ae 100644 --- a/bip_utils/cardano/cip1852/conf/cip1852_conf.py +++ b/bip_utils/cardano/cip1852/conf/cip1852_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/cip1852/conf/cip1852_conf_getter.py b/bip_utils/cardano/cip1852/conf/cip1852_conf_getter.py index 7cd41eb3..b9bf8bf5 100644 --- a/bip_utils/cardano/cip1852/conf/cip1852_conf_getter.py +++ b/bip_utils/cardano/cip1852/conf/cip1852_conf_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/mnemonic/cardano_byron_legacy_seed_generator.py b/bip_utils/cardano/mnemonic/cardano_byron_legacy_seed_generator.py index cc67b8d5..cbd42cec 100644 --- a/bip_utils/cardano/mnemonic/cardano_byron_legacy_seed_generator.py +++ b/bip_utils/cardano/mnemonic/cardano_byron_legacy_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/mnemonic/cardano_icarus_seed_generator.py b/bip_utils/cardano/mnemonic/cardano_icarus_seed_generator.py index a0117199..09d051ee 100644 --- a/bip_utils/cardano/mnemonic/cardano_icarus_seed_generator.py +++ b/bip_utils/cardano/mnemonic/cardano_icarus_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/shelley/cardano_shelley.py b/bip_utils/cardano/shelley/cardano_shelley.py index 4f82aab1..e5a0b4e1 100644 --- a/bip_utils/cardano/shelley/cardano_shelley.py +++ b/bip_utils/cardano/shelley/cardano_shelley.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/cardano/shelley/cardano_shelley_keys.py b/bip_utils/cardano/shelley/cardano_shelley_keys.py index 1cb96a1e..ff1ec6b4 100644 --- a/bip_utils/cardano/shelley/cardano_shelley_keys.py +++ b/bip_utils/cardano/shelley/cardano_shelley_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/coin_conf/coin_conf.py b/bip_utils/coin_conf/coin_conf.py index 245c5441..77e0cf98 100644 --- a/bip_utils/coin_conf/coin_conf.py +++ b/bip_utils/coin_conf/coin_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/coin_conf/coins_conf.py b/bip_utils/coin_conf/coins_conf.py index f53ca99d..7a1096a4 100644 --- a/bip_utils/coin_conf/coins_conf.py +++ b/bip_utils/coin_conf/coins_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,7 @@ # Imports from bip_utils.coin_conf.coin_conf import CoinConf from bip_utils.slip.slip173 import Slip173 +from bip_utils.ton.addr.ton_addr_versions import TonAddrVersions from bip_utils.utils.conf import CoinNames @@ -850,6 +851,15 @@ class CoinsConf: params={}, ) + # Configuration for Tron + Ton: CoinConf = CoinConf( + coin_name=CoinNames("The Open Network", "TON"), + params={ + "version": TonAddrVersions.V4, + "is_bounceable": False, + }, + ) + # Configuration for Tron Tron: CoinConf = CoinConf( coin_name=CoinNames("Tron", "TRX"), diff --git a/bip_utils/ecc/common/dummy_point.py b/bip_utils/ecc/common/dummy_point.py index 5e121189..32c29c72 100644 --- a/bip_utils/ecc/common/dummy_point.py +++ b/bip_utils/ecc/common/dummy_point.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/common/ikeys.py b/bip_utils/ecc/common/ikeys.py index bad2560b..8f111023 100644 --- a/bip_utils/ecc/common/ikeys.py +++ b/bip_utils/ecc/common/ikeys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/common/ipoint.py b/bip_utils/ecc/common/ipoint.py index b3fd2571..5246da40 100644 --- a/bip_utils/ecc/common/ipoint.py +++ b/bip_utils/ecc/common/ipoint.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/conf.py b/bip_utils/ecc/conf.py index d6d15118..28f2063b 100644 --- a/bip_utils/ecc/conf.py +++ b/bip_utils/ecc/conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/curve/elliptic_curve.py b/bip_utils/ecc/curve/elliptic_curve.py index a400443b..cdbb3401 100644 --- a/bip_utils/ecc/curve/elliptic_curve.py +++ b/bip_utils/ecc/curve/elliptic_curve.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/curve/elliptic_curve_getter.py b/bip_utils/ecc/curve/elliptic_curve_getter.py index cb6be49f..5b821637 100644 --- a/bip_utils/ecc/curve/elliptic_curve_getter.py +++ b/bip_utils/ecc/curve/elliptic_curve_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/curve/elliptic_curve_types.py b/bip_utils/ecc/curve/elliptic_curve_types.py index d30f0753..3b8df7ce 100644 --- a/bip_utils/ecc/curve/elliptic_curve_types.py +++ b/bip_utils/ecc/curve/elliptic_curve_types.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ecdsa/ecdsa_keys.py b/bip_utils/ecc/ecdsa/ecdsa_keys.py index 2997c47a..c33d46ab 100644 --- a/bip_utils/ecc/ecdsa/ecdsa_keys.py +++ b/bip_utils/ecc/ecdsa/ecdsa_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519/ed25519.py b/bip_utils/ecc/ed25519/ed25519.py index 80daac4d..5510f227 100644 --- a/bip_utils/ecc/ed25519/ed25519.py +++ b/bip_utils/ecc/ed25519/ed25519.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519/ed25519_const.py b/bip_utils/ecc/ed25519/ed25519_const.py index fe94ef2b..d2ab9087 100644 --- a/bip_utils/ecc/ed25519/ed25519_const.py +++ b/bip_utils/ecc/ed25519/ed25519_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519/ed25519_keys.py b/bip_utils/ecc/ed25519/ed25519_keys.py index 4e4bfc08..ad265c63 100644 --- a/bip_utils/ecc/ed25519/ed25519_keys.py +++ b/bip_utils/ecc/ed25519/ed25519_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519/ed25519_point.py b/bip_utils/ecc/ed25519/ed25519_point.py index 827f4c8b..4c72b4b1 100644 --- a/bip_utils/ecc/ed25519/ed25519_point.py +++ b/bip_utils/ecc/ed25519/ed25519_point.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519/ed25519_utils.py b/bip_utils/ecc/ed25519/ed25519_utils.py index 94b3dcc4..3d1b563e 100644 --- a/bip_utils/ecc/ed25519/ed25519_utils.py +++ b/bip_utils/ecc/ed25519/ed25519_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519/lib/ed25519_lib.py b/bip_utils/ecc/ed25519/lib/ed25519_lib.py index b9d27a0f..9db85514 100644 --- a/bip_utils/ecc/ed25519/lib/ed25519_lib.py +++ b/bip_utils/ecc/ed25519/lib/ed25519_lib.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b.py b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b.py index a3d76eff..c250ed39 100644 --- a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b.py +++ b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_const.py b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_const.py index 6069756b..76657b6d 100644 --- a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_const.py +++ b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_keys.py b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_keys.py index 73223582..1ba237e9 100644 --- a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_keys.py +++ b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_point.py b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_point.py index 8d4bf358..20bffe86 100644 --- a/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_point.py +++ b/bip_utils/ecc/ed25519_blake2b/ed25519_blake2b_point.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw.py b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw.py index 70eec0df..9060e565 100644 --- a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw.py +++ b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_const.py b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_const.py index 1b2c6f27..ddb7c6e1 100644 --- a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_const.py +++ b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_keys.py b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_keys.py index 20b35c0c..51673edf 100644 --- a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_keys.py +++ b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_point.py b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_point.py index 42c2e3fa..604663ec 100644 --- a/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_point.py +++ b/bip_utils/ecc/ed25519_kholaw/ed25519_kholaw_point.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_monero/ed25519_monero.py b/bip_utils/ecc/ed25519_monero/ed25519_monero.py index 4a08f6fd..94fc3445 100644 --- a/bip_utils/ecc/ed25519_monero/ed25519_monero.py +++ b/bip_utils/ecc/ed25519_monero/ed25519_monero.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_monero/ed25519_monero_const.py b/bip_utils/ecc/ed25519_monero/ed25519_monero_const.py index 7801dfdf..829cce6e 100644 --- a/bip_utils/ecc/ed25519_monero/ed25519_monero_const.py +++ b/bip_utils/ecc/ed25519_monero/ed25519_monero_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_monero/ed25519_monero_keys.py b/bip_utils/ecc/ed25519_monero/ed25519_monero_keys.py index 02e4c24a..40739654 100644 --- a/bip_utils/ecc/ed25519_monero/ed25519_monero_keys.py +++ b/bip_utils/ecc/ed25519_monero/ed25519_monero_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/ed25519_monero/ed25519_monero_point.py b/bip_utils/ecc/ed25519_monero/ed25519_monero_point.py index ff05d419..f51870f7 100644 --- a/bip_utils/ecc/ed25519_monero/ed25519_monero_point.py +++ b/bip_utils/ecc/ed25519_monero/ed25519_monero_point.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/nist256p1/nist256p1.py b/bip_utils/ecc/nist256p1/nist256p1.py index 8530e80e..6dcd3e63 100644 --- a/bip_utils/ecc/nist256p1/nist256p1.py +++ b/bip_utils/ecc/nist256p1/nist256p1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/nist256p1/nist256p1_const.py b/bip_utils/ecc/nist256p1/nist256p1_const.py index 9da13c35..a0d3bd6a 100644 --- a/bip_utils/ecc/nist256p1/nist256p1_const.py +++ b/bip_utils/ecc/nist256p1/nist256p1_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/nist256p1/nist256p1_keys.py b/bip_utils/ecc/nist256p1/nist256p1_keys.py index adcee6b5..bad45509 100644 --- a/bip_utils/ecc/nist256p1/nist256p1_keys.py +++ b/bip_utils/ecc/nist256p1/nist256p1_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/nist256p1/nist256p1_point.py b/bip_utils/ecc/nist256p1/nist256p1_point.py index 993f8bb1..35b947b1 100644 --- a/bip_utils/ecc/nist256p1/nist256p1_point.py +++ b/bip_utils/ecc/nist256p1/nist256p1_point.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/secp256k1/secp256k1.py b/bip_utils/ecc/secp256k1/secp256k1.py index 0cad4192..9c5397a1 100644 --- a/bip_utils/ecc/secp256k1/secp256k1.py +++ b/bip_utils/ecc/secp256k1/secp256k1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/secp256k1/secp256k1_const.py b/bip_utils/ecc/secp256k1/secp256k1_const.py index 1c10188c..9f6161fe 100644 --- a/bip_utils/ecc/secp256k1/secp256k1_const.py +++ b/bip_utils/ecc/secp256k1/secp256k1_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/secp256k1/secp256k1_keys_coincurve.py b/bip_utils/ecc/secp256k1/secp256k1_keys_coincurve.py index 2e53c503..3eed2403 100644 --- a/bip_utils/ecc/secp256k1/secp256k1_keys_coincurve.py +++ b/bip_utils/ecc/secp256k1/secp256k1_keys_coincurve.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/secp256k1/secp256k1_keys_ecdsa.py b/bip_utils/ecc/secp256k1/secp256k1_keys_ecdsa.py index 8502691f..e0e030a6 100644 --- a/bip_utils/ecc/secp256k1/secp256k1_keys_ecdsa.py +++ b/bip_utils/ecc/secp256k1/secp256k1_keys_ecdsa.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/secp256k1/secp256k1_point_coincurve.py b/bip_utils/ecc/secp256k1/secp256k1_point_coincurve.py index 5e10895c..341f13d5 100644 --- a/bip_utils/ecc/secp256k1/secp256k1_point_coincurve.py +++ b/bip_utils/ecc/secp256k1/secp256k1_point_coincurve.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/secp256k1/secp256k1_point_ecdsa.py b/bip_utils/ecc/secp256k1/secp256k1_point_ecdsa.py index c9eabe35..0da042f3 100644 --- a/bip_utils/ecc/secp256k1/secp256k1_point_ecdsa.py +++ b/bip_utils/ecc/secp256k1/secp256k1_point_ecdsa.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/sr25519/sr25519.py b/bip_utils/ecc/sr25519/sr25519.py index 7eeb51d0..274314a0 100644 --- a/bip_utils/ecc/sr25519/sr25519.py +++ b/bip_utils/ecc/sr25519/sr25519.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/sr25519/sr25519_const.py b/bip_utils/ecc/sr25519/sr25519_const.py index 79a457f2..d8107907 100644 --- a/bip_utils/ecc/sr25519/sr25519_const.py +++ b/bip_utils/ecc/sr25519/sr25519_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/sr25519/sr25519_keys.py b/bip_utils/ecc/sr25519/sr25519_keys.py index 85ae4b78..cbff5870 100644 --- a/bip_utils/ecc/sr25519/sr25519_keys.py +++ b/bip_utils/ecc/sr25519/sr25519_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ecc/sr25519/sr25519_point.py b/bip_utils/ecc/sr25519/sr25519_point.py index 713fcef6..aebd9930 100644 --- a/bip_utils/ecc/sr25519/sr25519_point.py +++ b/bip_utils/ecc/sr25519/sr25519_point.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/electrum_v1.py b/bip_utils/electrum/electrum_v1.py index aab51632..b1d4b69c 100644 --- a/bip_utils/electrum/electrum_v1.py +++ b/bip_utils/electrum/electrum_v1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/electrum_v2.py b/bip_utils/electrum/electrum_v2.py index efef7cbb..a94cda9a 100644 --- a/bip_utils/electrum/electrum_v2.py +++ b/bip_utils/electrum/electrum_v2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_entropy_generator.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_entropy_generator.py index eb6d3b55..2a0f17f9 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_entropy_generator.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_entropy_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic.py index e84d4054..e30976dd 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_decoder.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_decoder.py index 7ee4caae..cfbb886c 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_decoder.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_decoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_encoder.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_encoder.py index cee6f600..302232fc 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_encoder.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_encoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_generator.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_generator.py index 3a71250d..72a6b9af 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_generator.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_utils.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_utils.py index 172eafb5..75022c88 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_utils.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_validator.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_validator.py index 61180ccb..61ac3f69 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_validator.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_mnemonic_validator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v1/electrum_v1_seed_generator.py b/bip_utils/electrum/mnemonic_v1/electrum_v1_seed_generator.py index 1b0b528d..8ac8e99b 100644 --- a/bip_utils/electrum/mnemonic_v1/electrum_v1_seed_generator.py +++ b/bip_utils/electrum/mnemonic_v1/electrum_v1_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_entropy_generator.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_entropy_generator.py index 8e2f3f65..2c45d451 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_entropy_generator.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_entropy_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic.py index 02cbc4d6..c97d4bc9 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_decoder.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_decoder.py index fdc6eb9e..dc21dcee 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_decoder.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_decoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_encoder.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_encoder.py index 2f1cf868..70f60f0b 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_encoder.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_encoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_generator.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_generator.py index dcb650a1..38bcd13f 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_generator.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_utils.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_utils.py index c24c15b7..bc89fea2 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_utils.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_validator.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_validator.py index 8757018b..15fa74fc 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_validator.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_mnemonic_validator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/electrum/mnemonic_v2/electrum_v2_seed_generator.py b/bip_utils/electrum/mnemonic_v2/electrum_v2_seed_generator.py index 7db77a3b..58a643fa 100644 --- a/bip_utils/electrum/mnemonic_v2/electrum_v2_seed_generator.py +++ b/bip_utils/electrum/mnemonic_v2/electrum_v2_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/conf/monero_coin_conf.py b/bip_utils/monero/conf/monero_coin_conf.py index 11eb233b..7453e2f4 100644 --- a/bip_utils/monero/conf/monero_coin_conf.py +++ b/bip_utils/monero/conf/monero_coin_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/conf/monero_coins.py b/bip_utils/monero/conf/monero_coins.py index 13b240d1..6f2fd0ae 100644 --- a/bip_utils/monero/conf/monero_coins.py +++ b/bip_utils/monero/conf/monero_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/conf/monero_conf.py b/bip_utils/monero/conf/monero_conf.py index eb55e7d8..74f3634b 100644 --- a/bip_utils/monero/conf/monero_conf.py +++ b/bip_utils/monero/conf/monero_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/conf/monero_conf_getter.py b/bip_utils/monero/conf/monero_conf_getter.py index 50c35392..b7558b7d 100644 --- a/bip_utils/monero/conf/monero_conf_getter.py +++ b/bip_utils/monero/conf/monero_conf_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_entropy_generator.py b/bip_utils/monero/mnemonic/monero_entropy_generator.py index a9b4a061..4bc64683 100644 --- a/bip_utils/monero/mnemonic/monero_entropy_generator.py +++ b/bip_utils/monero/mnemonic/monero_entropy_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_mnemonic.py b/bip_utils/monero/mnemonic/monero_mnemonic.py index b882a61f..405a7e0c 100644 --- a/bip_utils/monero/mnemonic/monero_mnemonic.py +++ b/bip_utils/monero/mnemonic/monero_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_mnemonic_decoder.py b/bip_utils/monero/mnemonic/monero_mnemonic_decoder.py index b421bbd6..9051c307 100644 --- a/bip_utils/monero/mnemonic/monero_mnemonic_decoder.py +++ b/bip_utils/monero/mnemonic/monero_mnemonic_decoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_mnemonic_encoder.py b/bip_utils/monero/mnemonic/monero_mnemonic_encoder.py index 582c8820..3d5d6097 100644 --- a/bip_utils/monero/mnemonic/monero_mnemonic_encoder.py +++ b/bip_utils/monero/mnemonic/monero_mnemonic_encoder.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_mnemonic_generator.py b/bip_utils/monero/mnemonic/monero_mnemonic_generator.py index 22e93044..34e9789d 100644 --- a/bip_utils/monero/mnemonic/monero_mnemonic_generator.py +++ b/bip_utils/monero/mnemonic/monero_mnemonic_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_mnemonic_utils.py b/bip_utils/monero/mnemonic/monero_mnemonic_utils.py index cd33353b..5a518435 100644 --- a/bip_utils/monero/mnemonic/monero_mnemonic_utils.py +++ b/bip_utils/monero/mnemonic/monero_mnemonic_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_mnemonic_validator.py b/bip_utils/monero/mnemonic/monero_mnemonic_validator.py index 7956309c..c5e46ea3 100644 --- a/bip_utils/monero/mnemonic/monero_mnemonic_validator.py +++ b/bip_utils/monero/mnemonic/monero_mnemonic_validator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/mnemonic/monero_seed_generator.py b/bip_utils/monero/mnemonic/monero_seed_generator.py index 35a2b476..dbc6e40c 100644 --- a/bip_utils/monero/mnemonic/monero_seed_generator.py +++ b/bip_utils/monero/mnemonic/monero_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/monero.py b/bip_utils/monero/monero.py index 3584d9e1..e23ed0cf 100644 --- a/bip_utils/monero/monero.py +++ b/bip_utils/monero/monero.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/monero_ex.py b/bip_utils/monero/monero_ex.py index 77607271..1359d406 100644 --- a/bip_utils/monero/monero_ex.py +++ b/bip_utils/monero/monero_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/monero_keys.py b/bip_utils/monero/monero_keys.py index 261c512c..c0e40552 100644 --- a/bip_utils/monero/monero_keys.py +++ b/bip_utils/monero/monero_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/monero/monero_subaddr.py b/bip_utils/monero/monero_subaddr.py index 77dbc1af..7eb642fb 100644 --- a/bip_utils/monero/monero_subaddr.py +++ b/bip_utils/monero/monero_subaddr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/slip/slip173/slip173.py b/bip_utils/slip/slip173/slip173.py index c4ad835c..92f6d25c 100644 --- a/bip_utils/slip/slip173/slip173.py +++ b/bip_utils/slip/slip173/slip173.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/slip/slip32/slip32.py b/bip_utils/slip/slip32/slip32.py index 2166dad9..629cfda9 100644 --- a/bip_utils/slip/slip32/slip32.py +++ b/bip_utils/slip/slip32/slip32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/slip/slip32/slip32_key_net_ver.py b/bip_utils/slip/slip32/slip32_key_net_ver.py index aa11c19a..5ea18bb7 100644 --- a/bip_utils/slip/slip32/slip32_key_net_ver.py +++ b/bip_utils/slip/slip32/slip32_key_net_ver.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/slip/slip44/slip44.py b/bip_utils/slip/slip44/slip44.py index d32f0e87..97b44f80 100644 --- a/bip_utils/slip/slip44/slip44.py +++ b/bip_utils/slip/slip44/slip44.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -50,6 +50,7 @@ class Slip44: NANO: int = 165 EOS: int = 194 TRON: int = 195 + TON: int = 607 BITCOIN_SV: int = 236 NIMIQ: int = 242 ALGORAND: int = 283 diff --git a/bip_utils/solana/spl_token.py b/bip_utils/solana/spl_token.py index 4ee22211..1c63411d 100644 --- a/bip_utils/solana/spl_token.py +++ b/bip_utils/solana/spl_token.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ss58/ss58.py b/bip_utils/ss58/ss58.py index d3da6758..38c6bb96 100644 --- a/bip_utils/ss58/ss58.py +++ b/bip_utils/ss58/ss58.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ss58/ss58_ex.py b/bip_utils/ss58/ss58_ex.py index f239097f..efb5e255 100644 --- a/bip_utils/ss58/ss58_ex.py +++ b/bip_utils/ss58/ss58_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/conf/substrate_coin_conf.py b/bip_utils/substrate/conf/substrate_coin_conf.py index ab7c5103..ec5b5e1a 100644 --- a/bip_utils/substrate/conf/substrate_coin_conf.py +++ b/bip_utils/substrate/conf/substrate_coin_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/conf/substrate_coins.py b/bip_utils/substrate/conf/substrate_coins.py index ad6f8eb1..26b4acd4 100644 --- a/bip_utils/substrate/conf/substrate_coins.py +++ b/bip_utils/substrate/conf/substrate_coins.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/conf/substrate_conf.py b/bip_utils/substrate/conf/substrate_conf.py index 3575db41..274cf7e1 100644 --- a/bip_utils/substrate/conf/substrate_conf.py +++ b/bip_utils/substrate/conf/substrate_conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/conf/substrate_conf_getter.py b/bip_utils/substrate/conf/substrate_conf_getter.py index 4a653186..54a0933e 100644 --- a/bip_utils/substrate/conf/substrate_conf_getter.py +++ b/bip_utils/substrate/conf/substrate_conf_getter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/mnemonic/substrate_bip39_seed_generator.py b/bip_utils/substrate/mnemonic/substrate_bip39_seed_generator.py index 1470cd97..642b2a83 100644 --- a/bip_utils/substrate/mnemonic/substrate_bip39_seed_generator.py +++ b/bip_utils/substrate/mnemonic/substrate_bip39_seed_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/scale/substrate_scale_enc_base.py b/bip_utils/substrate/scale/substrate_scale_enc_base.py index 1acc3386..d47ba6bd 100644 --- a/bip_utils/substrate/scale/substrate_scale_enc_base.py +++ b/bip_utils/substrate/scale/substrate_scale_enc_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/scale/substrate_scale_enc_bytes.py b/bip_utils/substrate/scale/substrate_scale_enc_bytes.py index e00d5b0c..075db08d 100644 --- a/bip_utils/substrate/scale/substrate_scale_enc_bytes.py +++ b/bip_utils/substrate/scale/substrate_scale_enc_bytes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/scale/substrate_scale_enc_cuint.py b/bip_utils/substrate/scale/substrate_scale_enc_cuint.py index c9597ab5..8cf1a442 100644 --- a/bip_utils/substrate/scale/substrate_scale_enc_cuint.py +++ b/bip_utils/substrate/scale/substrate_scale_enc_cuint.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/scale/substrate_scale_enc_uint.py b/bip_utils/substrate/scale/substrate_scale_enc_uint.py index 2404c094..6f6c84a6 100644 --- a/bip_utils/substrate/scale/substrate_scale_enc_uint.py +++ b/bip_utils/substrate/scale/substrate_scale_enc_uint.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/substrate.py b/bip_utils/substrate/substrate.py index c66ed139..70784f93 100644 --- a/bip_utils/substrate/substrate.py +++ b/bip_utils/substrate/substrate.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/substrate_ex.py b/bip_utils/substrate/substrate_ex.py index d907bea5..040eb508 100644 --- a/bip_utils/substrate/substrate_ex.py +++ b/bip_utils/substrate/substrate_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/substrate_keys.py b/bip_utils/substrate/substrate_keys.py index 0aa6a11a..7bfe0091 100644 --- a/bip_utils/substrate/substrate_keys.py +++ b/bip_utils/substrate/substrate_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/substrate/substrate_path.py b/bip_utils/substrate/substrate_path.py index bd025dda..a55c46ed 100644 --- a/bip_utils/substrate/substrate_path.py +++ b/bip_utils/substrate/substrate_path.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/ton/__init__.py b/bip_utils/ton/__init__.py new file mode 100644 index 00000000..f754e99c --- /dev/null +++ b/bip_utils/ton/__init__.py @@ -0,0 +1,3 @@ +from bip_utils.ton.ton import Ton +from bip_utils.ton.ton_ex import TonKeyError +from bip_utils.ton.ton_keys import TonPrivateKey, TonPublicKey diff --git a/bip_utils/ton/addr/__init__.py b/bip_utils/ton/addr/__init__.py new file mode 100644 index 00000000..f3103a0d --- /dev/null +++ b/bip_utils/ton/addr/__init__.py @@ -0,0 +1,5 @@ +from bip_utils.ton.addr.ton_addr_versions import TonAddrVersions +from bip_utils.ton.addr.ton_v3r1_addr_encoder import TonV3R1AddrEncoder +from bip_utils.ton.addr.ton_v3r2_addr_encoder import TonV3R2AddrEncoder +from bip_utils.ton.addr.ton_v4_addr_encoder import TonV4AddrEncoder +from bip_utils.ton.addr.ton_v5r1_addr_encoder import TonV5R1AddrEncoder diff --git a/bip_utils/ton/addr/ton_addr_versions.py b/bip_utils/ton/addr/ton_addr_versions.py new file mode 100644 index 00000000..7cd97a41 --- /dev/null +++ b/bip_utils/ton/addr/ton_addr_versions.py @@ -0,0 +1,34 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Module for defining TON address versions.""" + +# Imports +from enum import Enum, auto, unique + + +@unique +class TonAddrVersions(Enum): + """Enumerative for TON address versions.""" + + V5R1 = auto() + V4 = auto() + V3R2 = auto() + V3R1 = auto() diff --git a/bip_utils/ton/addr/ton_v3r1_addr_encoder.py b/bip_utils/ton/addr/ton_v3r1_addr_encoder.py new file mode 100644 index 00000000..822458be --- /dev/null +++ b/bip_utils/ton/addr/ton_v3r1_addr_encoder.py @@ -0,0 +1,84 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module containing utility classes for TON V3R1 address computation. + +Reference: https://github.com/ton-org/ton/blob/main/src/wallets/v3/r1.ts +""" + +# Imports +from pytoniq_core import Address, Cell, begin_cell + +from bip_utils.ton.ton_keys import TonPublicKey +from bip_utils.utils.misc import Base64Decoder + + +class TonV3R1AddrEncoderConst: + """Class container for Ton V3R1 address encoder constants.""" + + CONTRACT_CODE: bytes = Base64Decoder.Decode("te6cckEBAQEAYgAAwP8AIN0gggFMl7qXMO1E0NcLH+Ck8mCDCNcYINMf0x/TH/gjE7vyY+1E0NMf0x/T/9FRMrryoVFEuvKiBPkBVBBV+RDyo/gAkyDXSpbTB9QC+wDo0QGkyMsfyx/L/8ntVD++buA=") # noqa: E501 + WORKCHAIN: int = 0 + + +class TonV3R1AddrEncoder: + """TON V3R1 address encoder class.""" + + m_pub_key: bytes + + def __init__(self, + pub_key_obj: TonPublicKey): + """ + Construct class. + + Args: + pub_key_obj (TonPublicKey object): Public key object + """ + self.m_pub_key = pub_key_obj.RawCompressed().ToBytes()[1:] + + def Encode(self, + is_bounceable: bool) -> str: + """ + Encode public key to V3R1 address. + + Args: + is_bounceable (bool): Whether the address is bounceable + + Returns: + str: Address string + """ + wallet_id = 698983191 + TonV3R1AddrEncoderConst.WORKCHAIN + + code = Cell.one_from_boc(TonV3R1AddrEncoderConst.CONTRACT_CODE) + + data = (begin_cell().store_uint(0, 32) + .store_uint(wallet_id, 32) + .store_bytes(self.m_pub_key) + .end_cell()) + + hash = (begin_cell().store_bit(False) + .store_bit(False) + .store_maybe_ref(code) + .store_maybe_ref(data) + .store_dict(None) + .end_cell().hash) + + addr_obj = Address((TonV3R1AddrEncoderConst.WORKCHAIN, hash)) + return addr_obj.to_str(is_bounceable=is_bounceable) diff --git a/bip_utils/ton/addr/ton_v3r2_addr_encoder.py b/bip_utils/ton/addr/ton_v3r2_addr_encoder.py new file mode 100644 index 00000000..78906438 --- /dev/null +++ b/bip_utils/ton/addr/ton_v3r2_addr_encoder.py @@ -0,0 +1,84 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module containing utility classes for TON V3R2 address computation. + +Reference: https://github.com/ton-org/ton/blob/main/src/wallets/v3/r2.ts +""" + +# Imports +from pytoniq_core import Address, Cell, begin_cell + +from bip_utils.ton.ton_keys import TonPublicKey +from bip_utils.utils.misc import Base64Decoder + + +class TonV3R2AddrEncoderConst: + """Class container for Ton V3R2 address encoder constants.""" + + CONTRACT_CODE: bytes = Base64Decoder.Decode("te6cckEBAQEAcQAA3v8AIN0gggFMl7ohggEznLqxn3Gw7UTQ0x/THzHXC//jBOCk8mCDCNcYINMf0x/TH/gjE7vyY+1E0NMf0x/T/9FRMrryoVFEuvKiBPkBVBBV+RDyo/gAkyDXSpbTB9QC+wDo0QGkyMsfyx/L/8ntVBC9ba0=") # noqa: E501 + WORKCHAIN: int = 0 + + +class TonV3R2AddrEncoder: + """TON V3R2 address encoder class.""" + + m_pub_key: bytes + + def __init__(self, + pub_key_obj: TonPublicKey): + """ + Construct class. + + Args: + pub_key_obj (TonPublicKey object): Public key object + """ + self.m_pub_key = pub_key_obj.RawCompressed().ToBytes()[1:] + + def Encode(self, + is_bounceable: bool) -> str: + """ + Encode public key to V3R2 address. + + Args: + is_bounceable (bool): Whether the address is bounceable + + Returns: + str: Address string + """ + wallet_id = 698983191 + TonV3R2AddrEncoderConst.WORKCHAIN + + code = Cell.one_from_boc(TonV3R2AddrEncoderConst.CONTRACT_CODE) + + data = (begin_cell().store_uint(0, 32) + .store_uint(wallet_id, 32) + .store_bytes(self.m_pub_key) + .end_cell()) + + hash = (begin_cell().store_bit(False) + .store_bit(False) + .store_maybe_ref(code) + .store_maybe_ref(data) + .store_dict(None) + .end_cell().hash) + + addr_obj = Address((TonV3R2AddrEncoderConst.WORKCHAIN, hash)) + return addr_obj.to_str(is_bounceable=is_bounceable) diff --git a/bip_utils/ton/addr/ton_v4_addr_encoder.py b/bip_utils/ton/addr/ton_v4_addr_encoder.py new file mode 100644 index 00000000..24a8124c --- /dev/null +++ b/bip_utils/ton/addr/ton_v4_addr_encoder.py @@ -0,0 +1,85 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module containing utility classes for TON V4 address computation. + +Reference: https://github.com/ton-org/ton/blob/main/src/wallets/v4/WalletContractV4.ts +""" + +# Imports +from pytoniq_core import Address, Cell, begin_cell + +from bip_utils.ton.ton_keys import TonPublicKey +from bip_utils.utils.misc import Base64Decoder + + +class TonV4AddrEncoderConst: + """Class container for Ton V4 address encoder constants.""" + + CONTRACT_CODE: bytes = Base64Decoder.Decode("te6ccgECFAEAAtQAART/APSkE/S88sgLAQIBIAIDAgFIBAUE+PKDCNcYINMf0x/THwL4I7vyZO1E0NMf0x/T//QE0VFDuvKhUVG68qIF+QFUEGT5EPKj+AAkpMjLH1JAyx9SMMv/UhD0AMntVPgPAdMHIcAAn2xRkyDXSpbTB9QC+wDoMOAhwAHjACHAAuMAAcADkTDjDQOkyMsfEssfy/8QERITAubQAdDTAyFxsJJfBOAi10nBIJJfBOAC0x8hghBwbHVnvSKCEGRzdHK9sJJfBeAD+kAwIPpEAcjKB8v/ydDtRNCBAUDXIfQEMFyBAQj0Cm+hMbOSXwfgBdM/yCWCEHBsdWe6kjgw4w0DghBkc3RyupJfBuMNBgcCASAICQB4AfoA9AQw+CdvIjBQCqEhvvLgUIIQcGx1Z4MesXCAGFAEywUmzxZY+gIZ9ADLaRfLH1Jgyz8gyYBA+wAGAIpQBIEBCPRZMO1E0IEBQNcgyAHPFvQAye1UAXKwjiOCEGRzdHKDHrFwgBhQBcsFUAPPFiP6AhPLassfyz/JgED7AJJfA+ICASAKCwBZvSQrb2omhAgKBrkPoCGEcNQICEekk30pkQzmkD6f+YN4EoAbeBAUiYcVnzGEAgFYDA0AEbjJftRNDXCx+AA9sp37UTQgQFA1yH0BDACyMoHy//J0AGBAQj0Cm+hMYAIBIA4PABmtznaiaEAga5Drhf/AABmvHfaiaEAQa5DrhY/AAG7SB/oA1NQi+QAFyMoHFcv/ydB3dIAYyMsFywIizxZQBfoCFMtrEszMyXP7AMhAFIEBCPRR8qcCAHCBAQjXGPoA0z/IVCBHgQEI9FHyp4IQbm90ZXB0gBjIywXLAlAGzxZQBPoCFMtqEssfyz/Jc/sAAgBsgQEI1xj6ANM/MFIkgQEI9Fnyp4IQZHN0cnB0gBjIywXLAlAFzxZQA/oCE8tqyx8Syz/Jc/sAAAr0AMntVA==") # noqa: E501 + WORKCHAIN: int = 0 + + +class TonV4AddrEncoder: + """TON V4 address encoder class.""" + + m_pub_key: bytes + + def __init__(self, + pub_key_obj: TonPublicKey): + """ + Construct class. + + Args: + pub_key_obj (TonPublicKey object): Public key object + """ + self.m_pub_key = pub_key_obj.RawCompressed().ToBytes()[1:] + + def Encode(self, + is_bounceable: bool) -> str: + """ + Encode public key to V4 address. + + Args: + is_bounceable (bool): Whether the address is bounceable + + Returns: + str: Address string + """ + wallet_id = 698983191 + TonV4AddrEncoderConst.WORKCHAIN + + code = Cell.one_from_boc(TonV4AddrEncoderConst.CONTRACT_CODE) + + data = (begin_cell().store_uint(0, 32) + .store_uint(wallet_id, 32) + .store_bytes(self.m_pub_key) + .store_bit(0) + .end_cell()) + + hash = (begin_cell().store_bit(False) + .store_bit(False) + .store_maybe_ref(code) + .store_maybe_ref(data) + .store_dict(None) + .end_cell().hash) + + addr_obj = Address((TonV4AddrEncoderConst.WORKCHAIN, hash)) + return addr_obj.to_str(is_bounceable=is_bounceable) diff --git a/bip_utils/ton/addr/ton_v5r1_addr_encoder.py b/bip_utils/ton/addr/ton_v5r1_addr_encoder.py new file mode 100644 index 00000000..823026fd --- /dev/null +++ b/bip_utils/ton/addr/ton_v5r1_addr_encoder.py @@ -0,0 +1,93 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module containing utility classes for TON V5R1 address. + +Reference: https://github.com/ton-org/ton/blob/main/src/wallets/v5r1/WalletContractV5R1.ts +""" + +# Imports +from pytoniq_core import Address, Cell, begin_cell + +from bip_utils.ton.ton_keys import TonPublicKey + + +class TonV5R1AddrEncoderConst: + """Class container for Ton V5R1 address encoder constants.""" + + CONTRACT_CODE: str = "b5ee9c7241021401000281000114ff00f4a413f4bcf2c80b01020120020d020148030402dcd020d749c120915b8f6320d70b1f2082106578746ebd21821073696e74bdb0925f03e082106578746eba8eb48020d72101d074d721fa4030fa44f828fa443058bd915be0ed44d0810141d721f4058307f40e6fa1319130e18040d721707fdb3ce03120d749810280b99130e070e2100f020120050c020120060902016e07080019adce76a2684020eb90eb85ffc00019af1df6a2684010eb90eb858fc00201480a0b0017b325fb51341c75c875c2c7e00011b262fb513435c280200019be5f0f6a2684080a0eb90fa02c0102f20e011e20d70b1f82107369676ebaf2e08a7f0f01e68ef0eda2edfb218308d722028308d723208020d721d31fd31fd31fed44d0d200d31f20d31fd3ffd70a000af90140ccf9109a28945f0adb31e1f2c087df02b35007b0f2d0845125baf2e0855036baf2e086f823bbf2d0882292f800de01a47fc8ca00cb1f01cf16c9ed542092f80fde70db3cd81003f6eda2edfb02f404216e926c218e4c0221d73930709421c700b38e2d01d72820761e436c20d749c008f2e09320d74ac002f2e09320d71d06c712c2005230b0f2d089d74cd7393001a4e86c128407bbf2e093d74ac000f2e093ed55e2d20001c000915be0ebd72c08142091709601d72c081c12e25210b1e30f20d74a111213009601fa4001fa44f828fa443058baf2e091ed44d0810141d718f405049d7fc8ca0040048307f453f2e08b8e14038307f45bf2e08c22d70a00216e01b3b0f2d090e2c85003cf1612f400c9ed54007230d72c08248e2d21f2e092d200ed44d0d2005113baf2d08f54503091319c01810140d721d70a00f2e08ee2c8ca0058cf16c9ed5493f2c08de20010935bdb31e1d74cd0b4d6c35e" # noqa: E501 + NETWORK_GLOBAL_ID: int = -239 + SUBWALLET_NUMBER: int = 0 + WORKCHAIN: int = 0 + + +class TonV5R1AddrEncoder: + """TON V5R1 address encoder class.""" + + m_pub_key: bytes + + def __init__(self, + pub_key_obj: TonPublicKey): + """ + Construct class. + + Args: + pub_key_obj (TonPublicKey object): Public key object + """ + self.m_pub_key = pub_key_obj.RawCompressed().ToBytes()[1:] + + def Encode(self, + is_bounceable: bool) -> str: + """ + Encode public key to V5R1 address. + + Args: + is_bounceable (bool): Whether the address is bounceable + + Returns: + str: Address string + """ + code = Cell.one_from_boc(TonV5R1AddrEncoderConst.CONTRACT_CODE) + + context = (begin_cell().store_uint(1, 1) + .store_int(TonV5R1AddrEncoderConst.WORKCHAIN, 8) + .store_uint(0, 8) + .store_uint(TonV5R1AddrEncoderConst.SUBWALLET_NUMBER, 15) + .end_cell() + .begin_parse() + .load_int(32)) + + data = (begin_cell().store_uint(1, 1) + .store_uint(0, 32) + .store_int(TonV5R1AddrEncoderConst.NETWORK_GLOBAL_ID ^ context, 32) + .store_bytes(self.m_pub_key) + .store_bit(0) + .end_cell()) + + hash = (begin_cell().store_bit(False) + .store_bit(False) + .store_maybe_ref(code) + .store_maybe_ref(data) + .store_dict(None) + .end_cell().hash) + + addr_obj = Address((TonV5R1AddrEncoderConst.WORKCHAIN, hash)) + return addr_obj.to_str(is_bounceable=is_bounceable) diff --git a/bip_utils/ton/mnemonic/__init__.py b/bip_utils/ton/mnemonic/__init__.py new file mode 100644 index 00000000..3bc984d7 --- /dev/null +++ b/bip_utils/ton/mnemonic/__init__.py @@ -0,0 +1,4 @@ +from bip_utils.ton.mnemonic.ton_mnemonic import TonLanguages, TonMnemonic, TonWordsNum +from bip_utils.ton.mnemonic.ton_mnemonic_generator import TonMnemonicGenerator +from bip_utils.ton.mnemonic.ton_mnemonic_validator import TonMnemonicValidator +from bip_utils.ton.mnemonic.ton_seed_generator import TonSeedGenerator, TonSeedTypes diff --git a/bip_utils/ton/mnemonic/ton_mnemonic.py b/bip_utils/ton/mnemonic/ton_mnemonic.py new file mode 100644 index 00000000..82333ce0 --- /dev/null +++ b/bip_utils/ton/mnemonic/ton_mnemonic.py @@ -0,0 +1,60 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Module for TON mnemonic.""" + +# Imports +from enum import IntEnum, unique +from typing import List + +from bip_utils.bip.bip39 import Bip39Languages, Bip39Mnemonic +from bip_utils.bip.bip39.bip39_mnemonic import Bip39MnemonicConst +from bip_utils.utils.mnemonic import MnemonicLanguages + + +@unique +class TonWordsNum(IntEnum): + """Enumerative for TON words number.""" + + WORDS_NUM_12 = 12 + WORDS_NUM_24 = 24 + + +@unique +class TonLanguages(MnemonicLanguages): + """Enumerative for TON languages.""" + + ENGLISH = Bip39Languages.ENGLISH + + +class TonMnemonicConst: + """Class container for TON mnemonic constants.""" + + # Accepted mnemonic word numbers + MNEMONIC_WORD_NUM: List[TonWordsNum] = [ + TonWordsNum.WORDS_NUM_12, + TonWordsNum.WORDS_NUM_24, + ] + # Total number of words + WORDS_LIST_NUM: int = Bip39MnemonicConst.WORDS_LIST_NUM + + +class TonMnemonic(Bip39Mnemonic): + """TON mnemonic class.""" diff --git a/bip_utils/ton/mnemonic/ton_mnemonic_generator.py b/bip_utils/ton/mnemonic/ton_mnemonic_generator.py new file mode 100644 index 00000000..964ca02c --- /dev/null +++ b/bip_utils/ton/mnemonic/ton_mnemonic_generator.py @@ -0,0 +1,103 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module for TON mnemonic generation. +Reference: https://github.com/ton-org/ton-crypto/blob/master/src/mnemonic/mnemonic.ts +""" + +# Imports +import secrets +from typing import Union + +from bip_utils.bip.bip39.bip39_mnemonic_utils import Bip39WordsListGetter +from bip_utils.ton.mnemonic.ton_mnemonic import TonLanguages, TonMnemonic, TonMnemonicConst, TonWordsNum +from bip_utils.ton.mnemonic.ton_seed_utils import TonSeedUtils +from bip_utils.utils.mnemonic import Mnemonic + + +class TonMnemonicGeneratorConst: + """Class container for TON mnemonic generator constants.""" + + # Max attempts to generate a valid mnemonic + MAX_ATTEMPTS: int = 10**6 + + +class TonMnemonicGenerator: + """ + TON mnemonic generator class. + It generates 12 or 24-words mnemonic in according to TON wallets. + """ + + m_lang: TonLanguages + + def __init__(self, + lang: TonLanguages = TonLanguages.ENGLISH) -> None: + """ + Construct class. + + Args: + lang (TonLanguages, optional): Language (default: English) + + Raises: + TypeError: If the language is not a TonLanguages enum + ValueError: If language words list is not valid + """ + if not isinstance(lang, TonLanguages): + raise TypeError("Language is not an enumerative of TonLanguages") + self.m_lang = lang + + def FromWordsNumber(self, + words_num: Union[int, TonWordsNum] = TonWordsNum.WORDS_NUM_24, + passphrase: str = "") -> Mnemonic: + """ + Generate mnemonic with the specified words. + + Args: + words_num (int or TonWordsNum, optional): Number of words (12 or 24 by default) + passphrase (str, optional) : Passphrase (empty by default) + + Returns: + Mnemonic object: Generated mnemonic + + Raises: + ValueError: If words number is not valid or if unable to generate a valid mnemonic + """ + # Check words number + if words_num not in TonMnemonicConst.MNEMONIC_WORD_NUM: + raise ValueError(f"Words number for mnemonic ({words_num}) is not valid") + + words_list = Bip39WordsListGetter().GetByLanguage(self.m_lang.value) + for _ in range(TonMnemonicGeneratorConst.MAX_ATTEMPTS): + # Generate mnemonic + mnemonic_array = [] + for _ in range(words_num): + idx = secrets.randbelow(TonMnemonicConst.WORDS_LIST_NUM) + mnemonic_array.append(words_list.GetWordAtIdx(idx)) + mnemonic = " ".join(mnemonic_array) + + # Stop if generated mnemonic is valid + if passphrase != "": + if TonSeedUtils.IsPasswordNeeded(mnemonic): + return TonMnemonic(mnemonic_array) + elif TonSeedUtils.IsBasicSeed(TonSeedUtils.GetEntropyBytes(mnemonic, passphrase)): + return TonMnemonic(mnemonic_array) + + raise ValueError("Unable to generate a valid mnemonic") diff --git a/bip_utils/ton/mnemonic/ton_mnemonic_validator.py b/bip_utils/ton/mnemonic/ton_mnemonic_validator.py new file mode 100644 index 00000000..c153e6f4 --- /dev/null +++ b/bip_utils/ton/mnemonic/ton_mnemonic_validator.py @@ -0,0 +1,101 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module for TON mnemonic validation. +Reference: https://github.com/ton-org/ton-crypto/blob/master/src/mnemonic/mnemonic.ts +""" + +# Imports +from typing import Union + +from bip_utils.bip.bip39.bip39_mnemonic_utils import Bip39WordsListGetter +from bip_utils.ton.mnemonic.ton_mnemonic import TonLanguages, TonMnemonic +from bip_utils.ton.mnemonic.ton_seed_utils import TonSeedUtils +from bip_utils.utils.mnemonic.mnemonic import Mnemonic + + +class TonMnemonicValidator: + """ + TON mnemonic validator class. + It validates a mnemonic phrase. + """ + + m_lang: TonLanguages + + def __init__(self, + lang: TonLanguages = TonLanguages.ENGLISH) -> None: + """ + Construct class. + + Args: + lang (TonLanguages, optional): Language (default: English) + + Raises: + TypeError: If the language is not a TonLanguages enum + ValueError: If language words list is not valid + """ + if not isinstance(lang, TonLanguages): + raise TypeError("Language is not an enumerative of TonLanguages") + self.m_lang = lang + + def IsValid(self, + mnemonic: Union[str, Mnemonic], + passphrase: str = "") -> bool: + """ + Get if the specified mnemonic is valid. + + Args: + mnemonic (str or Mnemonic object): Mnemonic + passphrase (str, optional) : Passphrase (empty by default) + + Returns: + bool: True if valid, False otherwise + """ + mnemonic_obj = TonMnemonic.FromString(mnemonic) if isinstance(mnemonic, str) else mnemonic + + # Check words + words_list = Bip39WordsListGetter().GetByLanguage(self.m_lang.value) + mnemonic_list = mnemonic_obj.ToList() + for word in mnemonic_list: + try: + words_list.GetWordIdx(word) + except ValueError: + return False + # Check seed + if passphrase != "": + return TonSeedUtils.IsPasswordNeeded(mnemonic_obj.ToStr()) + return TonSeedUtils.IsBasicSeed(TonSeedUtils.GetEntropyBytes(mnemonic_obj.ToStr(), passphrase)) + + def Validate(self, + mnemonic: Union[str, Mnemonic], + passphrase: str = "") -> None: + """ + Validate the specified mnemonic. + + Args: + mnemonic (str or Mnemonic object): Mnemonic + passphrase (str, optional) : Passphrase (empty by default) + + Raises: + ValueError: If the mnemonic is not valid + """ + if not self.IsValid(mnemonic, passphrase): + raise ValueError("Invalid mnemonic") diff --git a/bip_utils/ton/mnemonic/ton_seed_generator.py b/bip_utils/ton/mnemonic/ton_seed_generator.py new file mode 100644 index 00000000..aae20434 --- /dev/null +++ b/bip_utils/ton/mnemonic/ton_seed_generator.py @@ -0,0 +1,94 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module for TON mnemonic seed generation. +Reference: https://github.com/ton-org/ton-crypto/blob/master/src/mnemonic/mnemonic.ts +""" + +# Imports +from enum import Enum, auto, unique +from typing import Union + +from bip_utils.ton.mnemonic.ton_mnemonic import TonLanguages +from bip_utils.ton.mnemonic.ton_mnemonic_validator import TonMnemonicValidator +from bip_utils.ton.mnemonic.ton_seed_utils import TonSeedUtils +from bip_utils.utils.mnemonic import Mnemonic + + +@unique +class TonSeedTypes(Enum): + """Enumerative for TON seed types.""" + + HD_KEY = auto() + PRIVATE_KEY = auto() + + +class TonSeedGenerator: + """ + TON seed generator class. + It generates the seed from a mnemonic. + """ + + m_mnemonic: str + m_passphrase: str + + def __init__(self, + mnemonic: Union[str, Mnemonic], + passphrase: str = "", + lang: TonLanguages = TonLanguages.ENGLISH) -> None: + """ + Construct class. + + Args: + mnemonic (str or Mnemonic object): Mnemonic + passphrase (str, optional) : Passphrase (empty by default) + lang (TonLanguages, optional) : Language (default: English) + + Raises: + ValueError: If the mnemonic is not valid + """ + mnemonic_str = mnemonic if isinstance(mnemonic, str) else mnemonic.ToStr() + if not TonMnemonicValidator(lang).IsValid(mnemonic_str, passphrase): + raise ValueError(f"Invalid mnemonic {mnemonic_str}") + self.m_mnemonic = mnemonic_str + self.m_passphrase = passphrase + + def Generate(self, + seed_type: TonSeedTypes = TonSeedTypes.PRIVATE_KEY) -> bytes: + """ + Generate seed. + + Args: + seed_type (TonSeedTypes, optional): Seed type (PRIVATE_KEY by default) + + Returns: + bytes: Generated seed + + Raises: + TypeError: If the seed type is not a TonSeedTypes enum + """ + if not isinstance(seed_type, TonSeedTypes): + raise TypeError("Seed type is not an enumerative of TonSeedTypes") + + entropy_bytes = TonSeedUtils.GetEntropyBytes(self.m_mnemonic, self.m_passphrase) + if seed_type == TonSeedTypes.PRIVATE_KEY: + return TonSeedUtils.GetPrivateKeySeed(entropy_bytes) + return TonSeedUtils.GetHdKeySeed(entropy_bytes) diff --git a/bip_utils/ton/mnemonic/ton_seed_utils.py b/bip_utils/ton/mnemonic/ton_seed_utils.py new file mode 100644 index 00000000..23d7943b --- /dev/null +++ b/bip_utils/ton/mnemonic/ton_seed_utils.py @@ -0,0 +1,151 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +""" +Module for TON seed utilities. +Reference: https://github.com/ton-org/ton-crypto/blob/master/src/mnemonic/mnemonic.ts +""" + +# Imports +from bip_utils.utils.crypto.hmac import HmacSha512 +from bip_utils.utils.crypto.pbkdf2 import Pbkdf2HmacSha512 + + +class TonSeedUtilsConst: + """Class container for TON mnemonic validator constants.""" + + # Password seed + PASSWORD_SEED_SALT_MOD: str = "TON fast seed version" + PASSWORD_SEED_PBKDF2_ROUNDS: int = 1 + # Basic seed + BASIC_SEED_SALT_MOD: str = "TON seed version" + BASIC_SEED_PBKDF2_ROUNDS: int = 100000 // 256 + # Private key seed + PRIV_KEY_SEED_SALT_MOD: str = "TON default seed" + PRIV_KEY_SEED_PBKDF2_ROUNDS: int = 100000 + # HD key seed + HD_KEY_SEED_SALT_MOD: str = "TON HD Keys seed" + HD_KEY_SEED_PBKDF2_ROUNDS: int = 100000 + # Seed length in bytes + SEED_LEN_BYTES: int = 64 + + +class TonSeedUtils: + """ + TON seed utilities class. + It provides some utility functions for the seed generation and validation. + """ + + @staticmethod + def GetEntropyBytes(mnemonic: str, + passphrase: str = "") -> bytes: + """ + Get entropy bytes from mnemonic and passphrase. + + Args: + mnemonic (str or Mnemonic object): Mnemonic + passphrase (str, optional) : Passphrase (empty by default) + + Returns: + bytes: Entropy bytes + """ + return HmacSha512().QuickDigest(mnemonic, passphrase) + + @staticmethod + def IsBasicSeed(entropy_bytes: bytes) -> bool: + """ + Get if the entropy bytes are for a basic seed. + + Args: + entropy_bytes (bytes): Entropy bytes to validate + + Returns: + bool: True if the entropy bytes are for a basic seed, False otherwise + """ + seed_bytes = Pbkdf2HmacSha512().DeriveKey(entropy_bytes, + TonSeedUtilsConst.BASIC_SEED_SALT_MOD, + TonSeedUtilsConst.BASIC_SEED_PBKDF2_ROUNDS, + TonSeedUtilsConst.SEED_LEN_BYTES) + return seed_bytes[0] == 0 + + @staticmethod + def IsPasswordSeed(entropy_bytes: bytes) -> bool: + """ + Get if the entropy bytes are for a password seed. + + Args: + entropy_bytes (bytes): Entropy bytes to validate + + Returns: + bool: True if the entropy bytes are for a password seed, False otherwise + """ + seed_bytes = Pbkdf2HmacSha512().DeriveKey(entropy_bytes, + TonSeedUtilsConst.PASSWORD_SEED_SALT_MOD, + TonSeedUtilsConst.PASSWORD_SEED_PBKDF2_ROUNDS, + TonSeedUtilsConst.SEED_LEN_BYTES) + return seed_bytes[0] == 1 + + @classmethod + def IsPasswordNeeded(cls, + mnemonic: str) -> bool: + """ + Get if the mnemonic needs a password. + + Args: + mnemonic (str): Mnemonic to check + + Returns: + bool: True if the mnemonic needs a password, False otherwise + """ + # Use entropy bytes without passphrase in according to Ton source code + entropy_bytes = cls.GetEntropyBytes(mnemonic) + return cls.IsPasswordSeed(entropy_bytes) and not cls.IsBasicSeed(entropy_bytes) + + @staticmethod + def GetPrivateKeySeed(entropy_bytes: bytes) -> bytes: + """ + Get the private key seed from entropy bytes. + + Args: + entropy_bytes (bytes): Entropy bytes + + Returns: + bytes: Private key seed bytes + """ + return Pbkdf2HmacSha512().DeriveKey(entropy_bytes, + TonSeedUtilsConst.PRIV_KEY_SEED_SALT_MOD, + TonSeedUtilsConst.PRIV_KEY_SEED_PBKDF2_ROUNDS, + TonSeedUtilsConst.SEED_LEN_BYTES) + + @staticmethod + def GetHdKeySeed(entropy_bytes: bytes) -> bytes: + """ + Get the HD key seed from entropy bytes. + + Args: + entropy_bytes (bytes): Entropy bytes + + Returns: + bytes: HD key seed bytes + """ + return Pbkdf2HmacSha512().DeriveKey(entropy_bytes, + TonSeedUtilsConst.HD_KEY_SEED_SALT_MOD, + TonSeedUtilsConst.HD_KEY_SEED_PBKDF2_ROUNDS, + TonSeedUtilsConst.SEED_LEN_BYTES) diff --git a/bip_utils/ton/ton.py b/bip_utils/ton/ton.py new file mode 100644 index 00000000..b7fad70a --- /dev/null +++ b/bip_utils/ton/ton.py @@ -0,0 +1,117 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Module containing utility classes for Ton keys derivation (ton-crypto style).""" + +# Imports +from __future__ import annotations + +from typing import Union + +from bip_utils.ecc.common.ikeys import IPrivateKey +from bip_utils.ton.addr import ( + TonAddrVersions, + TonV3R1AddrEncoder, + TonV3R2AddrEncoder, + TonV4AddrEncoder, + TonV5R1AddrEncoder, +) +from bip_utils.ton.ton_keys import TonPrivateKey, TonPublicKey + + +class Ton: + """ + TON class. + It allows to generate keys and addresses for TON wallets like ton-crypto. + """ + + m_priv_key: TonPrivateKey + m_pub_key: TonPublicKey + + @classmethod + def FromSeed(cls, + seed_bytes: bytes) -> Ton: + """ + Construct class from seed bytes. + + Args: + seed_bytes (bytes): Seed bytes + + Returns: + Ton object: Ton object + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + return cls(seed_bytes[:32]) + + def __init__(self, + priv_key: Union[bytes, IPrivateKey]) -> None: + """ + Construct class. + + Args: + priv_key (Union[bytes, IPrivateKey]): Private key bytes or object + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + self.m_priv_key = TonPrivateKey.FromBytesOrKeyObject(priv_key) + self.m_pub_key = self.m_priv_key.PublicKey() + + def PublicKey(self) -> TonPublicKey: + """ + Return public key object. + + Returns: + TonPublicKey object: TonPublicKey object + """ + return self.m_pub_key + + def PrivateKey(self) -> TonPrivateKey: + """ + Return private key object. + + Returns: + TonPrivateKey object: TonPrivateKey object + """ + return self.m_priv_key + + def GetAddress(self, + version: TonAddrVersions = TonAddrVersions.V5R1, + is_bounceable: bool = False) -> str: + """ + Get address from public key. + + Args: + version (TonAddrVersions, optional): Address version (default: v5r1) + is_bounceable (bool, optional) : Whether the address is bounceable (default: False) + + Returns: + str: Address string + """ + if version == TonAddrVersions.V5R1: + return TonV5R1AddrEncoder(self.m_pub_key).Encode(is_bounceable) + elif version == TonAddrVersions.V4: + return TonV4AddrEncoder(self.m_pub_key).Encode(is_bounceable) + elif version == TonAddrVersions.V3R2: + return TonV3R2AddrEncoder(self.m_pub_key).Encode(is_bounceable) + else: + return TonV3R1AddrEncoder(self.m_pub_key).Encode(is_bounceable) diff --git a/bip_utils/ton/ton_ex.py b/bip_utils/ton/ton_ex.py new file mode 100644 index 00000000..d8d3dc5a --- /dev/null +++ b/bip_utils/ton/ton_ex.py @@ -0,0 +1,25 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Module for TON exceptions.""" + + +class TonKeyError(Exception): + """Exception in case of TON key error.""" diff --git a/bip_utils/ton/ton_keys.py b/bip_utils/ton/ton_keys.py new file mode 100644 index 00000000..c63d77a6 --- /dev/null +++ b/bip_utils/ton/ton_keys.py @@ -0,0 +1,241 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Module for TON keys handling.""" + +# Imports +from __future__ import annotations + +from functools import lru_cache +from typing import Union + +from bip_utils.ecc import IPrivateKey, IPublicKey +from bip_utils.ecc.ed25519.ed25519_keys import Ed25519PrivateKey, Ed25519PublicKey +from bip_utils.ton.ton_ex import TonKeyError +from bip_utils.utils.misc import DataBytes + + +class TonPublicKey: + """TON public key class.""" + + m_pub_key: IPublicKey + + @classmethod + def FromBytesOrKeyObject(cls, + pub_key: Union[bytes, IPublicKey]) -> TonPublicKey: + """ + Get the public key from key bytes or object. + + Args: + pub_key (bytes or IPublicKey): Public key + + Returns: + TonPublicKey object: TonPublicKey object + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + return (cls.FromBytes(pub_key) + if isinstance(pub_key, bytes) + else cls(pub_key)) + + @classmethod + def FromBytes(cls, + key_bytes: bytes) -> TonPublicKey: + """ + Create from bytes. + + Args: + key_bytes (bytes): Key bytes + + Returns: + TonPublicKey object: TonPublicKey object + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + return cls(cls.__KeyFromBytes(key_bytes)) + + def __init__(self, + pub_key: IPublicKey) -> None: + """ + Construct class. + + Args: + pub_key (IPublicKey object): Key object + + Raises: + TonKeyError: If the bytes length is not valid + TypeError: If the key is not a Ed25519PublicKey object + """ + if not isinstance(pub_key, Ed25519PublicKey): + raise TypeError("Invalid public key object type") + self.m_pub_key = pub_key + + def KeyObject(self) -> IPublicKey: + """ + Return the key object. + + Returns: + IPublicKey object: Key object + """ + return self.m_pub_key + + @lru_cache() + def RawCompressed(self) -> DataBytes: + """ + Return raw compressed public key. + + Returns: + DataBytes object: DataBytes object + """ + return self.m_pub_key.RawCompressed() + + @lru_cache() + def RawUncompressed(self) -> DataBytes: + """ + Return raw uncompressed public key. + + Returns: + DataBytes object: DataBytes object + """ + return self.m_pub_key.RawUncompressed() + + @staticmethod + def __KeyFromBytes(key_bytes: bytes) -> IPublicKey: + """ + Construct key from bytes. + + Args: + key_bytes (bytes): Key bytes + + Returns: + IPublicKey object: IPublicKey object + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + try: + return Ed25519PublicKey.FromBytes(key_bytes) + except ValueError as ex: + raise TonKeyError("Invalid public key") from ex + + +class TonPrivateKey: + """TON private key class.""" + + m_priv_key: IPrivateKey + + @classmethod + def FromBytesOrKeyObject(cls, + priv_key: Union[bytes, IPrivateKey]) -> TonPrivateKey: + """ + Get the private key from key bytes or object. + + Args: + priv_key (bytes or IPrivateKey): Private key + + Returns: + TonPrivateKey object: TonPrivateKey object + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + return (cls.FromBytes(priv_key) + if isinstance(priv_key, bytes) + else cls(priv_key)) + + @classmethod + def FromBytes(cls, + key_bytes: bytes) -> TonPrivateKey: + """ + Create from bytes. + + Args: + key_bytes (bytes): Key bytes + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + return cls(cls.__KeyFromBytes(key_bytes)) + + def __init__(self, + priv_key: IPrivateKey) -> None: + """ + Construct class. + + Args: + priv_key (IPrivateKey object): Key object + + Raises: + TonKeyError: If the bytes length is not valid + TypeError: If the key is not a Ed25519PrivateKey object + """ + if not isinstance(priv_key, Ed25519PrivateKey): + raise TypeError("Invalid private key object type") + self.m_priv_key = priv_key + + def KeyObject(self) -> IPrivateKey: + """ + Return the key object. + + Returns: + IPrivateKey object: Key object + """ + return self.m_priv_key + + @lru_cache() + def Raw(self) -> DataBytes: + """ + Return raw private key. + + Returns: + DataBytes object: DataBytes object + """ + return self.m_priv_key.Raw() + + @lru_cache() + def PublicKey(self) -> TonPublicKey: + """ + Get the public key correspondent to the private one. + + Returns: + TonPublicKey object: TonPublicKey object + """ + return TonPublicKey(self.m_priv_key.PublicKey()) + + @staticmethod + def __KeyFromBytes(key_bytes: bytes) -> IPrivateKey: + """ + Construct key from bytes. + + Args: + key_bytes (bytes): Key bytes + + Returns: + IPrivateKey object: IPrivateKey object + + Raises: + TonKeyError: If the key constructed from the bytes is not valid + """ + try: + return Ed25519PrivateKey.FromBytes(key_bytes) + except ValueError as ex: + raise TonKeyError("Invalid private key") from ex diff --git a/bip_utils/utils/conf/coin_names.py b/bip_utils/utils/conf/coin_names.py index 1b458c00..a7e19052 100644 --- a/bip_utils/utils/conf/coin_names.py +++ b/bip_utils/utils/conf/coin_names.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/aes_ecb.py b/bip_utils/utils/crypto/aes_ecb.py index 62ac596b..1ba43627 100644 --- a/bip_utils/utils/crypto/aes_ecb.py +++ b/bip_utils/utils/crypto/aes_ecb.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/blake2.py b/bip_utils/utils/crypto/blake2.py index 3268d784..d2b92a06 100644 --- a/bip_utils/utils/crypto/blake2.py +++ b/bip_utils/utils/crypto/blake2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/chacha20_poly1305.py b/bip_utils/utils/crypto/chacha20_poly1305.py index fde8dc89..79324968 100644 --- a/bip_utils/utils/crypto/chacha20_poly1305.py +++ b/bip_utils/utils/crypto/chacha20_poly1305.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/crc.py b/bip_utils/utils/crypto/crc.py index 9213c2c5..20fe45d4 100644 --- a/bip_utils/utils/crypto/crc.py +++ b/bip_utils/utils/crypto/crc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/hash160.py b/bip_utils/utils/crypto/hash160.py index 5b7e6f69..43bf139b 100644 --- a/bip_utils/utils/crypto/hash160.py +++ b/bip_utils/utils/crypto/hash160.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/hmac.py b/bip_utils/utils/crypto/hmac.py index 1aa49275..9bc1c7f2 100644 --- a/bip_utils/utils/crypto/hmac.py +++ b/bip_utils/utils/crypto/hmac.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/pbkdf2.py b/bip_utils/utils/crypto/pbkdf2.py index 458a31f3..9b1d0502 100644 --- a/bip_utils/utils/crypto/pbkdf2.py +++ b/bip_utils/utils/crypto/pbkdf2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/ripemd.py b/bip_utils/utils/crypto/ripemd.py index af4dd889..496b7de1 100644 --- a/bip_utils/utils/crypto/ripemd.py +++ b/bip_utils/utils/crypto/ripemd.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/scrypt.py b/bip_utils/utils/crypto/scrypt.py index 8ab5e9ab..e143610c 100644 --- a/bip_utils/utils/crypto/scrypt.py +++ b/bip_utils/utils/crypto/scrypt.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/sha2.py b/bip_utils/utils/crypto/sha2.py index d7eeaf20..a3bc369a 100644 --- a/bip_utils/utils/crypto/sha2.py +++ b/bip_utils/utils/crypto/sha2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/crypto/sha3.py b/bip_utils/utils/crypto/sha3.py index ab28a821..d2192bab 100644 --- a/bip_utils/utils/crypto/sha3.py +++ b/bip_utils/utils/crypto/sha3.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/__init__.py b/bip_utils/utils/misc/__init__.py index 7508bcd8..44618424 100644 --- a/bip_utils/utils/misc/__init__.py +++ b/bip_utils/utils/misc/__init__.py @@ -1,5 +1,6 @@ from bip_utils.utils.misc.algo import AlgoUtils from bip_utils.utils.misc.base32 import Base32Decoder, Base32Encoder +from bip_utils.utils.misc.base64 import Base64Decoder, Base64Encoder from bip_utils.utils.misc.bit import BitUtils from bip_utils.utils.misc.bytes import BytesUtils from bip_utils.utils.misc.cbor_indefinite_len_array import CborIndefiniteLenArrayDecoder, CborIndefiniteLenArrayEncoder diff --git a/bip_utils/utils/misc/algo.py b/bip_utils/utils/misc/algo.py index faec6d55..49c06230 100644 --- a/bip_utils/utils/misc/algo.py +++ b/bip_utils/utils/misc/algo.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/base32.py b/bip_utils/utils/misc/base32.py index c3065059..9c151d18 100644 --- a/bip_utils/utils/misc/base32.py +++ b/bip_utils/utils/misc/base32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/base64.py b/bip_utils/utils/misc/base64.py new file mode 100644 index 00000000..d5045e79 --- /dev/null +++ b/bip_utils/utils/misc/base64.py @@ -0,0 +1,74 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Module with helper class for Base32.""" + +# Imports +import base64 +import binascii +from typing import Union + +from bip_utils.utils.misc.algo import AlgoUtils + + +class Base64Decoder: + """ + Base64 decoder class. + It provides methods for decoding to Base64 format. + """ + + @staticmethod + def Decode(data: str) -> bytes: + """ + Decode from Base64. + + Args: + data (str): Data + + Returns: + bytes: Decoded bytes + + Raises: + ValueError: If the Base64 string is not valid + """ + try: + return base64.b64decode(data) + except binascii.Error as ex: + raise ValueError("Invalid Base64 string") from ex + + +class Base64Encoder: + """ + Base64 encoder class. + It provides methods for encoding to Base64 format. + """ + + @staticmethod + def Encode(data: Union[bytes, str]) -> bytes: + """ + Encode to Base64. + + Args: + data (str or bytes): Data + + Returns: + str: Encoded string + """ + return base64.b64encode(AlgoUtils.Encode(data)) diff --git a/bip_utils/utils/misc/bit.py b/bip_utils/utils/misc/bit.py index 950c3e51..0958de14 100644 --- a/bip_utils/utils/misc/bit.py +++ b/bip_utils/utils/misc/bit.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/bytes.py b/bip_utils/utils/misc/bytes.py index 50a544d1..555cad26 100644 --- a/bip_utils/utils/misc/bytes.py +++ b/bip_utils/utils/misc/bytes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/cbor_indefinite_len_array.py b/bip_utils/utils/misc/cbor_indefinite_len_array.py index ed3f7f97..bec12edc 100644 --- a/bip_utils/utils/misc/cbor_indefinite_len_array.py +++ b/bip_utils/utils/misc/cbor_indefinite_len_array.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/data_bytes.py b/bip_utils/utils/misc/data_bytes.py index 5695a9b2..69709c89 100644 --- a/bip_utils/utils/misc/data_bytes.py +++ b/bip_utils/utils/misc/data_bytes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/integer.py b/bip_utils/utils/misc/integer.py index 271d070c..a8a0e70f 100644 --- a/bip_utils/utils/misc/integer.py +++ b/bip_utils/utils/misc/integer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/misc/string.py b/bip_utils/utils/misc/string.py index 7f68c095..15356b0f 100644 --- a/bip_utils/utils/misc/string.py +++ b/bip_utils/utils/misc/string.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/mnemonic/entropy_generator.py b/bip_utils/utils/mnemonic/entropy_generator.py index 3878cba7..4384d920 100644 --- a/bip_utils/utils/mnemonic/entropy_generator.py +++ b/bip_utils/utils/mnemonic/entropy_generator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/mnemonic/mnemonic.py b/bip_utils/utils/mnemonic/mnemonic.py index 5e88a738..756734ee 100644 --- a/bip_utils/utils/mnemonic/mnemonic.py +++ b/bip_utils/utils/mnemonic/mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/mnemonic/mnemonic_decoder_base.py b/bip_utils/utils/mnemonic/mnemonic_decoder_base.py index 7634c3d5..b597c853 100644 --- a/bip_utils/utils/mnemonic/mnemonic_decoder_base.py +++ b/bip_utils/utils/mnemonic/mnemonic_decoder_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/mnemonic/mnemonic_encoder_base.py b/bip_utils/utils/mnemonic/mnemonic_encoder_base.py index b5cbc111..e622cd86 100644 --- a/bip_utils/utils/mnemonic/mnemonic_encoder_base.py +++ b/bip_utils/utils/mnemonic/mnemonic_encoder_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/mnemonic/mnemonic_ex.py b/bip_utils/utils/mnemonic/mnemonic_ex.py index 24ac6049..a0cfcc2f 100644 --- a/bip_utils/utils/mnemonic/mnemonic_ex.py +++ b/bip_utils/utils/mnemonic/mnemonic_ex.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/mnemonic/mnemonic_utils.py b/bip_utils/utils/mnemonic/mnemonic_utils.py index d2980b9c..001770f7 100644 --- a/bip_utils/utils/mnemonic/mnemonic_utils.py +++ b/bip_utils/utils/mnemonic/mnemonic_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/utils/mnemonic/mnemonic_validator.py b/bip_utils/utils/mnemonic/mnemonic_validator.py index cc617f10..8d7ef132 100644 --- a/bip_utils/utils/mnemonic/mnemonic_validator.py +++ b/bip_utils/utils/mnemonic/mnemonic_validator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -46,7 +46,7 @@ def __init__(self, def Validate(self, mnemonic: Union[str, Mnemonic]) -> None: """ - Validate the mnemonic specified at construction. + Validate the specified mnemonic. Args: mnemonic (str or Mnemonic object): Mnemonic @@ -62,7 +62,7 @@ def Validate(self, def IsValid(self, mnemonic: Union[str, Mnemonic]) -> bool: """ - Get if the mnemonic specified at construction is valid. + Get if the specified mnemonic is valid. Args: mnemonic (str or Mnemonic object): Mnemonic diff --git a/bip_utils/utils/typing/literal.py b/bip_utils/utils/typing/literal.py index acb30db6..4efb97ac 100644 --- a/bip_utils/utils/typing/literal.py +++ b/bip_utils/utils/typing/literal.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/bip_utils/wif/wif.py b/bip_utils/wif/wif.py index 0099e9fc..2ace897a 100644 --- a/bip_utils/wif/wif.py +++ b/bip_utils/wif/wif.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/docs/bip_utils/addr/index.rst b/docs/bip_utils/addr/index.rst index 3403d4bc..d28d73ef 100644 --- a/docs/bip_utils/addr/index.rst +++ b/docs/bip_utils/addr/index.rst @@ -37,6 +37,7 @@ addr sol_addr substrate_addr sui_addr + ton_addr trx_addr xlm_addr xmr_addr diff --git a/docs/bip_utils/addr/ton_addr.rst b/docs/bip_utils/addr/ton_addr.rst new file mode 100644 index 00000000..a431a4cf --- /dev/null +++ b/docs/bip_utils/addr/ton_addr.rst @@ -0,0 +1,7 @@ +ton_addr +======== + +.. automodule:: bip_utils.addr.ton_addr + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/index.rst b/docs/bip_utils/index.rst index ec518f01..bd4f7a3e 100644 --- a/docs/bip_utils/index.rst +++ b/docs/bip_utils/index.rst @@ -18,5 +18,6 @@ bip_utils solana/index.rst ss58/index.rst substrate/index.rst + ton/index.rst utils/index.rst wif/index.rst diff --git a/docs/bip_utils/ton/addr/index.rst b/docs/bip_utils/ton/addr/index.rst new file mode 100644 index 00000000..cfe54cde --- /dev/null +++ b/docs/bip_utils/ton/addr/index.rst @@ -0,0 +1,10 @@ +addr +==== +.. toctree:: + :maxdepth: 10 + + ton_addr_versions + ton_v3r1_addr_encoder + ton_v3r2_addr_encoder + ton_v4_addr_encoder + ton_v5r1_addr_encoder diff --git a/docs/bip_utils/ton/addr/ton_addr_versions.rst b/docs/bip_utils/ton/addr/ton_addr_versions.rst new file mode 100644 index 00000000..4a63b6ae --- /dev/null +++ b/docs/bip_utils/ton/addr/ton_addr_versions.rst @@ -0,0 +1,7 @@ +ton_addr_versions +================= + +.. automodule:: bip_utils.ton.addr.ton_addr_versions + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/addr/ton_v3r1_addr_encoder.rst b/docs/bip_utils/ton/addr/ton_v3r1_addr_encoder.rst new file mode 100644 index 00000000..5912e247 --- /dev/null +++ b/docs/bip_utils/ton/addr/ton_v3r1_addr_encoder.rst @@ -0,0 +1,7 @@ +ton_v3r1_addr_encoder +===================== + +.. automodule:: bip_utils.ton.addr.ton_v3r1_addr_encoder + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/addr/ton_v3r2_addr_encoder.rst b/docs/bip_utils/ton/addr/ton_v3r2_addr_encoder.rst new file mode 100644 index 00000000..9603d5f3 --- /dev/null +++ b/docs/bip_utils/ton/addr/ton_v3r2_addr_encoder.rst @@ -0,0 +1,7 @@ +ton_v3r2_addr_encoder +===================== + +.. automodule:: bip_utils.ton.addr.ton_v3r2_addr_encoder + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/addr/ton_v4_addr_encoder.rst b/docs/bip_utils/ton/addr/ton_v4_addr_encoder.rst new file mode 100644 index 00000000..7fad5f08 --- /dev/null +++ b/docs/bip_utils/ton/addr/ton_v4_addr_encoder.rst @@ -0,0 +1,7 @@ +ton_v4_addr_encoder +=================== + +.. automodule:: bip_utils.ton.addr.ton_v4_addr_encoder + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/addr/ton_v5r1_addr_encoder.rst b/docs/bip_utils/ton/addr/ton_v5r1_addr_encoder.rst new file mode 100644 index 00000000..b87e5669 --- /dev/null +++ b/docs/bip_utils/ton/addr/ton_v5r1_addr_encoder.rst @@ -0,0 +1,7 @@ +ton_v5r1_addr_encoder +===================== + +.. automodule:: bip_utils.ton.addr.ton_v5r1_addr_encoder + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/index.rst b/docs/bip_utils/ton/index.rst new file mode 100644 index 00000000..15ee7085 --- /dev/null +++ b/docs/bip_utils/ton/index.rst @@ -0,0 +1,10 @@ +ton +=== +.. toctree:: + :maxdepth: 10 + + addr/index.rst + mnemonic/index.rst + ton + ton_ex + ton_keys diff --git a/docs/bip_utils/ton/mnemonic/index.rst b/docs/bip_utils/ton/mnemonic/index.rst new file mode 100644 index 00000000..1cc69cea --- /dev/null +++ b/docs/bip_utils/ton/mnemonic/index.rst @@ -0,0 +1,10 @@ +mnemonic +======== +.. toctree:: + :maxdepth: 10 + + ton_mnemonic + ton_mnemonic_generator + ton_mnemonic_validator + ton_seed_generator + ton_seed_utils diff --git a/docs/bip_utils/ton/mnemonic/ton_mnemonic.rst b/docs/bip_utils/ton/mnemonic/ton_mnemonic.rst new file mode 100644 index 00000000..278a9820 --- /dev/null +++ b/docs/bip_utils/ton/mnemonic/ton_mnemonic.rst @@ -0,0 +1,7 @@ +ton_mnemonic +============ + +.. automodule:: bip_utils.ton.mnemonic.ton_mnemonic + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/mnemonic/ton_mnemonic_generator.rst b/docs/bip_utils/ton/mnemonic/ton_mnemonic_generator.rst new file mode 100644 index 00000000..c3596f7b --- /dev/null +++ b/docs/bip_utils/ton/mnemonic/ton_mnemonic_generator.rst @@ -0,0 +1,7 @@ +ton_mnemonic_generator +====================== + +.. automodule:: bip_utils.ton.mnemonic.ton_mnemonic_generator + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/mnemonic/ton_mnemonic_validator.rst b/docs/bip_utils/ton/mnemonic/ton_mnemonic_validator.rst new file mode 100644 index 00000000..6e7d55a0 --- /dev/null +++ b/docs/bip_utils/ton/mnemonic/ton_mnemonic_validator.rst @@ -0,0 +1,7 @@ +ton_mnemonic_validator +====================== + +.. automodule:: bip_utils.ton.mnemonic.ton_mnemonic_validator + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/mnemonic/ton_seed_generator.rst b/docs/bip_utils/ton/mnemonic/ton_seed_generator.rst new file mode 100644 index 00000000..2d73c88a --- /dev/null +++ b/docs/bip_utils/ton/mnemonic/ton_seed_generator.rst @@ -0,0 +1,7 @@ +ton_seed_generator +================== + +.. automodule:: bip_utils.ton.mnemonic.ton_seed_generator + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/mnemonic/ton_seed_utils.rst b/docs/bip_utils/ton/mnemonic/ton_seed_utils.rst new file mode 100644 index 00000000..d1cb133f --- /dev/null +++ b/docs/bip_utils/ton/mnemonic/ton_seed_utils.rst @@ -0,0 +1,7 @@ +ton_seed_utils +============== + +.. automodule:: bip_utils.ton.mnemonic.ton_seed_utils + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/ton.rst b/docs/bip_utils/ton/ton.rst new file mode 100644 index 00000000..43e5d0c8 --- /dev/null +++ b/docs/bip_utils/ton/ton.rst @@ -0,0 +1,7 @@ +ton +=== + +.. automodule:: bip_utils.ton.ton + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/ton_ex.rst b/docs/bip_utils/ton/ton_ex.rst new file mode 100644 index 00000000..30aa0e5d --- /dev/null +++ b/docs/bip_utils/ton/ton_ex.rst @@ -0,0 +1,7 @@ +ton_ex +====== + +.. automodule:: bip_utils.ton.ton_ex + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/ton/ton_keys.rst b/docs/bip_utils/ton/ton_keys.rst new file mode 100644 index 00000000..5a524a24 --- /dev/null +++ b/docs/bip_utils/ton/ton_keys.rst @@ -0,0 +1,7 @@ +ton_keys +======== + +.. automodule:: bip_utils.ton.ton_keys + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/utils/misc/base64.rst b/docs/bip_utils/utils/misc/base64.rst new file mode 100644 index 00000000..6d10ba12 --- /dev/null +++ b/docs/bip_utils/utils/misc/base64.rst @@ -0,0 +1,7 @@ +base64 +====== + +.. automodule:: bip_utils.utils.misc.base64 + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/bip_utils/utils/misc/index.rst b/docs/bip_utils/utils/misc/index.rst index 6fe18402..f07656c8 100644 --- a/docs/bip_utils/utils/misc/index.rst +++ b/docs/bip_utils/utils/misc/index.rst @@ -5,6 +5,7 @@ misc algo base32 + base64 bit bytes cbor_indefinite_len_array diff --git a/examples/bip32_slip10_nist256p1.py b/examples/bip32_slip10_nist256p1.py index 588367ae..f1b9b349 100644 --- a/examples/bip32_slip10_nist256p1.py +++ b/examples/bip32_slip10_nist256p1.py @@ -1,7 +1,12 @@ """Example of keys derivation using BIP32 (nist256p1 curve).""" from bip_utils import ( - Bip32Slip10Nist256p1, Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, CoinsConf, NeoLegacyAddrEncoder + Bip32Slip10Nist256p1, + Bip39MnemonicGenerator, + Bip39SeedGenerator, + Bip39WordsNum, + CoinsConf, + NeoLegacyAddrEncoder, ) diff --git a/examples/bip39_to_algorand.py b/examples/bip39_to_algorand.py index d001e5bf..5ad56db3 100644 --- a/examples/bip39_to_algorand.py +++ b/examples/bip39_to_algorand.py @@ -9,8 +9,13 @@ from enum import Enum, auto, unique from bip_utils import ( - AlgorandMnemonicGenerator, Bip32KholawEd25519, Bip32Slip10Ed25519, Bip32Slip10Secp256k1, Bip39SeedGenerator, - BytesUtils, Ed25519PrivateKey + AlgorandMnemonicGenerator, + Bip32KholawEd25519, + Bip32Slip10Ed25519, + Bip32Slip10Secp256k1, + Bip39SeedGenerator, + BytesUtils, + Ed25519PrivateKey, ) diff --git a/examples/cardano_byron.py b/examples/cardano_byron.py index 48827cfb..74de85de 100644 --- a/examples/cardano_byron.py +++ b/examples/cardano_byron.py @@ -1,8 +1,16 @@ """Example of key derivation for Cardano (Byron addresses).""" from bip_utils import ( - Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44, Bip44Changes, Bip44Coins, BytesUtils, - CardanoByronLegacy, CardanoByronLegacySeedGenerator, CardanoIcarusSeedGenerator + Bip39MnemonicGenerator, + Bip39SeedGenerator, + Bip39WordsNum, + Bip44, + Bip44Changes, + Bip44Coins, + BytesUtils, + CardanoByronLegacy, + CardanoByronLegacySeedGenerator, + CardanoIcarusSeedGenerator, ) diff --git a/examples/cardano_shelley.py b/examples/cardano_shelley.py index 5ed5b1e1..ed656e21 100644 --- a/examples/cardano_shelley.py +++ b/examples/cardano_shelley.py @@ -1,8 +1,14 @@ """Example of key derivation for Cardano (Shelley addresses).""" from bip_utils import ( - Bip39MnemonicGenerator, Bip39SeedGenerator, Bip39WordsNum, Bip44Changes, CardanoIcarusSeedGenerator, CardanoShelley, - Cip1852, Cip1852Coins + Bip39MnemonicGenerator, + Bip39SeedGenerator, + Bip39WordsNum, + Bip44Changes, + CardanoIcarusSeedGenerator, + CardanoShelley, + Cip1852, + Cip1852Coins, ) @@ -86,4 +92,4 @@ print(f" {i}. Address chain code (bytes): {shelley_addr_ctx.PublicKeys().AddressKey().ChainCode().ToHex()}") print(f" {i}. Address public key (bytes): {shelley_addr_ctx.PublicKeys().AddressKey().RawCompressed().ToHex()[2:]}") print(f" {i}. Address private key (bytes): {shelley_addr_ctx.PrivateKeys().AddressKey().Raw().ToHex()}") - print(f" {i}. Address: {shelley_addr_ctx.PublicKeys().ToAddress()}") \ No newline at end of file + print(f" {i}. Address: {shelley_addr_ctx.PublicKeys().ToAddress()}") diff --git a/examples/electrum.py b/examples/electrum.py index 2b3c4427..9d4f2cda 100644 --- a/examples/electrum.py +++ b/examples/electrum.py @@ -1,9 +1,21 @@ """Example of mnemonic generation and keys derivation like the Electrum wallet.""" from bip_utils import ( - BytesUtils, CoinsConf, ElectrumV1, ElectrumV1MnemonicGenerator, ElectrumV1SeedGenerator, ElectrumV1WordsNum, - ElectrumV2MnemonicGenerator, ElectrumV2MnemonicTypes, ElectrumV2SeedGenerator, ElectrumV2Segwit, ElectrumV2Standard, - ElectrumV2WordsNum, IPrivateKey, WifEncoder, WifPubKeyModes + BytesUtils, + CoinsConf, + ElectrumV1, + ElectrumV1MnemonicGenerator, + ElectrumV1SeedGenerator, + ElectrumV1WordsNum, + ElectrumV2MnemonicGenerator, + ElectrumV2MnemonicTypes, + ElectrumV2SeedGenerator, + ElectrumV2Segwit, + ElectrumV2Standard, + ElectrumV2WordsNum, + IPrivateKey, + WifEncoder, + WifPubKeyModes, ) diff --git a/examples/ton.py b/examples/ton.py new file mode 100644 index 00000000..77b05ffa --- /dev/null +++ b/examples/ton.py @@ -0,0 +1,87 @@ +"""Example of mnemonic generation and key derivation for TON.""" + +from bip_utils import ( + Bip32Ed25519Slip, + Bip39MnemonicGenerator, + Bip39SeedGenerator, + Bip39WordsNum, + Bip44, + Bip44Coins, + Bip44ConfGetter, + TonAddrEncoder, + TonAddrVersions, + TonMnemonicGenerator, + TonMnemonicValidator, + TonSeedGenerator, + TonSeedTypes, + TonWordsNum, + Ton, +) + +# +# Generation like ton-crypto +# + +# Generate random mnemonic +mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24) +print(f"Mnemonic: {mnemonic}") + +# Validate mnemonic +is_valid = TonMnemonicValidator().IsValid(mnemonic) +print(f"Mnemonic valid: {is_valid}") + +# Generate seed for HD keys +seed_bytes = TonSeedGenerator(mnemonic).Generate(seed_type=TonSeedTypes.HD_KEY) +print(f"Seed for HD keys: {seed_bytes.hex()}") + +# Generate seed for keypair +seed_bytes = TonSeedGenerator(mnemonic).Generate(seed_type=TonSeedTypes.PRIVATE_KEY) +print(f"Seed for keypair: {seed_bytes.hex()}") + +# Generate keypair and address +ton = Ton.FromSeed(seed_bytes) +print(f"Ton public key (ton-crypto): {ton.PublicKey().RawCompressed().ToHex()}") +print(f"Ton private key (ton-crypto): {ton.PrivateKey().Raw().ToHex()}") +print(f"Ton address (ton-crypto, V5R1): {ton.GetAddress(version=TonAddrVersions.V5R1)}") + + +# +# Generation like Tonkeeper, Tonwallet, Trustwallet +# + +# Generate random mnemonic +mnemonic = Bip39MnemonicGenerator().FromWordsNumber(Bip39WordsNum.WORDS_NUM_24) +print(f"Mnemonic string: {mnemonic}") +# Generate seed from mnemonic +seed_bytes = Bip39SeedGenerator(mnemonic).Generate() + +# Construct from seed +bip44_mst_ctx = Bip44.FromSeed(seed_bytes, Bip44Coins.TON) +bip44_def_ctx = bip44_mst_ctx.DeriveDefaultPath() + +# Print keys +print(f"Ton private key: {bip44_def_ctx.PrivateKey().Raw().ToHex()}") +print(f"Ton public key: {bip44_def_ctx.PublicKey().RawCompressed().ToHex()[1:]}") +# Print address (default version is V4) +print(f"Ton address (V4): {bip44_def_ctx.PublicKey().ToAddress()}") +# Print address with other versions +pub_key_obj = bip44_def_ctx.PublicKey().Bip32Key().KeyObject() +print(f"Ton address (V3R1): {TonAddrEncoder.EncodeKey(pub_key_obj, version=TonAddrVersions.V3R1)}") +print(f"Ton address (V3R2): {TonAddrEncoder.EncodeKey(pub_key_obj, version=TonAddrVersions.V3R2)}") +print(f"Ton address (V5R1): {TonAddrEncoder.EncodeKey(pub_key_obj, version=TonAddrVersions.V5R1)}") + +# +# Generation like Ledger +# + +# Get coin index from configuration +coin_idx = Bip44ConfGetter.GetConfig(Bip44Coins.TON).CoinIndex() +# Derive +derivation_path = f"m/44'/{coin_idx}'/0'/0'/0'/0'" +bip32_ctx = Bip32Ed25519Slip.FromSeed(seed_bytes).DerivePath(derivation_path) + +# Construct BIP44 object from private key +priv_key_bytes = bip32_ctx.PrivateKey().Raw().ToBytes() +bip44_ctx = Bip44.FromPrivateKey(priv_key_bytes, Bip44Coins.TON) +# Print address +print(f"Ton address (Ledger, V4): {bip44_ctx.PublicKey().ToAddress()}") diff --git a/pyproject.toml b/pyproject.toml index aac478cd..97024308 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,6 +121,7 @@ keywords = [ "terra", "tezos", "theta", + "ton", "tron", "vechain", "verge", diff --git a/pyproject_legacy.toml b/pyproject_legacy.toml index a7396a22..982b0b36 100644 --- a/pyproject_legacy.toml +++ b/pyproject_legacy.toml @@ -128,6 +128,7 @@ keywords = [ "terra", "tezos", "theta", + "ton", "tron", "vechain", "verge", diff --git a/readme/bip44.md b/readme/bip44.md index 10d3e75d..cbc98a90 100644 --- a/readme/bip44.md +++ b/readme/bip44.md @@ -91,6 +91,7 @@ Supported coins enumerative for BIP-0044: |Terra|`Bip44Coins.TERRA`|-| |Tezos|`Bip44Coins.TEZOS`|-| |Theta Network|`Bip44Coins.THETA`|-| +|Ton|`Bip44Coins.TON`|-| |Tron|`Bip44Coins.TRON`|-| |VeChain|`Bip44Coins.VECHAIN`|-| |Verge|`Bip44Coins.VERGE`|-| diff --git a/readme/ton.md b/readme/ton.md new file mode 100644 index 00000000..702a2bcd --- /dev/null +++ b/readme/ton.md @@ -0,0 +1,105 @@ +## TON library + +The TON library allows to generate and validate mnemonics, generate seeds and keys with the same algorithm of `ton-crypto`. + +### TON Mnemonics + +The usage of TON mnemonics is much simpler than other mnemonic modules, since there is no decoder/encoder but only generation and validation. + +Supported words number: + +|Words number|Enum| +|---|---| +|24|`TonWordsNum.WORDS_NUM_24`| + +Supported languages: + +|Language|Enum| +|---|---| +|English|`TonLanguages.ENGLISH`| + +**Code example (mnemonic generation)** + + from bip_utils import TonLanguages, TonWordsNum, TonMnemonicGenerator + + # Generate a random mnemonic string of 24 words with default language (English) + # A Mnemonic object will be returned + mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24) + + # Get words count + print(mnemonic.WordsCount()) + # Get as string + print(mnemonic.ToStr()) + print(str(mnemonic)) + # Get as list of strings + print(mnemonic.ToList()) + + # Generate a random mnemonic string of 24 words by specifying the language + mnemonic = TonMnemonicGenerator(TonLanguages.ENGLISH).FromWordsNumber(TonWordsNum.WORDS_NUM_24) + +**Code example (mnemonic validation)** + + from bip_utils import ( + TonLanguages, TonWordsNum, TonMnemonic, TonMnemonicGenerator, TonMnemonicValidator, + ) + + # Mnemonic can be generated with TonMnemonicGenerator + mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24) + # Or it can be a string + mnemonic = "dove option fame breeze orchard ecology pizza flight miracle film lemon dwarf axis tone soldier nut flavor wheat dish express path private sea ladder" + # Or from a list + mnemonic = TonMnemonic.FromList(mnemonic.split()) + + # Get if a mnemonic is valid with automatic language detection, return bool + is_valid = TonMnemonicValidator().IsValid(mnemonic) + # Same but specifying the language + is_valid = TonMnemonicValidator(TonLanguages.ENGLISH).IsValid(mnemonic) + # Validate a mnemonic, raise exceptions + try: + TonMnemonicValidator().Validate(mnemonic) + # Valid... + except ValueError: + # Invalid length or language... + pass + +**Code example (mnemonic seed generation)** + + from bip_utils import TonLanguages, TonWordsNum, TonMnemonicGenerator, TonSeedGenerator, TonSeedTypes + + # Mnemonic can be generated with TonMnemonicGenerator + mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24) + # Or it can be a string + mnemonic = "dove option fame breeze orchard ecology pizza flight miracle film lemon dwarf axis tone soldier nut flavor wheat dish express path private sea ladder" + + # Generate seed for private key (automatic language detection) + seed_bytes = TonSeedGenerator(mnemonic).Generate() + seed_bytes = TonSeedGenerator(mnemonic).Generate(TonSeedTypes.PRIVATE_KEY) + # Generate seed for HD keys (automatic language detection) + seed_bytes = TonSeedGenerator(mnemonic).Generate(TonSeedTypes.HD_KEY) + # Generate specifying the language + seed_bytes = TonSeedGenerator(mnemonic, lang=TonLanguages.ENGLISH).Generate() + +### TON Keys Derivation + +For deriving keys and getting addresses, a `Ton` class shall be created. + +**Code example** + + from bip_utils import Ton, TonAddrVersions, TonMnemonicGenerator, TonSeedGenerator, TonWordsNum + + # Generate mnemonic and seed for private key + mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24) + seed_bytes = TonSeedGenerator(mnemonic).Generate() + + # Create TON class + ton = Ton.FromSeed(seed_bytes) + # Get keys + print(ton.PublicKey().RawCompressed().ToHex()) + print(ton.PrivateKey().Raw().ToHex()) + # Get address (default: V5R1) + print(ton.GetAddress()) + # Get address specifying version + print(ton.GetAddress(version=TonAddrVersions.V3R1)) + print(ton.GetAddress(version=TonAddrVersions.V3R2)) + print(ton.GetAddress(version=TonAddrVersions.V4)) + print(ton.GetAddress(version=TonAddrVersions.V5R1)) diff --git a/readme/utility/addr.md b/readme/utility/addr.md index 73957430..03264743 100644 --- a/readme/utility/addr.md +++ b/readme/utility/addr.md @@ -201,6 +201,15 @@ The address library allows encoding/decoding addresses for all the supported coi pub_key_hash = MvrkAddrDecoder.DecodeAddr(addr, prefix=MvrkAddrPrefixes.MV1) + # Ton address with custom parameters + addr = TonAddrEncoder.EncodeKey(pub_key, + version=TonAddrVersions.V4) + # Or with the default parameters from BIP configuration: + addr = TonAddrEncoder.EncodeKey(pub_key, + **Bip44Conf.Ton.AddrParams()) + # NOTE: TonAddrDecoder is not currently implemented + + **Code example (coins based on the ed25519-blake2b curve)** import binascii diff --git a/requirements.txt b/requirements.txt index 95dfcb57..9ae908c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,4 +16,5 @@ py-sr25519-bindings>=0.1.3,<2.0.0; python_version < '3.10' py-sr25519-bindings>=0.1.4,<2.0.0; python_version == '3.10' py-sr25519-bindings>=0.2.0,<2.0.0; python_version >= '3.11' py-sr25519-bindings>=0.2.2,<2.0.0; python_version >= '3.13' +pytoniq-core-fork>=0.1.47,<0.2.0 typing_extensions; python_version == '3.7' diff --git a/tests/addr/test_P2PKH.py b/tests/addr/test_P2PKH.py index 1fddeefa..35e7992a 100644 --- a/tests/addr/test_P2PKH.py +++ b/tests/addr/test_P2PKH.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_P2SH.py b/tests/addr/test_P2SH.py index c95bd960..381e2415 100644 --- a/tests/addr/test_P2SH.py +++ b/tests/addr/test_P2SH.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_P2TR.py b/tests/addr/test_P2TR.py index 9d33b4f0..202444f5 100644 --- a/tests/addr/test_P2TR.py +++ b/tests/addr/test_P2TR.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_P2WPKH.py b/tests/addr/test_P2WPKH.py index a24d2c51..8e36d798 100644 --- a/tests/addr/test_P2WPKH.py +++ b/tests/addr/test_P2WPKH.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_ada_byron_addr.py b/tests/addr/test_ada_byron_addr.py index 88a42eb5..7ea6dbc7 100644 --- a/tests/addr/test_ada_byron_addr.py +++ b/tests/addr/test_ada_byron_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,16 @@ import binascii from bip_utils import ( - AdaByronAddrDecoder, AdaByronAddrTypes, AdaByronIcarusAddr, AdaByronIcarusAddrEncoder, AdaByronLegacyAddr, - AdaByronLegacyAddrEncoder, Bip32ChainCode, Bip32PathError, Bip32PathParser, ChaCha20Poly1305 + AdaByronAddrDecoder, + AdaByronAddrTypes, + AdaByronIcarusAddr, + AdaByronIcarusAddrEncoder, + AdaByronLegacyAddr, + AdaByronLegacyAddrEncoder, + Bip32ChainCode, + Bip32PathError, + Bip32PathParser, + ChaCha20Poly1305, ) from tests.addr.test_addr_base import AddrBaseTests from tests.addr.test_addr_const import TEST_ED25519_ADDR_INVALID_KEY_TYPES diff --git a/tests/addr/test_ada_shelley_addr.py b/tests/addr/test_ada_shelley_addr.py index 004a7c21..87badd76 100644 --- a/tests/addr/test_ada_shelley_addr.py +++ b/tests/addr/test_ada_shelley_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,9 +22,16 @@ import binascii from bip_utils import ( - AdaShelleyAddr, AdaShelleyAddrDecoder, AdaShelleyAddrEncoder, AdaShelleyAddrNetworkTags, AdaShelleyRewardAddr, - AdaShelleyRewardAddrDecoder, AdaShelleyRewardAddrEncoder, AdaShelleyStakingAddr, AdaShelleyStakingAddrDecoder, - AdaShelleyStakingAddrEncoder + AdaShelleyAddr, + AdaShelleyAddrDecoder, + AdaShelleyAddrEncoder, + AdaShelleyAddrNetworkTags, + AdaShelleyRewardAddr, + AdaShelleyRewardAddrDecoder, + AdaShelleyRewardAddrEncoder, + AdaShelleyStakingAddr, + AdaShelleyStakingAddrDecoder, + AdaShelleyStakingAddrEncoder, ) from tests.addr.test_addr_base import AddrBaseTests from tests.addr.test_addr_const import TEST_ED25519_ADDR_INVALID_KEY_TYPES diff --git a/tests/addr/test_addr_base.py b/tests/addr/test_addr_base.py index ee196bc4..ece4ca37 100644 --- a/tests/addr/test_addr_base.py +++ b/tests/addr/test_addr_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_addr_const.py b/tests/addr/test_addr_const.py index fcb249ea..a8443087 100644 --- a/tests/addr/test_addr_const.py +++ b/tests/addr/test_addr_const.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_algo_addr.py b/tests/addr/test_algo_addr.py index 3b862003..906d8883 100644 --- a/tests/addr/test_algo_addr.py +++ b/tests/addr/test_algo_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_aptos_addr.py b/tests/addr/test_aptos_addr.py index a5ef9dac..5027b484 100644 --- a/tests/addr/test_aptos_addr.py +++ b/tests/addr/test_aptos_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_atom_addr.py b/tests/addr/test_atom_addr.py index f9ab83ba..fb1b2f97 100644 --- a/tests/addr/test_atom_addr.py +++ b/tests/addr/test_atom_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_avax_addr.py b/tests/addr/test_avax_addr.py index 1285dc29..bcdcfa62 100644 --- a/tests/addr/test_avax_addr.py +++ b/tests/addr/test_avax_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,12 @@ # Imports from bip_utils import ( - AvaxPChainAddr, AvaxPChainAddrDecoder, AvaxPChainAddrEncoder, AvaxXChainAddr, AvaxXChainAddrDecoder, - AvaxXChainAddrEncoder + AvaxPChainAddr, + AvaxPChainAddrDecoder, + AvaxPChainAddrEncoder, + AvaxXChainAddr, + AvaxXChainAddrDecoder, + AvaxXChainAddrEncoder, ) from tests.addr.test_addr_base import AddrBaseTests from tests.addr.test_addr_const import TEST_SECP256K1_ADDR_INVALID_KEY_TYPES diff --git a/tests/addr/test_bch_P2PKH.py b/tests/addr/test_bch_P2PKH.py index a8de951a..a3f144f9 100644 --- a/tests/addr/test_bch_P2PKH.py +++ b/tests/addr/test_bch_P2PKH.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_bch_P2SH.py b/tests/addr/test_bch_P2SH.py index 7da96f4a..ade54afa 100644 --- a/tests/addr/test_bch_P2SH.py +++ b/tests/addr/test_bch_P2SH.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_bch_addr_converter.py b/tests/addr/test_bch_addr_converter.py index f9963633..c6370d28 100644 --- a/tests/addr/test_bch_addr_converter.py +++ b/tests/addr/test_bch_addr_converter.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_egld_addr.py b/tests/addr/test_egld_addr.py index 3703c8f7..6e551fd7 100644 --- a/tests/addr/test_egld_addr.py +++ b/tests/addr/test_egld_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_eos_addr.py b/tests/addr/test_eos_addr.py index 0a7005da..659331e0 100644 --- a/tests/addr/test_eos_addr.py +++ b/tests/addr/test_eos_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_ergo_addr.py b/tests/addr/test_ergo_addr.py index c2f0aa27..ac13f236 100644 --- a/tests/addr/test_ergo_addr.py +++ b/tests/addr/test_ergo_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_eth_addr.py b/tests/addr/test_eth_addr.py index db367cb9..d42e7a5a 100644 --- a/tests/addr/test_eth_addr.py +++ b/tests/addr/test_eth_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_fil_addr.py b/tests/addr/test_fil_addr.py index 04eca27a..6d362908 100644 --- a/tests/addr/test_fil_addr.py +++ b/tests/addr/test_fil_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_icx_addr.py b/tests/addr/test_icx_addr.py index 564f0369..cce1e760 100644 --- a/tests/addr/test_icx_addr.py +++ b/tests/addr/test_icx_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_inj_addr.py b/tests/addr/test_inj_addr.py index c82e370d..366a5767 100644 --- a/tests/addr/test_inj_addr.py +++ b/tests/addr/test_inj_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_mvrk_addr.py b/tests/addr/test_mvrk_addr.py index acdf17e6..a7adcae6 100644 --- a/tests/addr/test_mvrk_addr.py +++ b/tests/addr/test_mvrk_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_nano_addr.py b/tests/addr/test_nano_addr.py index eb5e3858..c1c02ee4 100644 --- a/tests/addr/test_nano_addr.py +++ b/tests/addr/test_nano_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_near_addr.py b/tests/addr/test_near_addr.py index 1e531177..292d165e 100644 --- a/tests/addr/test_near_addr.py +++ b/tests/addr/test_near_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_neo_legacy_addr.py b/tests/addr/test_neo_legacy_addr.py index a7c9f343..3b22c546 100644 --- a/tests/addr/test_neo_legacy_addr.py +++ b/tests/addr/test_neo_legacy_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_neo_n3_addr.py b/tests/addr/test_neo_n3_addr.py index e779e375..cb0dc4eb 100644 --- a/tests/addr/test_neo_n3_addr.py +++ b/tests/addr/test_neo_n3_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_nim_addr.py b/tests/addr/test_nim_addr.py index f0427c03..6f91842c 100644 --- a/tests/addr/test_nim_addr.py +++ b/tests/addr/test_nim_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_okex_addr.py b/tests/addr/test_okex_addr.py index 95af9cbe..e0b3ddf9 100644 --- a/tests/addr/test_okex_addr.py +++ b/tests/addr/test_okex_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_one_addr.py b/tests/addr/test_one_addr.py index 68b2bf6b..1dd4e053 100644 --- a/tests/addr/test_one_addr.py +++ b/tests/addr/test_one_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_sol_addr.py b/tests/addr/test_sol_addr.py index ea5f613c..387e732c 100644 --- a/tests/addr/test_sol_addr.py +++ b/tests/addr/test_sol_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_substrate_addr.py b/tests/addr/test_substrate_addr.py index faf8f71b..90b27cc2 100644 --- a/tests/addr/test_substrate_addr.py +++ b/tests/addr/test_substrate_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,13 +20,20 @@ # Imports from bip_utils import ( - SubstrateEd25519Addr, SubstrateEd25519AddrDecoder, SubstrateEd25519AddrEncoder, SubstrateSr25519Addr, - SubstrateSr25519AddrDecoder, SubstrateSr25519AddrEncoder + SubstrateEd25519Addr, + SubstrateEd25519AddrDecoder, + SubstrateEd25519AddrEncoder, + SubstrateSr25519Addr, + SubstrateSr25519AddrDecoder, + SubstrateSr25519AddrEncoder, ) from tests.addr.test_addr_base import AddrBaseTests from tests.addr.test_addr_const import TEST_ED25519_ADDR_INVALID_KEY_TYPES, TEST_SR25519_ADDR_INVALID_KEY_TYPES from tests.ecc.test_ecc import ( - TEST_VECT_ED25519_PUB_KEY_INVALID, TEST_VECT_SR25519_PUB_KEY_INVALID, Ed25519PublicKey, Sr25519PublicKey + TEST_VECT_ED25519_PUB_KEY_INVALID, + TEST_VECT_SR25519_PUB_KEY_INVALID, + Ed25519PublicKey, + Sr25519PublicKey, ) diff --git a/tests/addr/test_sui_addr.py b/tests/addr/test_sui_addr.py index f5c8cfc6..55cb3adb 100644 --- a/tests/addr/test_sui_addr.py +++ b/tests/addr/test_sui_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_ton_addr.py b/tests/addr/test_ton_addr.py new file mode 100644 index 00000000..137e0686 --- /dev/null +++ b/tests/addr/test_ton_addr.py @@ -0,0 +1,102 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Imports +from bip_utils import TonAddr, TonAddrEncoder, TonAddrVersions +from tests.addr.test_addr_base import AddrBaseTests +from tests.addr.test_addr_const import TEST_ED25519_ADDR_INVALID_KEY_TYPES +from tests.ecc.test_ecc import TEST_VECT_ED25519_PUB_KEY_INVALID, Ed25519PublicKey + + +# Some random public keys +TEST_VECT = [ + { + "pub_key": b"00c6ba5594e3334ff890d2ab1dcf6757099b3505fd802d9ca1b4fc8b883f89a9de", + "address_params": { + "version": TonAddrVersions.V3R1, + }, + "address": "UQCrT9wQSjIWfJIrWitT5dup79QzkHvKs8jWx_UOoKQlXvP_", + }, + { + "pub_key": b"00961411d8c9e817055fd615ad953cc0f87dad689ec23a1c48fc06e5472efecc55", + "address_params": { + "version": TonAddrVersions.V3R2, + }, + "address": "UQB-ejjqwZvzd8m7fcZbPTofsRbGbuw96bQ190Lgi198e1Gl", + }, + { + "pub_key": b"00479a59b16b5fe57fa99dd763a3de0908cdc05d8a72f1ae1b535545dc6514e2ac", + "address_params": { + "version": TonAddrVersions.V4, + }, + "address": "UQBhx8AhGyL7153Yaf8svkZkEKbG0JcsUcNpTwu2kOm5WaW7", + }, + { + "pub_key": b"1af97d53283a3c57f47db2b97263e86c93acc38853ca2246db5daa32cb7a1037", + "address_params": { + "version": TonAddrVersions.V4, + }, + "address": "UQD3dn7-3QdJT_36TEL16JYWDz0tWqkNbuEKyOEjy0-1NbfG", + }, + { + "pub_key": b"1af97d53283a3c57f47db2b97263e86c93acc38853ca2246db5daa32cb7a1037", + "address_params": {}, # Default: V4 + "address": "UQD3dn7-3QdJT_36TEL16JYWDz0tWqkNbuEKyOEjy0-1NbfG", + }, + { + "pub_key": b"ad724aba20a7591624efee55eae11ec1f765d483544a9bf42ff7467d0f88a113", + "address_params": { + "version": TonAddrVersions.V5R1, + }, + "address": "UQB8E-CQxLds85ZPY8sXEYGe_EQ1qlY6q7l3BNbWQC1srNHe", + }, +] + + +# +# Tests +# +class TonAddrTests(AddrBaseTests): + # Test encode key + def test_encode_key(self): + self._test_encode_key(TonAddrEncoder, Ed25519PublicKey, TEST_VECT) + + # Test invalid keys + def test_invalid_keys(self): + self._test_invalid_keys( + TonAddrEncoder, + { + "version": TonAddrVersions.V4, + }, + TEST_ED25519_ADDR_INVALID_KEY_TYPES, + TEST_VECT_ED25519_PUB_KEY_INVALID + ) + + # Test invalid parameters + def test_invalid_params(self): + self._test_invalid_params_enc( + TonAddrEncoder, + {"version": 0}, + TypeError + ) + + # Test old address class + def test_old_addr_cls(self): + self.assertTrue(TonAddr is TonAddrEncoder) diff --git a/tests/addr/test_trx_addr.py b/tests/addr/test_trx_addr.py index 9aca45f2..5daaacfb 100644 --- a/tests/addr/test_trx_addr.py +++ b/tests/addr/test_trx_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_xlm_addr.py b/tests/addr/test_xlm_addr.py index b08dce23..47f47a6e 100644 --- a/tests/addr/test_xlm_addr.py +++ b/tests/addr/test_xlm_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_xmr_addr.py b/tests/addr/test_xmr_addr.py index 27cca6ff..ed98fdbe 100644 --- a/tests/addr/test_xmr_addr.py +++ b/tests/addr/test_xmr_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,13 @@ import binascii from bip_utils import ( - CoinsConf, XmrAddr, XmrAddrDecoder, XmrAddrEncoder, XmrIntegratedAddr, XmrIntegratedAddrDecoder, - XmrIntegratedAddrEncoder + CoinsConf, + XmrAddr, + XmrAddrDecoder, + XmrAddrEncoder, + XmrIntegratedAddr, + XmrIntegratedAddrDecoder, + XmrIntegratedAddrEncoder, ) from bip_utils.addr.xmr_addr import XmrAddrConst from tests.addr.test_addr_base import AddrBaseTests diff --git a/tests/addr/test_xrp_addr.py b/tests/addr/test_xrp_addr.py index 0565d2d1..07d7ed97 100644 --- a/tests/addr/test_xrp_addr.py +++ b/tests/addr/test_xrp_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_xtz_addr.py b/tests/addr/test_xtz_addr.py index b37d5cd5..073b1364 100644 --- a/tests/addr/test_xtz_addr.py +++ b/tests/addr/test_xtz_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/addr/test_zil_addr.py b/tests/addr/test_zil_addr.py index d2dece69..f760e83e 100644 --- a/tests/addr/test_zil_addr.py +++ b/tests/addr/test_zil_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/algorand/mnemonic/test_algorand_mnemonic.py b/tests/algorand/mnemonic/test_algorand_mnemonic.py index af54ccf5..b54797d7 100644 --- a/tests/algorand/mnemonic/test_algorand_mnemonic.py +++ b/tests/algorand/mnemonic/test_algorand_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,9 +23,17 @@ import unittest from bip_utils import ( - AlgorandEntropyBitLen, AlgorandEntropyGenerator, AlgorandLanguages, AlgorandMnemonicDecoder, - AlgorandMnemonicGenerator, AlgorandMnemonicValidator, AlgorandSeedGenerator, AlgorandWordsNum, Bip44, Bip44Coins, - MnemonicChecksumError + AlgorandEntropyBitLen, + AlgorandEntropyGenerator, + AlgorandLanguages, + AlgorandMnemonicDecoder, + AlgorandMnemonicGenerator, + AlgorandMnemonicValidator, + AlgorandSeedGenerator, + AlgorandWordsNum, + Bip44, + Bip44Coins, + MnemonicChecksumError, ) @@ -141,9 +149,11 @@ def test_vector(self): # Test mnemonic validator (language specified) mnemonic_validator = AlgorandMnemonicValidator(lang) self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test mnemonic validator (automatic language detection) mnemonic_validator = AlgorandMnemonicValidator() self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test decoder (language specified) entropy = AlgorandMnemonicDecoder(lang).Decode(mnemonic) diff --git a/tests/base58/test_base58.py b/tests/base58/test_base58.py index 358cc15d..fc43d5c1 100644 --- a/tests/base58/test_base58.py +++ b/tests/base58/test_base58.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/base58/test_base58_xmr.py b/tests/base58/test_base58_xmr.py index 33040c9f..81174a0a 100644 --- a/tests/base58/test_base58_xmr.py +++ b/tests/base58/test_base58_xmr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bech32/test_bch_bech32.py b/tests/bech32/test_bch_bech32.py index ed7e1f87..44e15f23 100644 --- a/tests/bech32/test_bch_bech32.py +++ b/tests/bech32/test_bch_bech32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bech32/test_bech32.py b/tests/bech32/test_bech32.py index d7565ce8..50933e07 100644 --- a/tests/bech32/test_bech32.py +++ b/tests/bech32/test_bech32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bech32/test_segwit_bech32.py b/tests/bech32/test_segwit_bech32.py index ba56b9f9..f132a799 100644 --- a/tests/bech32/test_segwit_bech32.py +++ b/tests/bech32/test_segwit_bech32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip32/test_bip32_base.py b/tests/bip/bip32/test_bip32_base.py index cdd6dc08..06dd45e2 100644 --- a/tests/bip/bip32/test_bip32_base.py +++ b/tests/bip/bip32/test_bip32_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,16 @@ import unittest from bip_utils import ( - Bip32ChainCode, Bip32Depth, Bip32FingerPrint, Bip32KeyData, Bip32KeyError, Bip32KeyIndex, Bip32KeyNetVersions, - Bip32PrivateKey, Bip32PublicKey, EllipticCurveGetter + Bip32ChainCode, + Bip32Depth, + Bip32FingerPrint, + Bip32KeyData, + Bip32KeyError, + Bip32KeyIndex, + Bip32KeyNetVersions, + Bip32PrivateKey, + Bip32PublicKey, + EllipticCurveGetter, ) from bip_utils.bip.bip32.bip32_key_data import Bip32KeyDataConst from bip_utils.bip.bip32.slip10.bip32_slip10_mst_key_generator import Bip32Slip10MstKeyGeneratorConst diff --git a/tests/bip/bip32/test_bip32_ed25519_kholaw.py b/tests/bip/bip32/test_bip32_ed25519_kholaw.py index 1d879ab6..d3b409e7 100644 --- a/tests/bip/bip32/test_bip32_ed25519_kholaw.py +++ b/tests/bip/bip32/test_bip32_ed25519_kholaw.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip32/test_bip32_key_data.py b/tests/bip/bip32/test_bip32_key_data.py index ceef91ca..6353ec55 100644 --- a/tests/bip/bip32/test_bip32_key_data.py +++ b/tests/bip/bip32/test_bip32_key_data.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip32/test_bip32_key_net_ver.py b/tests/bip/bip32/test_bip32_key_net_ver.py index 83117793..38709ed7 100644 --- a/tests/bip/bip32/test_bip32_key_net_ver.py +++ b/tests/bip/bip32/test_bip32_key_net_ver.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip32/test_bip32_keys.py b/tests/bip/bip32/test_bip32_keys.py index 5fe0c5e8..96bf0603 100644 --- a/tests/bip/bip32/test_bip32_keys.py +++ b/tests/bip/bip32/test_bip32_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,14 @@ # Imports from bip_utils import ( - Bip32ChainCode, Bip32Depth, Bip32FingerPrint, Bip32KeyData, Bip32KeyError, Bip32KeyIndex, Bip32PrivateKey, - Bip32PublicKey + Bip32ChainCode, + Bip32Depth, + Bip32FingerPrint, + Bip32KeyData, + Bip32KeyError, + Bip32KeyIndex, + Bip32PrivateKey, + Bip32PublicKey, ) from bip_utils.bip.bip32.bip32_const import Bip32Const from tests.ecc.test_ecc import * diff --git a/tests/bip/bip32/test_bip32_path.py b/tests/bip/bip32/test_bip32_path.py index 2b8216bc..f05d78ce 100644 --- a/tests/bip/bip32/test_bip32_path.py +++ b/tests/bip/bip32/test_bip32_path.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,14 @@ import unittest from bip_utils import ( - Bip32KeyIndex, Bip32Path, Bip32PathError, Bip32PathParser, Bip32Slip10Ed25519, Bip32Slip10Ed25519Blake2b, - Bip32Slip10Nist256p1, Bip32Slip10Secp256k1 + Bip32KeyIndex, + Bip32Path, + Bip32PathError, + Bip32PathParser, + Bip32Slip10Ed25519, + Bip32Slip10Ed25519Blake2b, + Bip32Slip10Nist256p1, + Bip32Slip10Secp256k1, ) diff --git a/tests/bip/bip32/test_bip32_slip10_ed25519.py b/tests/bip/bip32/test_bip32_slip10_ed25519.py index 091857aa..340b4fd7 100644 --- a/tests/bip/bip32/test_bip32_slip10_ed25519.py +++ b/tests/bip/bip32/test_bip32_slip10_ed25519.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip32/test_bip32_slip10_ed25519_blake2b.py b/tests/bip/bip32/test_bip32_slip10_ed25519_blake2b.py index b0ff36fc..27b32edf 100644 --- a/tests/bip/bip32/test_bip32_slip10_ed25519_blake2b.py +++ b/tests/bip/bip32/test_bip32_slip10_ed25519_blake2b.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,11 @@ # Imports from bip_utils import ( - Bip32Ed25519Blake2bSlip, Bip32KeyError, Bip32KeyIndex, Bip32Slip10Ed25519Blake2b, EllipticCurveTypes + Bip32Ed25519Blake2bSlip, + Bip32KeyError, + Bip32KeyIndex, + Bip32Slip10Ed25519Blake2b, + EllipticCurveTypes, ) from bip_utils.bip.bip32.slip10.bip32_slip10_mst_key_generator import Bip32Slip10MstKeyGeneratorConst from tests.bip.bip32.test_bip32_base import TEST_SEED, Bip32BaseTests diff --git a/tests/bip/bip32/test_bip32_slip10_nist256p1.py b/tests/bip/bip32/test_bip32_slip10_nist256p1.py index 63ea21c3..e8a2068c 100644 --- a/tests/bip/bip32/test_bip32_slip10_nist256p1.py +++ b/tests/bip/bip32/test_bip32_slip10_nist256p1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip32/test_bip32_slip10_secp256k1.py b/tests/bip/bip32/test_bip32_slip10_secp256k1.py index 6a0b5483..8ad976b5 100644 --- a/tests/bip/bip32/test_bip32_slip10_secp256k1.py +++ b/tests/bip/bip32/test_bip32_slip10_secp256k1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip32/test_bip32_utils.py b/tests/bip/bip32/test_bip32_utils.py index f64ffc3e..5a7cb1dc 100644 --- a/tests/bip/bip32/test_bip32_utils.py +++ b/tests/bip/bip32/test_bip32_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip38/test_bip38_addr.py b/tests/bip/bip38/test_bip38_addr.py index 3a92b678..0254010f 100644 --- a/tests/bip/bip38/test_bip38_addr.py +++ b/tests/bip/bip38/test_bip38_addr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip38/test_bip38_ec.py b/tests/bip/bip38/test_bip38_ec.py index ba1d7f90..3ab8ee9f 100644 --- a/tests/bip/bip38/test_bip38_ec.py +++ b/tests/bip/bip38/test_bip38_ec.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip38/test_bip38_no_ec.py b/tests/bip/bip38/test_bip38_no_ec.py index 3efe29c9..0cd5184c 100644 --- a/tests/bip/bip38/test_bip38_no_ec.py +++ b/tests/bip/bip38/test_bip38_no_ec.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,8 +24,12 @@ from bip_utils import Base58ChecksumError, Bip38Decrypter, Bip38Encrypter, Bip38PubKeyModes from tests.ecc.test_ecc import ( - TEST_ED25519_BLAKE2B_PRIV_KEY, TEST_ED25519_MONERO_PRIV_KEY, TEST_ED25519_PRIV_KEY, TEST_NIST256P1_PRIV_KEY, - TEST_SR25519_PRIV_KEY, TEST_VECT_SECP256K1_PRIV_KEY_INVALID + TEST_ED25519_BLAKE2B_PRIV_KEY, + TEST_ED25519_MONERO_PRIV_KEY, + TEST_ED25519_PRIV_KEY, + TEST_NIST256P1_PRIV_KEY, + TEST_SR25519_PRIV_KEY, + TEST_VECT_SECP256K1_PRIV_KEY_INVALID, ) diff --git a/tests/bip/bip39/test_bip39.py b/tests/bip/bip39/test_bip39.py index c7b72b0b..78f8f036 100644 --- a/tests/bip/bip39/test_bip39.py +++ b/tests/bip/bip39/test_bip39.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,15 @@ import unittest from bip_utils import ( - Bip39EntropyBitLen, Bip39EntropyGenerator, Bip39Languages, Bip39MnemonicDecoder, Bip39MnemonicGenerator, - Bip39MnemonicValidator, Bip39SeedGenerator, Bip39WordsNum, MnemonicChecksumError + Bip39EntropyBitLen, + Bip39EntropyGenerator, + Bip39Languages, + Bip39MnemonicDecoder, + Bip39MnemonicGenerator, + Bip39MnemonicValidator, + Bip39SeedGenerator, + Bip39WordsNum, + MnemonicChecksumError, ) @@ -358,9 +365,11 @@ def test_vector(self): # Test mnemonic validator (language specified) mnemonic_validator = Bip39MnemonicValidator(lang) self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test mnemonic validator (automatic language detection) mnemonic_validator = Bip39MnemonicValidator() self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test decoder (language specified) entropy = Bip39MnemonicDecoder(lang).Decode(mnemonic) diff --git a/tests/bip/bip44/test_bip44.py b/tests/bip/bip44/test_bip44.py index 156bbe45..b33c045f 100644 --- a/tests/bip/bip44/test_bip44.py +++ b/tests/bip/bip44/test_bip44.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -1902,6 +1902,30 @@ "0x02f9C86C8dA95C6748d063AA00c6DCD581311C06", ], }, + # Ton + { + "coin": Bip44Coins.TON, + "names": ("The Open Network", "TON"), + "is_testnet": False, + "seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4", + "ex_master": "xprv9s21ZrQH143K4GYBne6aGFZLHUSCPzQ3amKxfzz6kHpqDLBHk58dvPW7twcRFJeo1oQAvNeiYpZEeUkWCW3YgdvXHUcQQU6xjh8jBo4Y8xG", + "wif_master": "", + "account": { + "ex_pub": "xpub6CRHWanBuDYomVH6yPdHjzw4mReJ1HRH2i3dqPcNA222SfCimALj1r1FAriJ1rRyw68qMtAgREW62kCMVQCMhR7WBnA7atSHLpiNDUhYjQA", + "ex_priv": "xprv9yRw75FJ4qzWZ1CdsN6HNrzLDPoobphRfV8331CkbgV3ZrsaDd2UU3gmKg24hLkDZJU1YoZQrTV2zVe4r8ApqvMRxdi2uMjoxLfrF5YcgQY", + }, + "chain_ext": { + "ex_pub": "xpub6EYY9ZsAv6251ZQRrgZMu5ApdTegaR2YWd1Yv2UWLczb9EvuYSri5bPZWPeCCyo6LVX3uWQR2HpYa7xbiwJVhXaWXMN9qhf1AtKdJiKXNxq", + "ex_priv": "xprvA1ZBk4LH5iTmo5Kxkf2MXwE65RpCAxJh9Q5x7e4tnHTcGSbkzuYTXo55fCbG3jH5JWDrLj31S4PAYyxhN95YQJpzeZn9EfL27m9eG6pZ6dw", + }, + "addresses": [ + "UQDxAUFadQXDd3EXGa3TLF_EF66gMc9h3_aZ0j0zXNoIYUCc", + "UQBHJG1XpSPMRBaS6Ae-xcufra2eXnAKQadJaEPXfTi8xVWR", + "UQA-ooQWPu_E8R0PfBC4Urg5RtNaelw538RIKTlMqGhy6dhM", + "UQB2G4IoTJnMB9sdRZHKKHuVrsoTZ1fJFlwRI84gsyncBp1c", + "UQAPUP6gFteMDnS6iJnKHd5Wx-yK_nk35Pk8SNGOKcCVd_69", + ], + }, # Tron { "coin": Bip44Coins.TRON, @@ -2794,6 +2818,12 @@ "seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4", "default_address": "0xB16f8D941d7D281aDCEf3e950aBF2147D7AC2D33", }, + # Ton + { + "coin": Bip44Coins.TON, + "seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4", + "default_address": "UQAzWZa6nM5mJev91wGc7VCSfBoIsYRqKJpV78N8Add9-RKY", + }, # Tron { "coin": Bip44Coins.TRON, diff --git a/tests/bip/bip44_base/test_bip44_base.py b/tests/bip/bip44_base/test_bip44_base.py index 7031305e..96fd97af 100644 --- a/tests/bip/bip44_base/test_bip44_base.py +++ b/tests/bip/bip44_base/test_bip44_base.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,18 @@ import unittest from bip_utils import ( - Bip32KeyData, Bip32KeyError, Bip44Changes, Bip44Coins, Bip44DepthError, Bip44Levels, Bip44PrivateKey, - Bip44PublicKey, Bip49Coins, CardanoShelley, Cip1852Coins, Monero + Bip32KeyData, + Bip32KeyError, + Bip44Changes, + Bip44Coins, + Bip44DepthError, + Bip44Levels, + Bip44PrivateKey, + Bip44PublicKey, + Bip49Coins, + CardanoShelley, + Cip1852Coins, + Monero, ) from bip_utils.bip.bip32.bip32_key_data import Bip32KeyDataConst from bip_utils.bip.conf.common import BipCoinConf diff --git a/tests/bip/bip44_base/test_bip44_keys.py b/tests/bip/bip44_base/test_bip44_keys.py index 828edfc9..03fdab3a 100644 --- a/tests/bip/bip44_base/test_bip44_keys.py +++ b/tests/bip/bip44_base/test_bip44_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,28 @@ import unittest from bip_utils import ( - Bip32PrivateKey, Bip32PublicKey, Bip44Conf, Bip44PrivateKey, Bip44PublicKey, Cip1852Coins, Cip1852ConfGetter, - DataBytes + Bip32PrivateKey, + Bip32PublicKey, + Bip44Conf, + Bip44PrivateKey, + Bip44PublicKey, + Cip1852Coins, + Cip1852ConfGetter, + DataBytes, ) from bip_utils.bip.bip32.bip32_const import Bip32Const from tests.bip.bip32.test_bip32_keys import TEST_BIP32_KEY_DATA from tests.ecc.test_ecc import ( - TEST_ED25519_BLAKE2B_PRIV_KEY, TEST_ED25519_BLAKE2B_PUB_KEY, TEST_ED25519_KHOLAW_PRIV_KEY, - TEST_ED25519_KHOLAW_PUB_KEY, TEST_ED25519_PRIV_KEY, TEST_ED25519_PUB_KEY, TEST_NIST256P1_PRIV_KEY, - TEST_NIST256P1_PUB_KEY, TEST_SECP256K1_PRIV_KEY, TEST_SECP256K1_PUB_KEY + TEST_ED25519_BLAKE2B_PRIV_KEY, + TEST_ED25519_BLAKE2B_PUB_KEY, + TEST_ED25519_KHOLAW_PRIV_KEY, + TEST_ED25519_KHOLAW_PUB_KEY, + TEST_ED25519_PRIV_KEY, + TEST_ED25519_PUB_KEY, + TEST_NIST256P1_PRIV_KEY, + TEST_NIST256P1_PUB_KEY, + TEST_SECP256K1_PRIV_KEY, + TEST_SECP256K1_PUB_KEY, ) diff --git a/tests/bip/bip49/test_bip49.py b/tests/bip/bip49/test_bip49.py index 64341c57..080c628e 100644 --- a/tests/bip/bip49/test_bip49.py +++ b/tests/bip/bip49/test_bip49.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip84/test_bip84.py b/tests/bip/bip84/test_bip84.py index edab85e7..48000ecb 100644 --- a/tests/bip/bip84/test_bip84.py +++ b/tests/bip/bip84/test_bip84.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/bip/bip86/test_bip86.py b/tests/bip/bip86/test_bip86.py index 9cd71102..c7a056bf 100644 --- a/tests/bip/bip86/test_bip86.py +++ b/tests/bip/bip86/test_bip86.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/brainwallet/test_brainwallet.py b/tests/brainwallet/test_brainwallet.py index b578cc44..ba66db3d 100644 --- a/tests/brainwallet/test_brainwallet.py +++ b/tests/brainwallet/test_brainwallet.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/cardano/bip32/test_cardano_byron_legacy_bip32.py b/tests/cardano/bip32/test_cardano_byron_legacy_bip32.py index 1f28ff9c..fffced78 100644 --- a/tests/cardano/bip32/test_cardano_byron_legacy_bip32.py +++ b/tests/cardano/bip32/test_cardano_byron_legacy_bip32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/cardano/bip32/test_cardano_icarus_bip32.py b/tests/cardano/bip32/test_cardano_icarus_bip32.py index 35998257..b8302d06 100644 --- a/tests/cardano/bip32/test_cardano_icarus_bip32.py +++ b/tests/cardano/bip32/test_cardano_icarus_bip32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/cardano/byron/test_cardano_byron_legacy.py b/tests/cardano/byron/test_cardano_byron_legacy.py index 6529f6b0..fec692fc 100644 --- a/tests/cardano/byron/test_cardano_byron_legacy.py +++ b/tests/cardano/byron/test_cardano_byron_legacy.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/cardano/cip1852/test_cip1852.py b/tests/cardano/cip1852/test_cip1852.py index 2a794433..489bbd65 100644 --- a/tests/cardano/cip1852/test_cip1852.py +++ b/tests/cardano/cip1852/test_cip1852.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/cardano/mnemonic/test_cardano_mnemonic.py b/tests/cardano/mnemonic/test_cardano_mnemonic.py index 0105ae4f..7c301dce 100644 --- a/tests/cardano/mnemonic/test_cardano_mnemonic.py +++ b/tests/cardano/mnemonic/test_cardano_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/cardano/shelley/test_cardano_shelley.py b/tests/cardano/shelley/test_cardano_shelley.py index cb2a7ac9..593fc040 100644 --- a/tests/cardano/shelley/test_cardano_shelley.py +++ b/tests/cardano/shelley/test_cardano_shelley.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,14 @@ import unittest from bip_utils import ( - Bip44, Bip44Changes, Bip44Coins, CardanoShelley, CardanoShelleyPrivateKeys, CardanoShelleyPublicKeys, Cip1852, - Cip1852Coins + Bip44, + Bip44Changes, + Bip44Coins, + CardanoShelley, + CardanoShelleyPrivateKeys, + CardanoShelleyPublicKeys, + Cip1852, + Cip1852Coins, ) diff --git a/tests/cardano/shelley/test_cardano_shelley_keys.py b/tests/cardano/shelley/test_cardano_shelley_keys.py index 9e31fd0e..e79c7e39 100644 --- a/tests/cardano/shelley/test_cardano_shelley_keys.py +++ b/tests/cardano/shelley/test_cardano_shelley_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,12 @@ import unittest from bip_utils import ( - Bip32PrivateKey, Bip32PublicKey, CardanoShelleyPrivateKeys, CardanoShelleyPublicKeys, Cip1852Conf, - EllipticCurveTypes + Bip32PrivateKey, + Bip32PublicKey, + CardanoShelleyPrivateKeys, + CardanoShelleyPublicKeys, + Cip1852Conf, + EllipticCurveTypes, ) from bip_utils.bip.bip32.bip32_const import Bip32Const from tests.bip.bip32.test_bip32_keys import TEST_BIP32_KEY_DATA diff --git a/tests/ecc/test_ecc.py b/tests/ecc/test_ecc.py index 8426afcc..f98b221c 100644 --- a/tests/ecc/test_ecc.py +++ b/tests/ecc/test_ecc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -30,12 +30,37 @@ from nacl import signing from bip_utils import ( - DataBytes, Ed25519, Ed25519Blake2b, Ed25519Blake2bPoint, Ed25519Blake2bPrivateKey, Ed25519Blake2bPublicKey, - Ed25519Kholaw, Ed25519KholawPoint, Ed25519KholawPrivateKey, Ed25519KholawPublicKey, Ed25519Monero, - Ed25519MoneroPoint, Ed25519MoneroPrivateKey, Ed25519MoneroPublicKey, Ed25519Point, Ed25519PrivateKey, - Ed25519PublicKey, EllipticCurveGetter, EllipticCurveTypes, Nist256p1, Nist256p1Point, Nist256p1PrivateKey, - Nist256p1PublicKey, Secp256k1, Secp256k1Point, Secp256k1PrivateKey, Secp256k1PublicKey, Sr25519, Sr25519Point, - Sr25519PrivateKey, Sr25519PublicKey + DataBytes, + Ed25519, + Ed25519Blake2b, + Ed25519Blake2bPoint, + Ed25519Blake2bPrivateKey, + Ed25519Blake2bPublicKey, + Ed25519Kholaw, + Ed25519KholawPoint, + Ed25519KholawPrivateKey, + Ed25519KholawPublicKey, + Ed25519Monero, + Ed25519MoneroPoint, + Ed25519MoneroPrivateKey, + Ed25519MoneroPublicKey, + Ed25519Point, + Ed25519PrivateKey, + Ed25519PublicKey, + EllipticCurveGetter, + EllipticCurveTypes, + Nist256p1, + Nist256p1Point, + Nist256p1PrivateKey, + Nist256p1PublicKey, + Secp256k1, + Secp256k1Point, + Secp256k1PrivateKey, + Secp256k1PublicKey, + Sr25519, + Sr25519Point, + Sr25519PrivateKey, + Sr25519PublicKey, ) from bip_utils.ecc.conf import EccConf from bip_utils.utils.misc import IntegerUtils diff --git a/tests/electrum/mnemonic/test_electrum_v1_mnemonic.py b/tests/electrum/mnemonic/test_electrum_v1_mnemonic.py index b0438e18..cb9fd5d3 100644 --- a/tests/electrum/mnemonic/test_electrum_v1_mnemonic.py +++ b/tests/electrum/mnemonic/test_electrum_v1_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,15 @@ import unittest from bip_utils import ( - ElectrumV1, ElectrumV1EntropyBitLen, ElectrumV1EntropyGenerator, ElectrumV1Languages, ElectrumV1MnemonicDecoder, - ElectrumV1MnemonicGenerator, ElectrumV1MnemonicValidator, ElectrumV1SeedGenerator, ElectrumV1WordsNum + ElectrumV1, + ElectrumV1EntropyBitLen, + ElectrumV1EntropyGenerator, + ElectrumV1Languages, + ElectrumV1MnemonicDecoder, + ElectrumV1MnemonicGenerator, + ElectrumV1MnemonicValidator, + ElectrumV1SeedGenerator, + ElectrumV1WordsNum, ) @@ -148,9 +155,11 @@ def test_vector(self): # Test mnemonic validator (language specified) mnemonic_validator = ElectrumV1MnemonicValidator(lang) self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test mnemonic validator (automatic language detection) mnemonic_validator = ElectrumV1MnemonicValidator() self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test decoder (language specified) entropy = ElectrumV1MnemonicDecoder(lang).Decode(mnemonic) diff --git a/tests/electrum/mnemonic/test_electrum_v2_mnemonic.py b/tests/electrum/mnemonic/test_electrum_v2_mnemonic.py index 8b0c0318..9a30c489 100644 --- a/tests/electrum/mnemonic/test_electrum_v2_mnemonic.py +++ b/tests/electrum/mnemonic/test_electrum_v2_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,9 +24,18 @@ import unittest from bip_utils import ( - BytesUtils, ElectrumV2EntropyBitLen, ElectrumV2EntropyGenerator, ElectrumV2Languages, ElectrumV2MnemonicDecoder, - ElectrumV2MnemonicGenerator, ElectrumV2MnemonicTypes, ElectrumV2MnemonicValidator, ElectrumV2SeedGenerator, - ElectrumV2Segwit, ElectrumV2Standard, ElectrumV2WordsNum + BytesUtils, + ElectrumV2EntropyBitLen, + ElectrumV2EntropyGenerator, + ElectrumV2Languages, + ElectrumV2MnemonicDecoder, + ElectrumV2MnemonicGenerator, + ElectrumV2MnemonicTypes, + ElectrumV2MnemonicValidator, + ElectrumV2SeedGenerator, + ElectrumV2Segwit, + ElectrumV2Standard, + ElectrumV2WordsNum, ) from bip_utils.electrum.mnemonic_v2.electrum_v2_mnemonic import ElectrumV2MnemonicConst @@ -170,12 +179,15 @@ def test_vector(self): # Test mnemonic validator (language specified, all mnemonic types) mnemonic_validator = ElectrumV2MnemonicValidator(lang=lang) self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test mnemonic validator (automatic language detection, all mnemonic types) mnemonic_validator = ElectrumV2MnemonicValidator() self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test mnemonic validator (mnemonic type specified) mnemonic_validator = ElectrumV2MnemonicValidator(mnemonic_type=test["mnemonic_type"]) self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test decoder (language specified, all mnemonic types) entropy = ElectrumV2MnemonicDecoder(lang=lang).Decode(mnemonic) diff --git a/tests/electrum/test_electrum_v1.py b/tests/electrum/test_electrum_v1.py index 5349dcc7..09586f22 100644 --- a/tests/electrum/test_electrum_v1.py +++ b/tests/electrum/test_electrum_v1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,13 @@ import unittest from bip_utils import ( - CoinsConf, ElectrumV1, Secp256k1PrivateKey, Secp256k1PublicKey, WifDecoder, WifEncoder, WifPubKeyModes + CoinsConf, + ElectrumV1, + Secp256k1PrivateKey, + Secp256k1PublicKey, + WifDecoder, + WifEncoder, + WifPubKeyModes, ) from bip_utils.bip.bip32.bip32_key_data import Bip32KeyDataConst from tests.ecc.test_ecc import TEST_ED25519_PRIV_KEY, TEST_ED25519_PUB_KEY diff --git a/tests/electrum/test_electrum_v2.py b/tests/electrum/test_electrum_v2.py index 7a858016..3804a9e1 100644 --- a/tests/electrum/test_electrum_v2.py +++ b/tests/electrum/test_electrum_v2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,14 @@ import unittest from bip_utils import ( - Bip32PrivateKey, Bip32PublicKey, Bip32Slip10Ed25519, Bip32Slip10Secp256k1, CoinsConf, ElectrumV2Segwit, - ElectrumV2Standard, WifEncoder + Bip32PrivateKey, + Bip32PublicKey, + Bip32Slip10Ed25519, + Bip32Slip10Secp256k1, + CoinsConf, + ElectrumV2Segwit, + ElectrumV2Standard, + WifEncoder, ) from tests.bip.bip32.test_bip32_base import TEST_SEED diff --git a/tests/monero/mnemonic/test_monero_mnemonic.py b/tests/monero/mnemonic/test_monero_mnemonic.py index 61f8d897..14ab0232 100644 --- a/tests/monero/mnemonic/test_monero_mnemonic.py +++ b/tests/monero/mnemonic/test_monero_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,16 @@ import unittest from bip_utils import ( - MnemonicChecksumError, Monero, MoneroEntropyBitLen, MoneroEntropyGenerator, MoneroLanguages, MoneroMnemonicDecoder, - MoneroMnemonicGenerator, MoneroMnemonicValidator, MoneroSeedGenerator, MoneroWordsNum + MnemonicChecksumError, + Monero, + MoneroEntropyBitLen, + MoneroEntropyGenerator, + MoneroLanguages, + MoneroMnemonicDecoder, + MoneroMnemonicGenerator, + MoneroMnemonicValidator, + MoneroSeedGenerator, + MoneroWordsNum, ) @@ -280,9 +288,11 @@ def test_vector(self): # Test mnemonic validator (language specified) mnemonic_validator = MoneroMnemonicValidator(lang) self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test mnemonic validator (automatic language detection) mnemonic_validator = MoneroMnemonicValidator() self.assertTrue(mnemonic_validator.IsValid(mnemonic)) + mnemonic_validator.Validate(mnemonic) # Test decoder with no checksum (language specified) entropy = MoneroMnemonicDecoder(lang).Decode(mnemonic) diff --git a/tests/monero/test_monero.py b/tests/monero/test_monero.py index 4daeb689..c9ee2603 100644 --- a/tests/monero/test_monero.py +++ b/tests/monero/test_monero.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,13 @@ import unittest from bip_utils import ( - Ed25519MoneroPrivateKey, Ed25519MoneroPublicKey, Monero, MoneroCoins, MoneroKeyError, MoneroPrivateKey, - MoneroPublicKey + Ed25519MoneroPrivateKey, + Ed25519MoneroPublicKey, + Monero, + MoneroCoins, + MoneroKeyError, + MoneroPrivateKey, + MoneroPublicKey, ) from bip_utils.monero.conf import MoneroCoinConf from bip_utils.monero.monero_subaddr import MoneroSubaddressConst diff --git a/tests/monero/test_monero_keys.py b/tests/monero/test_monero_keys.py index 63200b11..2f879524 100644 --- a/tests/monero/test_monero_keys.py +++ b/tests/monero/test_monero_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,14 +23,29 @@ import unittest from bip_utils import ( - DataBytes, Ed25519MoneroPrivateKey, Ed25519MoneroPublicKey, MoneroKeyError, MoneroPrivateKey, MoneroPublicKey + DataBytes, + Ed25519MoneroPrivateKey, + Ed25519MoneroPublicKey, + MoneroKeyError, + MoneroPrivateKey, + MoneroPublicKey, ) from tests.ecc.test_ecc import ( - TEST_ED25519_BLAKE2B_PRIV_KEY, TEST_ED25519_BLAKE2B_PUB_KEY, TEST_ED25519_MONERO_POINT, - TEST_ED25519_MONERO_PRIV_KEY, TEST_ED25519_MONERO_PUB_KEY, TEST_ED25519_PRIV_KEY, TEST_ED25519_PUB_KEY, - TEST_NIST256P1_PRIV_KEY, TEST_NIST256P1_PUB_KEY, TEST_SECP256K1_PRIV_KEY, TEST_SECP256K1_PUB_KEY, - TEST_SR25519_PRIV_KEY, TEST_SR25519_PUB_KEY, TEST_VECT_ED25519_MONERO_PRIV_KEY_INVALID, - TEST_VECT_ED25519_PUB_KEY_INVALID + TEST_ED25519_BLAKE2B_PRIV_KEY, + TEST_ED25519_BLAKE2B_PUB_KEY, + TEST_ED25519_MONERO_POINT, + TEST_ED25519_MONERO_PRIV_KEY, + TEST_ED25519_MONERO_PUB_KEY, + TEST_ED25519_PRIV_KEY, + TEST_ED25519_PUB_KEY, + TEST_NIST256P1_PRIV_KEY, + TEST_NIST256P1_PUB_KEY, + TEST_SECP256K1_PRIV_KEY, + TEST_SECP256K1_PUB_KEY, + TEST_SR25519_PRIV_KEY, + TEST_SR25519_PUB_KEY, + TEST_VECT_ED25519_MONERO_PRIV_KEY_INVALID, + TEST_VECT_ED25519_PUB_KEY_INVALID, ) diff --git a/tests/monero/test_monero_subaddr.py b/tests/monero/test_monero_subaddr.py index 1d7e899f..78b47438 100644 --- a/tests/monero/test_monero_subaddr.py +++ b/tests/monero/test_monero_subaddr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/slip/slip32/test_slip32.py b/tests/slip/slip32/test_slip32.py index b9cd0006..f4d79ceb 100644 --- a/tests/slip/slip32/test_slip32.py +++ b/tests/slip/slip32/test_slip32.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,12 @@ import unittest from bip_utils import ( - Bip32PathParser, Bip32Slip10Secp256k1, Bip39SeedGenerator, Slip32KeyDeserializer, Slip32PrivateKeySerializer, - Slip32PublicKeySerializer + Bip32PathParser, + Bip32Slip10Secp256k1, + Bip39SeedGenerator, + Slip32KeyDeserializer, + Slip32PrivateKeySerializer, + Slip32PublicKeySerializer, ) diff --git a/tests/solana/test_spl_token.py b/tests/solana/test_spl_token.py index 053bf04f..b5ba998b 100644 --- a/tests/solana/test_spl_token.py +++ b/tests/solana/test_spl_token.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/ss58/test_ss58.py b/tests/ss58/test_ss58.py index 237da424..a3e3a2b7 100644 --- a/tests/ss58/test_ss58.py +++ b/tests/ss58/test_ss58.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/substrate/mnemonic/test_substrate_mnemonic.py b/tests/substrate/mnemonic/test_substrate_mnemonic.py index f455b1aa..0d20b1da 100644 --- a/tests/substrate/mnemonic/test_substrate_mnemonic.py +++ b/tests/substrate/mnemonic/test_substrate_mnemonic.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/substrate/test_substrate.py b/tests/substrate/test_substrate.py index efd87555..32879647 100644 --- a/tests/substrate/test_substrate.py +++ b/tests/substrate/test_substrate.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,13 +23,23 @@ import unittest from bip_utils import ( - Sr25519PrivateKey, Sr25519PublicKey, Substrate, SubstrateCoins, SubstrateKeyError, SubstratePath, SubstratePathElem, - SubstratePrivateKey, SubstratePublicKey + Sr25519PrivateKey, + Sr25519PublicKey, + Substrate, + SubstrateCoins, + SubstrateKeyError, + SubstratePath, + SubstratePathElem, + SubstratePrivateKey, + SubstratePublicKey, ) from bip_utils.substrate.conf import SubstrateCoinConf from bip_utils.substrate.substrate import SubstrateConst from tests.ecc.test_ecc import ( - TEST_SR25519_PRIV_KEY, TEST_SR25519_PUB_KEY, TEST_VECT_SR25519_PRIV_KEY_INVALID, TEST_VECT_SR25519_PUB_KEY_INVALID + TEST_SR25519_PRIV_KEY, + TEST_SR25519_PUB_KEY, + TEST_VECT_SR25519_PRIV_KEY_INVALID, + TEST_VECT_SR25519_PUB_KEY_INVALID, ) diff --git a/tests/substrate/test_substrate_keys.py b/tests/substrate/test_substrate_keys.py index 88840802..29a1edbd 100644 --- a/tests/substrate/test_substrate_keys.py +++ b/tests/substrate/test_substrate_keys.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,14 +23,29 @@ import unittest from bip_utils import ( - DataBytes, Sr25519PrivateKey, Sr25519PublicKey, SubstrateKeyError, SubstratePrivateKey, SubstratePublicKey + DataBytes, + Sr25519PrivateKey, + Sr25519PublicKey, + SubstrateKeyError, + SubstratePrivateKey, + SubstratePublicKey, ) from bip_utils.substrate.conf.substrate_conf import SubstrateConf from tests.ecc.test_ecc import ( - TEST_ED25519_BLAKE2B_PRIV_KEY, TEST_ED25519_BLAKE2B_PUB_KEY, TEST_ED25519_MONERO_PRIV_KEY, - TEST_ED25519_MONERO_PUB_KEY, TEST_ED25519_PRIV_KEY, TEST_ED25519_PUB_KEY, TEST_NIST256P1_PRIV_KEY, - TEST_NIST256P1_PUB_KEY, TEST_SECP256K1_PRIV_KEY, TEST_SECP256K1_PUB_KEY, TEST_SR25519_PRIV_KEY, - TEST_SR25519_PUB_KEY, TEST_VECT_SR25519_PRIV_KEY_INVALID, TEST_VECT_SR25519_PUB_KEY_INVALID + TEST_ED25519_BLAKE2B_PRIV_KEY, + TEST_ED25519_BLAKE2B_PUB_KEY, + TEST_ED25519_MONERO_PRIV_KEY, + TEST_ED25519_MONERO_PUB_KEY, + TEST_ED25519_PRIV_KEY, + TEST_ED25519_PUB_KEY, + TEST_NIST256P1_PRIV_KEY, + TEST_NIST256P1_PUB_KEY, + TEST_SECP256K1_PRIV_KEY, + TEST_SECP256K1_PUB_KEY, + TEST_SR25519_PRIV_KEY, + TEST_SR25519_PUB_KEY, + TEST_VECT_SR25519_PRIV_KEY_INVALID, + TEST_VECT_SR25519_PUB_KEY_INVALID, ) diff --git a/tests/substrate/test_substrate_path.py b/tests/substrate/test_substrate_path.py index 47573cc2..096f877d 100644 --- a/tests/substrate/test_substrate_path.py +++ b/tests/substrate/test_substrate_path.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,12 @@ import unittest from bip_utils import ( - Substrate, SubstrateCoins, SubstratePath, SubstratePathElem, SubstratePathError, SubstratePathParser + Substrate, + SubstrateCoins, + SubstratePath, + SubstratePathElem, + SubstratePathError, + SubstratePathParser, ) from tests.substrate.test_substrate import TEST_SEED diff --git a/tests/substrate/test_substrate_scale_enc.py b/tests/substrate/test_substrate_scale_enc.py index 359f166d..d96546a2 100644 --- a/tests/substrate/test_substrate_scale_enc.py +++ b/tests/substrate/test_substrate_scale_enc.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,14 @@ import unittest from bip_utils import ( - SubstrateScaleBytesEncoder, SubstrateScaleCUintEncoder, SubstrateScaleU8Encoder, SubstrateScaleU16Encoder, - SubstrateScaleU32Encoder, SubstrateScaleU64Encoder, SubstrateScaleU128Encoder, SubstrateScaleU256Encoder + SubstrateScaleBytesEncoder, + SubstrateScaleCUintEncoder, + SubstrateScaleU8Encoder, + SubstrateScaleU16Encoder, + SubstrateScaleU32Encoder, + SubstrateScaleU64Encoder, + SubstrateScaleU128Encoder, + SubstrateScaleU256Encoder, ) diff --git a/tests/ton/__init__.py b/tests/ton/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/ton/mnemonic/__init__.py b/tests/ton/mnemonic/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/ton/mnemonic/test_ton_mnemonic.py b/tests/ton/mnemonic/test_ton_mnemonic.py new file mode 100644 index 00000000..5d4d3a36 --- /dev/null +++ b/tests/ton/mnemonic/test_ton_mnemonic.py @@ -0,0 +1,156 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Imports +import binascii +import unittest + +from bip_utils import ( + TonLanguages, + TonMnemonic, + TonMnemonicGenerator, + TonMnemonicValidator, + TonSeedGenerator, + TonSeedTypes, + TonWordsNum, +) + + +TEST_VECT = [ + { + "mnemonic": "ask fossil tragic dune session prize own bundle element shift pony trouble hamster topple mammal estate strike impulse post moment club hard step lamp", + "passphrase": "", + "seed_hd": b"1ebeff074cfc42d61e4819f48f86d4a8740c90acd5b515884a2ea58187fe16aa227ab03764349e7942136354c060f2074ed8dceeee45cfdabf0205cf476fb9fc", + "seed_priv": b"ef1c1bce29e7497157699b1b5365d69f02b30a567f9cc0ab74962c9a466106698909a23c6c00ea8426c40562c21868314496bfe10622a6016333efea30d51562", + "lang": TonLanguages.ENGLISH, + }, + { + "mnemonic": "polar regular twist rose satisfy dove allow prepare frown appear neck ready entry island win turkey consider social muffin door rough maze impact online", + "passphrase": "", + "seed_hd": b"fd26ff9457cfbe32f353a76ece6dd81894663ba9b403f29a17d1e836643269d2781b7c76f775c8dea90905d3673551046b46d01aa9a5f255d8d4729cae58aa7c", + "seed_priv": b"f5c79f584790dd71bb0517c2d25a7106120bda1a50e77cbf50676b922bbef2501b22306bc64d6ce02734ec86368430c83390976d63e1553417efe68f87cd0470", + "lang": TonLanguages.ENGLISH, + }, + { + "mnemonic": "enlist rhythm fortune stove enact effort step labor myself brand clay exercise easy copper chaos gospel holiday enrich stuff twist cement oblige core travel", + "passphrase": "test", + "seed_hd": b"f841fb6cf6dbd4fb2d6783057802253b21980f0a96d55f44dbf20725e648fe4b08bf2378a819d8fddf44cc9b1364483a767134abfa442f8e0c29ad8a91935d1f", + "seed_priv": b"2ae1035120d67a1fa6f69f5c816efcbb9bcbcfb778424dc30a3cbb24612ed3d25d55e30110ceecc5d63503d1410ac8be10eb020d6707c4af9274b337e4f1b08d", + "lang": TonLanguages.ENGLISH, + }, + { + "mnemonic": "wasp salad dice grit crew legal address peanut kingdom demise park patrol caution search usual stumble author inside ginger announce track reunion walnut sausage", + "passphrase": "test", + "seed_hd": b"f28193511e5c784674de0652d41d6625064483aa05eca360c55e44572f013a4ead501144dfbb42aad75340824307d34641d2a8091d41f4fce7def987ff954b68", + "seed_priv": b"2566dacf043a453fc142b7cbdd047001683e79d0df759aa6a841b5077bf7008b2fe71fde062126384e36da9a37c9790467ea1d51d2297d5d9297f13460827d99", + "lang": TonLanguages.ENGLISH, + }, +] + +# Tests for invalid mnemonics +TEST_VECT_MNEMONIC_INVALID = [ + # Wrong length + { + "mnemonic": "ask fossil tragic dune session prize own bundle element shift pony trouble hamster topple mammal estate strike impulse post moment club hard step", + "exception": ValueError, + }, + { + "mnemonic": "ask fossil tragic dune session prize own bundle element shift pony trouble hamster topple mammal estate strike impulse post moment club hard step lamp step", + "exception": ValueError, + }, + # Not existent word + { + "mnemonic": "ask fossil tragic dune session prize own bundle element shift pony trouble hamster topple mammal estate strike impulse post moment club hard step notexistent", + "exception": ValueError, + }, +] + + +# +# Tests +# +class TonMnemonicTests(unittest.TestCase): + # Run all tests in test vector + def test_vector(self): + for test in TEST_VECT: + lang = test["lang"] + mnemonic = test["mnemonic"] + passphrase = test["passphrase"] + + # Test mnemonic validator (language specified) + mnemonic_validator = TonMnemonicValidator(lang) + self.assertTrue(mnemonic_validator.IsValid(mnemonic, passphrase)) + mnemonic_validator.Validate(mnemonic, passphrase) + # Test mnemonic validator (automatic language detection) + mnemonic_validator = TonMnemonicValidator() + self.assertTrue(mnemonic_validator.IsValid(mnemonic, passphrase)) + mnemonic_validator.Validate(mnemonic, passphrase) + + # Test seed generator + seed_hd = TonSeedGenerator(mnemonic, passphrase, lang).Generate(TonSeedTypes.HD_KEY) + self.assertEqual(test["seed_hd"], binascii.hexlify(seed_hd)) + + seed_priv = TonSeedGenerator(mnemonic, passphrase, lang).Generate(TonSeedTypes.PRIVATE_KEY) + self.assertEqual(test["seed_priv"], binascii.hexlify(seed_priv)) + + seed_priv = TonSeedGenerator(mnemonic, passphrase, lang).Generate() + self.assertEqual(test["seed_priv"], binascii.hexlify(seed_priv)) + + # Test mnemonic generator + def test_generator(self): + for lang in TonLanguages: + for words_num in TonWordsNum: + for passphrase in ["", "test"]: + mnemonic = TonMnemonicGenerator(lang).FromWordsNumber(words_num, passphrase) + + self.assertTrue(isinstance(mnemonic, TonMnemonic)) + self.assertEqual(words_num, mnemonic.WordsCount()) + self.assertTrue(TonMnemonicValidator(lang).IsValid(mnemonic, passphrase)) + + self.assertRaises(ValueError, TonMnemonicGenerator(lang).FromWordsNumber, words_num - 1) + self.assertRaises(ValueError, TonMnemonicGenerator(lang).FromWordsNumber, words_num + 1) + + # Test validation of a mnemonic with/without a passphrase + def test_passphrase_validation(self): + mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24) + self.assertFalse(TonMnemonicValidator().IsValid(mnemonic, "test")) + self.assertRaises(ValueError, TonSeedGenerator, mnemonic, "test") + + mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24, "test") + self.assertFalse(TonMnemonicValidator().IsValid(mnemonic)) + self.assertRaises(ValueError, TonSeedGenerator, mnemonic) + + # Tests invalid mnemonic + def test_invalid_mnemonic(self): + for test in TEST_VECT_MNEMONIC_INVALID: + lang = test["lang"] if "lang" in test else TonLanguages.ENGLISH + + self.assertFalse(TonMnemonicValidator(lang).IsValid(test["mnemonic"])) + self.assertRaises(test["exception"], TonMnemonicValidator(lang).Validate, test["mnemonic"]) + self.assertRaises(test["exception"], TonSeedGenerator, test["mnemonic"], "", lang) + + # Tests invalid parameters + def test_invalid_params(self): + self.assertRaises(TypeError, TonMnemonicGenerator, 0) + self.assertRaises(TypeError, TonMnemonicValidator, 0) + self.assertRaises(TypeError, TonSeedGenerator, "", "", 0) + + mnemonic = TonMnemonicGenerator().FromWordsNumber(TonWordsNum.WORDS_NUM_24) + self.assertRaises(TypeError, TonSeedGenerator(mnemonic).Generate, 0) diff --git a/tests/ton/test_ton.py b/tests/ton/test_ton.py new file mode 100644 index 00000000..7fe2db34 --- /dev/null +++ b/tests/ton/test_ton.py @@ -0,0 +1,94 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Imports +import binascii +import unittest + +from bip_utils import ( + Ton, + TonAddrVersions, + TonMnemonicGenerator, + TonSeedGenerator, + TonPrivateKey, + TonPublicKey, +) + + +TEST_VECT = [ + { + "mnemonic": "flash garden eagle south occur hair believe pigeon shell later awake evoke club bundle humble just alarm start shoe depth curve sadness coast cruel", + "passphrase": "", + "seed": b"6dca2b6bae5495c9b32ad0e21585893393f49593b46528cf4364e2ce3de9fbc4d5d260f6e64db115a3116e3bcde1eda36272ade47d5f458a1224f8a6b82c725d", + "priv_key": "6dca2b6bae5495c9b32ad0e21585893393f49593b46528cf4364e2ce3de9fbc4", + "pub_key": "00b20e72a472a091f2d6e5c8daae89acffc1725796ecfdecb91028473227cccd40", + "address_v3r1": "UQBO7J5N3SRX5C36PjcLszc6mjtldjDO8399z2M_WFReD_Y6", + "address_v3r2": "UQC4isU1Xv7IG26fVJW_EuJvfyPMdjio6U5AOX_1ItZMdvvY", + "address_v4": "UQAL2-1_ypx8LjJq4kYrQCIHi4BiFoLzEtnoU6pnBxT0dlIW", + "address_v5r1": "UQBnsrgS6CQgUrSPbSsH8E2NqeJu_jcHHc7UMBgCYYy42mCT", + "address_def": "UQBnsrgS6CQgUrSPbSsH8E2NqeJu_jcHHc7UMBgCYYy42mCT", + }, + { + "mnemonic": "trip rude dry sand ahead pole spice knife lobster spider rather canyon caution catalog design process awesome garage coil climb daughter assault grab latin", + "passphrase": "", + "seed": b"bdeeedc743b2e0c7235b45b2247de18c7982f6f484c551ff21034cc761668e8513e53b519f187d5939d319525be16250890caa7ecc4781b8884c9eb444d2bcb6", + "priv_key": "bdeeedc743b2e0c7235b45b2247de18c7982f6f484c551ff21034cc761668e85", + "pub_key": "007b3a7c45f3889e7fcffa79f9508b1f0d4eb3e8e127f5e954e5b7b8c8bf3df2ac", + "address_v3r1": "UQCcn8mY71L7KdN0zZ34iQZBFmf8CEfS3sKMSXUHOhJt8hTC", + "address_v3r2": "UQAN8uYVEct8z7bR7jaqONOvFX4hiNAqCOMEBClc0W-h3q6f", + "address_v4": "UQDwRUWRenS3SdqOQlgzjXfh8pLmi6BHcycSRnjK356uEtmh", + "address_v5r1": "UQDBXf5dtEWokmn7H9i8DGF1hlFW9C0FTPn1-Lu6TU3dCcU9", + "address_def": "UQDBXf5dtEWokmn7H9i8DGF1hlFW9C0FTPn1-Lu6TU3dCcU9", + }, + { + "mnemonic": "one throw battle section gauge admit aware alarm shine van wreck record battle cancel advice kitten quote panther vault page degree march whisper truly", + "passphrase": "test", + "seed": b"00915030dbc91ca64e4384d6d1b743b50332d9741f60a844230d20dff5232708a714247a1ddc7b031ce0c414da40b156eefb968dc86b7b65c950a91f237d2ca9", + "priv_key": "00915030dbc91ca64e4384d6d1b743b50332d9741f60a844230d20dff5232708", + "pub_key": "0001da83e896f14a9ba71ba11b42199a2e814b64ef0f831c6b67d8ca31235da69c", + "address_v3r1": "UQBkw9A2EJ3mQyZMgSlNjti0iGaNf3iDzXt6sgvHE6sBtZXP", + "address_v3r2": "UQDANpdHk9f8kyosO62qczm3hYCWlPAE-w73lmEaoeLg2nnS", + "address_v4": "UQD4YDreaPB9VdhnicmMet4Xta6CAVK_pF1M_4_MHk4okPUR", + "address_v5r1": "UQBKpLgvvceEXGIH6IkzilTp5c0RPXYZWqq9G7ONVqc-lWPV", + "address_def": "UQBKpLgvvceEXGIH6IkzilTp5c0RPXYZWqq9G7ONVqc-lWPV", + }, +] + + +# +# Tests +# +class TonTests(unittest.TestCase): + # Run all tests in test vector + def test_vector(self): + for test in TEST_VECT: + # Generate seed + seed = TonSeedGenerator(test["mnemonic"], test["passphrase"]).Generate() + self.assertEqual(test["seed"], binascii.hexlify(seed)) + + # Test Ton class + ton = Ton.FromSeed(seed) + self.assertEqual(test["priv_key"], ton.PrivateKey().Raw().ToHex()) + self.assertEqual(test["pub_key"], ton.PublicKey().RawCompressed().ToHex()) + self.assertEqual(test["address_v3r1"], ton.GetAddress(TonAddrVersions.V3R1)) + self.assertEqual(test["address_v3r2"], ton.GetAddress(TonAddrVersions.V3R2)) + self.assertEqual(test["address_v4"], ton.GetAddress(TonAddrVersions.V4)) + self.assertEqual(test["address_v5r1"], ton.GetAddress(TonAddrVersions.V5R1)) + self.assertEqual(test["address_def"], ton.GetAddress()) diff --git a/tests/ton/test_ton_keys.py b/tests/ton/test_ton_keys.py new file mode 100644 index 00000000..cf2eb9c9 --- /dev/null +++ b/tests/ton/test_ton_keys.py @@ -0,0 +1,115 @@ +# Copyright (c) 2026 Emanuele Bellocchia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Imports +import binascii +import unittest + +from bip_utils import ( + DataBytes, + Ed25519PrivateKey, + Ed25519PublicKey, + TonKeyError, + TonPrivateKey, + TonPublicKey, +) +from tests.ecc.test_ecc import ( + TEST_ED25519_BLAKE2B_PRIV_KEY, + TEST_ED25519_BLAKE2B_PUB_KEY, + TEST_ED25519_PRIV_KEY, + TEST_ED25519_PUB_KEY, + TEST_NIST256P1_PRIV_KEY, + TEST_NIST256P1_PUB_KEY, + TEST_SECP256K1_PRIV_KEY, + TEST_SECP256K1_PUB_KEY, + TEST_SR25519_PRIV_KEY, + TEST_SR25519_PUB_KEY, + TEST_VECT_ED25519_PRIV_KEY_INVALID, + TEST_VECT_ED25519_PUB_KEY_INVALID, +) + + +# +# Tests +# +class TonKeysTests(unittest.TestCase): + # Test private key + def test_priv_key(self): + # FromBytesOrKeyObject (object) + self.__test_priv_key_obj(TonPrivateKey.FromBytesOrKeyObject(TEST_ED25519_PRIV_KEY)) + # FromBytesOrKeyObject (bytes) + self.__test_priv_key_obj(TonPrivateKey.FromBytesOrKeyObject(TEST_ED25519_PRIV_KEY.Raw().ToBytes())) + # FromBytes + self.__test_priv_key_obj(TonPrivateKey.FromBytes(TEST_ED25519_PRIV_KEY.Raw().ToBytes())) + + # Test public key + def test_pub_key(self): + # FromBytesOrKeyObject (object) + self.__test_pub_key_obj(TonPublicKey.FromBytesOrKeyObject(TEST_ED25519_PUB_KEY)) + # FromBytesOrKeyObject (compressed) + self.__test_pub_key_obj(TonPublicKey.FromBytesOrKeyObject(TEST_ED25519_PUB_KEY.RawCompressed().ToBytes())) + # FromBytesOrKeyObject (uncompressed) + self.__test_pub_key_obj(TonPublicKey.FromBytesOrKeyObject(TEST_ED25519_PUB_KEY.RawUncompressed().ToBytes())) + # FromBytes (compressed) + self.__test_pub_key_obj(TonPublicKey.FromBytes(TEST_ED25519_PUB_KEY.RawCompressed().ToBytes())) + # FromBytes (uncompressed) + self.__test_pub_key_obj(TonPublicKey.FromBytes(TEST_ED25519_PUB_KEY.RawUncompressed().ToBytes())) + + # Test invalid keys + def test_invalid_keys(self): + # Invalid private keys + for test in TEST_VECT_ED25519_PRIV_KEY_INVALID: + self.assertRaises(TonKeyError, TonPrivateKey.FromBytesOrKeyObject, binascii.unhexlify(test)) + self.assertRaises(TonKeyError, TonPrivateKey.FromBytes, binascii.unhexlify(test)) + # Invalid public keys + for test in TEST_VECT_ED25519_PUB_KEY_INVALID: + self.assertRaises(TonKeyError, TonPublicKey.FromBytesOrKeyObject, binascii.unhexlify(test)) + self.assertRaises(TonKeyError, TonPublicKey.FromBytes, binascii.unhexlify(test)) + + # Test invalid parameters + def test_invalid_params(self): + # Private key + for key in (TEST_ED25519_BLAKE2B_PRIV_KEY, TEST_NIST256P1_PRIV_KEY, + TEST_SECP256K1_PRIV_KEY, TEST_SR25519_PRIV_KEY): + self.assertRaises(TypeError, TonPrivateKey, key) + # Public key + for key in (TEST_ED25519_BLAKE2B_PUB_KEY, TEST_NIST256P1_PUB_KEY, + TEST_SECP256K1_PUB_KEY, TEST_SR25519_PUB_KEY): + self.assertRaises(TypeError, TonPublicKey, key) + + # Test private key object + def __test_priv_key_obj(self, priv_key): + # Object + self.assertTrue(isinstance(priv_key.KeyObject(), Ed25519PrivateKey)) + self.assertTrue(isinstance(priv_key.Raw(), DataBytes)) + # Keys + self.assertEqual(TEST_ED25519_PRIV_KEY.Raw().ToBytes(), priv_key.Raw().ToBytes()) + # Public key associated to the private one + self.__test_pub_key_obj(priv_key.PublicKey()) + + # Test public key object + def __test_pub_key_obj(self, pub_key): + # Object + self.assertTrue(isinstance(pub_key.KeyObject(), Ed25519PublicKey)) + self.assertTrue(isinstance(pub_key.RawCompressed(), DataBytes)) + self.assertTrue(isinstance(pub_key.RawUncompressed(), DataBytes)) + # Keys + self.assertEqual(TEST_ED25519_PUB_KEY.RawCompressed().ToBytes(), pub_key.RawCompressed().ToBytes()) + self.assertEqual(TEST_ED25519_PUB_KEY.RawUncompressed().ToBytes(), pub_key.RawUncompressed().ToBytes()) diff --git a/tests/utils/test_cbor_indefinite_len_array.py b/tests/utils/test_cbor_indefinite_len_array.py index 1de96baa..1f23d8ba 100644 --- a/tests/utils/test_cbor_indefinite_len_array.py +++ b/tests/utils/test_cbor_indefinite_len_array.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/utils/test_data_bytes.py b/tests/utils/test_data_bytes.py index 65c42154..a31165e6 100644 --- a/tests/utils/test_data_bytes.py +++ b/tests/utils/test_data_bytes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/tests/wif/test_wif.py b/tests/wif/test_wif.py index a1a4274a..77566d3b 100644 --- a/tests/wif/test_wif.py +++ b/tests/wif/test_wif.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Emanuele Bellocchia +# Copyright (c) 2026 Emanuele Bellocchia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,8 +24,11 @@ from bip_utils import Base58ChecksumError, CoinsConf, Secp256k1PrivateKey, WifDecoder, WifEncoder, WifPubKeyModes from tests.ecc.test_ecc import ( - TEST_ED25519_BLAKE2B_PRIV_KEY, TEST_ED25519_PRIV_KEY, TEST_NIST256P1_PRIV_KEY, TEST_SR25519_PRIV_KEY, - TEST_VECT_SECP256K1_PRIV_KEY_INVALID + TEST_ED25519_BLAKE2B_PRIV_KEY, + TEST_ED25519_PRIV_KEY, + TEST_NIST256P1_PRIV_KEY, + TEST_SR25519_PRIV_KEY, + TEST_VECT_SECP256K1_PRIV_KEY_INVALID, )