rust-bitcoin / rust-bech32

Bech32 format encoding and decoding
MIT License
92 stars 48 forks source link

Re-work `u5` to be a field element in GF32 #94

Closed tcharding closed 11 months ago

tcharding commented 1 year ago

All the while working on this crate I have mistook the u5 type to be a general purpose integer type. To improve the API and help the next non-mathematician reading the code we could re-work the u5 type to make its purpose more explicit.

I think of u5 as a field element in GF32, definitely not as a standalone integer type. We could rename it if this is confusing.

Do we have Add and Mul implemented on this type, and do they respect field operations or "mod 32" operatons?

To be clearer: this crate has no use for integers mod 32, and I can't think of any crate that does.

ref: https://github.com/rust-bitcoin/rust-bech32/pull/89#issuecomment-1456201412

Consider fixing #80 at the same time.

apoelstra commented 1 year ago

codex32 https://github.com/BlockstreamResearch/codex32/tree/master/reference/rust-codex32 has a Fe type which is the same as u5 in this library.

It's not obvious that either lib should depend on the other though so actually sharing a type doesn't seem clear.

tcharding commented 11 months ago

Closing as this was implicitly resolved by the recent crate re-write.