SessionlessNET 0.1.1

dotnet add package SessionlessNET --version 0.1.1                
NuGet\Install-Package SessionlessNET -Version 0.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SessionlessNET" Version="0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SessionlessNET --version 0.1.1                
#r "nuget: SessionlessNET, 0.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SessionlessNET as a Cake Addin
#addin nuget:?package=SessionlessNET&version=0.1.1

// Install SessionlessNET as a Cake Tool
#tool nuget:?package=SessionlessNET&version=0.1.1                

Sessionless

This is the C# implementation of the Sessionless protocol--a protocol for providing auth without user data like emails, passwords, or sessions.

Usage

Install

<a href="https://nuget.org/packages/SessionlessNET"> <img src="https://buildstats.info/nuget/SessionlessNET" alt="SessionlessNET nuget package" /> </a>

  • dotnet add package SessionlessNET

Import

  • Main implementations
using SessionlessNET.Impl.Sessionless;
using SessionlessNET.Impl.Vault;
  • Interfaces
using SessionlessNET.Models.ISessionless;
using SessionlessNET.Models.IVault;

Documentation:

Almost all classes / members have xaml documentation attached to them in source. This means your IDE will show you the documentation while hovering/viewing/etc...

<br/>

ISessionless provides the following members:

(Check out the complete class diagrams below)

public IVault Vault { get; }
  • The way to store and retrieve KeyPairHexs

<br/>

public string GenerateUUID();
  • Creates a unique UUID for a user.

<br/>

public KeyPairHex GenerateKeys();
  • Generates a private/public KeyPairHex and stores it using Vault
  • Returns: KeyPairHex that was generated

<br/>

public Task<KeyPairHex> GenerateKeysAsync();
  • Generates a private/public KeyPairHex asynchronously and stores it using Vault
  • Returns: KeyPairHex that was generated

<br/>

public KeyPairHex? GetKeys();
  • Retrieves keys using Vault
  • Returns: Key pair as KeyPairHex

<br/>

public MessageSignatureHex Sign(string message);
  • Signs a message with the user's stored private key (Get from Vault using GetKeys)
  • Parameters:
    • message The message to be signed
  • Returns: Signature as a MessageSignatureHex

<br/>

public MessageSignatureHex Sign(string message, string privateKeyHex);
  • Signs a message using the provided privateKeyHex
  • Parameters:
    • message The message to be signed
    • privateKeyHex The private key in hex format to use for signing
  • Returns: Signature as a MessageSignatureHex

<br/>

public MessageSignatureHex Sign(string message, ECPrivateKeyParameters privateKey);
  • Signs a message using the provided privateKey
  • Parameters:
    • message The message to be signed
    • privateKey The private key to use for signing
  • Returns: Signature as a MessageSignatureHex

<br/>

public bool VerifySignature(SignedMessage signedMessage);
  • Verifies a given signed message with the user's stored public key
  • Parameters:
    • signedMessage The message that was signed earlier
  • Returns: True if the signature is valid for the given message and public key

<br/>

public bool VerifySignature(SignedMessageWithKey signedMessage);
  • Verifies a given signed message with the included SignedMessageWithKey.PublicKey
  • Parameters:
    • signedMessage The message that was signed earlier
  • Returns: True if the signature is valid for the given message and public key

<br/>

public bool VerifySignature(SignedMessageWithECKey signedMessage);
  • Verifies a given signed message with the included SignedMessageWithECKey.PublicKey
  • Parameters:
    • signedMessage The message that was signed earlier
  • Returns: True if the signature is valid for the given message and public key

<br/>

public bool Associate(params SignedMessage[] messages);
  • Verifies each of the messages
  • Parameters:
    • ...messages Messages to be verified
  • Returns: True if all signatures were verified successfully
  • Throws:
    • ArgumentException if the messages count is <2

For more on associating keys check out this section of the dev README.

<br/> <br/>

More information

Check out the docs in the repo

<br/> <br/>

Class diagrams

  • SessionlessNET.Models.ISessionless

classDiagram
  class ISessionless {
    +Vault: IVault
    +GenerateUUID(): string
    +GenerateKeys(): KeyPairHex
    +GenerateKeysAsync(): Task<`KeyPairHex>
    +GetKeys(): KeypairHex?
    +Sign(string): MessageSignatureHex
    +Sign(string, string): MessageSignatureHex
    +Sign(string, ECPrivateKeyParameters): MessageSignatureHex
    +VerifySignature(SignedMessage): bool
    +VerifySignature(SignedMessageWithKey): bool
    +VerifySignature(SignedMessageWithECKey): bool
    +Associate(SignedMessages[]): bool
  }
  class Sessionless {
    constructor(IVault)
  }
  ISessionless <-- Sessionless
  • SessionlessNET.Models.IVault

classDiagram
  class IVault {
    +Get(): KeyPairHex?
    +Save(KeyPairHex)
  }
  class Vault {
    constructor(Func<`KeyPairHex?>, Action<`KeyPairHex>)
  }

  IVault <-- Vault
  • SessionlessNET.Impl.MessageSignature

classDiagram
  class IMessageSignature { }
  class MessageSignatureInt {
    +R: BigInteger
    +S: BigInteger
    +constructor(BigInteger, BigInteger)
    +constructor(BigInteger[])
    +constructor(MessageSignatureHex)
    +toHex(): MessageSignatureHex
    +op_explicit(MessageSignatureInt): MessageSignatureHex
  }
  class MessageSignatureHex {
    +RHex: string
    +SHex: string
    +constructor(string, string)
    +constructor(MessageSignatureInt)
    +toInt(): MessageSignatureInt
    +op_explicit(MessageSignatureHex): MessageSignatureInt
  }

  IMessageSignature <-- MessageSignatureInt
  IMessageSignature <-- MessageSignatureHex
  • SessionlessNET.Impl.MessageSignature

classDiagram
  class SignedMessage {
    +Message: string
    +Signature: MessageSignatureHex
    +constructor(string, MessageSignatureHex)
    +WithKey(string): SignedMessageWithKey
    +WithKey(ECPublicKeyParameters): SignedMessageWithECKey
  }
  class SignedMessageWithKey {
    +PublicKey: string
    +constructor(string, MessageSignatureHex, string)
    +constructor(SignedMessage, string)
  }
  class SignedMessageWithECKey {
    +PublicKey: ECPublicKeyParameters
    +constructor(string, MessageSignatureHex, ECPublicKeyParameters)
    +constructor(SignedMessage, ECPublicKeyParameters)
  }

  SignedMessage <-- SignedMessageWithKey
  SignedMessage <-- SignedMessageWithECKey
  • SessionlessNET.Impl....

classDiagram
  class KeyPairHex {
    +PrivateKey: string
    +PublicKey: string
    +constructor(string, string)
  }
  • SessionlessNET.Impl.Exceptions....

classDiagram
  class KeyPairNotFoundException {
    constructor()
  }
  class HexFormatRequiredException {
    constructor(string)
  }
  Exception <-- KeyPairNotFoundException
  Exception <.. FormatException
  FormatException <-- HexFormatRequiredException
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.1 111 4/26/2024
0.1.0 104 4/26/2024