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

Add PathEscape to MerklePath key #50

Closed
audtlr24 opened this issue Dec 20, 2022 · 0 comments · Fixed by #53
Closed

Add PathEscape to MerklePath key #50

audtlr24 opened this issue Dec 20, 2022 · 0 comments · Fixed by #53
Assignees
Labels
bug Something isn't working

Comments

@audtlr24
Copy link
Contributor

The oracle get data from panacea by GetStoreData that verify queried data with merkle proof.

GetStoreData use VerifyMembership function used by cosmos/ibc-go.
In VerifiyMemebership, the MerklePath use url path unescaping like below:

// GetKey will return a byte representation of the key
// after URL escaping the key element
func (mp MerklePath) GetKey(i uint64) ([]byte, error) {
	if i >= uint64(len(mp.KeyPath)) {
		return nil, fmt.Errorf("index out of range. %d (index) >= %d (len)", i, len(mp.KeyPath))
	}
	key, err := url.PathUnescape(mp.KeyPath[i])
	if err != nil {
		return nil, err
	}
	return []byte(key), nil
}

Path unescaping is that converting each 3-byte encoded substring of the form "%AB" into the hex-decoded byte 0xAB. It returns an error if any % is not followed by two hexadecimal digits.

Therefore, if we simply do string(key) when creating MerklePath like now, char % can be included in the string, and errors may occur.

To solve this, we can use PathEscape that does inverse transformation of PathUnescape.

@audtlr24 audtlr24 added the bug Something isn't working label Dec 20, 2022
@audtlr24 audtlr24 added this to the v2.1.0-beta milestone Dec 20, 2022
@audtlr24 audtlr24 self-assigned this Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant