Secret Key Wallet
SecretKeyWallet implements the Signer interface by holding a secret key directly in JavaScript memory and using @tari-project/ootle-wasm for all cryptographic operations.
Create a wallet
Section titled “Create a wallet”import { SecretKeyWallet } from "@tari-project/ootle-secret-key-wallet";import { Network } from "@tari-project/ootle";
// Generate a new random wallet with a view-only key (for stealth support)const wallet = SecretKeyWallet.randomWithViewKey(Network.Esmeralda);
// Restore from an existing secret keyconst wallet = SecretKeyWallet.fromSecretKey(ownerSecretKey, Network.Esmeralda);
// Restore with both account key and view-only keyconst wallet = SecretKeyWallet.fromSecretKey(ownerSecretKey, Network.Esmeralda, viewOnlySecretKey);
// Restore from both secret and public keys (e.g. from a keystore)const wallet = SecretKeyWallet.fromKeypair(ownerSecretKey, publicKey, Network.Esmeralda);Sign a transaction
Section titled “Sign a transaction”const signatures = await wallet.signTransaction(unsignedTx);Access keys
Section titled “Access keys”const address = await wallet.getAddress();const publicKey = await wallet.getPublicKey();
// View-only key for stealth output scanningconst viewKey = wallet.getViewOnlySecret();EphemeralKeySigner
Section titled “EphemeralKeySigner”For privacy-preserving transactions where no link to the sender should exist, use EphemeralKeySigner. It generates a one-time throwaway keypair that is discarded when the object is garbage-collected.
import { EphemeralKeySigner } from "@tari-project/ootle-secret-key-wallet";import { signTransaction } from "@tari-project/ootle";
const signer = EphemeralKeySigner.generate(); // defaults to Esmeraldaconst signed = await signTransaction([signer], unsignedTx);