-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Two related bugs cause put_with_address_funding to fail when creating identities from platform addresses:
Bug 1: rs-sdk proof verification compares against wrong identity ID
In packages/rs-sdk/src/platform/transition/put_identity.rs, put_identity_with_address_funding verifies the proof response by comparing the proved identity ID against identity.id() — the ID passed in by the caller:
let proved_identity_id = proved_identity.id();
if proved_identity_id != identity.id() {
return Err(Error::InvalidProvedResponse(...));
}For address-funded identity creation, the platform computes the identity ID deterministically from hash_double(bincode(address_nonce_map)) via identity_id_from_input_addresses(). The caller's identity.id() is typically a placeholder (e.g. from Identity::new()) and does not match the platform-computed ID.
dash-evo-tool works around this by calling Identity::new_with_input_addresses_and_keys() which pre-computes the correct ID from inputs before calling put_with_address_funding. But the rs-sdk function itself should not assume the caller did this.
Fix: Replace the comparison with the deterministic ID computed from inputs:
let expected_id = identity_id_from_input_addresses(&inputs)?;
if proved_identity_id != expected_id { ... }This requires computing the expected ID before inputs is moved into try_from_inputs_with_signer.
Bug 2: wasm-sdk identityCreateFromAddresses doesn't compute correct identity ID
In packages/wasm-sdk/src/state_transitions/addresses.rs, identity_create_from_addresses passes the caller's identity (with its placeholder ID) directly to put_with_address_funding. Since nonces are fetched internally by the WASM SDK, the caller cannot know the correct ID upfront.
The WASM SDK should either:
- Reconstruct the identity with the correct ID using
Identity::new_with_input_addresses_and_keys()after fetching nonces, or - Rely on the rs-sdk fix above to not check against the placeholder ID
Affected versions
- v3.0.x
- v3.1-dev (confirmed same code)
Steps to reproduce
- Create an identity with a placeholder ID:
new Identity(Identifier.random()) - Add public keys to the identity
- Call
sdk.addresses.createIdentity()(js-evo-sdk) orput_with_address_funding(rs-sdk) - The identity is successfully created on platform, but the SDK returns an error:
proof returned identity <correct_id> but <placeholder_id> was created