subxt_signer/lib.rs
1// Copyright 2019-2025 Parity Technologies (UK) Ltd.
2// This file is dual-licensed as Apache-2.0 or GPL-3.0.
3// see LICENSE for license details.
4
5//! # Subxt-signer
6//!
7//! The main output from this crate is the [`sr25519::Keypair`], which can
8//! be constructed from a bip39 phrase, secret URI or raw seed, and used to
9//! sign and verify arbitrary messages. This crate is aligned with how Substrate's
10//! `sp_core` crate constructs and signs keypairs, but is lighter on dependencies
11//! and can support compilation to WASM with the `web` feature.
12//!
13//! Enable the `subxt` feature to enable use of this [`sr25519::Keypair`] in signing
14//! subxt transactions for chains supporting sr25519 signatures.
15
16#![cfg_attr(docsrs, feature(doc_cfg))]
17#![cfg_attr(not(feature = "std"), no_std)]
18
19extern crate alloc;
20
21#[macro_use]
22mod utils;
23mod crypto;
24
25// An sr25519 key pair implementation.
26#[cfg(feature = "sr25519")]
27#[cfg_attr(docsrs, doc(cfg(feature = "sr25519")))]
28pub mod sr25519;
29
30// An ecdsa key pair implementation.
31#[cfg(feature = "ecdsa")]
32#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))]
33pub mod ecdsa;
34
35// An ethereum signer implementation.
36#[cfg(feature = "unstable-eth")]
37#[cfg_attr(docsrs, doc(cfg(feature = "unstable-eth")))]
38pub mod eth;
39
40/// A polkadot-js account json loader.
41#[cfg(feature = "polkadot-js-compat")]
42#[cfg_attr(docsrs, doc(cfg(feature = "polkadot-js-compat")))]
43pub mod polkadot_js_compat;
44
45// Re-export useful bits and pieces for generating a Pair from a phrase,
46// namely the Mnemonic struct.
47pub use bip39;
48
49// Used to hold strings in a more secure manner in memory for a little extra
50// protection.
51pub use secrecy::{ExposeSecret, SecretString};
52
53// SecretUri's can be parsed from strings and used to generate key pairs.
54// DeriveJunctions are the "path" part of these SecretUris.
55pub use crypto::{DEV_PHRASE, DeriveJunction, SecretUri, SecretUriError};