Skip to main content
In this step, you’ll learn how to complete the SIWB authentication process by signing the message you received in Step 1 and converting it into an Internet Computer identity.
This step builds on Step 1: Project Setup and Prepare Authentication. Make sure you’ve completed that step first.

What You’ll Accomplish

By the end of this step, you’ll have:
  • ✅ Created utility functions for delegation chain management
  • ✅ Implemented the complete SIWB login process
  • ✅ Generated a working Internet Computer identity
  • ✅ Tested the SIWB authentication flow Step 4

Phase 2: Complete SIWB Login

Now that you have a message to sign from Step 1, let’s complete the authentication process by signing that message with your Bitcoin wallet and converting it into an Internet Computer identity.

Authentication Utilities

First, let’s create utility functions that we’ll need for managing delegation chains:
utils/auth.ts
These utility functions handle the conversion between the SIWB canister’s response format and the Internet Computer’s delegation identity format.

Implementing the Login Function

Now let’s implement the main login function that completes the SIWB authentication process:
core/login.ts

Understanding the Login Process

The login function performs several important steps:
1

Create SIWB Actor

Establishes a connection to the SIWB canister using an anonymous agent
2

Generate Session Identity

Creates a temporary identity for this authentication session
3

Submit Login Credentials

Sends the signed message, address, and public key to the SIWB canister
4

Retrieve Delegation

Gets a delegation that proves the authentication was successful
5

Create Identity

Combines the session identity with the delegation to create a usable Internet Computer identity
At this point, you can start using the identity to interact with Odin canisters and other Internet Computer services.

Testing the Complete Flow

Let’s test our complete authentication flow by combining the prepare and login functions:
index.ts
Success! You now have a working Internet Computer identity generated through Bitcoin wallet authentication.

Bitcoin Wallet Integration

If you don’t know how to create and sign messages with Bitcoin, don’t worry! We’ve created a comprehensive guide in Sample Wallet Setup that shows you how to implement a complete Bitcoin wallet for testing.

Troubleshooting Common Issues

  • Ensure you are signing with Bip322 strict
  • Verify that the message being signed matches exactly the one returned from prepare()
  • Make sure that you are matching the signature method (Bip322 vs ECDSA)
  • If authentication fails due to expiration, restart from Step 1 with a fresh prepare() call

What’s Next?

Now that you have a working Internet Computer identity, you can use it to authenticate with Odin’s API services. In the next step, you’ll learn how to exchange your identity for an API token.

Continue to Step 3

Learn how to authenticate with Odin’s API using your Internet Computer identity