-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[framework] unify Rust and Move object ID derivation #143
Conversation
45aa28d
to
f63ce8d
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.
Nice, one and this unblocks #58 .
let ids_created = pop_arg!(args, u64); | ||
let inputs_hash = pop_arg!(args, Vec<u8>); | ||
|
||
// unwrap safe because digest length is checked in Move |
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.
Now that we do not have to keep rust and move in sync, we can address Issue #58 . We need to define a ObjectIDPreimage struct that holds (transaction_id, new_obj_sequence), then make it BcsSignable
and use sha3_hash
to get the digest. This ensures that we have one way to derive hashes (incl. for what we sign) and therefore domain separation is ensured uniformly.
Lets add a todo here, and add the above to issue #58 .
// TODO(https://github.com/MystenLabs/fastnft/issues/58): | ||
// audit ID derivation: do we want/need domain separation, different hash function, truncation ... | ||
|
||
let mut hasher = Sha3_256::default(); |
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.
See my comment above on how to derive this in a uniform way in relation to all other hashes we derive.
#[test_only] | ||
/// Create a `Signer` from `bytes` for testing | ||
public fun new_signer(bytes: vector<u8>): Signer { | ||
Signer { inner: new(bytes) } |
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.
Nit: I have a feeling a length check here would not go amiss.
Previously, there were two incompatible implementations of ObjectID derivation. This PR: - Eliminates the `ObjectID` derivation inside Move and replaces it with a native function that invokes the Rust `ObjectID` derivation. This ensures that Rust and Move agree on how ID's are generated, and should also be more efficient than the previous approach. - Introduces a harness for invoking Move unit tests and a unit tests for `TxContext` that shows the ID generation working as expected.
f63ce8d
to
e694f72
Compare
Previously, there were two incompatible implementations of ObjectID derivation. This PR:
ObjectID
derivation inside Move and replaces it with a native function that invokes the RustObjectID
derivation. This ensures that Rust and Move agree on how ID's are generated, and should also be more efficient than the previous approach.TxContext
that shows the ID generation working as expected.