# lannisterarthur/efficient-dgtotp architecture

> Architecture diagram of the GitHub repository lannisterarthur/efficient-dgtotp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lannisterarthur/efficient-dgtotp
- Repository: https://github.com/lannisterarthur/efficient-dgtotp

## Overview

This repository contains two experimental C implementations of DGTOTP: LWDGT (Low-Wastage) and NWDGT (No-Wastage). The visible runtime is built around cryptographic key generation, signing, and verification APIs, rather than an OTP service or registration server. Each scheme has its own parameterization and signature logic, with hash and randomness support. LWDGT’s parameters include FORS and custom counters; NWDGT sets FORS dimensions to zero. The README also mentions benchmarking, but that is build/test activity and is excluded. Some helper wiring is omitted because only partial source excerpts were supplied.

Main entry points: [`LWDGT/sign.c`](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/sign.c) (Key/sign/verify API), [`NWDGT/sign.c`](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/sign.c) (Key/sign/verify API), [`LWDGT/hash_shake.c`](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/hash_shake.c) (Hash selection), [`LWDGT/merkle.c`](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/merkle.c) (Merkle stage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lwdgt["LWDGT scheme"]
  node_l_api["Key/sign/verify API<br/>[sign.c]"]
  node_l_params["LWDGT parameters"]
  node_l_fors["FORS stage<br/>[fors.c]"]
  node_l_merkle["Merkle stage<br/>[merkle.c]"]
  node_l_wots["WOTS stage<br/>[wots.c]"]
end

subgraph group_nwdgt["NWDGT scheme"]
  node_n_api["Key/sign/verify API<br/>[sign.c]"]
  node_n_params["NWDGT parameters"]
  node_n_merkle["Merkle stage<br/>[merkle.c]"]
  node_n_wots["WOTS stage"]
end

subgraph group_cryptography["Crypto primitives"]
  node_l_hash_select["Hash selection<br/>[hash_shake.c]"]
  node_l_shake["SHAKE primitives<br/>[fips202.c]"]
  node_l_sha2["SHA-2 primitives<br/>[sha2.c]"]
  node_l_haraka["Haraka primitives<br/>[haraka.c]"]
  node_n_hash_select["Hash selection<br/>[hash_shake.c]"]
  node_n_shake["SHAKE primitives<br/>[fips202.c]"]
end

subgraph group_support["Scheme support"]
  node_n_random["Random bytes<br/>[randombytes.c]"]
  node_l_random["Random bytes<br/>[randombytes.c]"]
  node_l_context["Hash context<br/>[context.h]"]
  node_n_context["Hash context<br/>[context.h]"]
end

node_caller(("API caller"))

node_caller -->|"invokes"| node_l_api
node_caller -->|"invokes"| node_n_api
node_l_api -->|"signs / recovers"| node_l_fors
node_l_api -->|"builds / checks roots"| node_l_merkle
node_l_api -->|"requests randomness"| node_l_random
node_l_api -->|"hashes messages"| node_l_hash_select
node_l_merkle -->|"uses WOTS"| node_l_wots
node_l_hash_select -->|"uses SHAKE"| node_l_shake
node_l_hash_select -.->|"provides hash option"| node_l_sha2
node_l_hash_select -.->|"provides hash option"| node_l_haraka
node_l_api -->|"initializes context"| node_l_context
node_n_api -->|"builds / checks roots"| node_n_merkle
node_n_api -->|"signs / recovers"| node_n_wots
node_n_api -->|"requests randomness"| node_n_random
node_n_api -->|"hashes messages"| node_n_hash_select
node_n_merkle -->|"uses WOTS"| node_n_wots
node_n_hash_select -->|"uses SHAKE"| node_n_shake
node_n_api -->|"initializes context"| node_n_context

click node_l_api "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/sign.c"
click node_l_params "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/params/params-sphincs-shake-128s.h"
click node_l_fors "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/fors.c"
click node_l_merkle "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/merkle.c"
click node_l_wots "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/wots.c"
click node_n_api "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/sign.c"
click node_n_params "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/params/params-sphincs-shake-128s.h"
click node_n_merkle "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/merkle.c"
click node_l_hash_select "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/hash_shake.c"
click node_l_shake "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/fips202.c"
click node_l_sha2 "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/sha2.c"
click node_l_haraka "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/haraka.c"
click node_n_hash_select "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/hash_shake.c"
click node_n_shake "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/fips202.c"
click node_n_random "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/randombytes.c"
click node_l_random "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/randombytes.c"
click node_l_context "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/context.h"
click node_n_context "https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/context.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_l_api,node_l_params,node_l_fors,node_l_merkle,node_l_wots toneBlue
class node_n_api,node_n_params,node_n_merkle,node_n_wots toneAmber
class node_l_hash_select,node_l_shake,node_l_sha2,node_l_haraka,node_n_hash_select,node_n_shake,node_caller toneMint
class node_n_random,node_l_random,node_l_context,node_n_context toneRose
```

## Components

### LWDGT scheme

- [Key/sign/verify API](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/sign.c): `LWDGT/sign.c`
- [LWDGT parameters](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/params/params-sphincs-shake-128s.h): `LWDGT/params/params-sphincs-shake-128s.h`
- [FORS stage](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/fors.c): `LWDGT/fors.c`
- [Merkle stage](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/merkle.c): `LWDGT/merkle.c`
- [WOTS stage](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/wots.c): `LWDGT/wots.c`

### NWDGT scheme

- [Key/sign/verify API](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/sign.c): `NWDGT/sign.c`
- [NWDGT parameters](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/params/params-sphincs-shake-128s.h): `NWDGT/params/params-sphincs-shake-128s.h`
- [Merkle stage](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/merkle.c): `NWDGT/merkle.c`
- **WOTS stage**

### Crypto primitives

- [Hash selection](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/hash_shake.c): `LWDGT/hash_shake.c`
- [SHAKE primitives](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/fips202.c): `LWDGT/fips202.c`
- [SHA-2 primitives](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/sha2.c): `LWDGT/sha2.c`
- [Haraka primitives](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/haraka.c): `LWDGT/haraka.c`
- [Hash selection](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/hash_shake.c): `NWDGT/hash_shake.c`
- [SHAKE primitives](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/fips202.c): `NWDGT/fips202.c`

### Scheme support

- [Random bytes](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/randombytes.c): `NWDGT/randombytes.c`
- [Random bytes](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/randombytes.c): `LWDGT/randombytes.c`
- [Hash context](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/LWDGT/context.h): `LWDGT/context.h`
- [Hash context](https://github.com/lannisterarthur/efficient-dgtotp/blob/main/NWDGT/context.h): `NWDGT/context.h`

### Other components

- **API caller**

## Connections

- API caller → Key/sign/verify API: invokes
- API caller → Key/sign/verify API: invokes
- Key/sign/verify API → FORS stage: signs / recovers
- Key/sign/verify API → Merkle stage: builds / checks roots
- Key/sign/verify API → Random bytes: requests randomness
- Key/sign/verify API → Hash selection: hashes messages
- Merkle stage → WOTS stage: uses WOTS
- Hash selection → SHAKE primitives: uses SHAKE
- Hash selection → SHA-2 primitives: provides hash option
- Hash selection → Haraka primitives: provides hash option
- Key/sign/verify API → Hash context: initializes context
- Key/sign/verify API → Merkle stage: builds / checks roots
- Key/sign/verify API → WOTS stage: signs / recovers
- Key/sign/verify API → Random bytes: requests randomness
- Key/sign/verify API → Hash selection: hashes messages
- Merkle stage → WOTS stage: uses WOTS
- Hash selection → SHAKE primitives: uses SHAKE
- Key/sign/verify API → Hash context: initializes context
