# Stoic and Plug as login flow

**URL:** <https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369>\
**Category:** Developers\
**Created:** [May 30, 2024, 2:45pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369 "2024-05-30T14:45:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [May 30, 2024, 2:45pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/1 "2024-05-30T14:45:41Z")

</div>

Hi, this might be a stupid question, but I’ve got a doubt. Has anyone or any dApps of the community implemented a login flow\*\* using Stoic or Plug wallet? Or are those solutions primarily and only used by the community as wallets to sign and execute transactions?

\*\* By login flow, I mean a process such as sign-in, sign-out, synchronizing the authentication, or calling the IC with an identity and an agent derived from the login action. Something commonly implemented with Internet Identity or NFID.

---

<div class="post-metadata">

**Author:** ![senior.joinu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/senior.joinu/32/9240_2.png) [@senior.joinu](https://forum.dfinity.org/u/senior.joinu)\
**Post date:** [May 30, 2024, 6:59pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/2 "2024-05-30T18:59:24Z")

</div>

I’m trying to do that right now with Plug. Plus there is `Artemis` wallet connector, which also does that for a whole bunch of wallets, including Plug and Stoic.

What is your concern?

Btw, is Stoic even maintained? It looks exactly the same as 3 years ago.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [May 31, 2024, 6:05am UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/3 "2024-05-31T06:05:46Z")

</div>

Not really a concern, but some developers on the Juno Discord expressed an interest in supporting Stoic and Plug for sign-in purposes. Since adapting the related JS library would require some work, I was curious to know, before starting implementation, if such a login flow is actually possible and if anyone in the community did implement such a flow with those.

---

<div class="post-metadata">

**Author:** ![sea-snake](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/sea-snake/32/7243_2.png) [@sea-snake](https://forum.dfinity.org/u/sea-snake)\
**Post date:** [May 31, 2024, 7:15am UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/4 "2024-05-31T07:15:31Z")

</div>

In the [WG](https://github.com/dfinity/wg-identity-authentication) there’s ICRC-32 for signatures, combined with either:

> **[@dfinity/standalone-sig-verifier-web](https://www.npmjs.com/package/@dfinity/standalone-sig-verifier-web)**
>
> Standalone crypto library to verify cryptographic signatures for the Internet Computer. Latest version: 1.0.0, last published: 8 months ago. Start using @dfinity/standalone-sig-verifier-web in your project by running \`npm i...

> **[@slide-computer/signer-signatures](https://www.npmjs.com/package/@slide-computer/signer-signatures)**
>
> Verify signatures from signers on the Internet Computer. Latest version: 1.9.0, last published: 5 days ago. Start using @slide-computer/signer-signatures in your project by running \`npm i @slide-computer/signer-signatures\`. There are no other...

You can register a public key on your server and for login send the signature (and optional delegation chain) to your server and verify these.

Standard might still change and hasn’t been implemented in most yet wallets. Neither is there any documentation regarding this available at this moment.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [May 31, 2024, 11:17am UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/5 "2024-05-31T11:17:34Z")

</div>

Thanks, did not thought about using the standard in that way, good call. That said I’m interested about the current state - i.e. has anyone already implemented a login flow using those providers? Maybe no one indeed…

---

<div class="post-metadata">

**Author:** ![sea-snake](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/sea-snake/32/7243_2.png) [@sea-snake](https://forum.dfinity.org/u/sea-snake)\
**Post date:** [May 31, 2024, 2:42pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/6 "2024-05-31T14:42:44Z")

</div>

NFID is actively implementing the standards, also Plug is working on implementing them as far as I’m aware. Haven’t heard anything regarding Stoic.

But for wallets that return a delegation like II and Stoic, you could already implement a signature + delegation validation approach.

Given a key pair public1 and private1, you store public1 on the server and to login you then sign a random challenge with private1, this signature is sent to the server which then verifies it with public1.

With a delegation chain it’s basically the same approach but the account private key isn’t available to sign the challenge with directly.

Given a delegation chain: 3 → 4 → 5, this delegation chain contains public key 3, a signature from private3 with public4 as challenge, public4, a signature from private4 with public5 as challenge and lastly public5. You store public3 on the server and to login you then sign a random challenge with private5, this signature and the delegation chain are sent to the server which then verifies the signature with public5 and the delegation chain with the IC root key.

The libraries from my earlier post both basically implement the signature (and delegation) verification mentioned in the steps above. As for signing the challenge, you can do this with the sign method on the Identity instance (same one as you’re passing to HttpAgent).

---

<div class="post-metadata">

**Author:** ![dostro](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dostro/32/1161_2.png) [@dostro](https://forum.dfinity.org/u/dostro)\
**Post date:** [May 31, 2024, 2:54pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/7 "2024-05-31T14:54:11Z")

</div>

I’d be curious to get your and @sea-snake’s take on [this](https://forum.dfinity.org/t/authentication-recommendation-proposal-for-new-dapps/31411).

I think we need to give devs better guidance of the auth instrument they use based on their dapp’s use case.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [May 31, 2024, 3:07pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/8 "2024-05-31T15:07:31Z")

</div>

Thanks for the ideas and details, awesome!

However, just to be clear, my questions in this thread is not about the “how”, it’s really strictly about knowing if anyone in community already implemented a flow with Stoic or Plug?

Nothing less, nothing more. But again, great inputs!!!

---

<div class="post-metadata">

**Author:** ![pu0238](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/pu0238/32/14831_2.png) [@pu0238](https://forum.dfinity.org/u/pu0238)\
**Post date:** [May 31, 2024, 3:50pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/9 "2024-05-31T15:50:33Z")

</div>

Hi, here is the wallet adapter built by SonicDex: [GitHub - sonicdex/artemis: dfinity wallet adapter for connecting different wallets in IC](https://github.com/sonicdex/artemis). While building DeAI, we are also creating our own wallet adapter that will support TypeScript and standardize those wallets a little bit more accurately.

---

<div class="post-metadata">

**Author:** ![sea-snake](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/sea-snake/32/7243_2.png) [@sea-snake](https://forum.dfinity.org/u/sea-snake)\
**Post date:** [May 31, 2024, 4:47pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/10 "2024-05-31T16:47:36Z")

</div>

If you’re interested in standardizing wallet interaction, please join the [WG](https://github.com/dfinity/wg-identity-authentication) calls, here we’re trying to solve this issue from the wallet side, so hopefully per wallet custom adapters implementations are no longer needed at some point.

Feel free to reach to me on Discord(same username) for an introduction/questions.

---

<div class="post-metadata">

**Author:** ![patnorris](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/patnorris/32/11764_2.png) [@patnorris](https://forum.dfinity.org/u/patnorris)\
**Post date:** [June 5, 2024, 7:43pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/11 "2024-06-05T19:43:27Z")

</div>

Hi @peterparker , if I understand your question correctly, I’d say yes as we’ve got Plug as a login option on DeVinci: [https://x6occ-biaaa-aaaai-acqzq-cai.icp0.io/](https://x6occ-biaaa-aaaai-acqzq-cai.icp0.io/)  
We also used to have Stoic as a login option but as it didn’t seem that well maintained, we disabled this option.

If interested, please see the code here:  
Plug button: [DecentralizedAIonIC/src/DeVinci\_frontend/components/PlugButton.svelte at master · patnorris/DecentralizedAIonIC · GitHub](https://github.com/patnorris/DecentralizedAIonIC/blob/master/src/DeVinci_frontend/components/PlugButton.svelte)  
Stoic button (disabled): [DecentralizedAIonIC/src/DeVinci\_frontend/components/StoicButton.svelte at master · patnorris/DecentralizedAIonIC · GitHub](https://github.com/patnorris/DecentralizedAIonIC/blob/master/src/DeVinci_frontend/components/StoicButton.svelte)  
Login logic for both (and other options): [DecentralizedAIonIC/src/DeVinci\_frontend/store.ts at master · patnorris/DecentralizedAIonIC · GitHub](https://github.com/patnorris/DecentralizedAIonIC/blob/master/src/DeVinci_frontend/store.ts)

hope this helps 👍

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [June 5, 2024, 8:03pm UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/12 "2024-06-05T20:03:41Z")

</div>

Thanks so much, @patnorris! This has been helpful.

Contrary to my initial thoughts, it means that one project has indeed implemented a login flow with Plug and Stoic, not just a wallet flow.

Additionally, the source code you shared was really valuable. It confirmed my initial concerns, in terms of effort, that once signed in with these vendors, each actor needs to be initialized in a specific way, which sounds like a bummer 😄.

PS: [DecentralizedAIonIC](https://github.com/patnorris/DecentralizedAIonIC) ⭐👍 ✅

---

<div class="post-metadata">

**Author:** ![patnorris](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/patnorris/32/11764_2.png) [@patnorris](https://forum.dfinity.org/u/patnorris)\
**Post date:** [June 6, 2024, 7:55am UTC](https://forum.dfinity.org/t/stoic-and-plug-as-login-flow/31369/13 "2024-06-06T07:55:57Z")

</div>

Sure thing, happy if it was helpful 👍  
Yes, especially the setup for the browser extension-based login options was more custom from my experience.
