Skip to content
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

BLS12-381 host functions #1456

Merged
merged 20 commits into from
Sep 18, 2024
Merged

BLS12-381 host functions #1456

merged 20 commits into from
Sep 18, 2024

Conversation

jayz22
Copy link
Contributor

@jayz22 jayz22 commented Sep 6, 2024

What

This PR adds support for BLS12-381 in Soroban, by adding host functions for the field and curve operations, new metering cost types, and their calibration.

Why

Please refer to the CAP for motivation and design rationale.

Known limitations

The unit tests currently covers the low-level operations: G1/G2 operations, hashing to curve, pairing.
More test coverage will be added before the PR merged, at the integration level such as BLS signature and the Ethereum test vectors.

@jayz22 jayz22 requested review from graydon, sisuresh, dmkozh and a team as code owners September 6, 2024 16:35
@jayz22 jayz22 removed request for graydon and a team September 6, 2024 17:47
@jayz22 jayz22 force-pushed the bls12-381 branch 2 times, most recently from 7db31ae to fb40b3c Compare September 6, 2024 18:29
Cargo.toml Outdated Show resolved Hide resolved
soroban-builtin-sdk-macros/Cargo.toml Show resolved Hide resolved
soroban-env-common/env.json Outdated Show resolved Hide resolved
soroban-env-common/env.json Outdated Show resolved Hide resolved
soroban-env-common/env.json Outdated Show resolved Hide resolved
soroban-env-host/src/host.rs Outdated Show resolved Hide resolved
soroban-env-host/src/host.rs Outdated Show resolved Hide resolved
soroban-env-host/src/crypto/bls12_381.rs Outdated Show resolved Hide resolved
soroban-env-host/src/test/bls12_381.rs Outdated Show resolved Hide resolved
soroban-env-host/src/test/bls12_381.rs Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@dmkozh dmkozh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a few nitpicks

soroban-env-host/src/crypto/bls12_381.rs Outdated Show resolved Hide resolved
soroban-env-common/env.json Outdated Show resolved Hide resolved
soroban-env-host/src/crypto/bls12_381.rs Outdated Show resolved Hide resolved
soroban-env-host/src/crypto/bls12_381.rs Outdated Show resolved Hide resolved
soroban-env-host/src/crypto/bls12_381.rs Outdated Show resolved Hide resolved
soroban-env-host/src/crypto/bls12_381.rs Show resolved Hide resolved
soroban-env-host/src/crypto/bls12_381.rs Outdated Show resolved Hide resolved
soroban-env-host/src/host.rs Outdated Show resolved Hide resolved
@dmkozh dmkozh added the skip-env-interface-version-bump Skip the env-interface bump version check label Sep 18, 2024
@dmkozh dmkozh added this pull request to the merge queue Sep 18, 2024
Merged via the queue into stellar:main with commit 0497816 Sep 18, 2024
12 of 13 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Sep 27, 2024
### What

Replace cargo-deny `skip-tree` with explicit `skip`s for each dependency
we wish to allow duplicates.

### Why

The `skip-tree` obfuscates the dependencies that we're allowing to be
duplicated, and even seems to hide some dependencies being duplicated
that don't seem to be part of the soroban-wasmi dependency graph that we
depend. This may be due to a bug, or possibly the dep is in the dev
dependencies of soroban-wasmi, or some feature that we don't use.

I became aware of this issue because I noticed that in #1456 the
Cargo.lock file gained a duplicate dependency on the `syn` crate, having
already a dependency on version `2.0.39` and gaining a dependency on
version `1.0.109`. This is fine and not a problem in and of itself – we
can't eradicate all duplicates – except that the `deny.toml` file gained
no new entry, no statement to say that we were okay with this new
duplicate.

In my own testing locally it appears that when the `skip-tree` entry
containing `soroban-wasmi` is present, the `syn` duplicate dependency is
hidden/silenced, even though it was not a dependency prior to the change
that did not involve the `soroban-wasmi` crate.

The `skip-tree` config obfuscates the duplicate dependencies in a couple
ways.

Firstly due to the odd behaviour detailed above we appear to not get
notified of new duplicate dependencies, even if they do not appear to be
an active in use dependency in our existing graph.

Secondly because the `skip-tree` communicates only partially about what
is being allowed. In our case the `skip-tree` allows two versions of the
`hashbrown` dep, but we actually need the two versions for reasons other
than `soroban-wasmi`, so it doesn't tell the full story.

Listing out the duplicate dependencies one-by-one is explicit, and it
helps us at a glance know what our dupes are, and how many we have, as a
signal to "how bad it is getting".

### Known limitations

N/A
github-merge-queue bot pushed a commit to stellar/rs-soroban-sdk that referenced this pull request Sep 27, 2024
Corresponding env change:
stellar/rs-soroban-env#1456

---------

Co-authored-by: Siddharth Suresh <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
sisuresh pushed a commit to sisuresh/rs-soroban-env that referenced this pull request Sep 30, 2024
Replace cargo-deny `skip-tree` with explicit `skip`s for each dependency
we wish to allow duplicates.

The `skip-tree` obfuscates the dependencies that we're allowing to be
duplicated, and even seems to hide some dependencies being duplicated
that don't seem to be part of the soroban-wasmi dependency graph that we
depend. This may be due to a bug, or possibly the dep is in the dev
dependencies of soroban-wasmi, or some feature that we don't use.

I became aware of this issue because I noticed that in stellar#1456 the
Cargo.lock file gained a duplicate dependency on the `syn` crate, having
already a dependency on version `2.0.39` and gaining a dependency on
version `1.0.109`. This is fine and not a problem in and of itself – we
can't eradicate all duplicates – except that the `deny.toml` file gained
no new entry, no statement to say that we were okay with this new
duplicate.

In my own testing locally it appears that when the `skip-tree` entry
containing `soroban-wasmi` is present, the `syn` duplicate dependency is
hidden/silenced, even though it was not a dependency prior to the change
that did not involve the `soroban-wasmi` crate.

The `skip-tree` config obfuscates the duplicate dependencies in a couple
ways.

Firstly due to the odd behaviour detailed above we appear to not get
notified of new duplicate dependencies, even if they do not appear to be
an active in use dependency in our existing graph.

Secondly because the `skip-tree` communicates only partially about what
is being allowed. In our case the `skip-tree` allows two versions of the
`hashbrown` dep, but we actually need the two versions for reasons other
than `soroban-wasmi`, so it doesn't tell the full story.

Listing out the duplicate dependencies one-by-one is explicit, and it
helps us at a glance know what our dupes are, and how many we have, as a
signal to "how bad it is getting".

N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-env-interface-version-bump Skip the env-interface bump version check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants