zhenfeizhang / indifferentiable-hashing

MIT License
6 stars 2 forks source link

Implement MapToCurve for Parameters #3

Open drskalman opened 2 years ago

drskalman commented 2 years ago

In order for your hash to be usable and testable in Arkwork, you need to implement this trait for BLS12-381 and BLS12-377:

https://github.com/arkworks-rs/algebra/blob/master/ec/src/hashing/map_to_curve_hasher.rs#L6

similar to

https://github.com/arkworks-rs/algebra/blob/master/ec/src/hashing/curve_maps/swu/mod.rs#L39

This should quite similar to what you have already have in your code.

zhenfeizhang commented 2 years ago

This is currently impossible, and I suggest not to enable this at the current stage.

Anyway I have create a branch https://github.com/zhenfeizhang/indifferentiable-hashing/tree/prepare-for-0.4.0 https://github.com/zhenfeizhang/indifferentiable-hashing/blob/prepare-for-0.4.0/src/lib.rs#L26 and you can see that implementing the trait itself is kind of trivial. The main blocker right now is arkworks itself.

drskalman commented 2 years ago

Please use "https://github.com/w3f/arkworks-curves/" instead.

zhenfeizhang commented 2 years ago

same thing


error: cannot determine resolution for the macro `MontFp`
  --> /home/z/.cargo/git/checkouts/arkworks-curves-4155937fa1910b8a/efefa20/bls12_377/src/fields/fq12.rs:50:13
   |
50 |             MontFp!("165715080792691229252027773188420350858440463845631411558924158284924566418821255823372982649037525009328560463824"),
[dependencies]
ark-ff = { version = "^0.3.0", default-features = false }
ark-ec = { version = "^0.3.0", default-features = false }
ark-std = { version = "^0.3.0", default-features = false }
ark-bls12-381 = { git = "https://github.com/w3f/arkworks-curves/",  default-features = false, features = [ "curve" ] }
ark-bls12-377 = { git = "https://github.com/w3f/arkworks-curves/",  default-features = false, features = [ "curve" ] }
ark-serialize = { version = "^0.3.0", default-features = false }
zhenfeizhang commented 2 years ago

and TBH at the time this library is written the latest released version is 0.3.0. Keep updating this library for future unreleased version of Arkworks is not in the deliverables.

The deliverable is a rust implementation

**Deliverables**
| Number | Deliverable | Link | Notes |
| ------------- | ------------- | ------------- |------------- |
| 0a. | License | [LICENSE](https://github.com/zhenfeizhang/indifferentiable-hashing/blob/master/LICENSE) | MIT |
| 0b. | Documentation |  | Inline documentation |
| 0c. | Testing Guide | https://github.com/zhenfeizhang/indifferentiable-hashing#testing | You may need [SageMath](https://www.sagemath.org/) to validate test vectors
| 0e. | Article | Section 1.1 of my new article https://eprint.iacr.org/2021/1082 | ... |
| 1. | Rust non-constant-time implementation | https://github.com/zhenfeizhang/indifferentiable-hashing | ... |
Pratyush commented 1 year ago

I'm happy to help with merging this upstream, if that makes sense

drskalman commented 1 year ago
drskalman commented 1 year ago

hash to curve has been merged in arkworks-rs/algebra master as well. So you don't need any patch, just use arkworks 0.4.0.

zhenfeizhang commented 1 year ago

Thanks for the updates. So this repo remains as a self-contained implementation of ind hashes.

For integrated version with arkworks 0.4.0, please see

https://github.com/zhenfeizhang/algebra/pull/1 https://github.com/zhenfeizhang/curves/pull/1

drskalman commented 1 year ago

Very cool!