Skip to content

Commit

Permalink
Update readme: root, crypto3
Browse files Browse the repository at this point in the history
  • Loading branch information
akokoshn committed Jan 3, 2025
1 parent 973ed5e commit 9641c12
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 201 deletions.
9 changes: 4 additions & 5 deletions crypto3/docs/manual/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Crypto3 cryptography suite's purpose is:
3. To provide a Standard Template Library-alike C++ interface and concept-based architecture implementation.

Libraries are designed to be state of the art, highly performant and providing a one-stop solution for
all cryptographic operations. They are supported on all operating systems (*nix, windows, macOS)
and architectures(x86/ARM).
all cryptographic operations. They are supported on Linux operating system and architectures (x86/ARM).


See [contribution](contributing.md) guidelines if you wish to contribute to the project.
Expand All @@ -25,13 +24,13 @@ Detailed list of modules with tutorials is available at [Modules page](modules.h
```
root
├── cmake: cmake sub-module with helper functions/macros to build crypto3 library umbrella-repository
├── docs: documentation , tutorials and guides
├── docs: documentation, tutorials and guides
├── libs: all directories added as submodules which are independent projects.
│ ├── algebra: algebraic operations and structures being used for elliptic-curve cryptography
│ ├── block: block ciphers
│ ├── blueprint: components and circuits for zk schemes
│ ├── codec: encoding/decoding algorithms
│ ├── containers:containers and generic commitment schemes for accumulating data, includes Merkle Tree
│ ├── containers: containers and generic commitment schemes for accumulating data, includes Merkle Tree
│ ├── hash: hashing algorithms
│ ├── kdf: key derivation functions
│ ├── mac: message authentication codes
Expand Down Expand Up @@ -69,7 +68,7 @@ project as a submodule and would not need to resolve dependencies. See [crypto3-

### Selective
Developer can select to include a one or more modules to reduce the sources of resulting project and dependencies tree height. This however
does require the developer to manually resolve all required dependencies and stay upto date regarding
does require the developer to manually resolve all required dependencies and stay up to date regarding
compatibilities across modules.


Expand Down
8 changes: 4 additions & 4 deletions crypto3/docs/manual/intermediate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BLS weighted threshold signature [WIP]
=============================

In this tutorial we dive deeper into the cryptography constructs which crypto3 library implements.
By the end of this tutorial , a user will understand how to sign data and use different modes.
By the end of this tutorial, a user will understand how to sign data and use different modes.


Pre-requisites
Expand Down Expand Up @@ -38,7 +38,7 @@ which an algorithm needs to be performed.
- Finalisation: This steps requires accumulated data to be finalised padded before running an algorithm.

Algorithms in the crypto3 library will carry out the above steps for the user. Algorithms can do operations
such as signing , aggregating , verifying.
such as signing, aggregating, verifying.


Starting point to use any public key operations in crypto3 library is to create a cryptographic scheme.
Expand Down Expand Up @@ -74,7 +74,7 @@ using pubkey_type = public_key<scheme_type>;


Next we set up some types which we will use throughout the example
- `sss_public_key_group_type` : TODO : Describe them. Which one of these are accumulators?
- `sss_public_key_group_type`: TODO: Describe them. Which one of these are accumulators?
- `shares_dealing_processing_mode`
- `signing_processing_mode_type`
- `verification_processing_mode_type`
Expand Down Expand Up @@ -102,7 +102,7 @@ We now take a closer look at our main.
std::size_t n = 20;
std::size_t t = 10;
```
Next , we assign weights to our threshold values using the `weights_type` type which is a pair of (TODO)
Next, we assign weights to our threshold values using the `weights_type` type which is a pair of (TODO)

```c++
auto i = 1;
Expand Down
2 changes: 1 addition & 1 deletion crypto3/docs/manual/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Quickstart
========================

By the end of this guide ,you will have set up a development environment for crypto3 projects
By the end of this guide, you will have set up a development environment for crypto3 projects
and be able to run an example.This will enable you to test ideas quickly and further explore the
API's of the suite.

Expand Down
4 changes: 2 additions & 2 deletions crypto3/libs/algebra/docs/implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@tableofcontents

The key idea of `algebra` is to provide usefull interfaces for basic cryptography math. It's based on NilFoundation fork of
The key idea of `algebra` is to provide useful interfaces for basic cryptography math. It's based on NilFoundation fork of
Boost.Multiprecision so that it can be used with boost cpp_int, gmp or other backends.

We expanded Boost.Multiprecision with `modular_adaptor`, which is actually a multi-precision number by some modular. It contains
Expand Down Expand Up @@ -162,7 +162,7 @@ It also contains `pairing_policy` type, needed for comfortable usage of curve pa

### Curve Element Algorithms ### {#curve_element_algorithms}

Curve element corresponds an point of the curve and has all the needed methods and overloaded arithmetic operators. The corresponding algorithms
Curve element corresponds a point of the curve and has all the needed methods and overloaded arithmetic operators. The corresponding algorithms
are based on the underlying field algorithms are also defined here.

### Basic Curve Policies ### {#basic_curve_policies}
Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/docs/concepts.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Concepts # {#component_concepts}

A ```circuit``` is defined by ```Blueprint``` and ```Blueprint assignment table``` (contains ```Blueprint public assignment table``` and ```Blueprint private assignment table```) instances.
It consist of one or multiple components putted on these two.
It consists of one or multiple components putted on these two.
While ```Blueprint``` holds information about the circuit itself, its gates, constraints and other fixed expressions, ```Blueprint assignment table``` contains public and private assignments needed by zk-SNARK system.

## Blueprint
Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ w = [1, 3, 35, 9, 27, 30].

Now let’s see how we can enter this R1CS into =nil;Crypto3 Blueprint, produce proofs and verify them. We will use the `blueprint_variable` type to declare our variables. See the file `test.cpp` for the full code.

First lets define the finite field where all our values live, and initialize the curve parameters:
First let's define the finite field where all our values live, and initialize the curve parameters:

```
typedef libff::Fr<default_r1cs_ppzksnark_pp> field_type;
Expand Down
6 changes: 3 additions & 3 deletions crypto3/libs/hash/docs/pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ order we have the reverse order of input chunks in the *out* array.

An interested reader may wonder why changing of endiannesses leads to such a strange effect. Well, the answer to this
question lies in the following convention: all data divided into chunks with units ordered in `big_unit_big_bit`
endianness will stay unchanged when tranforming to data with chunk units ordered in `big_unit_big_bit` endianness. Let
endianness will stay unchanged when transforming to data with chunk units ordered in `big_unit_big_bit` endianness. Let
us explain it with the following example.

```cpp
Expand Down Expand Up @@ -162,7 +162,7 @@ struct1 [label="0x12 | 0x34 | 0x56 | 0x78 | 0x90 | 0xab | 0xcd | 0xef"];
} @enddot
Here it is easy to see that the data from `input` was just concatenated into the `output` data with no additional
tranformations. Now, notice that the first and the second example described in this section implicitly rely on the
transformations. Now, notice that the first and the second example described in this section implicitly rely on the
above-described convention. In the first example the input data is concatenated in reverse byte order, and in the second
example the byte order is reversed after the input data concatenation.
Expand Down Expand Up @@ -214,7 +214,7 @@ To conclude, there are three types of reversals that we must deal with in pack a

In this section we suppose that the chunk type of input and output data is integral.

Data chunk order reversal tranforms a group of consecutive input chunks with units in `InputEndianness` order into an
Data chunk order reversal transforms a group of consecutive input chunks with units in `InputEndianness` order into an
output chunk with units in `OutputEndianness` order and can be described as follows.

1. Check whether `InputEndianness` or `OutputEndianness` is `little_bit`. This condition determines the data chunk order
Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/zk/docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bp.set_input_sizes(1);
```

Note, that the first allocated variable on the blueprint is a constant 1. So, the variables on the blueprint would
be `1` , `res`, `A[0]`, ..., `A[n-1]`, `B[0]`, ..., `B[n-1]`.
be `1`, `res`, `A[0]`, ..., `A[n-1]`, `B[0]`, ..., `B[n-1]`.

To specify which variables are public and which ones are private we use the function `set_input_sizes(1)`, so only `res`
value is a primary input. Thus, usually, the primary input is allocated before the auxiliary input in the program.
Expand Down
125 changes: 27 additions & 98 deletions crypto3/readme.md
Original file line number Diff line number Diff line change
@@ -1,132 +1,61 @@
# =nil; Foundation's Cryptography Suite
[![Build docs](https://github.com/NilFoundation/crypto3/actions/workflows/build_docs.yaml/badge.svg)](https://github.com/NilFoundation/crypto3/actions/workflows/build_docs.yaml)
[![Discord](https://img.shields.io/discord/969303013749579846.svg?logo=discord&style=flat-square)](https://discord.gg/KmTAEjbmM3)
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=flat-square&logo=telegram&logoColor=dark)](https://t.me/nilfoundation)
[![Twitter](https://img.shields.io/twitter/follow/nil_foundation)](https://twitter.com/nil_foundation)

# Cryptography Suite
Crypto3 cryptography suite's purpose is:
1. To provide a secure, fast and architecturally clean C++ generic cryptography schemes implementation.
2. To provide a developer-friendly, modular suite, usable for novel schemes implementation and further
extension.
3. To provide a Standard Template Library-alike C++ interface and concept-based architecture implementation.

Libraries are designed to be state of the art, highly performant and providing a one-stop solution for
all cryptographic operations. They are supported on all operating systems (*nix, windows, macOS)
and architectures(x86/ARM).
all cryptographic operations. They are supported on Linux operating system and architectures (x86/ARM).

Developed by [=nil; Crypto3](https://crypto3.nil.foundation) and supported by [=nil; Foundation](https://nil.foundation).

Rationale, tutorials and references are available [here](https://crypto3.nil.foundation/projects/crypto3)

## Contents
1. [Repository Structure](#repository-structure)
2. [Installation](#installation)
3. [Usage](#usage)
3. [Contributing](#contributing)
4. [Community](#community)
1. [Structure](#structure)
2. [Build & test](#build_&_test)
3. [Usage](#uage)

## Repository Structure
This repository is an umbrella-repository for the whole suite. Single-purposed libraries repositories (e.g. [block
](https://github.com/nilfoundation/block) or [hash](https://github.com/nilfoundation/hash)) are not advised to be
## Structure
This folder contains the whole suite. Single-purposed libraries (e.g. [block
](https://github.com/NilFoundation/placeholder/tree/master/crypto3/libs/block) or [hash](https://github.com/NilFoundation/placeholder/tree/master/crypto3/libs/hash)) are not advised to be
used outside this suite or properly constructed CMake project and should be handled with great care.
```
root
crypto3
├── benchmarks
├── cmake: cmake sub-module with helper functions/macros to build crypto3 library umbrella-repository
├── docs: documentation , tutorials and guides
├── libs: all directories added as submodules which are independent projects.
├── algebra: algebraic operations and structures being used for elliptic-curve cryptography
├── benchmark_tools: utilities to run benchmarks
├── blueprint: components and circuits for zk schemes
├── docs: documentation, tutorials and guides
├── libs
   ├── algebra: algebraic operations and structures being used for elliptic-curve cryptography
   ├── benchmark_tools: utilities to run benchmarks
   ├── blueprint: components and circuits for zk schemes
│ ├── containers: containers and generic commitment schemes for accumulating data, includes Merkle Tree
│ ├── hash: hashing algorithms
│ ├── marshalling: marshalling libraries for types in crypto3 library
│ ├── math: set of Fast Fourier Transforms evaluation algorithms and Polynomial Arithmetics
│ ├── multiprecision: integer, rational, floating-point, complex and interval number types.
│ ├── random: randomisation primitives
│ ├── zk: zk cryptography schemes
```


## Installation
### Dependencies

- [clang](https://clang.llvm.org/) (>= 11.0)/GCC (>= 10.0)/MSVC (>= 14.20)
- [cmake](https://cmake.org) (>= 3.6)
- [boost](https://boost.org) (>= 1.76)

### Clone & Build

```
git clone --recurse-submodules https://github.com/nilfoundation/crypto3.git
cd crypto3 && mkdir build && cd build
cmake ..
make tests
```

## Nix support

This repository provides Nix flake, so once you have installed Nix with flake support, you can use single command to fetch all the dependencies and build:

```bash
nix build
```

To activate Nix development environment:

```bash
nix develop
│   ├── transpiler
│   └── zk: zk cryptography schemes
```

To run all tests:
## Build & test

To run single test:
```bash
nix flake check
nix develop .#<derivation>
eval "$configurePhase" // automatically move to the build directory
ninja <test-name>
```

To run single test:

For example:
```bash
nix develop . -c cmake -B build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=FALSE -DCMAKE_ENABLE_TESTS=TRUE -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-ggdb
nix develop -c cmake --build build -t <test_target> // for example multiprecision_modular_adaptor_fixed_test
nix develop .#crypto3-debug-tests
eval "$configurePhase" // automatically move to the build directory
ninja algebra_curves_test
```

## Usage

Cryptography suite can be used as follows:

1. Generic.
2. Selective.

The suite is used as a header-only and is currently statically linked. Future versions will allow dynamic linking.

#### Generic
Generic usage of cryptography suite consists of all modules available at
[GitHub =nil; Crypto3 Team Repositories](https://github.com/orgs/NilFoundation/teams/nil-crypto3/repositories).
This is an umbrella-repository where Modules
are added as submodules emplaced in `libs` directory. A developer can thus add this
project as a submodule and would not need to resolve dependencies. See [crypto3-scaffold](https://github.com/NilFoundation/crypto3-scaffold) as an example of usage.

The generic module can be added to your c++ project as follows

``` git submodule add https://github.com/NilFoundation/crypto3.git <dir>```


## Contributing

See [contributing](./docs/manual/contributing.md) for contribution guidelines.

## Support

This cryptography suite is authored by [=nil; Crypto3](https://crypto3.nil.foundation) team, so you can contact it
several ways:
* E-Mail. Just drop a line to [[email protected]](mailto:[email protected]).
* Telegram Group. Join our Telegram group [@nilfoundation](https://t.me/nilfoundation) and ask any question in there.
* Discord [channel](https://discord.gg/KmTAEjbmM3) for discussions.
* Issue. Issue which does not belong to any particular module (or you just don't know where to put it) can be
created in this repository. The team will answer that.
* Discussion Topic (proposal, tutorial request, suggestion, etc). Would be happy to discuss that in the repository's GitHub [Discussions](https://github.com/NilFoundation/crypto3/discussions)

## Licence

The software is provided under [MIT](LICENSE) Licence.

The suite is used as a header-only libraries.
31 changes: 31 additions & 0 deletions parallel-crypto3/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Paralle Cryptography Suite
Multi threaded implementation some modules from the cryptography suite.

## Contents
1. [Structure](#structure)
2. [Build & test](#build_&_test)
3. [Usage](#uage)

## Structure
parallel-crypto3
├── benchmarks
├── cmake
├── libs
└── test_tools

## Build & test

To run single test:

```bash
nix develop .#<derivation>
eval "$configurePhase" // automatically move to the build directory
ninja <test-name>
```

For example:
```bash
nix develop .#parallel-crypto3-debug-tests
eval "$configurePhase" // automatically move to the build directory
ninja actor_math_polinomial_test
```
Loading

0 comments on commit 9641c12

Please sign in to comment.