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

Feat: SelfSign trait #14

Merged
merged 15 commits into from
Aug 2, 2024
Merged

Feat: SelfSign trait #14

merged 15 commits into from
Aug 2, 2024

Conversation

gluax
Copy link
Contributor

@gluax gluax commented Jul 25, 2024

Motivation

So, the message signing and proof are all in one place and can be reused.

Explanation of Changes

A few things:

  • Split up types.
  • Added the SelfSign trait.
  • Changed U128 type for non-contracts to be a u128, which serializes as a String, to avoid double parsing a String as a u128. And I saw on the overlay side that we have this as a u128 before converting it to a string just to put in the message type.
  • Made a global instance of VRF, as we created instances of this several times. This was more for the contracts side.
  • I also had to add debugging and partial eq for tests to work again.

Testing

All tests still pass.

You can see an example of using the message hash in the contract branch.

Related PRs and Issues

Closes #10.
Closes #8.

@gluax gluax self-assigned this Jul 25, 2024
Copy link
Member

@Thomasvdam Thomasvdam left a comment

Choose a reason for hiding this comment

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

Would be good if someone else can comment on the rustiness and compatibility with the overlay 😬

src/types/sign_self.rs Outdated Show resolved Hide resolved
@gluax
Copy link
Contributor Author

gluax commented Jul 30, 2024

Based on discussion:

Getting the proof has been moved to trait.

I also made a new concrete type that does the strange mut setting of the proof.

I moved the verify fn to the concrete type as well.

This allows us to avoid making the trait public outside the crate to prevent user error.

@gluax gluax requested a review from Thomasvdam July 30, 2024 15:50
Copy link
Member

@Thomasvdam Thomasvdam left a comment

Choose a reason for hiding this comment

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

Still would be good for @mariocao or @FranklinWaller to check the rustiness :)

Comment on lines +45 to +46
stderr: Vec<String>,
stdout: Vec<String>,
Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if there should be any consideration not including these 2 fields in the signature. Any thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

The concern is about replaying the reveal transaction... but let's think about this.

Maybe they could be included as a sort of hash but inside of the reveal body.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to merge the PR without this, we should create an issue. :)

src/types/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@mariocao mariocao left a comment

Choose a reason for hiding this comment

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

Apart from comment the location of the lazy static VRF, all looks great! ;-)

@gluax gluax merged commit ebe5722 into main Aug 2, 2024
2 checks passed
@gluax gluax deleted the feat/proof-traits branch August 2, 2024 14:57
#[cfg(feature = "cosmwasm")]
pub(crate) type U128 = cosmwasm_std::Uint128;
#[cfg(not(feature = "cosmwasm"))]
pub(crate) type U128 = u128;
Copy link
Member

Choose a reason for hiding this comment

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

I didn't notice it before but this breaks the overlay node. u128 cannot be used on the overlay node side because JSON does not support this. We should probably create some JSON conversion tests? And add a comment to not change these types. I'll work on this right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should still work. The way it's setup is it's serialized as a string not a u128.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Message and Proof Traits ♻️ add Debug when in development mode to types
4 participants