Unified Accounts
Introduction
OP_NET introduces Unified Accounts, an innovative feature that simplifies interactions with Bitcoin by using tweaked public keys instead of traditional address strings. This approach unifies all account types under a single identifier, enhancing the developer and user experience while maintaining compatibility with Bitcoin's architecture.
Unified Accounts remove the complexity of managing multiple Bitcoin address types, allowing developers and users to focus on functionality without technical barriers.
How Does the Unified Account System Work?
Bitcoin traditionally uses different address types (e.g., P2PKH, P2SH, P2WPKH, P2TR), derived from public keys, to manage transactions. OP_NET simplifies this by directly associating all interactions with a single public key, removing the need to handle various address formats.
-
Single Identity: All interactions are tied to a single public key, regardless of address type.
-
Simplified Asset Management: Tokens, contracts, and balances are linked to the public key, making asset tracking easier.
-
Enhanced Interoperability: Seamlessly switch between address types without reconfiguring your account.
-
Signature Verification Inside Contracts: Since Unified Accounts rely on tweaked public keys, OP_NET contracts can verify Schnorr signatures directly. This enables advanced contract functionality like:
approveFrom
: Delegated approval of transactions.swapWithPermit
: Trustless swaps with built-in signature verification.- Claim Systems: Allowing users to claim assets or rewards via verifiable signatures.
Why Unified Accounts Matter
For Developers
Unified accounts simplify integration with Bitcoin by providing a consistent interface for interacting with accounts, contracts, and tokens.
- No More Address Type Confusion: Developers no longer need to write separate logic for different address formats.
- Signature-Based Authorization: Leverage public keys to build advanced contract features like signature-based claims or delegated permissions.
- Improved Efficiency: By working directly with public keys, developers can optimize gas usage, saving up to 40% on transaction fees.
For Users
The unified account system transforms the user experience:
- One Account, Many Possibilities: Users only need to manage their public key, which acts as a universal account identifier.
- Global Airdrops Made Simple: Tokens and assets can be airdropped directly to public keys, ensuring compatibility across all wallets.
- No More Address Switching: Users can interact with dApps and smart contracts without worrying about address compatibility.
How Does It Work in Practice?
Public Key Integration
On OP_NET, every interaction starts with the public key. For example:
- Sending Funds: Transactions can be initiated directly from the public key.
- Interacting with Contracts: Smart contracts on OP_NET accept public keys as identifiers, eliminating the need for address conversion.
Tweaked Public Keys and Signature Verification
With Taproot, public keys are tweaked to enhance privacy and enable advanced scripting. OP_NET fully integrates this feature:
Where:
P
is the original public key.H
is a hash function.c
is optional commitment data.G
is the elliptic curve generator point.
Using tweaked public keys allows OP_NET contracts to perform Schnorr signature verification directly. For instance:
Example: Schnorr Signature Verification
Inside a contract, OP_NET uses a function like this:
private verifySignature(calldata: Calldata): BytesWriter {
const signature = calldata.readBytesWithLength();
const message = calldata.readBytesWithLength();
const isValidSignature = Blockchain.verifySchnorrSignature(
Blockchain.tx.origin, // Signer's public key
signature, // Schnorr signature
message // Original message to verify
);
const result = new BytesWriter(1);
result.writeBoolean(isValidSignature);
return result;
}
This functionality enables features like approveFrom
, swapWithPermit
, and other advanced interactions, allowing users to sign off-chain data securely and submit it for verification on-chain.
Features of the Unified Account System
Compatibility with Bitcoin
Unified accounts are fully compatible with Bitcoin's existing protocols:
- Backward Compatibility: Works seamlessly with all address types (e.g., legacy, SegWit, Taproot).
- Forward Compatibility: Ready for future Bitcoin upgrades and enhancements.
Public Key Retrieval API
Retrieving public key information on OP_NET is straightforward using the provider's API.
For detailed instructions, refer to the Fetching Public Key from Address documentation.
Considerations
While unified accounts bring many benefits, there are edge cases to consider:
- Fresh Wallets: Public keys must be revealed through a transaction before they can be used.
- Non-Standard Scripts: Addresses created with custom scripts may require manual public key input.