> ## Documentation Index
> Fetch the complete documentation index at: https://docs.riseworks.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Understanding Private Keys

> Learn about private keys, their importance, and how to use them securely with Rise B2B API

<Note>
  Understanding private keys is crucial for secure authentication and transaction signing in blockchain-based applications.
</Note>

## What is a Private Key?

A private key is a cryptographic secret that allows you to:

* **Sign messages** to prove your identity
* **Authorize transactions** on the blockchain
* **Control digital assets** associated with your wallet
* **Authenticate** with blockchain-based services

Think of it as a digital signature that only you can create, proving you are who you claim to be.

## Why Private Keys Are Important

Private keys are essential for secure blockchain interactions and API authentication:

### **Digital Identity Verification**

* **Cryptographic proof**: Your private key creates mathematical proof of your identity
* **Impossible to forge**: Only you can create signatures with your private key
* **Immutable verification**: Signatures cannot be altered or tampered with
* **Trustless authentication**: No need to trust third parties for identity verification

### **Transaction Authorization**

* **Secure signing**: Private keys sign transactions to authorize them
* **Intent verification**: Signatures prove you intended to perform the action
* **Non-repudiation**: You cannot deny performing actions you've signed
* **Blockchain security**: Ensures only authorized users can perform operations

### **API Authentication with Rise**

* **SIWE signing**: Sign-In with Ethereum uses your private key for authentication
* **Message signing**: Sign cryptographic messages to prove wallet ownership
* **Session management**: Generate JWT tokens through secure signing
* **Access control**: Control which operations your application can perform

## How Private Keys Are Used for Signing

### **Message Signing Process**

When you authenticate with Rise, your private key is used to sign messages:

<Steps>
  <Step title="Message Creation">
    Rise creates a cryptographic message with your Rise ID and timestamp
  </Step>

  <Step title="Private Key Signing">
    Your private key creates a unique signature for this message
  </Step>

  <Step title="Signature Verification">
    Rise verifies the signature using your wallet's public address
  </Step>

  <Step title="Authentication Grant">
    If valid, Rise grants you access and provides a JWT token
  </Step>
</Steps>

### **Security Benefits of Signing**

<CardGroup cols={2}>
  <Card title="Identity Proof" icon="user-check">
    * Proves you control the wallet
    * Verifies your Rise account ownership
    * Prevents impersonation attacks
    * Ensures account security
  </Card>

  <Card title="Transaction Security" icon="shield">
    * Authorizes specific operations
    * Prevents unauthorized transactions
    * Creates audit trails
    * Ensures transaction integrity
  </Card>

  <Card title="Session Management" icon="key">
    * Generates secure JWT tokens
    * Manages API session security
    * Handles token renewal
    * Maintains secure connections
  </Card>

  <Card title="Access Control" icon="lock">
    * Controls API permissions
    * Limits operation scope
    * Prevents privilege escalation
    * Ensures proper authorization
  </Card>
</CardGroup>

## Creating Your First Wallet

If you don't have a wallet yet, you'll need to create one first. Here are the most popular options:

### Option 1: MetaMask (Browser Extension)

<Steps>
  <Step title="Install MetaMask">
    Go to [metamask.io](https://metamask.io) and install the browser extension
  </Step>

  <Step title="Create Account">
    Click "Create a Wallet" and follow the setup process
  </Step>

  <Step title="Secure Your Wallet">
    Write down your 12-word recovery phrase and store it securely
  </Step>

  <Step title="Set Password">
    Create a strong password for your MetaMask wallet
  </Step>

  <Step title="Verify Setup">
    Complete the recovery phrase verification
  </Step>
</Steps>

### Option 2: Coinbase Wallet (Browser Extension)

<Steps>
  <Step title="Install Coinbase Wallet">
    Go to [wallet.coinbase.com](https://wallet.coinbase.com) and install the browser extension
  </Step>

  <Step title="Create Wallet">
    Click "Create new wallet" and follow the setup process
  </Step>

  <Step title="Backup Recovery Phrase">
    Write down your 12-word recovery phrase and store it securely
  </Step>

  <Step title="Set Password">
    Create a strong password for your Coinbase Wallet
  </Step>

  <Step title="Verify Recovery">
    Complete the recovery phrase verification
  </Step>
</Steps>

### Option 3: Coinbase Wallet (Mobile App)

<Steps>
  <Step title="Download App">
    Install Coinbase Wallet from your app store
  </Step>

  <Step title="Create Wallet">
    Open the app and tap "Create new wallet"
  </Step>

  <Step title="Backup Recovery Phrase">
    Write down your 12-word recovery phrase
  </Step>

  <Step title="Verify Recovery">
    Complete the recovery phrase verification
  </Step>

  <Step title="Set Security">
    Enable biometric authentication if available
  </Step>
</Steps>

<Warning>
  **Important**: When creating a wallet, always write down your recovery phrase (seed phrase) and store it securely. This is the only way to recover your wallet if you lose access to your device.
</Warning>

## How to Get Your Private Key

### From MetaMask

<Steps>
  <Step title="Open MetaMask">
    Click on the MetaMask extension in your browser
  </Step>

  <Step title="Access Account">
    Click on the three dots menu → Account details
  </Step>

  <Step title="Export Private Key">
    Click "Export Private Key" and enter your password
  </Step>

  <Step title="Copy Key">
    Copy the private key (starts with 0x)
  </Step>
</Steps>

### From Other Wallets

Most wallets provide an export function:

* **Trust Wallet**: Settings → Security → Export Private Key
* **Coinbase Wallet**: Settings → Advanced → Export Private Key
* **Rainbow**: Settings → Security → Export Private Key

### Generate New Key

```typescript theme={null}
import { ethers } from 'ethers';

// Generate a new wallet
const wallet = ethers.Wallet.createRandom();

// Get the private key
const privateKey = wallet.privateKey;
const address = wallet.address;

console.log('Private Key:', privateKey);
console.log('Address:', address);
```

## Private Key Security Best Practices

<CardGroup cols={2}>
  <Card title="Secure Storage" icon="lock">
    * Use password managers
    * Hardware security modules (HSM)
    * Encrypted storage
    * Never store in plain text
  </Card>

  <Card title="Access Control" icon="user-shield">
    * Limit access to authorized personnel
    * Use role-based access
    * Implement audit logging
    * Regular access reviews
  </Card>

  <Card title="Backup Strategy" icon="floppy-disk">
    * Create secure backups
    * Use multiple locations
    * Test recovery process
    * Update backups regularly
  </Card>

  <Card title="Monitoring" icon="eye">
    * Monitor wallet activity
    * Set up alerts
    * Regular security audits
    * Track usage patterns
  </Card>
</CardGroup>

## Private Key Format

Private keys in Ethereum are:

* **64 characters** long (32 bytes)
* **Hexadecimal** format
* **Start with 0x**
* **Case sensitive**

Example: `0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef`

## Why Private Keys Matter

Private keys are the foundation of blockchain-based security and provide several critical benefits:

<CardGroup cols={2}>
  <Card title="Cryptographic Security" icon="shield">
    * Mathematically unbreakable
    * Quantum-resistant algorithms
    * Zero-knowledge proofs
    * Tamper-evident signatures
  </Card>

  <Card title="User Control" icon="user">
    * You control your own identity
    * No reliance on third-party authentication
    * Direct ownership of digital assets
    * Self-sovereign identity
  </Card>

  <Card title="Audit Trail" icon="file-lines">
    * Blockchain-verifiable signatures
    * Immutable transaction history
    * Transparent audit logs
    * Compliance-ready records
  </Card>

  <Card title="Compliance" icon="circle-check">
    * Self-sovereign identity
    * Regulatory compliance
    * Audit trail requirements
    * Data privacy standards
  </Card>
</CardGroup>
