User Share Encryption Keys
The UserShareEncryptionKeys class is a core component for managing cryptographic keys in the Ika network. It handles the creation and management of encryption/decryption keys and signing keypairs needed for secure user share operations. You pass it to IkaTransaction to perform user share operations.
Overview
In the Ika network, users need to securely manage their secret shares while maintaining the ability to prove ownership and authorization. The UserShareEncryptionKeys class provides a unified interface for:
- Encrypting secret shares - Protecting sensitive cryptographic material
- Proving ownership - Creating signatures to demonstrate control over keys
- Authorizing operations - Signing dWallet public outputs for various operations
- Key management - Deriving, storing, and retrieving cryptographic keys
Security Reminder
UserShareEncryptionKeys handles extremely sensitive cryptographic material. Always follow security best practices, conduct security reviews, and consider getting security audits for production applications.
Supported Curves
UserShareEncryptionKeys supports the following elliptic curves:
Curve.SECP256K1- Used by ECDSASecp256k1 and Taproot signature algorithmsCurve.SECP256R1- Used by ECDSASecp256r1 signature algorithmCurve.ED25519- Used by EdDSA signature algorithmCurve.RISTRETTO- Used by SchnorrkelSubstrate signature algorithm
Curve Matching Required
You must create UserShareEncryptionKeys BEFORE creating a dWallet, and the curve you choose MUST match the curve you'll use when creating the dWallet.
The workflow is:
- Choose a curve based on the signature algorithm you want to use
- Create UserShareEncryptionKeys with that curve
- Create your dWallet with the same curve/signature algorithm
- Use the UserShareEncryptionKeys for all operations with that dWallet
For example:
- To use
ECDSASecp256k1orTaproot, create keys withCurve.SECP256K1 - To use
EdDSA, create keys withCurve.ED25519 - To use
ECDSASecp256r1, create keys withCurve.SECP256R1 - To use
SchnorrkelSubstrate, create keys withCurve.RISTRETTO
Using mismatched curves will cause all operations to fail.
Creating UserShareEncryptionKeys
There are several ways to create a UserShareEncryptionKeys instance depending on your use case.
From Root Seed Key
The most common way is to create keys from a root seed. This method deterministically derives all necessary keys from a single seed:
Examples with different curves:
Choosing the Right Curve
Choose your curve based on the signature algorithm you intend to use:
- SECP256K1: Best for Ethereum, Bitcoin (ECDSA), and general ECDSA use cases
- ED25519: Best for high-performance EdDSA signatures
- SECP256R1: For NIST P-256 compliance requirements
- RISTRETTO: For Substrate/Polkadot ecosystem compatibility
From Serialized Bytes
If you have previously serialized keys, you can restore them:
Serializing Keys for Storage
You can serialize keys for persistent storage:
Security Warning
Always store serialized keys securely. The serialized data contains sensitive cryptographic material including private keys. Use appropriate encryption and access controls for storage.
Key Methods and Operations
Getting Key Information
Access basic information about your keys:
Signature Operations
Verifying Signatures
Verify signatures over messages using the public key:
Creating Encryption Key Signatures
Create a signature over your own encryption key to prove ownership:
dWallet Authorization Signatures
For Newly Created dWallets
When you participate in dWallet creation, you need to sign the public output to authorize its use:
For Transferred dWallets
When receiving a transferred dWallet, you need to verify the sender and create your authorization signature:
Security Warning
When handling transferred dWallets, always verify that sourceEncryptionKey belongs to the expected sender. Don't fetch this from the network without proper verification - the sender's public key should be known to you through secure channels.
Decrypting User Shares
The most critical operation is decrypting your encrypted user secret key shares:
Curve Matching Critical
The UserShareEncryptionKeys instance MUST have been created with the same curve as the dWallet.
For dWallets you created: You already created the UserShareEncryptionKeys first with a specific curve, then used it to create the dWallet - so they match by design.
For transferred/existing dWallets: You must check the dWallet's curve and create UserShareEncryptionKeys with the matching curve (see "For Existing or Transferred dWallets" section above).
If the curves don't match, all operations including decryption will fail.
Decryption Process
The decryptUserShare method performs several security checks:
- Verifies the dWallet state - Ensures the dWallet is active and has valid public output
- Validates the encrypted share - Checks the encrypted share signature against your public key
- Decrypts the share - Uses your decryption key to recover the secret share
- Verifies consistency - Ensures the decrypted share matches the dWallet's public output
This multi-layer verification ensures the integrity and authenticity of your secret shares.