-
Notifications
You must be signed in to change notification settings - Fork 135
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
Add example for BLS signature #1153
base: main
Are you sure you want to change the base?
Conversation
Preview is available here: |
|
||
### BLS Signature verification | ||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ```rust
|
||
Most of what's here is needed in order to create the contract client and ensure the invocation of its custom account interface for signature authorization. After the setup, calling `env.try_invoke_contract_check_auth` on the client will invoke the `__check_auth` logic we've defined in our contract. | ||
|
||
The invocation will return nothing on success, and will panic on failure. The other thing we are interested here is budget consumption for this call. At the beginning setting `env.budget().reset_unlimited()` ensure all the prep work (which emulates the off-chain work needed to be performed by e.g. a smart wallet) will not run out of budget. This isn't strictly necessary since the default budget should be large enough. `env.budget().reset_default()` right before the invocation makes sure the budget is reset to default state (also resetting metering counters) so that we can get an accurate capture of the budget for the invocation alone. `env.budget().print()` at the end prints out the budget. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since SDK 22.0.4 we shouldn't need to do budget resets anymore. We should update the example first, but I think for the doc we can just omit this, so that there is less to change when the example is updated.
Running this test will produce the following budget output, the total cpu consumption for signature verification is around 31M. And you can add as many additional public keys as you like. In general `pairing_check` is a function with linear cost, so the more unique messages that needs to be signed, the higher cost. Here because all signers sign the same content (hash of the call stack of this contract), we can do this in constant time. | ||
|
||
``` | ||
---- test::test stdout ---- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to omit all the cost type rows here and just leave the non-zero BLS rows?
Preview is available here: |
Corresponding example source code: https://github.com/stellar/soroban-examples/tree/v22.0.1/bls_signature