ETAMP 3.0.0
See the version list below for details.
dotnet add package ETAMP --version 3.0.0
NuGet\Install-Package ETAMP -Version 3.0.0
<PackageReference Include="ETAMP" Version="3.0.0" />
paket add ETAMP --version 3.0.0
#r "nuget: ETAMP, 3.0.0"
// Install ETAMP as a Cake Addin #addin nuget:?package=ETAMP&version=3.0.0 // Install ETAMP as a Cake Tool #tool nuget:?package=ETAMP&version=3.0.0
ETAMP (Encrypted Token And Message Protocol)
Overview
ETAMP (Encrypted Token And Message Protocol) is designed for secure and efficient message transmission in a semi-decentralized network. The protocol ensures message integrity and supports encryption and signing using ECC ( Elliptic Curve Cryptography).
Architecture
The protocol includes the following fields:
GUID Id
double Version
string Token
(compressed JSON)string UpdateType
string SignatureMessage
string CompressionType
Token Structure
The token structure includes the following fields:
Guid Id
Guid MessageId
bool IsEncrypted
string Data
DateTimeOffset TimeStamp
Installation
Install ETAMP using the NuGet Package Manager:
Install-Package ETAMP
Usage
Prerequisites
Ensure you have the necessary dependencies and services configured in your application. The examples below
use Microsoft.Extensions.DependencyInjection
for dependency injection.
Example Files
Program.cs
This file serves as the entry point of the application, demonstrating the creation, signing, encryption, and validation of ETAMP messages.
// Program.cs using ETAMPManagement.Extensions; using Microsoft.Extensions.DependencyInjection; namespace ETAMPExample { internal static class Program { private static void Main() { var provider = ConfigureServices(); var createETAMP = new CreateETAMP(provider); var createSignETAMP = new CreateSignETAMP(provider); var validateETAMP = new ValidateETAMP(provider); var encrypted = new CreateEncryptedETAMP(provider); Console.WriteLine("Create default ETAMP: \n" + createETAMP.CreateETAMPMessage() + "\n"); Console.WriteLine("Create ETAMP with sign: \n" + createSignETAMP.CreateAndSignETAMPMessage() + "\n"); Console.WriteLine("Create encrypted ETAMP: \n" + encrypted.CreateEncryptedETAMPMessage() + "\n"); Console.WriteLine("Validate ETAMP: \n" + validateETAMP.Validate()); } private static ServiceProvider ConfigureServices() { var serviceCollection = new ServiceCollection(); serviceCollection.AddETAMPServices(); return serviceCollection.BuildServiceProvider(); } } }
CreateETAMP.cs
This class is responsible for creating a basic ETAMP message.
// CreateETAMP.cs using ETAMPManagement.ETAMP.Interfaces; using ETAMPManagement.Extensions.Builder; using ETAMPManagement.Factory.Interfaces; using ETAMPManagement.Models; using Microsoft.Extensions.DependencyInjection; namespace ETAMPExample { public class CreateETAMP { private readonly ServiceProvider _provider; public CreateETAMP(ServiceProvider provider) { _provider = provider; } public string CreateETAMPMessage() { var etampBase = _provider.GetService<IETAMPBase>(); var compression = _provider.GetService<ICompressionServiceFactory>(); var token = CreateToken("SomeDataInJson"); var etamp = etampBase.CreateETAMPModel("Message", token, CompressionNames.Deflate); return etamp.Build(compression); } private Token CreateToken(string data) { return new Token { Data = data }; } } }
CreateSignETAMP.cs
This class handles the creation and signing of ETAMP messages.
// CreateSignETAMP.cs using System.Security.Cryptography; using ETAMPManagement.Encryption.ECDsaManager.Interfaces; using ETAMPManagement.ETAMP.Interfaces; using ETAMPManagement.Extensions.Builder; using ETAMPManagement.Factory.Interfaces; using ETAMPManagement.Models; using Microsoft.Extensions.DependencyInjection; namespace ETAMPExample { public class CreateSignETAMP { private readonly ServiceProvider _provider; public CreateSignETAMP(ServiceProvider provider) { _provider = provider; } public IECDsaProvider ECDsaProvider { get; private set; } public HashAlgorithmName HashAlgorithm { get; private set; } public string CreateAndSignETAMPMessage() { var etampBase = _provider.GetService<IETAMPBase>(); var sign = _provider.GetService<SignWrapperBase>(); var creator = _provider.GetService<IECDsaCreator>(); var compression = _provider.GetService<ICompressionServiceFactory>(); InitializeSignature(sign, creator); var token = CreateToken("SomeDataInJson"); var etamp = etampBase.CreateETAMPModel("Message", token, CompressionNames.Deflate); return etamp.Sign(sign).Build(compression); } private void InitializeSignature(SignWrapperBase sign, IECDsaCreator creator) { ECDsaProvider = creator.CreateECDsa(); HashAlgorithm = HashAlgorithmName.SHA512; sign.Initialize(ECDsaProvider, HashAlgorithm); } private Token CreateToken(string data) { return new Token { Data = data }; } } }
CreateEncryptedETAMP.cs
This class demonstrates how to create an encrypted ETAMP message.
// CreateEncryptedETAMP.cs using System.Security.Cryptography; using ETAMPManagement.Encryption.Base; using ETAMPManagement.Encryption.Interfaces; using ETAMPManagement.ETAMP.Interfaces; using ETAMPManagement.Extensions.Builder; using ETAMPManagement.Factory.Interfaces; using ETAMPManagement.Models; using Microsoft.Extensions.DependencyInjection; namespace ETAMPExample { public class CreateEncryptedETAMP { private readonly ServiceProvider _provider; public CreateEncryptedETAMP(ServiceProvider provider) { _provider = provider; } public string CreateEncryptedETAMPMessage() { var etampBase = _provider.GetService<IETAMPBase>(); var ecies = _provider.GetService<ECIESEncryptionServiceBase>(); var compression = _provider.GetService<ICompressionServiceFactory>(); var keyExchanger = _provider.GetService<KeyExchangerBase>(); var keyPairProvider = _provider.GetService<KeyPairProviderBase>(); var aes = _provider.GetService<IEncryptionService>(); keyPairProvider.Initialize(ECDiffieHellman.Create()); keyExchanger.Initialize(keyPairProvider); keyExchanger.DeriveKey(ECDiffieHellman.Create().PublicKey); ecies.Initialize(keyExchanger, aes); var token = CreateToken("SomeDataInJson"); var etamp = etampBase.CreateETAMPModel("Message", token, CompressionNames.Deflate); return etamp.EncryptData(ecies).Build(compression); } private Token CreateToken(string data) { return new Token { Data = data }; } } }
ValidateETAMP.cs
This class is responsible for validating ETAMP messages.
// ValidateETAMP.cs using ETAMPManagement.Extensions.Builder; using ETAMPManagement.Factory.Interfaces; using ETAMPManagement.Models; using ETAMPManagement.Validators.Base; using Microsoft.Extensions.DependencyInjection; namespace ETAMPExample { public class ValidateETAMP { private readonly ServiceProvider _provider; public ValidateETAMP(ServiceProvider provider) { _provider = provider; } public bool Validate() { var validator = _provider.GetService<ETAMPValidatorBase>(); var compression = _provider.GetService<ICompressionServiceFactory>(); var createSignETAMP = new CreateSignETAMP(_provider); var etamp = createSignETAMP.CreateAndSignETAMPMessage(); var model = etamp.DeconstructETAMP<Token>(compression); validator?.Initialize(createSignETAMP.ECDsaProvider, createSignETAMP.HashAlgorithm); var result = validator?.ValidateETAMP(model, false); return result.IsValid; } } }
Conclusion
This documentation provides an overview of the ETAMP protocol and its usage with example implementations. Follow the structure and examples to integrate ETAMP into your projects, ensuring secure and efficient message handling.
Contributing
Contributions to ETAMP are welcome! Please fork the repository, make your changes, and submit a pull request. We appreciate your input in improving the project.
License
ETAMP is licensed under the MIT License. For more information, see the LICENSE file in the repository.
Product | Versions 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Newtonsoft.Json (>= 13.0.3)
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 |
---|---|---|
3.1.2 | 52 | 10/29/2024 |
3.0.2 | 101 | 5/31/2024 |
3.0.1 | 96 | 5/31/2024 |
3.0.0 | 99 | 5/31/2024 |
2.0.0 | 121 | 5/5/2024 |
1.4.0 | 132 | 3/23/2024 |
1.3.1 | 133 | 3/4/2024 |
1.3.0 | 116 | 3/2/2024 |
1.2.0 | 140 | 3/1/2024 |
1.1.5 | 138 | 2/8/2024 |
1.1.4 | 216 | 12/16/2023 |
1.1.3 | 166 | 12/6/2023 |
1.1.2 | 147 | 12/5/2023 |
1.1.1 | 145 | 12/3/2023 |
1.1.0 | 159 | 12/3/2023 |
1.0.2 | 161 | 11/28/2023 |
1.0.1 | 144 | 11/27/2023 |
1.0.0 | 127 | 11/26/2023 |