Kryptostack
README

Project Goal

A minimalist stack-based programming language designed as a flexible framework for implementing and exploring cryptologic algorithms.
Its syntax and semantics are inspired by PostScript, offering a concise and expressive environment for learning and experimentation.

Manifesto

KryptoStack is an open-source project.

The following interests could be addressed by the project:
>A minimalist implementation of a stack-oriented programming language
>The implementation of mathematical algorithms with a focus on cryptography
>The execution of pre-built cryptographic algorithms
>The coding of the interaction between pre-built algorithms

The project and the code are written in English. For mathematical operators, whose creation is a primary goal of the project, multilingualism is enabled.

Readability and clarity of the program code take precedence over optimization in the implementation.

All artifacts can be built with a minimal toolset. Currently, these are the GNU C++ compiler, make, flex, Bash, and git. The project is hosted on Gitlab, and the environment's features like CI/CD are used. However, a build of all artifacts and tests must always be possible without Gitlab.

Documentation is preferably embedded in the code and should be cleanly extractable with Doxygen. All documentation is included in the git repository.

The main branch of the code must always allow a build of the artifacts at the turn of the day, and these must pass the automated tests.

There is a constant refactoring of the code and documentation.

There is an extensive catalog of automated tests. When making design decisions, the testability of a possible solution is given high priority.

Quick Build and Run and the Command Line

TODO: How to build

‍parser
reads from standard in

‍-v
-h

‍ks
reads from standard in

‍-v
-h

‍kb
reads from standard in

TODO: How to run

Technologies

  • GNU C++ 17
  • make
  • flex
  • git
  • Gitlab with features: Issues, Pipelines, Pages
  • Bash
  • Doxygen
  • Markdown
  • quadmath, 128-bit integers and 128-bit floating point numbers
  • cppcheck

We support:

  • KDevelop
  • Visual Studio Code
  • more to come

Glossary

KSN-Format

The exchange format between the first interpreter step called "parser" und the second interpreter step called "ks".

Procedure Level

The procedure level counts the nesting level of opening ____ SO's in the program code.

OT-Code

for Object Type Code

A one character code for each SO* class. The virtual ot() member function of all SO* classes
return this code and allows explicit type-based decisions beside the C++ language poylmorphisms.
See Object Types

Operator

x

Parser

The first interpreter step.

SO

for Semantic Object

Task Tags

We use IDEA:, TODO: and FIXME: as Task Tags

Verbose Mode

x

Parser Step Details

Reads standard input stream, runs checks and normailzes it into the KSN-Format on standard out.

Ignores the remainder of lines starting with %.

Halts execution upon error detection.

Normalizes I tokens by stripping leading plus signs.

Removes the opening and closing parentheses from the string.

Removes all single backslashes from the string, preserving double backslashes (\\) and newline sequences (\n). These are the only escape sequences recognized in the KSN format.

The -v option activates verbose mode.

The -h option prints a command line help.

KSN Details

This is a simple line-oriented format. Each line begins with a KSN code followed by a colon (':'). The code identifies the data type of the subsequent value.

The differnt KSN codes and data types are:
>I: A signed integer
>R: A floating-point number
>B: A boolean literal
>S: An unquoted string with just two escape sequences \\ and \n
>N: A literal name token consisting of alphanumeric and underscore characters, but not starting with a digit
>X: An executable name token consisting of alphanumeric and underscore characters, but not starting with a digit
>#: The value is a comment
>E: An error message

Object Types

A list of SO* classes and their OTCodes.

All objects are executable or non-executable aka literal.

Simple Objects

A duplicate of an object of these types duplicates the value of the object.

SO0 - 0
The null object is used as placeholder in arrays.

SOB - B
A boolean value.

SOI - I
A 128-bit integer.

SOM - M
A mark object.

SON - N or n
N ... for non-executable name objects
n ... for executable name objecs

SOO - O
A regular registered operator.

SOo - o
An unregistered operator.

SOR - R
A real number.

Composite Objects

A duplicate of an object of these types shares its value with the original object.

SOA - A and a
A ... for a non-executable array
a ... for a executable array aka procedure

SOD - D
A dictionary is a list of key-value pairs of SO's.

SOS - S
A string.

Operators

Details: OPERATORS.md

Directories of the git Repository

./tmp
Exists for temporary files e.g. for testing purposes.

/Suite*
Each 'Suite' directory contains a collection of test cases.

./html
The Doxygen-generated HTML documentation.

./latex
The Doxygen-generated LaTeX source for documentation.

./.git That's the git Repository.

./.kdev4 Is a living propsal for a KDevelop configuration.

Tests

Details: TESTS.md

Naming and Structure Conventions

Class names are written in uppercase.

Class attributes end with an underscore.

Parameters are consistently prefixed with 'p_'.

An intentation by 2 spaces.

Order of Class Members

class AClass { private:

protected:

public:
starting with ctors and dtors

public_accessor
setters and getters

public_virtual
virtual member functions

public_other
other member functions };

The pseudo-access levels like "public_accessor" are defined as macros with no value in helper.h to improve the class member segmentation.

Prerequisites and makefile and Gitlab Integration

prerequisites are:

  • GNU CPP with all usual tools like make
  • flex
  • doxygen
  • quadmath library

The available makefile targets will be displayed by the makefile itself.

We use Ghostscript as our reference implementation for PostScript.

Hint: To invoke gs without rendering, you can set the environment variable export GS_DEVICE=nullpage.

The makefile will be triggered from the Gitlab pipelines.

C++ Notes

The minumum C++ standard in use is C++ 17 with GNU extensions, because of the usage of std::gcd().

Remarkable C++ features in use:

  • lambdas
  • virtual dtors
  • anonymous namespaces
  • 128 bit integer and 128 bit floating point data types
  • initialization of static inline int attributes within the class definition
  • curiously recurring template pattern
  • explicit ctors

cppcheck

cppcheck ist used as integrated Code tool in KDevelop.

Task Tags

The task tags information is extracted using the tasktags.sh script. This script is directly integrated into the makefile, making it part of the automated build process. Editors and IDEs support this kind of tagging by highligthing the texts.

We utilize three distinct tags to categorize different types of tasks. However, specific configuration might be required depending on the editor or IDE used.

\FIXME:
This is a known bug in the software. This bug should be fixed in the next software release.

\TODO:
A task that still needs to be completed. This task should be finished before the next major software release.

\IDEA:
This is an idea for a potential improvement to the software. Implementing this idea is planned, but the exact timing is not yet determined.

KDevelop

KDevelop creates a .kdev4 file and a ./kdev4 directory. These files are integrated into the git repository to share them.

Visual Studio Code

VSC creates a ./vscode directory. This directory is integrated into the git repository to share it.
ThJAVADOC_AUTOBRIEFe 'Todo Tree' extension can handle our task tags appropriately.

Doxygen

Commenting is done in Doxygen Javadoc style. This allows for loose integration into KDevelop, which parses these comments.
JAVADOC_AUTOBRIEF ist enabled in Doxyfile to eliminate explicit @brief tags.
The Doxygen output is located in the ./html and ./latex directories.
The launch of Doxygen is integrated as a target within the makefile.
The Doxygen output is published as GitLab pages. The process is automated using GitLab's CI/CD features.

References