Package: arcula
ArculaThis repository contains a proof of concept implementation of Arcula, our design of Secure Hierarchical Deterministic Wallet released under the MIT license.InstallArcula requires Python 3.7 or higher.You can install Arcula from the Python Package Index as follows:$pipinstall--userarcula# use "arcula[dev]" to install the optional development dependencies$python3-c'import arcula; print(arcula.__version__)'# Test the installationUsageArcula can be either used as a command line executable or as a library.Command line usageTo be completed.Library usageFirst, generate a seed. In our examples we use themnemonic package, that implements BIP39 to generate a seed.importmnemonicm=mnemonic.Mnemonic(language='english').generate()print(m)seed=mnemonic.Mnemonic.to_seed(m)Next, we define the structure of your hierarchy.
If you'd like to use the BIP44 standard, you can use our helper defined inarcula.bip44, e.g.:fromarculaimportbip44WALLET_CONFIG={'BCH':(# (n. of public, private addresses)(1,2),(4,5),(0,1))}w=bip44.ArculaBIP44(seed,WALLET_CONFIG)This generates a wallet with the hierarchy of the image below.
TheArculaBIP44class provides the helper methodsget_cold_storage_public_key()andget_signing_key_certificate(path)that respectively return the cold storage public key and the signing key and the authorization certificate of the node specified bypath(e.g.m/44'/BCH/1/xpub/3).
Please refer to the Bitcoin Cash example below for detailed usages.Otherwise, thearcula.hierarchy.ArculaNodeclass represents a node in a Arcula hierarchy and allows creating any custom hierarchy.
Every node is identified by a numericidand an additionaltag.
In addition, it holds a listedgesof references to other nodes.As an example, you can instantiate a custom binary hierarchy as follows:fromarcula.hierarchyimportArculaNoderoot=ArculaNode(id=0,tag='root')left=ArculaNode(id=1,tag='l')right=ArculaNode(id=1,tag='r')root.edges=[left,right]Next, run the key derivation process:fromarculaimportarculawallet=arcula.Arcula(root)wallet.keygen()The instances ofArculaNodehold their signing keys and their authorization certificates in thecertificateand_signing_keyattributes.
Thecertificateis a pair containing both the signature and the message signed.
E.g.:left.certificate,left._signing_keyExamplesBitcoin CashThe fileutils/bch_test.pyprovides an example of how to use Arcula to send and receive funds on the Bitcoin Cash test network.In our example, we fix the randomness of the seed generation to becorrect horse battery staple, then we generate a BIP44 compatible wallet having the following structure:The node highlighted in green first received BCH from the testnet faucet, and then returned them back through the following transactions:337a67d36b8ecdd6bfbf2db654e54d71fcfd7a295cc97494e47272d305a6f44410594853b5dc6d482fc1abf24b68afde04ba71bbf7c780db4c98381064ded302DocumentationMost of the Arcula functions are heavily documented.
Ouracademical paperdescribes our design insights, the formal definitions of Arcula and of the Deterministic Hierarchical Key Assignment key at its core, a detailed comparison with BIP32, and the formal security proofs.AuthorsAdriano Di Luzio, Sapienza University of Rome and Stevens Institute of Technology.Danilo Francati, Stevens Institute of Technology.Giuseppe Ateniese, Stevens Institute of Technology.