pluto / ronkathon

Cryptography Educational Foundations
https://pluto.xyz/blog/ronkathon-learn-cryptography-from-first-principles
Apache License 2.0
191 stars 23 forks source link

feat: algebra #135

Closed lonerapier closed 3 months ago

lonerapier commented 4 months ago

It changes the following:

lonerapier commented 4 months ago

@Autoparallel Thanks for the review.

Autoparallel commented 3 months ago

@lonerapier let me take a look.

One thing we could also consider is making the ring/field + op be a AbelianGroup. Food for thought.

Give me a sec to go look through this.

lonerapier commented 3 months ago

One thing we could also consider is making the ring/field + op be a AbelianGroup. Food for thought.

Regarding this suggestion, I can't find a way to add this without complicating the traits and structs more

Like it wouldn't be easy for a beginner to implement 5 traits just to have a PrimeField implementation

Autoparallel commented 3 months ago

Like it wouldn't be easy for a beginner to implement 5 traits just to have a PrimeField implementation

That's true... it would introduce having some wrapper types and what not. The only benefit it would give is that if you did something like:

let element: impl FiniteField = ...;
let (element as impl AbelianGroup) + ... 

but that's probably not worth it.

Another option is something like

trait FiniteField {
    type Monoid: ...
    type AbelianGroup: ...
    ...
}

but then I think we are hitting abstraction for the sake of abstraction.

You're right, let's not make the implementation needs abusive to beginners.

lonerapier commented 3 months ago

That's true... it would introduce having some wrapper types and what not.

Maybe we can implement this as an example demonstration with Ring implementation. Like showing a ring with inverse and commutativity forms a field, and then comparing it with the actual Field implementation.