From d7289d28bad2d0170c56d9eea161624b35fb5cc8 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Sat, 25 Jan 2025 16:21:30 +0300 Subject: [PATCH 01/16] Update broken link ghash.rs --- src/hashes/ghash.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hashes/ghash.rs b/src/hashes/ghash.rs index 625ac28f..b27bf854 100644 --- a/src/hashes/ghash.rs +++ b/src/hashes/ghash.rs @@ -1,7 +1,7 @@ //! Implementation of [`GHASH`] algorithm which is used in AES-GCM to compute the authentication //! tag. //! Based on GCM specification given by NIST: -//! [The Galois/Counter Mode of Operation (GCM)](http://www.csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf) +//! [The Galois/Counter Mode of Operation (GCM)](https://csrc.nist.rip/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf) //! //! ASCII diagram of GHASH, courtesy of @0xJepsen: //! X1 X2 ... XM From f17dc9421f760b7509bcef0194473f8cc20bc170 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Sat, 25 Jan 2025 16:22:24 +0300 Subject: [PATCH 02/16] Update broken link gcm.rs --- src/encryption/symmetric/modes/gcm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encryption/symmetric/modes/gcm.rs b/src/encryption/symmetric/modes/gcm.rs index 0ae4f581..bc966d60 100644 --- a/src/encryption/symmetric/modes/gcm.rs +++ b/src/encryption/symmetric/modes/gcm.rs @@ -1,5 +1,5 @@ //! Implementation of GCM cipher mode of operation based on NIST GCM specification. -//! [The Galois/Counter Mode of Operation (GCM)](http://www.csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf) +//! [The Galois/Counter Mode of Operation (GCM)](https://csrc.nist.rip/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf) //! //! GCM has two parts GCTR (used of encryption/decryption) and GHASH (used for authentication). //! From f293ded7144b2f4981306476bbe9ebacaf3c6d56 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Sat, 25 Jan 2025 16:38:15 +0300 Subject: [PATCH 03/16] fix formatting in aes/README.md --- src/encryption/symmetric/aes/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/encryption/symmetric/aes/README.md b/src/encryption/symmetric/aes/README.md index ea6b3468..3874eea9 100644 --- a/src/encryption/symmetric/aes/README.md +++ b/src/encryption/symmetric/aes/README.md @@ -132,8 +132,8 @@ In production-level AES code, fast AES software uses special techniques called t ## References -- [FIPS197](fips197) -- [Serious Cryptography - A Practical Introduction to Modern Cryptography](seriouscrypto) +- [FIPS197][fips197] +- [Serious Cryptography - A Practical Introduction to Modern Cryptography][seriouscrypto] [aes]: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard [des]: ../des/README.md From 27ec761075d9217729165ff61b30354c9c9fedf7 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Wed, 29 Jan 2025 21:55:57 +0300 Subject: [PATCH 04/16] Update broken links README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 803587fd..37d55d76 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Ronkathon is a collection of cryptographic primitives implemented in Rust. It is - **Fundamental Algebraic Structures** - [Group](src/algebra/group/README.md) - [Fields and Their Extensions](src/algebra/field/README.md) - - [Binary Fields](src/field/binary_towers/README.md) + - [Binary Fields](src/algebra/field/binary_towers/README.md) - [Curves and Their Pairings](src/curve/README.md) - [Polynomials](src/polynomial/mod.rs) - [KZG Commitments](src/kzg/README.md) @@ -98,7 +98,7 @@ If you want to serve locally, run `mdbook serve`. ## License -Licensed under the Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +Licensed under the Apache License, Version 2.0 ([LICENSE-APACHE](./LICENSE) or http://www.apache.org/licenses/LICENSE-2.0) ## Contributing From 80b63e6482da2011373738ef95aa9b1cd0b96f81 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Wed, 29 Jan 2025 21:56:28 +0300 Subject: [PATCH 05/16] Create checklinks.yml --- .github/workflows/checklinks.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/checklinks.yml diff --git a/.github/workflows/checklinks.yml b/.github/workflows/checklinks.yml new file mode 100644 index 00000000..d16d567c --- /dev/null +++ b/.github/workflows/checklinks.yml @@ -0,0 +1,19 @@ +name: Check links + +on: + push: + branches: + - "**" + +jobs: + check-links: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check links + uses: lycheeverse/lychee-action@v2 + with: + args: --no-progress --verbose "**/README.md" From 3995f1133efef422e5b4f513043d71cca1e4612d Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Sun, 2 Feb 2025 12:46:46 +0300 Subject: [PATCH 06/16] Update deploy.yml --- .github/workflows/deploy.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 696efb3d..1b0a5d73 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,6 +27,7 @@ jobs: env: MDBOOK_VERSION: 0.4.43 MDBOOK_KATEX_VERSION: 0.9.2 + MDBOOK_LINKCHECK_VERSION: 0.7.7 steps: - uses: actions/checkout@v4 @@ -42,6 +43,7 @@ jobs: run: | cargo binstall --no-confirm --version ${MDBOOK_VERSION} mdbook cargo binstall --no-confirm --version ${MDBOOK_KATEX_VERSION} mdbook-katex + cargo binstall --no-confirm --version ${MDBOOK_LINKCHECK_VERSION} mdbook-linkcheck - name: Setup Pages id: pages @@ -53,18 +55,35 @@ jobs: cp -r assets book/ mdbook build + - name: Run mdBook tests + run: mdbook test + - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: ./docs + # Link checking job + linkcheck: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + + - name: Install mdbook-linkcheck + run: | + cargo binstall --no-confirm mdbook-linkcheck + + - name: Run mdbook-linkcheck + run: mdbook-linkcheck + # Deployment job deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest - needs: build + needs: [build, linkcheck] steps: - name: Deploy to GitHub Pages id: deployment From d5edc2d2c1dcfbcbb98d7d24d6cc9c0c5884a203 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Sun, 2 Feb 2025 12:47:16 +0300 Subject: [PATCH 07/16] Update checklinks.yml --- .github/workflows/checklinks.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checklinks.yml b/.github/workflows/checklinks.yml index d16d567c..609c4217 100644 --- a/.github/workflows/checklinks.yml +++ b/.github/workflows/checklinks.yml @@ -1,9 +1,10 @@ name: Check links on: + pull_request: + types: [opened, synchronize, reopened] push: - branches: - - "**" + branches: [main] jobs: check-links: @@ -16,4 +17,4 @@ jobs: - name: Check links uses: lycheeverse/lychee-action@v2 with: - args: --no-progress --verbose "**/README.md" + args: --no-progress --verbose "**/*.md" From 5d6cbeba53fb0f8dafb85b60350bf3f849ea8ed2 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Tue, 4 Feb 2025 17:55:07 +0300 Subject: [PATCH 08/16] Update README.md --- src/encryption/symmetric/chacha/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/encryption/symmetric/chacha/README.md b/src/encryption/symmetric/chacha/README.md index 53abac2c..278bb98a 100644 --- a/src/encryption/symmetric/chacha/README.md +++ b/src/encryption/symmetric/chacha/README.md @@ -42,7 +42,7 @@ During initial round, **counters** are initialised to 0, and for next rounds, in [uct]: [ietf]: -[xchacha]: +[xchacha]: [salsa]: [chacha]: -[chacha-family]: \ No newline at end of file +[chacha-family]: From 9de2dec9d063b97f5075b1c56e94411f20175cc0 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Tue, 4 Feb 2025 17:57:55 +0300 Subject: [PATCH 09/16] Delete lychee --- .github/workflows/checklinks.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .github/workflows/checklinks.yml diff --git a/.github/workflows/checklinks.yml b/.github/workflows/checklinks.yml deleted file mode 100644 index 609c4217..00000000 --- a/.github/workflows/checklinks.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Check links - -on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: [main] - -jobs: - check-links: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Check links - uses: lycheeverse/lychee-action@v2 - with: - args: --no-progress --verbose "**/*.md" From 2b06bc2becc0b391affa54b6ea4092d9d4322201 Mon Sep 17 00:00:00 2001 From: youyyytrok Date: Tue, 4 Feb 2025 18:01:18 +0300 Subject: [PATCH 10/16] Update book.toml --- book.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/book.toml b/book.toml index a64aa4f3..e4cc9ee9 100644 --- a/book.toml +++ b/book.toml @@ -14,6 +14,12 @@ create-missing = true [preprocessor.katex] after = ["links"] +[preprocessor.linkcheck] +follow-web-links = true +# ignore = ["https://example.com/broken-link"] +traverse-parent-directories = true +warning = false + [output.html] default-theme = "dark" preferred-dark-theme = "ayu" From 53e90d842e7900bd2339349a79ae4dad8d1b7421 Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 5 Feb 2025 06:14:06 -0700 Subject: [PATCH 11/16] Create mdbook-test.yaml --- .github/workflows/mdbook-test.yaml | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/mdbook-test.yaml diff --git a/.github/workflows/mdbook-test.yaml b/.github/workflows/mdbook-test.yaml new file mode 100644 index 00000000..b8716d8a --- /dev/null +++ b/.github/workflows/mdbook-test.yaml @@ -0,0 +1,41 @@ +name: MDBook Tests + +on: + pull_request: + branches: ["main"] + +jobs: + test: + runs-on: ubuntu-latest + env: + MDBOOK_VERSION: 0.4.43 + MDBOOK_KATEX_VERSION: 0.9.2 + MDBOOK_LINKCHECK_VERSION: 0.7.7 + steps: + - uses: actions/checkout@v4 + + - name: Install cargo-binstall + uses: cargo-bins/cargo-binstall@main + + - name: Install rust + run: | + curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh + rustup update + + - name: Install mdbook and plugins + run: | + cargo binstall --no-confirm --version ${MDBOOK_VERSION} mdbook + cargo binstall --no-confirm --version ${MDBOOK_KATEX_VERSION} mdbook-katex + cargo binstall --no-confirm --version ${MDBOOK_LINKCHECK_VERSION} mdbook-linkcheck + + - name: Build mdBook + run: | + cargo run --bin create_mdbook + cp -r assets book/ + mdbook build + + - name: Run mdBook tests + run: mdbook test + + - name: Run linkcheck + run: mdbook-linkcheck \ No newline at end of file From 1c19c221ef7aab2cb35c827ff8e769dc09a96c5d Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 5 Feb 2025 06:24:21 -0700 Subject: [PATCH 12/16] fix: two tests in `poseidon/README.md` --- src/hashes/poseidon/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hashes/poseidon/README.md b/src/hashes/poseidon/README.md index 931973e0..ac766204 100644 --- a/src/hashes/poseidon/README.md +++ b/src/hashes/poseidon/README.md @@ -91,7 +91,7 @@ sage poseidon_constants.sage 1 0 7 16 3 10 0x65 Here's an example to use [Poseidon](./mod.rs) struct for hashing input of length `WIDTH`. Note that input is padded with extra zeroes if length is not equal to width. ```rust -use ronkathon::field::prime::PlutoBaseField; // can be any field that implements FiniteField trait +use ronkathon::{hashes::poseidon::Poseidon, field::prime::PlutoBaseField}; // can be any field that implements FiniteField trait const WIDTH: usize = 10; const ALPHA: usize = 5; @@ -117,7 +117,7 @@ Another example using Sponge API for arbitrary length element hashing. Simplex s ```rust use rand::rng; -use ronathon::field::prime::PlutoBaseField; +use ronathon::{field::prime::PlutoBaseField, hashes::poseidon::sponge::PoseidonSponge}; let size = rng.gen::(); From 8b2af74aaef614ebee63e4c843f5bfd8aadbb024 Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 5 Feb 2025 08:17:23 -0700 Subject: [PATCH 13/16] cleanup mdbook --- Cargo.toml | 12 ++-- README.md | 4 +- book.toml | 48 +++++++++----- src/algebra/field/README.md | 4 +- src/algebra/group/README.md | 2 +- src/bin/create_mdbook.rs | 78 ----------------------- src/compiler/README.md | 10 +-- src/encryption/symmetric/aes/README.md | 6 +- src/encryption/symmetric/chacha/README.md | 2 +- src/hashes/poseidon/README.md | 15 ++++- 10 files changed, 63 insertions(+), 118 deletions(-) delete mode 100644 src/bin/create_mdbook.rs diff --git a/Cargo.toml b/Cargo.toml index 0defb709..fda332c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,12 +9,12 @@ version ="0.1.1" exclude =["CHANGELOG.md", "assets/"] [dependencies] -rand ="0.8" -itertools ="0.14" -hex ="0.4" -crypto-bigint ="0.6.0-rc.6" -regex ="1.11.1" -num-traits ="0.2.19" +rand ="0.8" +itertools ="0.14" +hex ="0.4" +crypto-bigint="0.6.0-rc.6" +regex ="1.11.1" +num-traits ="0.2.19" [dev-dependencies] rstest ="0.24" diff --git a/README.md b/README.md index 37d55d76..20ea5ed8 100644 --- a/README.md +++ b/README.md @@ -82,13 +82,13 @@ In particular, the `math/field.sage` computes roots of unity in the `PlutoField` ## Building mdBook To locally build/serve the [mdBook](https://github.com/rust-lang/mdBook) site, install mdBook and [mdbook-katex](https://github.com/lzanini/mdbook-katex): -``` +```ignore cargo install mdbook cargo install mdbook-katex ``` To build, run: -``` +```ignore cargo run --bin create_mdbook cp -r assets book/ mdbook build diff --git a/book.toml b/book.toml index e4cc9ee9..681161a3 100644 --- a/book.toml +++ b/book.toml @@ -1,26 +1,40 @@ [book] -authors = ["Contributors to Ronkathon"] -language = "en" -multilingual = false -src = "book" -title = "Ronkathon: Cryptography Educational Foundations" -description = "Cryptography Educational Foundations" +authors =["Contributors to Ronkathon"] +language ="en" +multilingual=false +src ="." +title ="Ronkathon: Cryptography Educational Foundations" +description ="Cryptography Educational Foundations" [build] -build-dir = "docs" -use-default-preprocessors = true -create-missing = true +build-dir ="docs" +use-default-preprocessors=true +create-missing =true [preprocessor.katex] -after = ["links"] +after=["links"] [preprocessor.linkcheck] -follow-web-links = true -# ignore = ["https://example.com/broken-link"] -traverse-parent-directories = true -warning = false +follow-web-links =true +traverse-parent-directories=true + +[preprocessor.keeper] +command ="mdbook-keeper" +manifest_dir="." +externs =["ronkathon", "rand"] [output.html] -default-theme = "dark" -preferred-dark-theme = "ayu" -git-repository-url = "https://github.com/pluto/ronkathon" +default-theme ="dark" +preferred-dark-theme="ayu" +git-repository-url ="https://github.com/pluto/ronkathon" + +[output.html.playground] +editable=true +runnable=true + +[rust] +edition="2021" + +[[output.html.playground.pre-installed-crates]] +name ="rand" +version="0.8" diff --git a/src/algebra/field/README.md b/src/algebra/field/README.md index 3e7da65b..9793e40c 100644 --- a/src/algebra/field/README.md +++ b/src/algebra/field/README.md @@ -46,7 +46,7 @@ The structs that implement these traits are ### `PrimeField` The `PrimeField` struct is a wrapper around a `usize` by: -```rust +```rust,ignore pub struct PrimeField { value: usize, } @@ -62,7 +62,7 @@ All of the relevant arithmetic operations for `PrimeField

` are implemented in ### `GaloisField` The `GaloisField` struct is a wrapper around a `PrimeField

` by: -```rust +```rust,ignore use ronkathon::algebra::field::prime::PrimeField; pub struct GaloisField { value: [PrimeField

; N], diff --git a/src/algebra/group/README.md b/src/algebra/group/README.md index 91e0b056..94c4b730 100644 --- a/src/algebra/group/README.md +++ b/src/algebra/group/README.md @@ -19,7 +19,7 @@ The structs that implement these traits are ### `MultiplicativePrimeGroup` The `MultiplicativePrimeGroup` struct is a wrapper around a `usize` that defines $(Z/nZ)^{*}$ for a prime power $n=p^k$ with binary operation as $\times$: -```rust +```rust,ignore pub struct MultiplicativePrimeGroup(usize); ``` diff --git a/src/bin/create_mdbook.rs b/src/bin/create_mdbook.rs deleted file mode 100644 index 09128e6c..00000000 --- a/src/bin/create_mdbook.rs +++ /dev/null @@ -1,78 +0,0 @@ -/// 1. Read SUMMARY.md and copy `README.md` files given in it to `book` directory. -/// 2. Change the links to other `README.md` files to `index.md`, so that link points to -/// correct file in the mdbook. -/// 3. Change links that point to a '.rs' file to their github repo link. -use std::{ - fs::{self, File}, - io::{self, BufRead, BufReader, Write}, - path::{Path, PathBuf}, -}; - -use regex::Regex; - -const DEST: &str = "book"; -const REPO_LINK: &str = "https://github.com/pluto/ronkathon/blob/main/"; -const SHOW_CHANGES: bool = false; - -fn main() -> io::Result<()> { - let dest_path = Path::new(DEST); - if !dest_path.exists() { - fs::create_dir(dest_path)?; - } - - let mut readmes = Vec::::new(); - let f = File::open("SUMMARY.md")?; - let reader = BufReader::new(f); - - let re = Regex::new(r"\[.*\]\((.*)\)").unwrap(); - - for line in reader.lines() { - for (_, [link]) in re.captures_iter(&line?).map(|c| c.extract()) { - if !link.is_empty() { - readmes.push(PathBuf::from(link)); - } - } - } - - let readme_re = Regex::new(r"README.md").unwrap(); - let rs_links = Regex::new(r"(?\[.*\])\([/]?(?.*\.rs)\)").unwrap(); - - for src in &readmes { - println!("Working on: {}", src.display()); - let mut src_parent = src.parent().unwrap().to_str().unwrap().to_owned(); - if !src_parent.is_empty() { - src_parent.push('/'); - } - - let dest = Path::new(DEST).join(src); - let dest_folder = dest.parent().unwrap(); - if !dest_folder.exists() { - fs::create_dir_all(dest_folder)?; - } - let src_file = File::open(src)?; - let reader = BufReader::new(src_file); - - let mut dest_file = File::create(&dest)?; - - for line in reader.lines() { - let before = line.unwrap(); - let after1 = readme_re.replace_all(&before, "index.md"); - if before != after1 && SHOW_CHANGES { - println!("1. {before} -> {after1}"); - } - let after2 = rs_links.replace_all(&after1, format!("$t({}{}$l)", REPO_LINK, src_parent)); - if after1 != after2 && SHOW_CHANGES { - println!("2. {after1} -> {after2}"); - } - dest_file.write_all(after2.as_bytes())?; - dest_file.write_all(b"\n")?; - } - } - - println!("Copying SUMMARY.md to {DEST}/SUMMARY.md"); - fs::copy("SUMMARY.md", "book/SUMMARY.md")?; - - println!("Done!"); - - Ok(()) -} diff --git a/src/compiler/README.md b/src/compiler/README.md index 4c0de6ef..890a0be7 100644 --- a/src/compiler/README.md +++ b/src/compiler/README.md @@ -24,7 +24,7 @@ Outputs parsed output in form of `WireCoeffs` values and coefficients. - `coefficients`: coefficient corresponding to each variable. -```rust +```rust,ignore use std::collections::HashMap; /// Values of wires with coefficients of each wire name #[derive(Debug, PartialEq)] @@ -68,7 +68,7 @@ r2[right input]-->b b-->o2[output=l+r] ``` -```rust +```rust,ignore use ronkathon::algebra::field::prime::PlutoScalarField; /// Fan-in 2 Gate representing a constraint in the computation. /// Each constraint satisfies PLONK's arithmetic equation: `a(X)QL(X) + b(X)QR(X) + a(X)b(X)QM(X) + @@ -107,7 +107,7 @@ Converts `WireValues` to required polynomials in PLONK, i.e. To get selector polynomials from constraints, each constraint is parsed into fan-in 2 arithmetic gates as explained above and wire values are assigned to respective wires in lagrange form. -```rust +```rust,ignore /// `CommonPreprocessedInput` represents circuit related input which is apriori known to `Prover` /// and `Verifier` involved in the process. use ronkathon::{ @@ -154,8 +154,8 @@ permutation helper creates $\sigma_i$ polynomials for $i = \{1,2,3\}$. - for example: x's usage gets shifted 1 to right, new one becomes: `{'x': [(3, RIGHT), (1, LEFT), (2, LEFT), (2, RIGHT)]}`. - This ensures that variables `x` is copied from $x_i$ to $x_{i+1}$ -```rust - use ronkathon::compiler::parser::WireCoeffs; +```rust,ignore +use ronkathon::compiler::parser::WireCoeffs; /// `Program` represents constraints used while defining the arithmetic on the inputs /// and group order of primitive roots of unity in the field. diff --git a/src/encryption/symmetric/aes/README.md b/src/encryption/symmetric/aes/README.md index 3874eea9..2833f5de 100644 --- a/src/encryption/symmetric/aes/README.md +++ b/src/encryption/symmetric/aes/README.md @@ -45,7 +45,7 @@ To generate more round keys out of the original key, we do a series of word rota For round **i**, if i is a multiple of the length of the key (in words): -```rust +```rust,ignore Self::rotate_word(&mut last); word = (u32::from_le_bytes(Self::sub_word(last)) ^ u32::from_le_bytes(ROUND_CONSTANTS[(i / key_len) - 1])) @@ -54,13 +54,13 @@ For round **i**, if i is a multiple of the length of the key (in words): if i + 4 is a multiple of 8: -```rust +```rust,ignore word = Self::sub_word(last) ``` The final step is always to XOR previous round's round key with the *(i - key_len)*-th round key: -```rust +```rust,ignore let round_key = expanded_key[i - key_len] .iter() .zip(last.iter()) diff --git a/src/encryption/symmetric/chacha/README.md b/src/encryption/symmetric/chacha/README.md index 278bb98a..d25c1456 100644 --- a/src/encryption/symmetric/chacha/README.md +++ b/src/encryption/symmetric/chacha/README.md @@ -21,7 +21,7 @@ Then, chacha stream cipher's internal state is defined using $F$ with a 256-bit Let's define what happens inside $F$, it runs a quarter round that takes as input 4 4-byte input and apply constant time ARX operations: -``` +```ignore a += b; d ^= a; d <<<= 16; c += d; b ^= c; b <<<= 12; a += b; d ^= a; d <<<= 8; diff --git a/src/hashes/poseidon/README.md b/src/hashes/poseidon/README.md index ac766204..8895e756 100644 --- a/src/hashes/poseidon/README.md +++ b/src/hashes/poseidon/README.md @@ -98,6 +98,7 @@ const ALPHA: usize = 5; const NUM_P: usize = 16; const NUM_F: usize = 8; +# pub fn main() { // load round constants and mds matrix let (rc, mds) = load_constants::(); @@ -111,14 +112,21 @@ let input = std::iter::repeat(PlutoBaseField::ZERO).take(WIDTH).collect(); let res = poseidon.hash(input); println!("{:?}", res); +# } ``` Another example using Sponge API for arbitrary length element hashing. Simplex sponge supports arbitrary length absorption with arbitrary length squeeze. ```rust -use rand::rng; -use ronathon::{field::prime::PlutoBaseField, hashes::poseidon::sponge::PoseidonSponge}; +use rand::Rng; +use ronkathon::{field::prime::PlutoBaseField, hashes::poseidon::sponge::PoseidonSponge}; +const WIDTH: usize = 10; +const ALPHA: usize = 5; +const NUM_P: usize = 16; +const NUM_F: usize = 8; + +# pub fn main() { let size = rng.gen::(); // create any state @@ -126,13 +134,14 @@ let input = std::iter::repeat(PlutoBaseField::ONE).take(size).collect(); let (rc, mds) = load_constants::(); -let mut pluto_poseidon_sponge = PoseidonSponge::new(WIDTH, ALPHA, NUM_P, NUM_F, rate, rc, mds) +let mut pluto_poseidon_sponge = PoseidonSponge::new(WIDTH, ALPHA, NUM_P, NUM_F, rate, rc, mds); let absorb_res = pluto_poseidon_sponge.absorb(&input); assert!(absorb_res.is_ok()); let pluto_result = pluto_poseidon_sponge.squeeze(squeeze_size); assert!(pluto_result.is_ok()); +# } ``` More info and examples can be found in [tests](./tests/mod.rs). From 18976e2d7372a15d2c87e1e20a2bc9926fd76da3 Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 5 Feb 2025 08:18:06 -0700 Subject: [PATCH 14/16] Update mdbook-test.yaml --- .github/workflows/mdbook-test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mdbook-test.yaml b/.github/workflows/mdbook-test.yaml index b8716d8a..7092dfc2 100644 --- a/.github/workflows/mdbook-test.yaml +++ b/.github/workflows/mdbook-test.yaml @@ -34,8 +34,8 @@ jobs: cp -r assets book/ mdbook build - - name: Run mdBook tests - run: mdbook test + # - name: Run mdBook tests + # run: mdbook test - name: Run linkcheck run: mdbook-linkcheck \ No newline at end of file From 1e28dc99f614050d6f9cb1bae52e605f49790d11 Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 5 Feb 2025 08:19:16 -0700 Subject: [PATCH 15/16] Update book.toml --- book.toml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/book.toml b/book.toml index 681161a3..9996b3c5 100644 --- a/book.toml +++ b/book.toml @@ -18,10 +18,11 @@ after=["links"] follow-web-links =true traverse-parent-directories=true -[preprocessor.keeper] -command ="mdbook-keeper" -manifest_dir="." -externs =["ronkathon", "rand"] +# TODO (autoparallel): there's a bunch to fix with this +# [preprocessor.keeper] +# command ="mdbook-keeper" +# manifest_dir="." +# externs =["ronkathon", "rand"] [output.html] default-theme ="dark" From 7a5202aa313a7e00da187ba15de6bdb73750c36f Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 5 Feb 2025 08:23:40 -0700 Subject: [PATCH 16/16] fix: update workflows --- .github/workflows/deploy.yml | 24 ++----------------- .../{mdbook-test.yaml => mdbook-build.yaml} | 13 ++-------- 2 files changed, 4 insertions(+), 33 deletions(-) rename .github/workflows/{mdbook-test.yaml => mdbook-build.yaml} (76%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1b0a5d73..cb41d5cc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -50,40 +50,20 @@ jobs: uses: actions/configure-pages@v5 - name: Build with mdBook - run: | - cargo run --bin create_mdbook - cp -r assets book/ - mdbook build - - - name: Run mdBook tests - run: mdbook test + run: mdbook build - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: ./docs - # Link checking job - linkcheck: - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v4 - - - name: Install mdbook-linkcheck - run: | - cargo binstall --no-confirm mdbook-linkcheck - - - name: Run mdbook-linkcheck - run: mdbook-linkcheck - # Deployment job deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest - needs: [build, linkcheck] + needs: [build] steps: - name: Deploy to GitHub Pages id: deployment diff --git a/.github/workflows/mdbook-test.yaml b/.github/workflows/mdbook-build.yaml similarity index 76% rename from .github/workflows/mdbook-test.yaml rename to .github/workflows/mdbook-build.yaml index 7092dfc2..0ea1d1c6 100644 --- a/.github/workflows/mdbook-test.yaml +++ b/.github/workflows/mdbook-build.yaml @@ -1,4 +1,4 @@ -name: MDBook Tests +name: MDBook Build on: pull_request: @@ -29,13 +29,4 @@ jobs: cargo binstall --no-confirm --version ${MDBOOK_LINKCHECK_VERSION} mdbook-linkcheck - name: Build mdBook - run: | - cargo run --bin create_mdbook - cp -r assets book/ - mdbook build - - # - name: Run mdBook tests - # run: mdbook test - - - name: Run linkcheck - run: mdbook-linkcheck \ No newline at end of file + run: mdbook build \ No newline at end of file