Dag4.Net
1.0.0-preview.1
This is a prerelease version of Dag4.Net.
dotnet add package Dag4.Net --version 1.0.0-preview.1
NuGet\Install-Package Dag4.Net -Version 1.0.0-preview.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="Dag4.Net" Version="1.0.0-preview.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dag4.Net" Version="1.0.0-preview.1" />
<PackageReference Include="Dag4.Net" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dag4.Net --version 1.0.0-preview.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dag4.Net, 1.0.0-preview.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.
#:package Dag4.Net@1.0.0-preview.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dag4.Net&version=1.0.0-preview.1&prerelease
#tool nuget:?package=Dag4.Net&version=1.0.0-preview.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Dag4.Net - .NET SDK for Constellation (DAG)
This is he DAG .NET/C#/F# SDK for Constellation Network.
The Dag4.Net library provides secure wallet functionality and convenient wrappers for interacting with Constellation Network APIs. The library is platform agnostic and can be used to build apps on servers, desktop, smartphones, and browsers through WASM.
Installation
Add the NuGet package Dag4.Net:
dotnet add package Dag4.Net
Or install it via the NuGet Package Manager Console:
Install-Package Dag4.Net
Usage
Create a key and address
using Dag4.Net;
var wallet = DagAddress.FromPrivateKeyHex("0x<32-byte-hex>");
var dag = wallet.ToDagAddress(); // e.g., DAG1...
var publicKeyHex = wallet.ToPublicKeyHex(); // 64-byte X||Y hex (lowercase)
Sign and verify data (dag4.js-style)
var json = "{\"hello\":\"world\"}"; // any JSON string
// Signs normalized JSON (via L0Json) and returns key + DER signature
DagDataSignature signed = wallet.SignData(json);
// Verify (also normalizes JSON before hashing)
bool ok = wallet.VerifyData(json, signed.Signature.AsAsn1DerHex());
Sign L0 payloads (Brotli path)
var json = "{\"source\":\"...\",\"destination\":\"...\",\"amount\":1}";
DerSignature sig = wallet.SignL0(json);
var sigHex = sig.AsAsn1DerHex();
Normalize arbitrary JSON for L0
using System.Text.Json.Nodes;
using Dag4.Net;
var node = JsonNode.Parse(json);
var normalizedNode = L0Json.Normalize(node); // JsonNode → JsonNode
var normalizedText = L0Json.NormalizeToString(json); // string → string
Public API
DagAddress
static DagAddress FromPrivateKeyHex(string)static DagAddress FromPublicKeyHex(string)static DagAddress FromPublicKeyCoordinates(ReadOnlySpan<byte> x32, ReadOnlySpan<byte> y32)string ToDagAddress()string ToPublicKeyHex()DagDataSignature SignData(string jsonMessage)bool VerifyData(string jsonMessage, string signatureDerHex)DerSignature SignL0(string jsonMessage)
Types
PublicKey: 64-byte X||Y (big-endian)ReadOnlySpan<byte> AsBytes()string AsHex()
DerSignature: ASN.1 DER-encoded ECDSA (R,S)ReadOnlySpan<byte> AsAsn1DerBytes()string AsAsn1DerHex()
DagDataSignaturePublicKey PublicKeyDerSignature Signature
L0Json
JsonNode? Normalize(JsonNode? node)JsonNode? Normalize(string json)string? NormalizeToString(JsonNode? node)string? NormalizeToString(string json)
Notes
- Public key format is uncompressed 64-byte X||Y (lowercase hex when stringified).
- Signatures are ASN.1 DER; signatures produced by this library are normalized to low-S.
- JSON inputs are normalized (sorted object keys, nulls removed, array order preserved) before hashing.
- Kryo signing is not supported in this build.
License
MIT License
| 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- System.Formats.Asn1 (>= 9.0.0)
- System.Text.Json (>= 9.0.0)
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 |
|---|---|---|
| 1.0.0-preview.1 | 577 | 9/16/2025 |