sui icon indicating copy to clipboard operation
sui copied to clipboard

Add poseidon_bn254 to sui framework

Open jonas-lj opened this issue 1 year ago • 1 comments

Description

Add the Poseidon hash function over BN254 to the Sui move framework. Since this is the hash function used by zkLogin, this will enable various extensions to zkLogin.

For 1 to 16 inputs it is compatible with poseidon-rs and circomlib. For more than 16 inputs, the result is computed as the root of a merkle tree of degree 16. See also this PR in fastcrypto.

There might be added more variations (over other elliptic curve constructions, such as BLS12381), so I've put it the function in a new sui::poseidon module, but it could also be in the sui::hash module.

This shouldn't be merged until after this PR lands.

Test Plan

Unit tests.


If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

Type of Change (Check all that apply)

  • [x] protocol change
  • [x] user-visible impact
  • [ ] breaking change for a client SDKs
  • [x] breaking change for FNs (FN binary must upgrade)
  • [x] breaking change for validators or node operators (must upgrade binaries)
  • [ ] breaking change for on-chain data layout
  • [ ] necessitate either a data wipe or data migration

Release notes

Add the Poseidon hash function over the scalar field of the BN254 elliptic curve construction. This hash function is compatible with the one used in zkLogin.

jonas-lj avatar Nov 02 '23 08:11 jonas-lj

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 10:59am
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 10:59am
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 10:59am
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 10:59am
mysten-ui ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 10:59am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2024 10:59am

vercel[bot] avatar Nov 02 '23 08:11 vercel[bot]

I think things look good? Though for the vector limit thing, we should decide about a limit for all of these hash functions, but since this is inline with the existing functions, it should be nonblocking?

Sounds good! I'll add an issue so we don't forget the limit thing and then discuss with the team what the limit should be.

jonas-lj avatar Jan 08 '24 22:01 jonas-lj