-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Create a JSON RPC API for threshold-BLS signing & add the Randomness Move module #6824
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 4 Ignored Deployments
|
e03a2bf
to
cdfa0ab
Compare
@@ -94,6 +95,66 @@ async fn test_public_transfer_object() -> Result<(), anyhow::Error> { | |||
Ok(()) | |||
} | |||
|
|||
// TODO: WIP, complete this tests | |||
#[sim_test] |
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.
probably ok to have this be sui_test so it can be run under a bare cargo test
342cbbf
to
f93d4e2
Compare
0ecf05e
to
dc39fc7
Compare
37446c3
to
2184b4b
Compare
f742c06
to
9fdeda3
Compare
@damirka, this is the implementation of the Randomness object we discussed awhile ago. Would appreciate your review of the Move related files. @bmwill, updated the PR after some changes I've done in fastcrypto that blocked this change. I'm planning to fix the TODO on verifying the effects cert in a follow up PR. |
7ffb058
to
056c4ae
Compare
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.
Amazing work! Move part is done well!
Left a few comments but feel free to ignore.
sui_programmability/examples/games/tests/randomness_based_lottery_tests.move
Outdated
Show resolved
Hide resolved
const EInvalidRndLength: u64 = 2; | ||
|
||
/// All signatures are prefixed with Domain. | ||
const Domain: vector<u8> = b"randomness"; |
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.
I'm not sure if this needs to be static or dynamic (probably former) but you can use type of the T
as a signing parameter through type reflection:
let unique_type_signature: TypeName = std::type_name::get<T>();
// and then something like
let bytes = sui::bcs::to_bytes(&unique_type_signature);
} | ||
|
||
/// Verify signature sig on message msg using the epoch's BLS key. | ||
native fun native_tbls_verify_signature(epoch: u64, msg: &vector<u8>, sig: &vector<u8>): bool; |
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 these functions are relatively important (although not available publicly, it might be better to move them up for visibility).
7e7632b
to
26fdd48
Compare
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.
Some nits on error handling, otherwise LGTM
.await | ||
.map_err(|e| anyhow!(e))?; | ||
let ObjectRead::Exists(_obj_ref, obj, layout) = obj_read else { | ||
Err(anyhow!("Object not found"))? }; |
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.
if you return Result<Object,Error> instead of RpcResult, you can use a proper error (SuiError or sui-json-rpc::Error) instead of Err(anyhow!())?
, e.g.
sui/crates/sui-json-rpc/src/coin_api.rs
Lines 40 to 42 in 2a3d285
async fn get_object(&self, object_id: &ObjectID) -> Result<Object, Error> { | |
Ok(self.state.get_object_read(object_id).await?.into_object()?) | |
} |
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.
I changed the function response (here and elsewhere) and used enums for "canonical errors" and anyhow for user specific ones.
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.
LGTM!
Co-authored-by: Damir Shamanaev <damirka.ru@gmail.com>
fdce2cf
to
1df407b
Compare
Implementation of TBlsSignatureApi and the Move side according to the HLD. Currently computes everything locally, without calling f+1 validators.
Includes also examples of a lottery and an auto generated NFTs using owned objects.