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

Enforce a padding scheme #22

Closed
arajasek opened this issue Jun 18, 2021 · 2 comments · Fixed by #28
Closed

Enforce a padding scheme #22

arajasek opened this issue Jun 18, 2021 · 2 comments · Fixed by #28

Comments

@arajasek
Copy link
Contributor

Because we don't enforce a padding scheme, we have f1xpbyy4tkdx5si2bgo37dubc2xwv6fum5tk57mid and f1xpbyy4tkdx5si2bgo37dubc2xwv6fum5tk57mia "actually" being the same address.

This isn't the easiest thing to fix, since we currently operate with "no padding", but the solution is probably to refuse to decode other padding schemes:

  • decode string X to address A
  • re-encode address A to string X'
  • fail if X not equal to X'
@arajasek
Copy link
Contributor Author

Better suggestions welcome

@Stebalien
Copy link
Member

It looks like padding isn't the issue:

package main

import (
	"bytes"
	"fmt"

	"encoding/base32"
)

const encodeStd = "abcdefghijklmnopqrstuvwxyz234567"

// AddressEncoding defines the base32 config used for address encoding and decoding.
var AddressEncoding = base32.NewEncoding(encodeStd)

func main() {
	a := "xpbyy4tkdx5si2bgo37dubc2xwv6fum5tk57mia="
	b := "xpbyy4tkdx5si2bgo37dubc2xwv6fum5tk57mid="
	x, err := AddressEncoding.DecodeString(a)
	if err != nil {
		panic(err)
	}
	y, err := AddressEncoding.DecodeString(b)
	if err != nil {
		panic(err)
	}
	fmt.Println(bytes.Equal(x, y))
}

(prints true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants