-
Notifications
You must be signed in to change notification settings - Fork 288
ed448-goldilocks: initial import #1219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
1b145ab
add ed448
mikelodder7 19f6f4b
update rustfmt.toml
mikelodder7 c3a8bec
fixes to scalar
mikelodder7 bfdd0db
fix tests and compile issues
mikelodder7 53c7d97
add ed448 workflow
mikelodder7 1130927
update to no_std
mikelodder7 0c8cf8f
clean up warnings
mikelodder7 c2b6519
update workflows
mikelodder7 9ddb92b
clippy
mikelodder7 3869590
ed448: bump edition to 2024
baloo f4c55c4
fixup after bumping dependencies
baloo 271260d
fixup deprecation
baloo 9eced60
pkcs8 support
baloo 598dde4
bump signature
baloo 3984441
bump crypto-bigint
baloo 750d681
bump hex-literal
baloo 1921934
fixup api breaks
baloo adabbed
rename crate to ed448-goldilocks
baloo 9533ea1
ed448: fixup clippy 1.87 errors
baloo a120816
ed448: rename crate to ed448-goldilocks
baloo 09af265
ed448: do not consume rng
baloo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| name: ed448 | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - ".github/workflows/ed448.yml" | ||
| - "ed448/**" | ||
| - "Cargo.*" | ||
| push: | ||
| branches: master | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: ed448 | ||
|
|
||
| env: | ||
| CARGO_INCREMENTAL: 0 | ||
| RUSTFLAGS: "-Dwarnings" | ||
| RUSTDOCFLAGS: "-Dwarnings" | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| rust: | ||
| - 1.85.0 # MSRV | ||
| - stable | ||
| target: | ||
| - thumbv7em-none-eabi | ||
| - wasm32-unknown-unknown | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: ${{ matrix.rust }} | ||
| targets: ${{ matrix.target }} | ||
| - run: cargo build --target ${{ matrix.target }} --release --no-default-features | ||
| - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc | ||
| - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8 | ||
| - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features signing | ||
| - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde | ||
| - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features zeroize | ||
| - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc,pkcs8,signing,serde,zeroize | ||
|
|
||
| benches: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| rust: | ||
| - 1.85.0 # MSRV | ||
| - stable | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: ${{ matrix.rust }} | ||
| - run: cargo build --all-features --benches | ||
|
|
||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| # 32-bit Linux | ||
| - target: i686-unknown-linux-gnu | ||
| rust: 1.85.0 # MSRV | ||
| deps: sudo apt update && sudo apt install gcc-multilib | ||
| - target: i686-unknown-linux-gnu | ||
| rust: stable | ||
| deps: sudo apt update && sudo apt install gcc-multilib | ||
|
|
||
| # 64-bit Linux | ||
| - target: x86_64-unknown-linux-gnu | ||
| rust: 1.85.0 # MSRV | ||
| - target: x86_64-unknown-linux-gnu | ||
| rust: stable | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: ${{ matrix.rust }} | ||
| targets: ${{ matrix.target }} | ||
| - run: ${{ matrix.deps }} | ||
| - run: cargo check --target ${{ matrix.target }} --all-features | ||
| - run: cargo test --release --target ${{ matrix.target }} --no-default-features | ||
| - run: cargo test --release --target ${{ matrix.target }} | ||
| - run: cargo test --release --target ${{ matrix.target }} --all-features | ||
|
|
||
| cross: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| # ARM32 | ||
| - target: armv7-unknown-linux-gnueabihf | ||
| rust: 1.85.0 # MSRV (cross) | ||
| - target: armv7-unknown-linux-gnueabihf | ||
| rust: stable | ||
|
|
||
| # ARM64 | ||
| - target: aarch64-unknown-linux-gnu | ||
| rust: 1.85.0 # MSRV (cross) | ||
| - target: aarch64-unknown-linux-gnu | ||
| rust: stable | ||
|
|
||
| # PPC32 | ||
| - target: powerpc-unknown-linux-gnu | ||
| rust: 1.85.0 # MSRV (cross) | ||
| - target: powerpc-unknown-linux-gnu | ||
| rust: stable | ||
|
|
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - run: ${{ matrix.deps }} | ||
| - uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: ${{ matrix.rust }} | ||
| targets: ${{ matrix.target }} | ||
| - uses: RustCrypto/actions/cross-install@master | ||
| - run: cross test --release --target ${{ matrix.target }} --all-features | ||
|
|
||
| doc: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: RustCrypto/actions/cargo-cache@master | ||
| - uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: stable | ||
| - run: cargo doc --all-features |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ members = [ | |
| "p256", | ||
| "p384", | ||
| "p521", | ||
| "ed448", | ||
| "primefield", | ||
| "primeorder", | ||
| "sm2" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| [package] | ||
| authors = ["RustCrypto Developers"] | ||
| categories = ["cryptography"] | ||
| description = """A pure-Rust implementation of Ed448 and Curve448 and Decaf. | ||
| This crate also includes signing and verifying of Ed448 signatures. | ||
| """ | ||
| documentation = "https://docs.rs/ed448-goldilocks" | ||
| exclude = [".gitignore", ".github/*"] | ||
| edition = "2024" | ||
| homepage = "https://docs.rs/ed448-goldilocks/" | ||
| keywords = ["cryptography", "decaf", "ed448", "ed448-goldilocks"] | ||
| license = "BSD-3-Clause" | ||
| name = "ed448" | ||
| readme = "README.md" | ||
| repository = "https://github.com/RustCrypto/elliptic-curves/tree/master/ed448" | ||
| rust-version = "1.85" | ||
| version = "0.17.0-pre.0" | ||
|
|
||
| [dependencies] | ||
| crypto-bigint = { version = "=0.7.0-pre.4", features = ["hybrid-array"], default-features = false } | ||
| crypto_signature = { version = "3.0.0-rc.0", default-features = false, features = ["digest", "rand_core"], optional = true, package = "signature" } | ||
| elliptic-curve = { version = "0.14.0-rc.3", features = ["arithmetic", "bits", "hash2curve", "jwk", "pkcs8", "pem", "sec1"] } | ||
| rand_core = { version = "0.9", default-features = false } | ||
| serdect = { version = "0.3.0", optional = true } | ||
| sha3 = { version = "0.11.0-rc.0", default-features = false } | ||
| subtle = { version = "2.6", default-features = false } | ||
| zeroize = { version = "1.8", default-features = false, optional = true } | ||
|
|
||
| [features] | ||
| default = ["std", "signing", "pkcs8"] | ||
| alloc = ["serdect/alloc", "zeroize/alloc", "crypto_signature/alloc"] | ||
| pkcs8 = ["elliptic-curve/pkcs8"] | ||
| signing = ["dep:crypto_signature", "zeroize"] | ||
| serde = ["dep:serdect"] | ||
| std = ["serdect/default", "zeroize/default"] | ||
| zeroize = ["dep:zeroize"] | ||
|
|
||
| [dev-dependencies] | ||
| hex-literal = "1" | ||
| hex = "0.4" | ||
| rand_core = { version = "0.9", features = ["os_rng"] } | ||
| rand_chacha = "0.9" | ||
| serde_bare = "0.5" | ||
| serde_json = "1.0" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <p align="center"> | ||
| <img src="resources/bear.png" width = "400"> | ||
| </p> | ||
|
|
||
| ed448-goldilocks-plus | ||
|
|
||
| [![Crate][crate-image]][crate-link] | ||
| [![Docs][docs-image]][docs-link] | ||
| ![BSD-3 Licensed][license-image] | ||
|
|
||
| THIS CODE HAS NOT BEEN AUDITED OR REVIEWED. USE AT YOUR OWN RISK. | ||
|
|
||
| ## Field Choice | ||
|
|
||
| The field size is a Solinas trinomial prime 2^448 - 2^224 -1. This prime is called the Goldilocks prime. | ||
|
|
||
| ## Curves | ||
|
|
||
| This repository implements three curves explicitly and another curve implicitly. | ||
|
|
||
| The three explicitly implemented curves are: | ||
|
|
||
| - Ed448-Goldilocks | ||
|
|
||
| - Curve448 | ||
|
|
||
| - Twisted-Goldilocks | ||
|
|
||
|
|
||
| ## Ed448-Goldilocks Curve | ||
|
|
||
| - The goldilocks curve is an Edwards curve with affine equation x^2 + y^2 = 1 - 39081x^2y^2 . | ||
| - This curve was defined by Mike Hamburg in https://eprint.iacr.org/2015/625.pdf . | ||
| - The cofactor of this curve over the goldilocks prime is 4. | ||
|
|
||
| ## Twisted-Goldilocks Curve | ||
|
|
||
| - The twisted goldilocks curve is a Twisted Edwards curve with affine equation y^2 - x^2 = 1 - 39082x^2y^2 . | ||
| - This curve is also defined in https://eprint.iacr.org/2015/625.pdf . | ||
| - The cofactor of this curve over the goldilocks prime is 4. | ||
|
|
||
| ### Isogeny | ||
|
|
||
| - This curve is 2-isogenous to Ed448-Goldilocks. Details of the isogeny can be found here: https://www.shiftleft.org/papers/isogeny/isogeny.pdf | ||
|
|
||
| ## Curve448 | ||
|
|
||
| This curve is 2-isogenous to Ed448-Goldilocks. Details of Curve448 can be found here: https://tools.ietf.org/html/rfc7748 | ||
|
|
||
| The main usage of this curve is for X448. | ||
|
|
||
| N.B. In that document there is an Edwards curve that is birationally equivalent to Curve448, with a large `d` value. This curve is not implemented and to my knowledge, has no utility. | ||
|
|
||
| ## Strategy | ||
|
|
||
| The main strategy for group arithmetic on Ed448-Goldilocks is to perform the 2-isogeny to map the point to the Twisted-Goldilocks curve, then use the faster Twisted Edwards formulas to perform scalar multiplication. Computing the 2-isogeny then the dual isogeny will pick up a factor of 4 once we map the point back to the Ed448-Goldilocks curve, so the scalar must be adjusted by a factor of 4. Adjusting the scalar is dependent on the point and the scalar. More details can be found in the 2-isogenous paper. | ||
|
|
||
| # Decaf | ||
|
|
||
| The Decaf strategy [link paper] is used to build a group of prime order from the Twisted Goldilocks curve. The Twisted Goldilocks curve is used as it has faster formulas. We can also use Curve448 or Ed448-Goldilocks. Decaf takes advantage of an isogeny with a Jacobi Quartic curve which is not explicitly defined. Details of this can be found here: https://www.shiftleft.org/papers/decaf/decaf.pdf However, to my knowledge there is no documentation for the Decaf protocol implemented in this repository, which is a tweaked version of the original decaf protocol linked in the paper. | ||
|
|
||
| ## Completed Point vs Extensible Point | ||
|
|
||
| Deviating from Curve25519-Dalek, this library will implement Extensible points instead of Completed Points. Due to the following observation: | ||
|
|
||
| - There is a cost of 3/4 Field multiplications to switch from the CompletedPoint. So if we were to perform repeated doubling, this would add an extra cost for each doubling in projective form. More details on the ExtensiblePoint can be found here [3.2]: https://www.shiftleft.org/papers/fff/fff.pdf | ||
|
|
||
| ## Credits | ||
|
|
||
| The library design was taken from Dalek's design of Curve25519. The code for Montgomery curve arithmetic was also taken from Dalek's library. | ||
|
|
||
| The golang implementation of Ed448 and libdecaf were used as references. | ||
|
|
||
| Special thanks to Mike Hamburg for answering all the questions asked regarding Decaf and goldilocks. | ||
|
|
||
| This library adds [hash_to_curve](https://datatracker.ietf.org/doc/rfc9380/) and serialization of structs. | ||
|
|
||
| ## Contribution | ||
|
|
||
| Unless you explicitly state otherwise, any contribution intentionally | ||
| submitted for inclusion in the work by you, as defined in the BSD-3-Clause | ||
| license, shall be dual licensed as above, without any additional terms or | ||
| conditions. | ||
|
|
||
| [//]: # (badges) | ||
|
|
||
| [crate-image]: https://img.shields.io/crates/v/ed448-goldilocks-plus.svg | ||
| [crate-link]: https://crates.io/crates/ed448-goldilocks-plus | ||
| [docs-image]: https://docs.rs/ed448-goldilocks-plus/badge.svg | ||
| [docs-link]: https://docs.rs/ed448-goldilocks-plus/ | ||
| [license-image]: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| use_field_init_shorthand = true | ||
| reorder_imports = true | ||
| reorder_modules = true | ||
| reorder_impl_items = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| use crate::*; | ||
| use crate::{Scalar, decaf::DecafPoint}; | ||
|
|
||
| pub const DECAF_BASEPOINT: DecafPoint = DecafPoint(curve::twedwards::extended::ExtendedPoint { | ||
| X: TWISTED_EDWARDS_BASE_POINT.X, | ||
| Y: TWISTED_EDWARDS_BASE_POINT.Y, | ||
| Z: TWISTED_EDWARDS_BASE_POINT.Z, | ||
| T: TWISTED_EDWARDS_BASE_POINT.T, | ||
| }); | ||
|
|
||
| /// `BASEPOINT_ORDER` is the order of the Ed448 basepoint, i.e., | ||
| /// $$ | ||
| /// \ell = 2^\{446\} + 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d. | ||
| /// $$ | ||
| pub const BASEPOINT_ORDER: Scalar = Scalar(ORDER); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| pub mod edwards; | ||
| pub mod montgomery; | ||
| pub(crate) mod scalar_mul; | ||
| pub(crate) mod twedwards; | ||
|
|
||
| pub use edwards::{AffinePoint, CompressedEdwardsY, EdwardsPoint}; | ||
| pub use montgomery::{MontgomeryPoint, ProjectiveMontgomeryPoint}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.